https://github.com/thesobersobber/cp-snippets
CP-Snippets, will write good doc someday
https://github.com/thesobersobber/cp-snippets
atcoder codechef codeforces competitive-programming competitive-programming-contests cpp17 hackerank hackerearth pdf programming snippets
Last synced: about 1 month ago
JSON representation
CP-Snippets, will write good doc someday
- Host: GitHub
- URL: https://github.com/thesobersobber/cp-snippets
- Owner: theSoberSobber
- Created: 2023-02-17T10:31:48.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-26T15:45:13.000Z (4 months ago)
- Last Synced: 2024-12-26T16:32:00.146Z (4 months ago)
- Topics: atcoder, codechef, codeforces, competitive-programming, competitive-programming-contests, cpp17, hackerank, hackerearth, pdf, programming, snippets
- Language: C++
- Homepage: https://bit.ly/cpsnippets
- Size: 7.72 MB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
```bash
curl -L "https://raw.githubusercontent.com/theSoberSobber/CP-Snippets/main/snippets.json" > snippets.json
```
---
# Index -- **[BIT-general](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L2)** : easy BIT general with range updates by diff array too
- **[DSU](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L74)** : DSU
- **[Efficient-Divsibility-Trick-7-and-13](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L109)** : used here: https://codeforces.com/contest/2043/problem/B
- **[ExtendedGcdDiophantine](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L117)** : Diophantine any and all soln
- **[General-Hash](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L239)** : General Hash functions that returns two hashes, takes in 0 indexed arr or string, allows hash query on range, beware that this uses the decreasing power convention
- **[Inline-break](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L314)** : Inline Break by defining break to a function that basically breaks but returns value and hence can be used as a expression with comma operator
- **[LCA-RMQ](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L334)** : LCA using Range Min Query(Sparse) on ETT ([Reference](https://codeforces.com/contest/1975/submission/262585070))
- **[PrefSum2D](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L400)** : 2D Prefix Sum
- **[Segtree-General](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L423)** : General segree, needs node struct (with members def and epsilon(default) for all of them) and operation lambda (merge)
- **[Simpler-Segtree](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L500)** : Init with an array simply using the build fn, customize operation and epslion in the struct itself, supports point updates and range queries
- **[Sparse-General](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L554)** : General Implementation of Sparse table with the template structure
- **[Weird_Lazy_Segtree](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L605)** : A lazy segtree taken from a abc340 E mridulahi submission, it's supposed to be able to do range updates and point queries
- **[Xor-Of-First-N-Natural-Numbers](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L754)** : based on the fact that if n%4==3 then xor till n from 1 is 0
- **[arr-inp](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L777)** : arr-inp
- **[arr-pref](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L785)** : arr-pref
- **[bfs-dist](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L793)** : bfs that measures levels/dist
- **[binpow](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L812)** : binpow
- **[binsearch](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L827)** : binsearch
- **[bp-small](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L848)** : bp-small
- **[bp](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L893)** : bp
- **[clock_for_TL](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L971)** : clock
- **[combi-mint](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L983)** : combi template with mint
- **[combi-struct](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1059)** : combi-struct
- **[combination-non-mod](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1110)** : combination-non-mod
- **[combination-small](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1127)** : combination-small
- **[combination](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1143)** : combination
- **[crt](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1156)** : crt
- **[cute-lcm](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1180)** : [a,b,c]=abc(a,b,c)/(a,b)(b,c)(c,a), where []=lcm adn ()=gcd or [a,b,c]=abc/gcd(ab,bc,ca)
- **[derangments](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1190)** : derangments
- **[dfs-full](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1203)** : dfs with lots of stuff implemented
- **[dfs](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1233)** : weird ass dfs
- **[diophantine](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1253)** : linear diophantine
- **[dsu-rr](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1329)** : dsu-rr
- **[easy_seive](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1368)** : easy_seive
- **[euclid](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1387)** : euclid
- **[explanation_binsearch](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1412)** : explanation_binsearch
- **[fac](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1447)** : fac
- **[factorization](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1461)** : factorization
- **[fenwick](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1491)** : binary indexed tree
- **[file_io](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1531)** : for coding competetions
- **[freq-map](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1541)** : freq-map
- **[gr-inp-Fwt](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1552)** : graph input weight
- **[gr-inp](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1565)** : graph input
- **[highest_exponent](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1578)** : power_in_fac
- **[interactive](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1593)** : essential measures for interactive problems
- **[ip-overloads](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1618)** : I/O Overloads that I don't use
- **[kadane](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1635)** : max subarray sum O(n)
- **[kahn's algo](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1651)** : toposort using bfs (kahn's algo)
- **[kosaraju](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1673)** : kosaraju
- **[kruskal](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1753)** : kruskal
- **[lambda_function](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1774)** : lambda_function
- **[lca-isAncestor](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1783)** : lca that uses isAncestor instead of level jumping, sets a level upper limit of 25 itself since 2^25 is bigger than any N give anyways
- **[lca](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1834)** : LCA path satisfying some condition
- **[log](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1895)** : log
- **[matrix](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1926)** : matrix
- **[mint](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L1977)** : modular integer
- **[modpow](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L2036)** : modpow
- **[pbds](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L2052)** : pbds
- **[pq](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L2067)** : pq
- **[prime-related-stuff](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L2075)** : implements prime fac, fac list and is_prime in both space optimized and time optimized ways
- **[re-write](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L2266)** : a bunch of re and write functions based on template meta programming heklpful in cp.
- **[recur-binsearch](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L2288)** : recursive binary search implementation to make intution easier ig
- **[recur-modpow](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L2305)** : recur-modpow
- **[rng](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L2321)** : rng
- **[rr-segtree](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L2330)** : best segtree
- **[segtree](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L2474)** : sextree
- **[seive](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L2588)** : seive
- **[splay-tree-rr-sir](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L2606)** : used here by rr sir, I have no idea how to use it or what it's used in mostly, [RR Sir ABC F Submission](https://atcoder.jp/contests/abc350/submissions/52600529)
- **[tokenizer](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L2801)** : tokenizer that has no use
- **[totient-seive](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L2808)** : totient-seive
- **[totient](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L2822)** : totient
- **[trie](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L2842)** : trie
- **[troll](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L2878)** : troll
- **[two-sat (kosaraju)](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L2888)** : two-sat (kosaraju)
- **[variadic](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L3025)** : variadic lambdas with 1 and 2 arguments
- **[xor-basis](https://github.com/theSoberSobber/CP-Snippets/blob/main/snippets.json#L3034)** : xor-basis