{"id":24707736,"url":"https://github.com/utsavkash19/my-debug-template","last_synced_at":"2025-03-22T05:27:46.330Z","repository":{"id":270575390,"uuid":"910798910","full_name":"UtsavKash19/My-Debug-Template","owner":"UtsavKash19","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-01T13:18:25.000Z","size":78,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-27T06:18:33.520Z","etag":null,"topics":["competitive-programming","contests","cpp","templates"],"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/UtsavKash19.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":"2025-01-01T13:15:23.000Z","updated_at":"2025-01-11T15:40:04.000Z","dependencies_parsed_at":"2025-01-01T14:34:37.619Z","dependency_job_id":null,"html_url":"https://github.com/UtsavKash19/My-Debug-Template","commit_stats":null,"previous_names":["utsavkash19/my-debug-template"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UtsavKash19%2FMy-Debug-Template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UtsavKash19%2FMy-Debug-Template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UtsavKash19%2FMy-Debug-Template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UtsavKash19%2FMy-Debug-Template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UtsavKash19","download_url":"https://codeload.github.com/UtsavKash19/My-Debug-Template/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244912789,"owners_count":20530764,"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","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":["competitive-programming","contests","cpp","templates"],"created_at":"2025-01-27T06:18:35.936Z","updated_at":"2025-03-22T05:27:46.311Z","avatar_url":"https://github.com/UtsavKash19.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# C++ Debug Template\nSimplify variable tracking across functions and loops!\n\n## Simple Usage \n```c++\nint mat[3][5]{};\nvector\u003cint\u003e v;\nfor (int i = 1; i \u003c= 3; i++)\n{\n    v.push_back(i * i);\n    debug(i, v);\n}\ndebug(mat);\n\n// stderr\n23: [i = 1 || v = {1}]\n23: [i = 2 || v = {1,4}]\n23: [i = 3 || v = {1,4,9}]\n25: [mat = \n~~~~~\n0 {0,0,0,0,0}\n1 {0,0,0,0,0}\n2 {0,0,0,0,0}\n~~~~~\n]\n```\nThis template supports datatypes such as:\n\n- Primitive: `int`, `char`, `bool`, `long long int` etc.\n- STL: `pair`, `tuple`, `vector`, `set`, `oset`, `map`, `omap`,`stack`, `queue`, `priority_queue`, `bitset` etc.\n- Arrays of all datatypes: `int arr[]`, `bool arr[]`, `vector\u003cint\u003e adj[]` etc.\n- Matrix: `int dp[100][200]`, `vector\u003cvector\u003cbool\u003e\u003e vis(100, vector\u003cbool\u003e (200, 0))` etc.\n- Arrays that have been decayed or declared at runtime `int arr[n]`.\n- Rvalue Literals like `\"Hello\"`, `false`, `'z'`, `isSafe(i, j), dfs(u)` etc. \n- User defined structs / classes like `Point`, `Node`. \n- Even complicated nested datatypes like: `map\u003cstring, vector\u003cpair\u003cchar, unordered_set\u003clong long\u003e\u003e\u003e\u003e WHATTT;` etc.\n\nColoured version of this template is also supported. (Terminal Only)\n\n\u003cimg src=\"colouredTemplateDark.png\"\u003e\n\nYou can use it on your computer when doing coding challenges on sites like **CodeForces**. \u003cbr\u003e\nAdditionally, you can use it in online coding environments like **LeetCode** for practicing data structures and algorithms.\n\n## How to use it?\n\nLet's say you have different datatypes such as:\n```c++\nchar Char = 'A';\nint arr[] = {1, 2, 3, 4};\nbitset\u003c8\u003e Bitset(100);\nmap\u003cstring, int\u003e map_String_Int = {{\"apple\", 5}, {\"banana\", 3}, {\"orange\", 7}};\n```\nYou can debug them like this `debug(var1, var2, var3, var4, ...);`\n```c++ \ndebug(Char, arr, Bitset, map_String_Int);\n\n// Output\n21: [Char = 'A' || arr = {1,2,3,4} || Bitset = 01100100 || map_String_Int = {(\"apple\",5),(\"banana\",3),(\"orange\",7)}]\n```\nIf you have user defined structs / classes, you just need to make a `print()` function, and use `debug(...)` like you do :)\n```c++\nvoid print(Point ob) { cerr \u003c\u003c \"(\" \u003c\u003c ob.x \u003c\u003c \",\" \u003c\u003c ob.y \u003c\u003c \")\"; }\n```\n\nIn instances where array have decayed into pointer, or you declared array at runtime, use `debugArr(arr, n)`;\n\n**Note:**\n\n\n- You don't need to remove `debug(var, ...)` statements in your code when submitting it. \u003cbr\u003e\n- On platforms like Codeforces, there's a macro called `ONLINE_JUDGE` that's defined, automatically disregarding all your debug statements. This ensures your solution will be accepted unless there's a logical error.\n  \n## How to Setup?\n\n- Copy this template into your own templates. The output will be directed to the stderr stream.\n- Alternatively you can make a separate header file and include this into your template.\n  ```c++\n  #ifndef ONLINE_JUDGE\n  #include \"template.cpp\"\n  #else\n  #define debug(...)\n  #define debugArr(...)\n  #endif\n  ```\n- When using it for LeetCode uncomment `#define cerr cout` and before submitting change `#ifndef` to `#ifdef` to ignore `debug(...);`. For convenience, after changing it, copy it, and keep it pinned in your clipboard for repetitive use.\n\n**For Complete Beginners who need step by step tutorial (using VS Code), follow these steps:**\n\u003cdetails\u003e\n  \u003csummary\u003e \u003cstrong\u003e Steps \u003c/strong\u003e \u003c/summary\u003e\n  \n  1. Open VS Code\n  2. In your workspace, create a file _template.cpp_\n  3. Copy content of one of my _template.cpp_ into your _template.cpp_\n  4. Press **Ctrl + Shift + P** to open Command Pallete\n  5. Search **Configure User Snippet** and click on _cpp.json_\n  6. Now copy the content of my _cpp.json_ into your _cpp.json_ file\n  7. Now you have configured your user snippets. Create a _main.cpp_ file and type **wow** and press TAB!!! Magic!!! \u003cbr\u003e\n\n  Additionally, you can install `Competitive Programming Helper` extension from VS Code to make your journey easy.\n\n  Now for LeetCode\n\n  1. Uncomment `#define cerr cout` and copy this template\n  2. Keep it pinned in your clipboard. If you are using windows, you can press **Win + V** to open clipboard.\n  3. When solving DSA problems in LeetCode, paste this above `class Solution` and use debug normally.\n  4. Before submitting, change `#ifndef` to `#ifdef` to ignore `debug(...);`.\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futsavkash19%2Fmy-debug-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Futsavkash19%2Fmy-debug-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futsavkash19%2Fmy-debug-template/lists"}