{"id":19149235,"url":"https://github.com/glebegor/competitive-template","last_synced_at":"2025-08-29T21:37:37.446Z","repository":{"id":250894245,"uuid":"835730926","full_name":"Glebegor/competitive-template","owner":"Glebegor","description":"Competitive programming template","archived":false,"fork":false,"pushed_at":"2025-04-24T21:39:44.000Z","size":57,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-24T22:41:10.072Z","etag":null,"topics":["algo","competitive-programming","cpp"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Glebegor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-30T12:22:58.000Z","updated_at":"2025-04-24T21:39:47.000Z","dependencies_parsed_at":"2024-12-19T18:23:54.754Z","dependency_job_id":"a8b7ec54-0de5-449b-95f8-64cc6f95b1d9","html_url":"https://github.com/Glebegor/competitive-template","commit_stats":null,"previous_names":["glebegor/competitive-template"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Glebegor/competitive-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Glebegor%2Fcompetitive-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Glebegor%2Fcompetitive-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Glebegor%2Fcompetitive-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Glebegor%2Fcompetitive-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Glebegor","download_url":"https://codeload.github.com/Glebegor/competitive-template/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Glebegor%2Fcompetitive-template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272766903,"owners_count":24989407,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-29T02:00:10.610Z","response_time":87,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algo","competitive-programming","cpp"],"created_at":"2024-11-09T08:07:18.906Z","updated_at":"2025-08-29T21:37:37.440Z","avatar_url":"https://github.com/Glebegor.png","language":"C++","readme":"# Competitive Template\n\n## Description\n\nThis is the template I use for competitive programming. Below is a detailed description of the main functions and utilities included.\n\n## Imports\n\n```cpp\n#include \u003calgorithm\u003e\n#include \u003ciostream\u003e\n#include \u003cmemory.h\u003e\n#include \u003cnumeric\u003e\n#include \u003csstream\u003e\n#include \u003citerator\u003e\n#include \u003ccassert\u003e\n#include \u003cfstream\u003e\n#include \u003ccstdlib\u003e\n#include \u003cvector\u003e\n#include \u003ccstdio\u003e\n#include \u003cstring\u003e\n#include \u003cqueue\u003e\n#include \u003cdeque\u003e\n#include \u003ccmath\u003e\n#include \u003cctime\u003e\n#include \u003cstack\u003e\n#include \u003cset\u003e\n#include \u003cmap\u003e\n#include \u003cunordered_set\u003e\n#include \u003cunordered_map\u003e\n#include \u003cbitset\u003e\n#include \u003ciomanip\u003e\n#include \u003ccomplex\u003e\n```\n\n## Types\n\n```cpp\nusing ll = long long;\nusing ld = long double;\nusing l128 = __int128_t;\nusing u32 = unsigned;\nusing u64 = unsigned long long;\nusing lli = long long int;\nusing Com = std::complex\u003cll\u003e; // Complex numbers\n#define ComX real()\n#define ComY imag()\n```\n\n## Constants\n\n```cpp\n#define INF 1e12 + 7\n#define MOD7 1e9 + 7\n#define MOD9 1e12 + 9\n#define MIN 0\n#define EU exp(1.0)\nconst ld PI = acos((ld)-1);\nconst int maxNum = 111111111;\n```\n\n## Vectors\n\n```cpp\ntemplate\u003ctypename T\u003e\nusing V = std::vector\u003cT\u003e;\ntypedef V\u003cint\u003e vi;\ntypedef V\u003cV\u003cint\u003e\u003e vii;\ntypedef V\u003cstd::string\u003e vs;\ntypedef V\u003cbool\u003e vb;\ntypedef V\u003cll\u003e vl;\ntypedef V\u003cld\u003e vd;\ntypedef V\u003clli\u003e vli;\ntypedef V\u003cV\u003cint\u003e\u003e vvi;\ntypedef V\u003cV\u003cll\u003e\u003e vvl;\n\n#define sz(x) int(size(x))\n#define bg(x) begin(x)\n#define all(x) bg(x), end(x)\n#define rall(x) rbegin(x), rend(x)\n#define sor(x) sort(all(x))\n#define rsz resize\n#define ins insert\n#define pb push_back\n#define eb emplace_back\n#define ft front()\n#define bk back()\n```\n\n## Basic Functions\n\n```cpp\ntemplate\u003ctypename T\u003e\nll cdiv(T a, T b) {\n    return a / b + ((a ^ b) \u003e 0 \u0026\u0026 a % b);\n}  // Divide a by b rounded up\n\ntemplate\u003ctypename T\u003e\nll fdiv(T a, T b) {\n    return a / b - ((a ^ b) \u003c 0 \u0026\u0026 a % b);\n}  // Divide a by b rounded down\n\ntemplate\u003ctypename T\u003e\nbool ckmin(T \u0026a, const T \u0026b) {\n    return b \u003c a ? a = b, 1 : 0;\n}  // Set a = min(a, b)\n\ntemplate\u003ctypename T\u003e\nbool ckmax(T \u0026a, const T \u0026b) {\n    return a \u003c b ? a = b, 1 : 0;\n}  // Set a = max(a, b)\n\ntemplate\u003ctypename T\u003e\nvoid remDup(V\u003cT\u003e \u0026v) {\n    sort(v.begin(), v.end());\n    v.erase(unique(v.begin(), v.end()), v.end());\n}  // Remove duplicates\n\ntemplate\u003ctypename T\u003e\nT gcd_euclid(T a, T b) {\n    while (b \u003e 0) {\n        ll temp = a / b;\n        a -= temp * b;\n        std::swap(a, b);\n    }\n    return a;\n}  // Greatest common divisor\n\ntemplate\u003ctypename T\u003e\nT lcd(T a, T b) {\n    return a / gcd_euclid(a, b) * b;\n}  // Least common denominator\n\ntemplate\u003ctypename T\u003e\nT lcm(T a, T b) {\n    return abs(a * b) / gcd_euclid(a, b);\n}  // Least common multiple\n\ntemplate\u003ctypename T\u003e\nT factorial(T a) {\n    if (a == 0) {\n        return 1;\n    }\n    return factorial(a - 1) * a;\n}  // Factorial\n\ntemplate\u003ctypename T\u003e\nstd::vector\u003cT\u003e divisors(T n) {\n    std::vector\u003cT\u003e res;\n    for (T d = 1; d * d \u003c= n; ++d) {\n        if (n % d == 0) {\n            res.pb(d);\n            if (d * d != n) {\n                res.pb(n / d);\n            }\n        }\n    }\n    sort(all(res));\n    return res;\n}  // Find all divisors\n\nstd::vector\u003cbool\u003e seive_count(int n) {\n    std::vector\u003cbool\u003e is_prime(n + 1, true);\n    is_prime[0] = is_prime[1] = false;\n    for (int i = 2; i \u003c= n; i++) {\n        if (is_prime[i] \u0026\u0026 (long long)i * i \u003c= n) {\n            for (int j = i * i; j \u003c= n; j += i)\n                is_prime[j] = false;\n        }\n    }\n    return is_prime;\n}  // Prime numbers\n\nbool is_prime_number(int n) {\n    if (n \u003c 2) {\n        return false;\n    }\n    for (int x = 2; x * x \u003c= n; x++) {\n        if (n % x == 0) {\n            return false;\n        }\n    }\n    return true;\n}  // Check if prime\n\nstruct pair_hash {\n    template \u003cclass T1, class T2\u003e\n    std::size_t operator()(const std::pair\u003cT1, T2\u003e \u0026pair) const {\n        auto h1 = std::hash\u003cT1\u003e{}(pair.first);\n        auto h2 = std::hash\u003cT2\u003e{}(pair.second);\n        return h1 ^ h2;\n    }\n};  // Pair hash\n```\n\n## Pairs\n\n```cpp\n#define f first\n#define s second\n#define mkp make_pair\ntypedef std::pair\u003cint, int\u003e pii;\n```\n\n## Loops\n\n```cpp\n#define FOR(i, a, b) for (int _n(b), i(a); i \u003c= _n; i++)\n#define FORD(i, b, a) for (int _n(b), i(a); i \u003c= _n; i--)\n#define REP(i, n) for (int i = 0; i \u003c n; i++)\n#define trav(a, x) for (auto \u0026a : x)\n```\n\n## Files\n\n```cpp\n// freopen(\"input.txt\", \"r\", stdin);\n// freopen(\"output.txt\", \"w\", stdout);\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglebegor%2Fcompetitive-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fglebegor%2Fcompetitive-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglebegor%2Fcompetitive-template/lists"}