This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SelfLoveRecoveryProgram: | |
| def __init__(self): | |
| self.self_love_level = 50 | |
| def increase_self_love(self, amount): | |
| self.self_love_level += amount | |
| def decrease_self_love(self, amount): | |
| self.self_love_level -= amount |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::collections::BTreeMap; | |
| #[derive(Debug)] | |
| pub struct CoCo<K: Ord> { | |
| forward: BTreeMap<K, usize>, | |
| backward: Vec<K>, | |
| } | |
| impl<K: Ord> CoCo<K> { | |
| pub const fn new() -> Self { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| import itertools | |
| from typing import Any, Dict, List, Set, Tuple | |
| from tqdm import tqdm | |
| from functools import reduce | |
| import operator | |
| import math | |
| def product_of_positive_factorials(multi_index): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::{borrow::Borrow, collections::BTreeMap, num::NonZeroUsize}; | |
| #[derive(Debug, Clone)] | |
| pub struct BTreeMultiSet<T> { | |
| counts: BTreeMap<T, NonZeroUsize>, | |
| len: usize, | |
| } | |
| impl<T> BTreeMultiSet<T> { | |
| pub const fn new() -> Self { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Make `<canvas>` prepared for more pixel density display and returns a 2D rendering context. | |
| * | |
| * @param canvas {HTMLCanvasElement} - To be preapared. | |
| * @param devicePixelRatio {number} - The pixel ratio by device. | |
| * @returns {Canvas2DRenderingContext} - The scaled 2D rendering context. | |
| */ | |
| export function setupCanvas(canvas, devicePixelRatio) { | |
| const { width, height } = canvas; | |
| canvas.width *= devicePixelRatio; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pragma once | |
| #include <vector> | |
| class Fenwick { | |
| std::vector<size_t> data; | |
| size_t parent(size_t i) const { | |
| return i - (i & (-i)); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pragma once | |
| template<class T> | |
| inline void insert_sort(vector<T> &vec, size_t g) { | |
| for (size_t i = g; i < vec.size(); ++i) { | |
| int v = vec[i]; | |
| int j = i - g; | |
| while (0 <= j && v < vec[j]) { | |
| vec[j + g] = vec[j]; | |
| j -= g; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pragma once | |
| #include <algorithm> | |
| #include <optional> | |
| enum class Direction { | |
| North, | |
| West, | |
| East, | |
| South, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pragma once | |
| #include <cmath> | |
| #include <ostream> | |
| const double PI = 3.141592653589793; | |
| struct Quaternion { | |
| double a, b, c, d; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <algorithm> | |
| #include <iostream> | |
| #include <numeric> | |
| using namespace std; | |
| int main() { | |
| int nums[3]; | |
| for (auto &num: nums) { | |
| cin >> num; |