[
  {
    "path": "00-Setting-up-local-environment/README.md",
    "content": "# Setting up Competitive Programming on Local Machine :\n\n#### Content\n\n- [Benefits](#Benefits)\n\n- [SetUp](#Setting-up-env)\n\n- [Snippets](#Snippets)\n\n\n<br> <hr> <br>\n\n\n## Benefits\n\n\n#### It is always a good practice to set up your coding environment right on your pc as :\n\n* It helps in faster code execution.\n\n* Independent of the load on IDE's during the contest.\n\n* Various Code Snippets can be used.\n\n* Interaction with command line and terminal.\n\n* Less chances of your code getting leaked.\n\n\n\n<br> <hr> <br>\n\n\n\n## Setting up env:\n\nSo below are some good setups which you may like and may modify as well as per your choice.\n\nAlso, you can set up your environment as you like if you have basic knowledge and read any of the blogs below. Just set up the compiler and a text editor or ide. Remember to add the path of your compiler to environment variable.\n\np.s. Should read about precompiling the headers if you use C++ for faster build.\n\n[Codeforces blog for some editor preferences](https://codeforces.com/blog/entry/356)\n\n<br>\n\n### VSCode and C++ :\n* [Setting up VS Code for CP - Rachit Jain - Youtube](https://www.youtube.com/watch?v=Y-_3rXgrRAY)\n\n<br>\n\n### Sublime and C++ :\n* [Codingblocks Blog](https://blog.codingblocks.com/2019/setting-up-a-c-competitive-programming-environment/)\n* [Codingblocks - Youtube](https://www.youtube.com/watch?v=Mt6Jb8u9XBk)\n* [Blog - the-hyp0cr1t3](https://github.com/the-hyp0cr1t3/CC/blob/master/Setting%20up%20Sublime.md)\n\n<br>\n\n### C++ in Ubuntu :\n* [GeeksforGeeks Blog](https://www.geeksforgeeks.org/setting-up-a-c-competitive-programming-environment/)\n\n<br>\n\n### Linux Setup with Geany :\n* [Linux Setup with Geany - Errichto - Youtube](https://www.youtube.com/watch?v=ePZEkbbf3fc)\n\n<br>\n\n### Precompiling C++ headers :\n\nIt is always important to precompile the C++ header files to save your precious time in compilation. You can search for the same on the internet if you run into error.\n\nAll you have to do is to find your stdc++.h file in your compiler path and then compile it like normal file with the flags you use to run.\n\n`g++ [your-flags] stdc++.h`\n\n* [Codeforces blog for windows](https://codeforces.com/blog/entry/66809)\n\n* [Codeforces blog for linux distro](https://codeforces.com/blog/entry/53909?)\n\n* [Another Codeforces blog](https://codeforces.com/blog/entry/79026)\n\n<br>\n\n### VSCode and Python3 :\n\nI prefer Python and VSCode setup. Here's how you can set it up :\n\n* Download and install Python3 and VSCode.\n\n* Add path to environment variable. \n\n* Install CodeRunner Extension on VSCode.\n\n* Open your settings.json file on VSCode and modify the coderunner command for any python file as `python -u <input.txt> output.txt` to take input from input.txt and write to output.txt. Then you can easily run your file with <kbd> ctrl + alt + n </kbd>\n\n<br>\n\n### Bonus \n\n[CP Editor](https://cpeditor.org/)\n\nThis editor is purposely designed for CP and Codeforces. Easy to use and many interesting features. It greatly improves typing speed as one of my friends who is a big fan of this editor suggests.\n\n<br> <hr> <br>\n\n## Snippets\n\nSnippets are the cool features offered by the text editors through which you can add a bunch of code just by a few taps. \n\n- [CP Snippets by Atom.io](https://atom.io/packages/cpp-competitive-programming-snippets)\n\n<br> \nYou can add your own snippets as for loading your template, adding a bfs code or for anything you want. Just look for how to add custom snippets in your text editor.\n\n- [VSCode Guide - Blog](https://code.visualstudio.com/docs/editor/userdefinedsnippets)\n\n- [Sublime Text 3 - Video & Blog](https://devdojo.com/episode/how-to-create-sublime-text-snippets)\n\n<br> <br>\n\n> Now you're all set to solve the [problems](https://github.com/luctivud/All-Of-Competitive-Programming/tree/master/01-Material).\n\n> I've mentioned all the popular setups. If you're facing an error in setting up it is easy to google it and find solution on stackoverflow. "
  },
  {
    "path": "01-Material/README.md",
    "content": "# CP Material\n\nMany of the seniors as well good competitive coders advice to not waste any money on the courses which are designed for beginners. It is always easy to start cp on your own and be good at it. However you can choose to have a good certification on Data Structures and ALgorithms offered by [Codechef](https://www.codechef.com/certification/data-structures-and-algorithms/about) or choose a course which aims at advanced data structures and algorithms.\n\n\n\n<br>\n\n\n\n#### Content\n\n* [Books](#books)\n\n* [Informative Blogs](#some-good-and-informative-blogs-)\n\n* [Problemset](#Problemset)\n\n\n\n<br> <hr> <br>\n\n\n\n## Books:\n<br>\n\n* Check out [this](https://github.com/lnishan/awesome-competitive-programming#books-for-algorithms) section for a long list of books.\n\n* I prefer to have [Competitive Programmers Handbook by Antti Laaksonen](https://cses.fi/book/book.pdf) and [Introduction To Algorithms by CLRS](https://web.iiit.ac.in/~pratik.kamble/storage/Algorithms/Cormen_Algorithms_3rd.pdf) as mandatory. \n\n> Note: The best time to read the topics in any book is either in the morning or in the evening to grasp everything. \n\n\n\n\n<br> <hr> <br>\n\n\n\n## Some good and informative blogs :\n<br>\n\nBelow is the encyclopedia of all that one needs to set up the schedule of cp and start away asap.\n\n* [ACM-ICPC Preparation Repository by BedirT](https://github.com/BedirT/ACM-ICPC-Preparation) : The curriculum and schedule one needs to follow to learn data structures and algorithms for ICPC.\n\n* [Getting into Competitive Coding by hyp0cr1t3](https://github.com/the-hyp0cr1t3/CC) : This repo is best for starting cp. It contains everything you need to master cp from basic setup to data structures along with decent problemset. Make sure to check the tips and tricks section.\n \n* [Awesome Competitive Programming by lnishan](https://github.com/lnishan/awesome-competitive-programming) : The encyclopedia of cp. It contains in-depth analysis as well as topic wise practice problems. Probably more than one can ask for.\n\n* [Competitive Coding Implementation (C++) by Ashishgup](https://github.com/Ashishgup1/Competitive-Coding) : Whenever you run into any problem, just check the implementation of Ashish Sir. His codes are easy to understand and beautifully formatted.\n\n* [Competitive Coding Implementation (Python) by cheran-senthil](https://github.com/cheran-senthil/PyRival) : Python Oriented Library for Competitive Programming.\n\n* [OEIS](https://oeis.org/) : who doesn't love integer sequences? Well everyone should.\n\n\n\n\n\n\n<br> [Back To Top](#cp-material) <hr> <br>\n\n\n\n\n\n\n## Problemset\n<br>\n\nThe problemset is divided into two broad categories based on beginner or intermediate level of knowledge. \n\n* [Beginners](#Beginners)\n\n* [Intermediate](#intermediate)\n\n\n\n<br> [Back To Top](#cp-material) <hr> <br>\n\n\n\n\n### Beginners\n\n<br>\n\n\n* **Start :**\n\n    :page_facing_up: [TopCoder-Introduction to Competitive Programming](https://www.topcoder.com/community/competitive-programming/tutorials) \n\n    :movie_camera: [Starting CP - Errichto - Youtube](https://www.youtube.com/watch?v=xAeiXy8-9Y8) \n\n    :page_facing_up: [Codingblocks](https://blog.codingblocks.com/2019/start-with-competitive-programming/)  \n\n    :page_facing_up: [How to start CC - cf](https://codeforces.com/blog/entry/49157)  \n<br>\n\n* **Train :**\n\n    :page_facing_up: [Must do Maths in CP - Gfg](https://www.geeksforgeeks.org/math-in-competitive-programming/?ref=leftbar-rightbar) \n\n    :page_facing_up: [Hackerearth - Codemonk](https://www.hackerearth.com/blog/developers/hackerearth-codemonk-v2-0/) \n\n    :page_facing_up: [Training Roadmap for newcomers - cf](https://codeforces.com/blog/entry/65133) \n\n    - [ ] [Arabic CP](https://github.com/mostafa-saad/ArabicCompetitiveProgramming/) and the [Junior Training Sheet](https://docs.google.com/spreadsheets/d/1iJZWP2nS_OB3kCTjq8L6TrJJ4o-5lhxDOyTaocSYc-k/edit#gid=1160016643) as well as [Supervision Template](https://docs.google.com/spreadsheets/d/1QUegTqKnVtdejCwttYFXHeOQs6Q5nmAT77sxWh3qYMc/edit#gid=2139527441).\n\n    - [ ] [20+ leetcode problems on Sliding Window](https://leetcode.com/discuss/general-discussion/657507/Sliding-Window-for-Beginners-Problems-or-Template-or-Sample-Solutions)\n<br>\n\n\n* **Solve :**\n\n    It is adviced to solve beginner level problems with lower rating first and then jump to higher ratings when you start feeling comfortable. \n\n    Do not copy paste solutions directly from editorial without implementing on your own.\n\n    - [ ] [CSES Problemset](https://cses.fi/problemset/)\n\n    - [ ] [A2OJ Ladders](https://a2oj.com/ladders)\n\n    - [ ] [Another A2OJ ladder](https://earthshakira.github.io/a2oj-clientside/server/Categories.html) : Mirror\n\n    - [ ] [CodeForces-Ladders with updated problemset](https://github.com/karansinghgit/CodeForces-Ladders)\n<br>\n\n* **Bonus :**\n\n    :page_facing_up: [Simple Trick to detect integer overflow - codechef discuss](https://discuss.codechef.com/t/simple-trick-to-detect-integer-overflow-c-c/54373) \n\n    :page_facing_up: [Catching silly mistakes with GCC](https://codeforces.com/blog/entry/15547) \n\n\n\n\n\n<br> [Back To Problemset](#problemset) <hr> <br>\n\n\n\n\n### Intermediate\n\n<br>\n\nSolving the beginner level problems from the above resources will be enough to get a sound knowledge of basic Maths, Greedy, AdHoc and other constructive problems and their approach.\n\nFor Data Structures and Algorithms, consider: \n\n- [ ] [Codechef Blog on Data Structures and Algorithms with 100+ Problems and Tutorial](https://discuss.codechef.com/t/data-structures-and-algorithms/6599)  : This blog has tutorials and practice problems for most of the data structures and algorithms that one can come across.\n\n:page_facing_up: [CP Algorithm](https://cp-algorithms.com/)  : This online project is the English translation of a popular [russian site](http://e-maxx.ru/algo) containing descriptions of many algorithms and data structures especially popular in field of competitive programming and practice problems.\n\n:page_facing_up: [Important Algorithms for Competitive Programming - Code of Geeks](https://codeofgeeks.com/important-algorithms-for-competitive-programming/) \n\n:page_facing_up: [vplanetcoding](https://www.vplanetcoding.com/course2)  : Check out all the free courses.\n\n- [ ] [Junior Training Sheet](https://docs.google.com/spreadsheets/d/1iJZWP2nS_OB3kCTjq8L6TrJJ4o-5lhxDOyTaocSYc-k/edit#gid=1160016643) & [CSES Prolemset](https://cses.fi/problemset/) - (Again!)\n\n<br> \n\n\n>The problems are majorly categorized into following topics for now:\n<br>\n\n**Content**\n<br>\n\n* [Graphs](#Graphs)\n\n* [Dynamic Programming](#Dynamic-Programming)\n\n* [Trees](#Trees)\n\n* [Other](#Other)\n\n\n\n\n<br> [Back To Problemset](#problemset) <hr> <br>\n \n\n\n \n## Graphs\n<br>\n\n* #### Tutorial :\n\n    :page_facing_up: [CF-Center of graph](https://codeforces.com/blog/entry/17974) \n\n    :page_facing_up: [Longest Path Problem - Wikipedia](https://en.wikipedia.org/wiki/Longest_path_problem) \n\n    :page_facing_up: [Graph Diameter - Mathworld](https://mathworld.wolfram.com/GraphDiameter.html) \n\n\n* #### Problemset :\n\n   - [ ] [Codeforces comment with 100+ graph problems](https://codeforces.com/blog/entry/55219?#comment-390897)\n\n   - [ ] [international-open-olympiad-kpiopen-2013-round-1](https://codeforces.com/gym/100279/attachments/download/2025/20122013-international-open-olympiad-kpiopen-2013-round-1-en.pdf)\n\n   - [ ] [LeetCode Graph Related Problems](https://leetcode.com/list/x1vj23fh/)\n\n   - [ ] [500+ Problems on BFS/DFS/Dijkshtra - A2OJ](https://a2oj.com/category?ID=13)\n\n\n   **IARCS**\n   - [ ] [Graphs](https://www.iarcs.org.in/inoi/online-study-material/topics/graphs.php)\n   - [ ] [Advanced Graph Algo](https://www.iarcs.org.in/inoi/online-study-material/topics/advanced-graph-algorithms.php)\n\n   **Union Find**\n   - [ ] [leetcode : friend-circle](https://leetcode.com/problems/friend-circles/)\n   - [ ] [leetcode : redundant-connection](https://leetcode.com/problems/redundant-connection/)\n   - [ ] [leetcode : most-stones-removed-with-same-row-or-column](https://leetcode.com/problems/most-stones-removed-with-same-row-or-column/)\n   - [ ] [leetcode : number-of-operations-to-make-network-connected](https://leetcode.com/problems/number-of-operations-to-make-network-connected/)\n   - [ ] [leetcode : satisfiability-of-equality-equation](https://leetcode.com/problems/satisfiability-of-equality-equations/)\n   - [ ] [leetcode : accounts-merge](https://leetcode.com/problems/accounts-merge/)\n\n   **DFS - Basic**\n   - [ ] [leetcode : surrounded-region](https://leetcode.com/problems/surrounded-regions/)\n   - [ ] [leetcode : number-of-enclave](https://leetcode.com/problems/number-of-enclaves/)\n   - [ ] [leetcode : time-needed-to-inform-all-employee](https://leetcode.com/problems/time-needed-to-inform-all-employees/)\n   - [ ] [leetcode : find-eventual-safe-state](https://leetcode.com/problems/find-eventual-safe-states/)\n\n   **Island Problems**\n   - [ ] [leetcode : number-of-closed-island](https://leetcode.com/problems/number-of-closed-islands/)\n   - [ ] [leetcode : number-of-island](https://leetcode.com/problems/number-of-islands/)\n   - [ ] [leetcode : keys-and-room](https://leetcode.com/problems/keys-and-rooms/)\n   - [ ] [leetcode : max-area-of-island](https://leetcode.com/problems/max-area-of-island/)\n   - [ ] [leetcode : flood-fill](https://leetcode.com/problems/flood-fill/)\n\n   **BFS**\n   - [ ] [http://codeforces.com/contest/653/problem/E](http://codeforces.com/contest/653/problem/E)\n   - [ ] [https://codeforces.com/contest/769/problem/C](https://codeforces.com/contest/769/problem/C)\n   - [ ] [https://codeforces.com/contest/796/problem/D](https://codeforces.com/contest/796/problem/D)\n   - [ ] [https://codeforces.com/contest/821/problem/D](https://codeforces.com/contest/821/problem/D)\n   - [ ] [http://www.spoj.com/problems/DIGOKEYS/](http://www.spoj.com/problems/DIGOKEYS/)\n   - [ ] [http://www.spoj.com/problems/SPIKES/](http://www.spoj.com/problems/SPIKES/)\n   - [ ] [http://www.spoj.com/problems/MULTII/](http://www.spoj.com/problems/MULTII/)\n   - [ ] [http://www.spoj.com/problems/ADV04F1/](http://www.spoj.com/problems/ADV04F1/)\n   - [ ] [http://www.spoj.com/problems/ADV04F1/](http://www.spoj.com/problems/ADV04F1/)\n   - [ ] [leetcode : 01-matrix](https://leetcode.com/problems/01-matrix/)\n   - [ ] [leetcode : as-far-from-land-as-possible](https://leetcode.com/problems/as-far-from-land-as-possible/)\n   - [ ] [leetcode : rotting-orange](https://leetcode.com/problems/rotting-oranges/)\n   - [ ] [leetcode : shortest-path-in-binary-matrix](https://leetcode.com/problems/shortest-path-in-binary-matrix/)\n\n   **Graph Coloring**\n   - [ ] [leetcode : possible-bipartition](https://leetcode.com/problems/possible-bipartition/)\n   - [ ] [leetcode : is-graph-bipartite](https://leetcode.com/problems/is-graph-bipartite/)\n\n   **Topological Sort**\n   - [ ] [leetcode : course-schedule](https://leetcode.com/problems/course-schedule/)\n   - [ ] [leetcode : course-schedule-ii](https://leetcode.com/problems/course-schedule-ii/)\n   - [ ] [codeforces : 510C-Fox and names](https://codeforces.com/contest/510/problem/C)\n\n   **Other**\n   - [ ] [https://dmoj.ca/problem/tle16c4p4](https://dmoj.ca/problem/tle16c4p4)\n   - [ ] [https://codeforces.com/problemset/problem/322/E](https://codeforces.com/problemset/problem/322/E)\n   - [ ] [https://codeforces.com/problemset/problem/592/D](https://codeforces.com/problemset/problem/592/D)\n   - [ ] [https://codeforces.com/contest/456/problem/E](https://codeforces.com/contest/456/problem/E)\n   \n\n   The above problems were extracted from [this leetcode article](https://leetcode.com/discuss/general-discussion/655708/graph-for-beginners-problems-pattern-sample-solutions). Thanks to the work of [wh0ami sir](https://leetcode.com/wh0ami/).\n\n\n\n\n\n\n<br> [Back To Problemset](#problemset) <hr> <br>\n \n\n\n\n\n \n## Dynamic Programming\n<br>\n\n* #### Tutorial :\n\n    :page_facing_up: [Hackerearth](https://www.hackerearth.com/practice/algorithms/dynamic-programming/introduction-to-dynamic-programming-1/tutorial/) \n\n    :page_facing_up: [Codechef Tutorial and few problems](https://www.codechef.com/wiki/tutorial-dynamic-programming) \n\n    :page_facing_up: [TutorialsPoint Blog](https://www.tutorialspoint.com/data_structures_algorithms/dynamic_programming.htm) \n\n    :movie_camera: [CS Dojo - Youtube](https://www.youtube.com/watch?v=vYquumk4nWw) \n\n    :movie_camera: [Aditya Verma - Youtube](https://www.youtube.com/watch?v=nqowUJzG-iM&list=PL_z_8CaSLPWekqhdCPmFohncHwz8TY2Go)  Check this one out.\n\n    :movie_camera: [CodeN Code - youtube](https://www.youtube.com/watch?v=AfE1nZjG5ZM&list=PL2q4fbVm1Ik71hmKyay-GkU6J9GTXCe5g) \n\n    :page_facing_up: [Dynamic Programming Beginner's Course](https://discuss.codechef.com/t/dynamic-programming-beginners-course/70936) contains problems and video tutorials.\n\n* #### Problemset :\n\n    - [ ] [100+ LeetCode problems - wh0ami](https://leetcode.com/discuss/general-discussion/662866/Dynamic-Programming-for-Practice-Problems-Patterns-and-Sample-Solutions)\n\n    - [ ] [100+ codeforces problems - karansinghgit](https://github.com/karansinghgit/CodeForces-Ladders/blob/master/dynamicProgramming.md)\n\n    - [ ] [1000+ problems on DP - A2OJ](http://a2oj.com/category?ID=33)\n\n    - [ ] [Few other DP problems - A2OJ](https://a2oj.com/category?ID=758)\n\n    - [ ] [AtCoder DP Contest](https://atcoder.jp/contests/dp/tasks)\n\n    - [ ] [30+ Non-Classical Dynamic Programming problems - A2OJ](https://a2oj.com/category?ID=126)\n\n\n\n<br> [Back To Problemset](#problemset) <hr> <br>\n \n \n\n\n\n## Trees\n<br>\n\n* #### Tutorial :\n\n    :page_facing_up: [Trees - hackerearth](https://www.hackerearth.com/practice/notes/trees/) \n\n    :page_facing_up: [Fenwick Tree - gfg](https://www.geeksforgeeks.org/binary-indexed-tree-or-fenwick-tree-2/) \n\n    :page_facing_up: [Dynamic Programming on Trees - gfg](https://www.geeksforgeeks.org/dynamic-programming-trees-set-1/) \n    \n    :movie_camera: [Dynamic Programming on Trees - Aditya Verma - Youtube](https://www.youtube.com/playlist?list=PL_z_8CaSLPWfxJPz2-YKqL9gXWdgrhvdn) \n\n\n* #### Problemset :\n\n    - [ ] [Vplanet](https://www.vplanetcoding.com/course3)\n\n    - [ ] [Binary and n-ary trees - Hackerearth](https://www.hackerearth.com/practice/data-structures/trees/binary-and-nary-trees/practice-problems/)\n\n    - [ ] [BST - hackerearth](https://www.hackerearth.com/practice/data-structures/trees/binary-search-tree/practice-problems/)\n\n    - [ ] [Heaps - hackerearth](https://www.hackerearth.com/practice/data-structures/trees/heapspriority-queues/practice-problems/)\n\n    - [ ] [GERALD2 - codechef](http://www.codechef.com/NOV13/problems/GERALD2)\n\n    - [ ] [GERALD07 - codechef](http://www.codechef.com/MARCH14/problems/GERALD07)\n\n    - [ ] [FBCHEF - codechef](http://www.codechef.com/APRIL14/problems/FBCHEF)\n\n    - [ ] [GERALD08 - codechef](http://www.codechef.com/APRIL14/problems/GERALD08)\n\n    - [ ] [MLCHEF - codechef](https://www.codechef.com/SEPT13/problems/MLCHEF)\n    \n    - [ ] [200+ Problems on Trees - A2OJ](https://a2oj.com/category?ID=89)\n\n    - [ ] [150+ Problems on Segment Trees - A2OJ](https://a2oj.com/category?ID=25)\n\n    - [ ] [20+ problems on Balanced BST - A2OJ](https://a2oj.com/category?ID=14)\n\n    - [ ] [20+ problems on suffix array  A2OJ](https://a2oj.com/category?ID=44)\n\n\n\n\n<br> [Back To Problemset](#problemset) <hr> <br>\n \n\n\n\n\n \n## Other\n<br>\n\n:movie_camera: [Algorithm - SecondThread - Youtube](https://www.youtube.com/watch?v=cVBzMXYc4ss&list=PLZU0kmvryb_HZpDW2yfn-H-RxAu_ts6xq)\n\n:page_facing_up: [Matrix Exponentiation cf Blog](https://codeforces.com/blog/entry/67776) \n\n:page_facing_up: [Matrix Expo - gfg](https://www.geeksforgeeks.org/matrix-exponentiation/) \n\n:movie_camera: [Matrix Expo - Errichto - Youtube](https://www.youtube.com/watch?v=eMXNWcbw75E) \n\n- [ ] [Matrix Expo - Problems - Mashup](https://codeforces.com/gym/102644)\n\n- [ ] [90+ problems on matrix expo - A2OJ](https://a2oj.com/category?ID=32)\n\n\n\n<br> [Back To Problemset](#problemset) <hr> <br>\n\n\n\n\n> Note: There's a whole lot of problems still to be added. Any help will be appreciated."
  },
  {
    "path": "02-Codes/Editorials/ConvertToStrictlyIncreasing/ConevertToStrictlyIncreasing.md",
    "content": "<h2> Convert an array into Strictly Increasing Array </h2>\n<i> Solution by Udit Gupta </i>\n\n</br>\n<br>\n\n<h3> Problem Statement </h3>\n\nGiven an array consisting of <b> N </b> elements namely from A<sub>1</sub> to A<sub>N</sub>. You have to convert this array to <strong>strictly increasing </strong> array in not more than <strong> K</strong> cost. \nOperations allowed :\n1. Increase an element by 1.\n2. Decrease an element by 1.\n\nCost of each operation is 1 unit.\n\n</br>\n\n<h3> Constraints </h3>\n\n- <b> N < 3000 </b>\n  \n- <b> K < 5000 </b>\n  \n- <b> |A<sub>i</sub>| < 10<sup>9</sup> </b> for all i from 1 to N.\n  \n</br>\n\n<h4> Expected Time Complexity : O(N<sup>2</sup>) </h4>\n  \n  </hr>\n  </br>\n  \n<br>\n\n<h3> Solution </h3>\n\n<h4> Observation </h4>\n  <p>\n    \n  1. After solving a few examples on pen and paper, we get to see that a greedy solution would fail on cases like [8, 1, 2, 3, 4] or [7, 1, 5, 2, 4, 8, 6].\n  \n  2. Another key observation is that in the transformed array which is strictly increasing, we will find that  there is atleast one element which remains unchanged. \n  </p>\n  \n<h4> Deduction </h4>\n\nThe problem statement above can be translated into simpler terms by stating that \n\nfor each i from _1_ to _N-1_,  &nbsp; **A<sub>i</sub> &nbsp; < &nbsp; A<sub>i+1</sub>**\n\nNow we shall work on simplifying it further and deducing a general formula for all terms, \n\n- **A<sub>i</sub> &nbsp; < &nbsp; A<sub>i+1</sub>**\n\n- **A<sub>i</sub> &nbsp; &le; &nbsp; A<sub>i+1</sub> - 1**\n\n- Subtracting i from both sides, \n\n- **A<sub>i</sub>-i &nbsp; &le; &nbsp; A<sub>i+1</sub>-1-i**\n\n_or_\n\n- **A<sub>i</sub>-i &nbsp; &le; &nbsp; A<sub>i+1</sub>-(i+1)**\n\nThis is the general formulation which should work for all indices in range [1, N].\ni.e.  \n\nThe sequence represented by **(A<sub>i</sub>-i)** &nbsp; &forall; &nbsp; i &isin; [1, N] should be a **non decreasing sequence**.\n\nTo achieve this we take use of dynamic programming and brute force our way to make the subsequent array element equal to the previous one if not or leaving it as it is depending on the previous dp state. \n\nThis idea, here, comes from observation 2 and we can even end up converting the whole array to a single element. \n\n<p style = \"padding-left: 50pt;\">\nDP transition states:\n\n- **dp[j] = min(dp[j-1], dp[j] + abs(A[i] - B[j]))** &nbsp; &forall; &nbsp; i, j &isin; [1, N]. \n\nPlease note that the array **A** here is the converted array represented by (A<sub>i</sub>-i) &nbsp; &forall; &nbsp; i &isin; [1, N] and **B** is its sorted version. \n\nOur final answer that represents the minimum cost is stored in the final index of our **dp** array which represents the optimal array till last index of **A**.\n</p>\n\nIf our minimum cost is not more than **K** then we can certainly achieve the optimal solution.\n\nNote : This dp solution can be made more state verbose by storing the brute forced optimal substructure into their respective states in dp[i][j] but I prefer it this way. \n\n<details>\n  <summary>Python Code</summary>\n<p>\n\n```python\nN = int(input())\nK = int(input())\nA = [0] + list(map(int, input().split()))\n\n# Convert A[i] = A[i] - i\nfor i in range(1, N+1):\n\tA[i] = A[i] - i\n\n# store sorted A in B to stay working\n# with best possible element already\nB = [0] + sorted(A[1:])\n\n# dp array \ndp = [0 for x in range(N+1)]\n\n# unreachable state\ndp[0] = float('inf')\n\nfor i in range(1, N+1):\n\tfor j in range(1, N+1):\n\t\tdp[j] = min(dp[j-1], dp[j] + abs(A[i] - B[j]))\n\n\n# dp[N] represent the ans\nprint(\"YES \"+str(dp[N]) if dp[N] <= K else \"NO\")\n```\n  \n</p>\n</details>\n\n<details>\n  <summary>C++ Code</summary>\n<p>\n\n```cpp\n#include<iostream>\n#include<vector>\n#include<algorithm>\n\nsigned main() {\n\tlong long N, K;\n\tstd::cin >> N >> K;\n\n\tstd::vector<long long> A(N+1, 0ll);\n\tfor (long long i = 1ll; i <= N; i++) {\n\t\tstd::cin >> A.at(i);\n\t\tA.at(i) -= i;\n\t}\n\n\t// sorted version of A\n\tstd::vector<long long> B{A};\n\tstd::sort(B.begin() + 1ll, B.end());\n\n\t// dp array\n\tstd::vector<long long> dp(N+1, 0ll);\n\tdp.at(0) = (long long) 1e9;\n\n\tfor (long long i = 1ll; i <= N; i++) {\n\t\tfor (long long j = 1ll; j <= N; j++) {\n\t\t\tdp.at(j) = std::min(dp.at(j-1), dp.at(j) + llabs(A.at(i) - B.at(j)));\n\t\t}\n\t}\n\n\tif (dp.at(N) <= K) {\n\t\tstd::cout << \"YES \" << dp.at(N);\n\t} else {\n\t\tstd::cout << \"NO\";\n\t}\n\n\treturn 0;\n}\n```\n  \n</p>\n</details>\n\n\n\n\nTime Complexity : O(N<sup>2</sup>)\n\nSpace Complexity : O (N)\n\n\n\n\n  \n  \n"
  },
  {
    "path": "02-Codes/Editorials/ConvertToStrictlyIncreasing/convertToIncreasing.cpp",
    "content": "#include<bits/stdc++.h>\n\nusing namespace std;\n\nsigned main() {\n\tlong long N, K;\n\tcin >> N >> K;\n\n\tvector<long long> A(N+1, 0ll);\n\tfor (long long i = 1ll; i <= N; i++) {\n\t\tcin >> A.at(i);\n\t\tA.at(i) -= i;\n\t}\n\n\t// sorted version of A\n\tvector<long long> B{A};\n\tsort(B.begin() + 1ll, B.end());\n\n\t// dp array\n\tvector<long long> dp(N+1, 0ll);\n\tdp.at(0) = (long long) 1e9;\n\n\tfor (long long i = 1ll; i <= N; i++) {\n\t\tfor (long long j = 1ll; j <= N; j++) {\n\t\t\tdp.at(j) = min(dp.at(j-1), dp.at(j) + llabs(A.at(i) - B.at(j)));\n\t\t}\n\t}\n\n\tif (dp.at(N) <= K) {\n\t\tcout << \"YES \" << dp.at(N);\n\t} else {\n\t\tcout << \"NO\";\n\t}\n\n\treturn 0;\n}"
  },
  {
    "path": "02-Codes/Editorials/ConvertToStrictlyIncreasing/convertToIncreasing.py",
    "content": "N = int(input())\nK = int(input())\nA = [0] + list(map(int, input().split()))\n\n# Convert A[i] = A[i] - i\nfor i in range(1, N+1):\n\tA[i] = A[i] - i\n\n# store sorted A in B to stay working\n# with best possible element already\nB = [0] + sorted(A[1:])\n\n# dp array \ndp = [0 for x in range(N+1)]\n\n# unreachable state\ndp[0] = float('inf')\n\nfor i in range(1, N+1):\n\tfor j in range(1, N+1):\n\t\tdp[j] = min(dp[j-1], dp[j] + abs(A[i] - B[j]))\n\n\n# dp[N] represent the ans\nprint(\"YES \"+str(dp[N]) if dp[N] <= K else \"NO\")"
  },
  {
    "path": "02-Codes/Editorials/Random/TransposeColorsWork.cpp",
    "content": "//  J A I  S H R E E  R A M  //\n\n#include <bits/stdc++.h>\n\n#pragma GCC optimize \"trapv\"\n// #pragma GCC optimize (\"Ofast\")\n// // #pragma GCC target (\"fpmath=sse,sse2\")\n// #pragma GCC target (\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx\")\n// #pragma GCC optimize (\"-ffloat-store\")\n\n\nusing namespace std;\n\ntypedef long long int lld;\ntypedef unsigned long long int llu;\n\n#define        forn(I7, E4)    for(lld I7=0ll; I7 < E4; (I7)+=1ll)\n#define       forn1(I7, E4)    for(lld I7=1ll; I7 < E4+1; (I7)+=1ll)\n#define              len(v)    ((int)((v).size()))\n#define              all(x)    (x).begin(), (x).end()\n#define             rall(x)    (x).rbegin(), (x).rend()\n#define                  f1    first\n#define                  s2    second\n\ntemplate<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << \", \" << p.second << ')'; }\ntemplate < typename T_container, typename T = typename enable_if < !is_same<T_container, string>::value, typename T_container::value_type >::type >\nostream & operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = \", \"; return os << '}'; }\nvoid dbg_out() { cout << \"\\n\"; }\ntemplate<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << H << \", \"; dbg_out(T...);}\n#define _____error_____(...) cout << #__VA_ARGS__ << \" : \", dbg_out(__VA_ARGS__)\n\nconst lld d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};\nconst lld d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};\n\n\nconst long double EPS = 1e-6;\nlld TempVar, mod, MOD;\n\n\n/*\n:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n*/\n\n\n\n\n\n\nvoid solveEachTest(int _TestCase) {\n    // cout << \"Case #\" << _TestCase << \": \";\n    vector<int>moves;\n    while(cin >> TempVar) {\n    \tmoves.push_back((int)TempVar);\n    }\n    int n = (int)sqrt(moves.back());\n\n    vector<vector<char>> matr(n+1, vector<char>(n, '-'));\n    forn(i, n) {\n    \tforn(j, n) {\n    \t\tmatr[i][j] = char('A' + i);\n    \t}\n    }\n\n    matr[n][0] = '.';\n\n\n //    for (auto row : matr) {\n\t// \tcout << row << \"\\n\";\n\t// } cout << \"\\n\";\n\n    int sz = (int)moves.size();\n    int tempX = n, tempY = 0;\n    forn(i, sz-1) {\n    \tint posX = moves[i] / n, posY = moves[i] % n;\n    \tswap(matr[posX][posY], matr[tempX][tempY]);\n    \ttempX = posX, tempY = posY;\n    \t// for (auto row : matr) {\n    \t// \tcout << row << \"\\n\";\n    \t// } cout << \"\\n\";\n    }\n\n    bool ok = true;\n    forn(i, n) {\n    \tset<char> cnt;\n    \tforn(j, n) {\n    \t\tcnt.insert(matr[i][j]);\n    \t}\n    \tok &= ((int)cnt.size() == n);\n    }\n\n    cout << \"Checker Verdict:\\n\";\n    cout << (ok ? \"Accepted\" : \"Wrong Answer\") << \"\\n\";\n    cout << \"Moves : \" << moves.size();\n    \n    return;\n}\n\n\nsigned main() {\n    ios_base::sync_with_stdio(false); cin.tie(0);\n    // cout.precision(10); cout << fixed;\n    #ifdef LUCTIVUD\n      // const auto start_time = std::chrono::high_resolution_clock::now();\n      freopen(\"/home/luctivud/CPPractice/Zinput.txt\", \"r\", stdin);\n      freopen(\"/home/luctivud/CPPractice/Zoutput.txt\", \"w\", stdout);\n    #endif\n\n\n    MOD = mod = lld(1e9) + 7ll;\n    lld _T0T4 = 1;\n    // cin >> _T0T4; \n\n    for (int _TestCase = 1; _TestCase <= _T0T4; _TestCase++) {\n        solveEachTest(_TestCase);\n        cout << \"\\n\"; \n    }\n\n\n    #ifdef LUCTIVUD\n      // auto end_time = std::chrono::high_resolution_clock::now();\n      // std::chrono::duration<double> diff = end_time - start_time;\n      // cerr << \"Finished in : \" << diff.count() << \"\\n\";\n    #endif\n\n    return 0; \n}\n\n\n/*  ~~\nAuthor   :  Udit \"luctivud\" Gupta \nlinkedin :  https://www.linkedin.com/in/udit-gupta-1b7863135/\n*/\n"
  },
  {
    "path": "02-Codes/README.md",
    "content": "<h1> Containing codes of some problems </h1>\n\n<p> Check the subfolders for contents, it has some snippets and editorials </p> \n"
  },
  {
    "path": "02-Codes/Snippets/Raw/166_e_MatMul_w_Ashishgup.cpp",
    "content": "//  J A I  S H R E E  R A M  //\n\n#include <bits/stdc++.h>\n\n#pragma GCC optimize \"trapv\"\n// #pragma GCC optimize (\"Ofast\")\n// // #pragma GCC target (\"fpmath=sse,sse2\")\n// #pragma GCC target (\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx\")\n// #pragma GCC optimize (\"-ffloat-store\")\n\n\nusing namespace std;\n\ntypedef long long int lld;\ntypedef unsigned long long int llu;\n\n#define        forn(I7, E4)    for(lld I7=0ll; I7 < E4; (I7)+=1ll)\n#define       forn1(I7, E4)    for(lld I7=1ll; I7 < E4+1; (I7)+=1ll)\n#define              len(v)    ((int)((v).size()))\n#define              all(x)    (x).begin(), (x).end()\n#define             rall(x)    (x).rbegin(), (x).rend()\n#define                  f1    first\n#define                  s2    second\n\ntemplate<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << \", \" << p.second << ')'; }\ntemplate < typename T_container, typename T = typename enable_if < !is_same<T_container, string>::value, typename T_container::value_type >::type >\nostream & operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = \", \"; return os << '}'; }\nvoid dbg_out() { cout << \"\\n\"; }\ntemplate<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << H << \", \"; dbg_out(T...);}\n#define _____error_____(...) cout << #__VA_ARGS__ << \" : \", dbg_out(__VA_ARGS__)\n\nconst lld d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};\nconst lld d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};\n\n\nconst long double EPS = 1e-6;\nlld TempVar, mod, MOD;\n\n\n/*\n:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n*/\n\n\n// matrix exponentiation snippet::\n// // courtesy Ashishgup3 via Github\n\n\n\n\n\nlld add(lld a, lld b) {\n    lld res = a + b;\n    if(res >= MOD) return res - MOD;\n    return res;\n}\n\nlld mult(lld a, lld b) {\n    long long res = a;\n    res *= b;\n    if(res >= MOD) return res % MOD;\n    return res;\n}\n\n\n\nconst lld SZ = 2; // size of MaGiC \n\nstruct matrix {\n    lld MaGiC[SZ][SZ];\n\n    void reset() {\n        memset(MaGiC, 0, sizeof(MaGiC));\n    }\n\n    void makeiden() {\n        reset();\n        for(lld i=0;i<SZ;i++) {\n            MaGiC[i][i] = 1;\n        }\n    }\n\n    matrix operator + (const matrix &o) const {\n        matrix res;\n        for(lld i=0;i<SZ;i++) {\n            for(lld j=0;j<SZ;j++) {\n                res.MaGiC[i][j] = add(MaGiC[i][j], o.MaGiC[i][j]);\n            }\n        }\n        return res;\n    }\n\n    matrix operator * (const matrix &o) const {\n        matrix res;\n        for(lld i=0;i<SZ;i++) {\n            for(lld j=0;j<SZ;j++) {\n                res.MaGiC[i][j] = 0;\n                for(lld k=0;k<SZ;k++) {\n                    res.MaGiC[i][j] = add(res.MaGiC[i][j] , mult(MaGiC[i][k] , o.MaGiC[k][j]));\n                }\n            }\n        }\n        return res;\n    }\n};\n\nmatrix power(matrix a, lld b) {\n    if (b == 0) {\n        a.makeiden();\n    }\n    matrix res;\n    res.makeiden();\n    while(b) {\n        if(b & 1) {\n            res = res * a;\n        }\n        a = a * a;\n        b >>= 1;\n    }\n    return res;\n}\n\n\n// // GUIDE :\n//\n//  matrix m;\n//  m.makeiden();\n//\n//  m.MaGiC[0][0] = 0, m.MaGiC[0][1] = 1;\n//  m.MaGiC[1][0] = 3, m.MaGiC[1][1] = 2;\n//\n//  m = power(m, n);\n//\n//  cout << m.MaGiC[0][0];\n\n\t\t\n\n\n\n\n\n\nvoid solveEachTest(int _TestCase) {\n    // cout << \"Case #\" << _TestCase << \": \";\n    lld n; cin >> n;\n\n    matrix m;\n    m.makeiden();\n\n    m.MaGiC[0][0] = 0, m.MaGiC[0][1] = 1;\n    m.MaGiC[1][0] = 3, m.MaGiC[1][1] = 2;\n\n    m = power(m, n);\n\n    cout << m.MaGiC[0][0];\n    \n    return;\n}\n\n\nsigned main() {\n    ios_base::sync_with_stdio(false); cin.tie(0);\n    // cout.precision(10); cout << fixed;\n    #ifdef LUCTIVUD\n      // const auto start_time = std::chrono::high_resolution_clock::now();\n      freopen(\"/home/luctivud/CPPractice/Zinput.txt\", \"r\", stdin);\n      freopen(\"/home/luctivud/CPPractice/Zoutput.txt\", \"w\", stdout);\n    #endif\n\n\n    MOD = mod = lld(1e9) + 7ll;\n    lld _T0T4 = 1;\n    // cin >> _T0T4; \n\n    for (int _TestCase = 1; _TestCase <= _T0T4; _TestCase++) {\n        solveEachTest(_TestCase);\n        cout << \"\\n\"; \n    }\n\n\n    #ifdef LUCTIVUD\n      // auto end_time = std::chrono::high_resolution_clock::now();\n      // std::chrono::duration<double> diff = end_time - start_time;\n      // cerr << \"Finished in : \" << diff.count() << \"\\n\";\n    #endif\n\n    return 0; \n}\n\n\n/*  ~~\nAuthor   :  Udit \"luctivud\" Gupta \nlinkedin :  https://www.linkedin.com/in/udit-gupta-1b7863135/\n*/\n"
  },
  {
    "path": "02-Codes/Snippets/Sublime/FastReadWrite.sublime-snippet",
    "content": "<snippet>\n  <content><![CDATA[\n\n// Fast Read Write \n\n#define gc getchar_unlocked\nvoid scanint(int &x) {\n    register int c = gc();\n    x = 0;\n    bool neg = 0;\n    for (; ((c < 48 || c > 57) && c != '-'); c = gc());\n    if (c == '-') {neg = 1; c = gc();}\n    for (; c > 47 && c < 58; c = gc()) {x = (x << 1) + (x << 3) + c - 48;}\n    if (neg) x = -x;\n}\n\nvoid scanLong(lld &x) {\n    register lld c = gc();\n    x = 0;\n    bool neg = 0;\n    for (; ((c < 48 || c > 57) && c != '-'); c = gc());\n    if (c == '-') {neg = 1; c = gc();}\n    for (; c > 47 && c < 58; c = gc()) {x = (x << 1) + (x << 3) + c - 48;}\n    if (neg) x = -x;\n}\n\n#define pc(x) putchar_unlocked(x);\n\ninline void writeInt (int n) {\n    int N = n, rev, count = 0;\n    rev = N;\n    if (N == 0) { pc('0'); pc('\\n'); return ;}\n    while ((rev % 10) == 0) { count++; rev /= 10;} //obtain the count of the number of 0s\n    rev = 0;\n    while (N != 0) { rev = (rev << 3) + (rev << 1) + N % 10; N /= 10;} //store reverse of N in rev\n    while (rev != 0) { pc(rev % 10 + '0'); rev /= 10;}\n    while (count--) pc('0');\n    pc ('\\n');\n}\n\n\ninline void writeLong (lld n) {\n    lld N = n, rev, count = 0;\n    rev = N;\n    if (N == 0) { pc('0'); pc('\\n'); return ;}\n    while ((rev % 10) == 0) { count++; rev /= 10;} //obtain the count of the number of 0s\n    rev = 0;\n    while (N != 0) { rev = (rev << 3) + (rev << 1) + N % 10; N /= 10;} //store reverse of N in rev\n    while (rev != 0) { pc(rev % 10 + '0'); rev /= 10;}\n    while (count--) pc('0');\n    pc ('\\n');\n}\n\n\n\n]]></content>\n  <tabTrigger>snip-read-write-fast</tabTrigger>\n  <description>FastIo</description>\n  <!-- Optional: Set a scope to limit where the snippet will trigger -->\n  <scope>source.c++</scope>\n</snippet>\n\n\n\n"
  },
  {
    "path": "02-Codes/Snippets/Sublime/addundirectededge.sublime-snippet",
    "content": "<snippet>\n  <content><![CDATA[\n\nvoid add_undirected_edge(lld a, lld b, vector<lld> adj[]) {\n    adj[a].push_back(b);\n    adj[b].push_back(a);\n    return;\n}\n\n\n]]></content>\n  <tabTrigger>snip-add-undirected-edge</tabTrigger>\n  <description>Add Undirected Edge</description>\n  <!-- Optional: Set a scope to limit where the snippet will trigger -->\n  <scope>source.c++</scope>\n</snippet>\n\n\n\n"
  },
  {
    "path": "02-Codes/Snippets/Sublime/basic-template.sublime-snippet",
    "content": "<snippet>\n  <content><![CDATA[\n#include <bits/stdc++.h>\n#pragma GCC optimize \"trapv\"\n\nusing namespace std;\n\ntypedef long long int lld;\n\nsigned main() {\n\t\n\t// Input - Output and optimization\n\t\n    ios_base::sync_with_stdio(false); cin.tie(0);\n    cout.precision(10); cout << fixed;\n\n    #ifdef LUCTIVUD\n      freopen(\"/home/luctivud/CPPractice/Zinput.txt\", \"r\", stdin);\n      freopen(\"/home/luctivud/CPPractice/Zoutput.txt\", \"w\", stdout);\n    #endif\n\n    $0\n    return 0;\n}\n\n]]></content>\n  <tabTrigger>snip-basic-template</tabTrigger>\n  <description>Basic Template for c++</description>\n  <!-- Optional: Set a scope to limit where the snippet will trigger -->\n  <scope> source.c++ </scope>\n</snippet>"
  },
  {
    "path": "02-Codes/Snippets/Sublime/check execution time.sublime-snippet",
    "content": "<snippet>\n  <content><![CDATA[\n    auto S34t = chrono:: high_resolution_clock::now(); \n    auto S34p = chrono::high_resolution_clock::now(); \n    auto D34n = chrono::duration_cast<chrono::microseconds>(S34p - S34t);\n    cout << \"Time Elapsed: \" << D34n.count() / (long double) 1e6 << \" seconds\" << endl; \n\n]]></content>\n  <tabTrigger>snip-debug</tabTrigger>\n  <description>CP Template</description>\n  <!-- Optional: Set a scope to limit where the snippet will trigger -->\n  <scope >source.c++</scope >\n</snippet>"
  },
  {
    "path": "02-Codes/Snippets/Sublime/checkvalid.sublime-snippet",
    "content": "<snippet>\n\t<content><![CDATA[\n\nbool isvalid(lld i, lld n) {\n\treturn i >= 0 and i < n;\n}\n\n]]></content>\n\t<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->\n\t<tabTrigger>snip-checkvalid</tabTrigger>\n\t<!-- Optional: Set a scope to limit where the snippet will trigger -->\n\t<scope>source.c++</scope>\n</snippet>\n"
  },
  {
    "path": "02-Codes/Snippets/Sublime/cmp-priority.sublime-snippet",
    "content": "<snippet>\n  <content><![CDATA[\n\n// sab ulta rkhna >>\nclass ${1:cmp} {\npublic:\n    bool operator() (${2:const pair <lld, lld>} &a, ${2:const pair <lld, lld>} &b) {\n        return ${3:a.s2 > b.s2};\n    }\n};\n]]></content>\n  <tabTrigger>snip-cmp-pq</tabTrigger>\n  <description>cmp for priority queue</description>\n  <!-- Optional: Set a scope to limit where the snippet will trigger -->\n  <scope >source.c++ </scope >\n</snippet>\n"
  },
  {
    "path": "02-Codes/Snippets/Sublime/common-completions.sublime-completions",
    "content": "{\n    \"scope\": \"source.c++, meta.block.c++, meta.function.c++\",\n\n    \"completions\":\n    [\n        {\"trigger\": \"vectorlld\", \"contents\": \"vector<lld> ${1:arr}\"}, \n        {\"trigger\": \"vectorpalld\", \"contents\": \"vector<pair<lld,lld>> ${1:arr}\"}, \n        {\"trigger\": \"vectorvelldp2\", \"contents\": \"vector<vector<lld>> ${1:dp}(${2:n}, vector<lld>(${3:m}, ${4:-1})) $0\"}, \n        {\"trigger\": \"vectorstr\", \"contents\": \"vector<string> ${1:arr}\"}, \n        {\"trigger\": \"vectorcha\", \"contents\": \"vector<char> ${1:arr}\"}, \n        {\"trigger\": \"vectorboo\", \"contents\": \"vector<bool> ${1:visited}\"}, \n        {\"trigger\": \"setlld\", \"contents\": \"set<lld> ${1:visited}\"}, \n        {\"trigger\": \"setpall\", \"contents\": \"set<pair<lld,lld>> ${1:arr}\"}, \n        {\"trigger\": \"setstr\", \"contents\": \"set<string> ${1:arr}\"}, \n        {\"trigger\": \"setchar\", \"contents\": \"set<char> ${1:arr}\"}, \n        {\"trigger\": \"setbool\", \"contents\": \"set<bool> ${1:arr}\"}, \n        {\"trigger\": \"maplld\", \"contents\": \"map<lld,lld> ${1:arr}\"}, \n        {\"trigger\": \"mapstr\", \"contents\": \"map<string, lld> ${1:arr}\"}, \n        {\"trigger\": \"front\", \"contents\": \"front()\"}, \n        {\"trigger\": \"first\", \"contents\": \"first\"}, \n        {\"trigger\": \"second\", \"contents\": \"second\"}, \n        {\"trigger\": \"make_pair\", \"contents\": \"make_pair(${1:fir}, ${2:sec})\"}, \n        {\"trigger\": \"make_tuple\", \"contents\": \"make_tuple\"}, \n        {\"trigger\": \"push_back\", \"contents\": \"push_back(${1:el})\"}, \n        {\"trigger\": \"max_element\", \"contents\": \"max_element(all(${1:arr}))\"}, \n        {\"trigger\": \"min_element\", \"contents\": \"min_element(all(${1:arr}))\"}, \n        {\"trigger\": \"accumulate\", \"contents\": \"accumulate(all(${1:arr}), ${2:0ll})\"}, \n        {\"trigger\": \"sortarr\", \"contents\": \"sort(${1:r}all(${2:arr}))\"}, \n        {\"trigger\": \"emplace_back\", \"contents\": \"emplace_back()\"}, \n        {\"trigger\": \"insert\", \"contents\": \"insert()\"}, \n        {\"trigger\": \"push\", \"contents\": \"push()\"}, \n        {\"trigger\": \"for4\", \"contents\": \"for4(${1: i}, ${2:0ll}, ${3:n}, ${4:1ll}) {${0}}\"}, \n        {\"trigger\": \"EACH\", \"contents\": \"EACH(${1:it}, ${2:arr}) {${0}}\"}, \n        {\"trigger\": \"find\", \"contents\": \"find(all(${1:arr}), ${2:val}) != ${1:arr}.end()\"}, \n        {\"trigger\": \"lower_bound\", \"contents\": \"lower_bound(all(${1:arr}), ${2:val})\"}, \n        {\"trigger\": \"upper_bound\", \"contents\": \"upper_bound(all(${1:arr}), ${2:val})\"}, \n        {\"trigger\": \"reverse\", \"contents\": \"reverse(all(${1:arr}))\"}, \n        {\"trigger\": \"len\", \"contents\": \"len(${1:arr})\"}, \n        // {\"trigger\": \"debspace\", \"contents\": \"debspace(${1})\"}, \n        // {\"trigger\": \"debline\", \"contents\": \"debline(${1})\"}, \n        {\"trigger\": \"error\", \"contents\": \"_____error_____(${1})\"}, \n        {\"trigger\": \"cin\", \"contents\": \"cin >> \"}, \n        {\"trigger\": \"cout\", \"contents\": \"cout << \"}, \n        {\"trigger\": \"d4dir\", \"contents\": \"const lld d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};\"}, \n        {\"trigger\": \"d8dir\", \"contents\": \"const lld d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};\"},\n        // {\"trigger\": \"read\", \"contents\": \"Read(${1})\"}, \n        // {\"trigger\": \"println\", \"contents\": \"Println(${1})\"}, \n        // {\"trigger\": \"NOYES\", \"contents\": \"Println(\\\"NO\\\\0YES\\\" + 3 * (${1:condition}));\"}, \n        {\"trigger\": \"transform\", \"contents\": \"transform(all(${1:str}), ${1:str}.begin(), ::to${2:low}er);\"}, \n    ]\n}\n\n\n\n// \"vector<lld> ${1:arr}\",\n// \"vector<pair<lld,lld>> ${1:arr}\",\n// \"vector<vector<lld>> ${1:dp}(${2:n}, vector<lld>(${3:m}, ${4:-1})) $0\",\n// \"vector<string> ${1:arr}\",\n// \"vector<char> ${1:arr}\",\n// \"vector<bool> ${1:visited}\",\n// \"set<lld> ${1:visited}\",\n// \"set<pair<lld,lld>> ${1:arr}\",\n// \"set<string> ${1:arr}\",\n// \"set<char> ${1:arr}\",\n// \"set<bool> ${1:arr}\",\n// \"map<lld,lld> ${1:arr}\",\n// \"map<string, lld> ${1:arr}\",\n// \"map<lld,string> ${1:arr}\",\n// \"front()\",\n// \"first\",\n// \"second\",\n// \"make_pair(${1:fir}, ${2:sec})\",\n// \"make_tuple\",\n// \"push_back(${1:el})\",\n// \"max_element(all(${1:arr}))\",\n// \"min_element(all(${1:arr}))\",\n// \"accumulate(all(${1:arr}), ${2:0ll})\", \n// \"emplace_back()\",\n// \"insert()\",\n// \"push()\",\n// \"input(${0})\",\n// \"for4(${1: i}, ${2:0ll}, ${3:n}, ${4:1ll}) {${0}}\",\n// \"EACH(${1:it}, ${2:arr}) {${0}}\",\n// \"find(all(${1:arr}), ${2:val}) != ${1:arr}.end()\",\n// \"lower_bound(all(${1:arr}), ${2:val})\",\n// \"upper_bound(all(${1:arr}), ${2:val})\",\n// \"reverse(all(${1:arr}))\",\n// \"len(${1:arr})\",\n// \"debspace(${1})\",\n// \"debline(${1})\",\n// \"error(${1})\",\n// \"read(${1})\",\n// \"println(${1})\","
  },
  {
    "path": "02-Codes/Snippets/Sublime/dsu-array.sublime-snippet",
    "content": "<snippet>\n  <content><![CDATA[\n\n/*          D S U         */\n\ntemplate<lld SZ> struct DSU {\n    lld par3t[SZ], ran4k[SZ];\n    DSU() {\n        forn(i,SZ) par3t[i] = i, ran4k[i] = 1;\n    }\n    \n    lld find_repr(lld x) { // path compression\n        if (par3t[x] != x) par3t[x] = find_repr(par3t[x]);\n        return par3t[x];\n    }\n    \n    bool Union(lld x, lld y) { // union-by-ran4k\n        x = find_repr(x), y = find_repr(y);\n        if (x == y) return 0;\n        if (ran4k[x] < ran4k[y]) swap(x,y);\n        ran4k[x] += ran4k[y], par3t[y] = x;\n        return 1;\n    }\n};\n \nDSU<100001> D;\n\n\n]]></content>\n  <tabTrigger>snip-dsu-array</tabTrigger>\n  <description>dsu using path compression</description>\n  <!-- Optional: Set a scope to limit where the snippet will trigger -->\n  <scope >source.c++</scope >\n</snippet>"
  },
  {
    "path": "02-Codes/Snippets/Sublime/dsu.sublime-snippet",
    "content": "<snippet>\n  <content><![CDATA[\n/*          D S U         */\n\nvoid makeSet(lld n, vector<lld> &par3t, vector<lld> &ran4k) {\n    iota(all(par3t), 0ll);\n}\n\nlld find_repr(lld x, vector<lld> &par3t, vector<lld> &ran4k) {\n    if (x != par3t[x])\n        par3t[x] = find_repr(par3t[x], par3t, ran4k);\n    return par3t[x];\n}\n\nvoid Union(lld x, lld y, vector<lld> &par3t, vector<lld> &ran4k) {\n    x = find_repr(x, par3t, ran4k);\n    y = find_repr(y, par3t, ran4k);\n\n    if (x == y) return;\n\n    if (ran4k[x] < ran4k[y]) { \n        par3t[x] = y; \n    } else if (ran4k[x] > ran4k[y]) { \n        par3t[y] = x; \n    } else { \n        par3t[y] = x; \n        ran4k[x] = ran4k[x] + 1; \n    } \n    return;\n}\n\n\n\n    // create par3t and ran4k at the place.\n    vector<lld> par3t(n, 0);\n    vector<lld> ran4k(n, 0);\n    makeSet(n, par3t, ran4k);\n]]></content>\n  <tabTrigger>snip-dsu</tabTrigger>\n  <description>dsu using path compression</description>\n  <!-- Optional: Set a scope to limit where the snippet will trigger -->\n  <scope >source.c++</scope >\n</snippet>"
  },
  {
    "path": "02-Codes/Snippets/Sublime/errorWatch.sublime-snippet",
    "content": "<snippet>\n  <content><![CDATA[\n\n#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); huehue(_it, args); cout << \"\\n\";}\n\nvoid huehue(istream_iterator<string> it) {}\ntemplate<typename T, typename... Args>\nvoid huehue(istream_iterator<string> it, T a, Args... args) {\n    cout << *it << \" = \" << a << \", \";\n    huehue(++it, args...);\n}\n\n]]></content>\n  <tabTrigger>snip-error-watch</tabTrigger>\n  <description>Error Watch</description>\n  <!-- Optional: Set a scope to limit where the snippet will trigger -->\n  <scope>source.c++</scope>\n</snippet>\n\n\n\n"
  },
  {
    "path": "02-Codes/Snippets/Sublime/eulerTotientFunc.sublime-snippet",
    "content": "<snippet>\n  <content><![CDATA[\n\n\n// find totient Value complexity O(sqrt(N))\nlld getPhiVal(lld n0n) {\n    lld result = n0n;\n    for (lld i = 2; i * i <= n0n; i++) {\n        if (n0n % i == 0) {\n            while (n0n % i == 0)\n                n0n /= i;\n            result -= result / i;\n        }\n    }\n    if (n0n > 1)\n        result -= result / n0n;\n    return result;\n}\n\nvector<lld> phiVal;\n// precompute_phiVal complexity O(N.log(log(N)))\nvoid precompute_phiVal(lld n0n) {\n    phiVal.resize(n0n+1);\n    phiVal[0] = 0;\n    phiVal[1] = 1;\n    for (lld i = 2; i <= n0n; i++)\n        phiVal[i] = i;\n\n    for (lld i = 2; i <= n0n; i++) {\n        if (phiVal[i] == i) {\n            for (lld j = i; j <= n0n; j += i)\n                phiVal[j] -= phiVal[j] / i;\n        }\n    }\n}\n\n// precompute_phiVal(n);\n\n\n]]></content>\n  <tabTrigger>snip-totient-euler-phi</tabTrigger>\n  <description>Euler totient Phi</description>\n  <!-- Optional: Set a scope to limit where the snippet will trigger -->\n  <scope>source.c++</scope>\n</snippet>\n\n\n\n"
  },
  {
    "path": "02-Codes/Snippets/Sublime/leetcode-solution-class.sublime-snippet",
    "content": "<snippet>\n  <content><![CDATA[\n//             Author: Udit \"luctivud\" Gupta @ (https://www.linkedin.com/in/udit-gupta-1b7863135/)                  //\n\n\n#include <bits/stdc++.h>\n#pragma GCC optimize \"trapv\"\n\nusing namespace std;\n// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n// Solution class to work with\nclass Solution {\n\t\n};\n\n\n// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\nsigned main() {\n\n    ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(10);\n\n\tSolution Obj;\n\n\t// read input vars here and pass it to solve.\n\n\tint ans = Obj.solve();\n\n\tcout << ans;\n\n    return 0;\n}\n// Random Thought :  null  \n]]></content>\n  <tabTrigger>snip-leetcode-solution</tabTrigger>\n  <description>Solution class implementation</description>\n  <!-- Optional: Set a scope to limit where the snippet will trigger -->\n  <scope >source.c++</scope >\n</snippet>\n"
  },
  {
    "path": "02-Codes/Snippets/Sublime/manipulated-sieve-of-eratosthene.sublime-snippet",
    "content": "<snippet>\n  <content><![CDATA[\n\n\n/* This part should be outside the main in global paradigm. */\n\nconst long long MAXN = (lld)(1e7) + 1ll; // MAXN Size\n\nvector<long long >isPrime(MAXN , true); // checkIfPrime\nvector<long long >prime_numbers; // List of prime numbers\nvector<long long >smallest_prime_factor(MAXN); // smallest_prime_factor of a number\n\n\nvoid manipulated_seive() {\n\tisPrime[0] = isPrime[1] = false ;\n\t\n\tprime_numbers.push_back(2);\n\tsmallest_prime_factor[2] = 2ll;\n\n\tfor (long long int i=4; i < MAXN ; i+=2) {\n\t\tisPrime[i] = false;\n\t\tsmallest_prime_factor[i] = 2ll;\n\t}\n\n\tfor (long long int i = 3; i < MAXN ; i+=2) {\n\t\tif (isPrime[i]) {\n\t\t\tprime_numbers.push_back(i);\n\t\t\tsmallest_prime_factor[i] = i;\n\t\t}\n\n\t\tfor (long long int j = 0; j < (int)prime_numbers.size() && i * prime_numbers[j] < MAXN && prime_numbers[j] <= smallest_prime_factor[i]; j++) {\n\t\t\tisPrime[i * prime_numbers[j]] = false;\n\t\t\tsmallest_prime_factor[i * prime_numbers[j]] = prime_numbers[j] ;\n\t\t}\n\t}\n}\n\n\n/* This should be called inside main. */\n\tmanipulated_seive();\n\n\n\n]]></content>\n  <tabTrigger>snip-fast-sieve</tabTrigger>\n  <description>sieve-manipulated</description>\n  <!-- Optional: Set a scope to limit where the snippet will trigger -->\n  <scope> source.c++ </scope>\n</snippet>\n"
  },
  {
    "path": "02-Codes/Snippets/Sublime/matrix-expo.sublime-snippet",
    "content": "<snippet>\n  <content><![CDATA[\n\n// matrix exponentiation snippet::\n// // courtesy Ashishgup3 via Github\n\n\n\n\n\nlld add(lld a, lld b) {\n    lld res = a + b;\n    if(res >= MOD) return res - MOD;\n    return res;\n}\n\nlld mult(lld a, lld b) {\n    long long res = a;\n    res *= b;\n    if(res >= MOD) return res % MOD;\n    return res;\n}\n\n\n\nconst lld SZ = 2; // size of MaGiC \n\nstruct matrix {\n    lld MaGiC[SZ][SZ];\n\n    void reset() {\n        memset(MaGiC, 0, sizeof(MaGiC));\n    }\n\n    void makeiden() {\n        reset();\n        for(lld i=0;i<SZ;i++) {\n            MaGiC[i][i] = 1;\n        }\n    }\n\n    matrix operator + (const matrix &o) const {\n        matrix res;\n        for(lld i=0;i<SZ;i++) {\n            for(lld j=0;j<SZ;j++) {\n                res.MaGiC[i][j] = add(MaGiC[i][j], o.MaGiC[i][j]);\n            }\n        }\n        return res;\n    }\n\n    matrix operator * (const matrix &o) const {\n        matrix res;\n        for(lld i=0;i<SZ;i++) {\n            for(lld j=0;j<SZ;j++) {\n                res.MaGiC[i][j] = 0;\n                for(lld k=0;k<SZ;k++) {\n                    res.MaGiC[i][j] = add(res.MaGiC[i][j] , mult(MaGiC[i][k] , o.MaGiC[k][j]));\n                }\n            }\n        }\n        return res;\n    }\n};\n\nmatrix power(matrix a, lld b) {\n    if (b == 0) {\n        a.makeiden();\n    }\n    matrix res;\n    res.makeiden();\n    while(b) {\n        if(b & 1) {\n            res = res * a;\n        }\n        a = a * a;\n        b >>= 1;\n    }\n    return res;\n}\n\n\n// // GUIDE :\n//\n//  matrix m;\n//  m.makeiden();\n//\n//  m.MaGiC[0][0] = 0, m.MaGiC[0][1] = 1;\n//  m.MaGiC[1][0] = 3, m.MaGiC[1][1] = 2;\n//\n//  m = power(m, n);\n//\n//  cout << m.MaGiC[0][0];\n\n\n]]></content>\n  <tabTrigger>snip-matrix-expo</tabTrigger>\n  <description>Matrix Expo on recurrence formula</description>\n  <!-- Optional: Set a scope to limit where the snippet will trigger -->\n  <scope>source.c++</scope>\n</snippet>\n\n\n\n"
  },
  {
    "path": "02-Codes/Snippets/Sublime/max-biparite-matching.sublime-snippet",
    "content": "<snippet>\n  <content><![CDATA[\n\nlld n, m;\n\nbool bpm(vector<vector<bool >> graph, lld u, vector<bool> &visited, vector<lld> &matchR) {\n\tfor (lld v = 0; v < n; v++) {\n\t\tif (graph[u][v] and !visited[v]) {\n\t\t\tvisited[v] = true;\n\t\t\tif (matchR[v] < 0 || bpm(graph, matchR[v], visited, matchR)) {\n\t\t\t\tmatchR[v] = u;\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t}\n\treturn false;\n}\n\n\nlld maxBPM(vector<vector<bool >> graph, vector<lld> &matchR) {\n\tlld result = 0;\n\tfor (lld u = 0; u < m; u++) {\n\t\tvector<bool> visited(n, 0);\n\t\tif (bpm(graph, u, visited, matchR))\n\t\t\tresult++;\n\t}\n\treturn result;\n}\n\n\n// This should be in main // 0.indexed\n\tn = 6, m = 6; \n\t// for i -> m then for j -> n\n\tvector<vector<bool >> graph(m, vector<bool>(n, false));\n\tvector<lld> matchR(n, -1);\n\tmaxBPM(graph, matchR);\n]]></content>\n  <tabTrigger>snip-bipartite-matching</tabTrigger>\n  <description>Max B M</description>\n  <!-- Optional: Set a scope to limit where the snippet will trigger -->\n  <scope >source.c++</scope >\n</snippet>"
  },
  {
    "path": "02-Codes/Snippets/Sublime/modop.sublime-snippet",
    "content": "<snippet>\n  <content><![CDATA[\nnamespace modop {\n\tlld madd(lld a, lld b) {\n\t\treturn (a + b) % mod;\n\t}\n\tlld msub(lld a, lld b) {\n\t\treturn (((a - b) % mod) + mod) % mod;\n\t}\n\tlld mmul(lld a, lld b) {\n\t\treturn ((a % mod) * (b % mod)) % mod;\n\t}\n\tlld mpow(lld base, lld exp) {\n\t\tlld res = 1;\n\t\twhile (exp) {\n\t\t\tif (exp % 2 == 1) {\n\t\t\t\tres = (res * base) % mod;\n\t\t\t}\n\t\t\texp >>= 1;\n\t\t\tbase = (base * base) % mod;\n\t\t}\n\t\treturn res;\n\t}\n\tlld minv(lld base) {\n\t\treturn mpow(base, mod - 2);\n\t}\n\tlld mdiv(lld a, lld b) {\n\t\treturn mmul(a, minv(b));\n\t}\n}\n\n\n\nlld nck(lld n, lld k) {\n\tif (n < k) return 0;\n\tlld r = 1;\n\n\tfor (lld i = n; i > n - k; i--) {\n\t\tr = (r * i) % mod;\n\t}\n\n\tfor (lld i = 1; i <= k; i++) {\n\t\tr = (r * minv(i)) % mod;\n\t}\n\treturn r;\n}\n]]></content>\n  <tabTrigger>snip-namespace-modop</tabTrigger>\n  <description>modops and ncr on demand</description>\n  <!-- Optional: Set a scope to limit where the snippet will trigger -->\n  <scope >source.c++</scope >\n</snippet>"
  },
  {
    "path": "02-Codes/Snippets/Sublime/myReadTemplate.sublime-snippet",
    "content": "<snippet>\n  <content><![CDATA[\n\nvoid Read() { return; }\nvoid Print() { return; }\nvoid Println() { cout << \"\\n\"; return; }\ntemplate<class T> T Read(T& x)   { cin >> x; return x; }\ntemplate<class T> void Print(T a)   { cout << a; }\ntemplate<class T> void Println(T a) { cout << a << \"\\n\"; }\n\ntemplate<class T> void Read(vector<T> &arr)   { EACH(i, arr) cin >> (i); }\ntemplate<class T> void Print(vector<T> arr)   { EACH(i, arr) {cout << i << \" \";} }\ntemplate<class T> void Println(vector<T> arr) { EACH(i, arr) {cout << i << \" \";} cout << \"\\n\"; }\n\ntemplate<class T> void Read(vector<vector<T>> &arr)   { EACH(i, arr) Read(i); }\ntemplate<class T> void Print(vector<vector<T>> arr)   { EACH(i, arr) Println(i); }\ntemplate<class T> void Println(vector<vector<T>> arr) { EACH(i, arr) Println(i); }\n\ntemplate<typename T, typename... Args> void Read(vector<T> &arr, Args &... args)   { Read(arr); Read(args...);}\ntemplate<typename T, typename... Args> void Read(vector<vector<T>> &arr, Args &... args)   { Read(arr); Read(args...);}\ntemplate<typename T, typename... Args> void Read(T &a, Args &... args) { cin >> (a); Read(args...); }\ntemplate<typename T, typename... Args> void Print(vector<T> &arr, Args &... args)   { Print(arr); Print(args...);}\ntemplate<typename T, typename... Args> void Print(T a, Args... args) { cout << a << \" \"; Print(args...); };\ntemplate<typename T, typename... Args> void Println(vector<T> &arr, Args &... args)   { Print(arr); Println(args...);}\ntemplate<typename T, typename... Args> void Println(T a, Args... args) { cout << a << \" \"; Println(args...); };\n\n]]></content>\n  <tabTrigger>snip-read-template</tabTrigger>\n  <description>Read-Print-Template</description>\n  <!-- Optional: Set a scope to limit where the snippet will trigger -->\n  <scope>source.c++</scope>\n</snippet>\n\n\n\n"
  },
  {
    "path": "02-Codes/Snippets/Sublime/ncr-on-demand.sublime-snippet",
    "content": "<snippet>\n  <content><![CDATA[\n\nlld EE(lld a, lld b, lld *x, lld *y) {\n\tif (a == 0) {\n\t\t*x = 0, *y = 1;\n\t\treturn b;\n\t}\n\n\tlld x1, y1;\n\tlld gcd = EE(b % a, a, &x1, &y1);\n\n\t*x = y1 - (b / a) * x1;\n\t*y = x1;\n\n\treturn gcd;\n}\n\n\nlld inverse(lld a, lld m) {\n\tlld x, y;\n\tEE(a, m, &x, &y);\n\tif (x < 0) x += m;\n\treturn x;\n}\n\nlld choose(lld n, lld k) {\n\tlld i;\n\n\tlld num = 1, den = 1;\n\n\tfor (i = 2; i <= k; i++) {\n\t\tden *= i;\n\t\tden %= mod;\n\t}\n\n\tfor (i = n - k + 1; i <= n; i++) {\n\t\tnum *= i;\n\t\tnum %= mod;\n\t}\n\n\ti = num * inverse(den, mod);\n\ti %= mod;\n\treturn i;\n}\n\n]]></content>\n  <tabTrigger>snip-ncr-binomial</tabTrigger>\n  <description>NCR on demand</description>\n  <!-- Optional: Set a scope to limit where the snippet will trigger -->\n  <scope >source.c++</scope >\n</snippet>"
  },
  {
    "path": "02-Codes/Snippets/Sublime/pbds.sublime-snippet",
    "content": "<snippet>\n  <content><![CDATA[\n#include <ext/pb_ds/assoc_container.hpp>\n#include <ext/pb_ds/tree_policy.hpp>\nusing namespace __gnu_pbds;\n\ntemplate <typename T> using PBSET = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;\n\n/*  \n    .insert(el) - set hai!\n    .find_by_order(3) - returns an iterator to the k-th largest element (counting from zero)\n    .order_of_key(6) - the number of items in a set that are strictly smaller than our item\n*/\n\n]]></content>\n  <tabTrigger>snip-pbds</tabTrigger>\n  <description>pbds</description>\n  <!-- Optional: Set a scope to limit where the snippet will trigger -->\n  <scope >source.c++</scope >\n</snippet>"
  },
  {
    "path": "02-Codes/Snippets/Sublime/power-expo.sublime-snippet",
    "content": "<snippet>\n  <content><![CDATA[\n\n\nlld power(lld x, lld y) {\n\tlld res = 1;\n\n\tx = x % MOD;\n\n\tif (x == 0) return 0;\n\n\twhile (y > 0)  {\n\t\tif (y & 1)\n\t\t\tres = (res * x) % MOD;\n\n\t\ty = y >> 1; \n\t\tx = (x * x) % MOD;\n\t}\n\treturn res;\n}\n\n\n]]></content>\n  <tabTrigger>snip-power</tabTrigger>\n  <description>power exponentiation</description>\n  <!-- Optional: Set a scope to limit where the snippet will trigger -->\n  <scope >source.c++</scope >\n</snippet>"
  },
  {
    "path": "02-Codes/Snippets/Sublime/sieve-of-eratosthene.sublime-snippet",
    "content": "<snippet>\n  <content><![CDATA[\n\n/* This part should be outside the main in global paradigm. */\n\nconst lld MAXN = (lld)(1e5) + 1ll; // Maximum sieve upto\nvector<bool> isPrime(MAXN, true); // Temp vector for sieve result\nvector<lld> prime_numbers; // vector of primes\n\nvoid sieve() {\n\tisPrime[0] = isPrime[1] = false;\n\tprime_numbers.push_back(2);\n\tfor (lld i=4; i< MAXN; i+=2)\n\t\tisPrime[i] = false;\n\tfor (lld i = 3; i < MAXN; i+=2) {\n\t\tif (isPrime[i]) {\n\t\t\tprime_numbers.push_back(i); // remove if not necessary\n\t\t\tfor (lld j = 2 * i; j < MAXN; j += i) {\n\t\t\t\tisPrime[j] = false;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/* This should be called inside main. */\nsieve();\t// function call in main\n\n\n]]></content>\n  <tabTrigger>snip-sieve</tabTrigger>\n  <description>sieve</description>\n  <!-- Optional: Set a scope to limit where the snippet will trigger -->\n  <scope >source.c++</scope >\n</snippet>"
  },
  {
    "path": "02-Codes/Snippets/Sublime/topcoder-template.sublime-snippet",
    "content": "<snippet>\n  <content><![CDATA[\n\n#include <bits/stdc++.h>\nusing namespace std;\n\n\ntypedef long long int lld;\ntypedef unsigned long long int llu;\n\n#define        forn(I7, E4)    for(lld I7=0ll; I7 < E4; (I7)+=1ll)\n#define       forn1(I7, E4)    for(lld I7=1ll; I7 < E4+1; (I7)+=1ll)\n#define              len(v)    ((int)((v).size()))\n#define              all(x)    (x).begin(), (x).end()\n#define             rall(x)    (x).rbegin(), (x).rend()\n#define                  f1    first\n#define                  s2    second\n\ntemplate<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << \", \" << p.second << ')'; }\ntemplate < typename T_container, typename T = typename enable_if < !is_same<T_container, string>::value, typename T_container::value_type >::type >\nostream & operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = \", \"; return os << '}'; }\nvoid dbg_out() { cout << \"\\n\"; }\ntemplate<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << H << \", \"; dbg_out(T...);}\n#define _____error_____(...) cout << #__VA_ARGS__ << \" : \", dbg_out(__VA_ARGS__)\n\nconst lld d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};\nconst lld d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};\n\n\nconst long double EPS = 1e-6;\nlld TempVar, mod, MOD;\n\n\nclass ${1:} {\n    public:\n    ${0:}\n};\n\n\n\n\n//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n\n\n\n/*\nsigned main() {\n\n    ios_base::sync_with_stdio(false); cin.tie(0);\n    // cout.precision(10); cout << fixed;\n    #ifdef LUCTIVUD\n      // const auto start_time = std::chrono::high_resolution_clock::now();\n      freopen(\"/home/luctivud/CPPractice/Zinput.txt\", \"r\", stdin);\n      freopen(\"/home/luctivud/CPPractice/Zoutput.txt\", \"w\", stdout);\n    #endif\n\n    ${1:} obj;\n\n    \n\n\n  return 0;\n}\n\n*/\n\n]]></content>\n  <tabTrigger>snip-topcoder-template</tabTrigger>\n  <description>Topcoder class template</description>\n  <!-- Optional: Set a scope to limit where the snippet will trigger -->\n  <scope>source.c++</scope>\n</snippet>\n\n\n\n"
  },
  {
    "path": "02-Codes/Snippets/mydebug.h",
    "content": "// C++ includes used for precompiling -*- C++ -*-\n\n// Copyright (C) 2003-2021 Free Software Foundation, Inc.\n//\n// This file is part of the GNU ISO C++ Library.  This library is free\n// software; you can redistribute it and/or modify it under the\n// terms of the GNU General Public License as published by the\n// Free Software Foundation; either version 3, or (at your option)\n// any later version.\n\n// This library is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n\n// Under Section 7 of GPL version 3, you are granted additional\n// permissions described in the GCC Runtime Library Exception, version\n// 3.1, as published by the Free Software Foundation.\n\n// You should have received a copy of the GNU General Public License and\n// a copy of the GCC Runtime Library Exception along with this program;\n// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see\n// <http://www.gnu.org/licenses/>.\n\n/** @file stdc++.h\n *  This is an implementation file for a precompiled header.\n */\n\n// 17.4.1.2 Headers\n\n// C\n#ifndef _GLIBCXX_NO_ASSERT\n#include <cassert>\n#endif\n#include <cctype>\n#include <cerrno>\n#include <cfloat>\n#include <ciso646>\n#include <climits>\n#include <clocale>\n#include <cmath>\n#include <csetjmp>\n#include <csignal>\n#include <cstdarg>\n#include <cstddef>\n#include <cstdio>\n#include <cstdlib>\n#include <cstring>\n#include <ctime>\n#include <cwchar>\n#include <cwctype>\n\n#if __cplusplus >= 201103L\n#include <ccomplex>\n#include <cfenv>\n#include <cinttypes>\n#include <cstdalign>\n#include <cstdbool>\n#include <cstdint>\n#include <ctgmath>\n#include <cuchar>\n#endif\n\n// C++\n#include <algorithm>\n#include <bitset>\n#include <complex>\n#include <deque>\n#include <exception>\n#include <fstream>\n#include <functional>\n#include <iomanip>\n#include <ios>\n#include <iosfwd>\n#include <iostream>\n#include <istream>\n#include <iterator>\n#include <limits>\n#include <list>\n#include <locale>\n#include <map>\n#include <memory>\n#include <new>\n#include <numeric>\n#include <ostream>\n#include <queue>\n#include <set>\n#include <sstream>\n#include <stack>\n#include <stdexcept>\n#include <streambuf>\n#include <string>\n#include <typeinfo>\n#include <utility>\n#include <valarray>\n#include <vector>\n\n#include <cxxabi.h> // for prettyprint\n\n#if __cplusplus >= 201103L\n#include <array>\n#include <atomic>\n#include <chrono>\n#include <codecvt>\n#include <condition_variable>\n#include <forward_list>\n#include <future>\n#include <initializer_list>\n#include <mutex>\n#include <random>\n#include <ratio>\n#include <regex>\n#include <scoped_allocator>\n#include <system_error>\n#include <thread>\n#include <tuple>\n#include <typeindex>\n#include <type_traits>\n#include <unordered_map>\n#include <unordered_set>\n#endif\n\n#if __cplusplus >= 201402L\n#include <shared_mutex>\n#endif\n\n#if __cplusplus >= 201703L\n#include <any>\n#include <charconv>\n// #include <execution>\n#include <filesystem>\n#include <optional>\n#include <memory_resource>\n#include <string_view>\n#include <variant>\n#endif\n\n#if __cplusplus > 201703L\n#include <barrier>\n#include <bit>\n#include <compare>\n#include <concepts>\n#if __cpp_impl_coroutine\n# include <coroutine>\n#endif\n#include <latch>\n#include <numbers>\n#include <ranges>\n#include <span>\n#include <stop_token>\n#include <semaphore>\n#include <source_location>\n#include <syncstream>\n#include <version>\n#endif\n\n\n/*\n\nstdc++.h end\n\n*/\n\nusing namespace std;\n\n\n\n\ntemplate <class T1, class T2>\nostream &operator<<(ostream &os, const pair<T1, T2> &p) {\n  return os << '{' << p.first << \", \" << p.second << '}';\n}\n\ntemplate <class T, class = decay_t<decltype(*begin(declval<T>()))>,\n          class = enable_if_t<!is_same<T, string>::value>>\nostream &operator<<(ostream &os, const T &c) {\n  os << '[';\n  for (auto it = c.begin(); it != c.end(); ++it)\n    os << &\", \"[2 * (it == c.begin())] << *it;\n  return os << ']';\n}\n\n\n\n//support up to 5 args\n#define _NTH_ARG(_1, _2, _3, _4, _5, _6, N, ...) N\n#define _FE_0(_CALL, ...)\n#define _FE_1(_CALL, x) _CALL(x)\n#define _FE_2(_CALL, x, ...) _CALL(x) _FE_1(_CALL, __VA_ARGS__)\n#define _FE_3(_CALL, x, ...) _CALL(x) _FE_2(_CALL, __VA_ARGS__)\n#define _FE_4(_CALL, x, ...) _CALL(x) _FE_3(_CALL, __VA_ARGS__)\n#define _FE_5(_CALL, x, ...) _CALL(x) _FE_4(_CALL, __VA_ARGS__)\n#define FOR_EACH_MACRO(MACRO, ...)                                             \\\n  _NTH_ARG(dummy, ##__VA_ARGS__, _FE_5, _FE_4, _FE_3, _FE_2, _FE_1, _FE_0)     \\\n  (MACRO, ##__VA_ARGS__)\n\n\n//Change output format here\n#define out(x) #x \" = \" << x << \"; \"\n\n\n#define _____error_____(...)                                                              \\\n  cerr << \"(Line \" << __LINE__ << \"): \" FOR_EACH_MACRO(out, __VA_ARGS__) << \"\\n\"\n\n  \n\n\n\n\n/*\n _______  _______  ______    ___   __    _  _______\n|       ||       ||    _ |  |   | |  |  | ||       |\n|    _  ||    _  ||   | ||  |   | |   |_| ||_     _|\n|   |_| ||   |_| ||   |_||_ |   | |       |  |   |\n|    ___||    ___||    __  ||   | |  _    |  |   |\n|   |    |   |    |   |  | ||   | | | |   |  |   |\n|___|    |___|    |___|  |_||___| |_|  |__|  |___|\nPretty Printer for Modern C++\nhttps://github.com/p-ranav/pprint\nLicensed under the MIT License <http://opensource.org/licenses/MIT>.\nSPDX-License-Identifier: MIT\nCopyright (c) 2019 Pranav Srinivas Kumar <pranav.srinivas.kumar@gmail.com>.\nPermission is hereby  granted, free of charge, to any  person obtaining a copy\nof this software and associated  documentation files (the \"Software\"), to deal\nin the Software  without restriction, including without  limitation the rights\nto  use, copy,  modify, merge,  publish, distribute,  sublicense, and/or  sell\ncopies  of  the Software,  and  to  permit persons  to  whom  the Software  is\nfurnished to do so, subject to the following conditions:\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\nTHE SOFTWARE  IS PROVIDED \"AS  IS\", WITHOUT WARRANTY  OF ANY KIND,  EXPRESS OR\nIMPLIED,  INCLUDING BUT  NOT  LIMITED TO  THE  WARRANTIES OF  MERCHANTABILITY,\nFITNESS FOR  A PARTICULAR PURPOSE AND  NONINFRINGEMENT. IN NO EVENT  SHALL THE\nAUTHORS  OR COPYRIGHT  HOLDERS  BE  LIABLE FOR  ANY  CLAIM,  DAMAGES OR  OTHER\nLIABILITY, WHETHER IN AN ACTION OF  CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE  OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n*/\n#pragma once\n// #include <iostream>\n// #include <string>\n// #include <typeinfo>\n// #include <type_traits>\n// #include <vector>\n// #include <list>\n// #include <deque>\n// #include <set>\n// #include <unordered_set>\n// #include <array>\n// #include <map>\n// #include <unordered_map>\n// #include <iomanip>\n// #include <variant>\n// #include <algorithm>\n// #include <cassert>\n// #include <cstddef>\n// #include <iosfwd>\n// #include <limits>\n// #include <string_view>\n// #include <optional>\n// #include <utility>\n// #include <sstream>\n// #include <queue>\n// #include <stack>\n// #include <tuple>\n// #include <initializer_list>\n// #include <complex>\n// #include <cmath>\n// #include <memory>\n#ifdef __GNUG__\n// #include <cstdlib>\n// #include <memory>\n// #include <cxxabi.h>\n#endif\n\n// Check if a type is stream writable, i.e., std::cout << foo;\ntemplate<typename S, typename T, typename = void>\nstruct is_to_stream_writable: std::false_type {};\n\ntemplate<typename S, typename T>\nstruct is_to_stream_writable<S, T,\n           std::void_t<  decltype( std::declval<S&>()<<std::declval<T>() ) >>\n  : std::true_type {};\n\n\n// Printing std::tuple\n// The indices trick: http://loungecpp.wikidot.com/tips-and-tricks:indices\nnamespace pprint {\n\n  template<std::size_t...> struct seq{};\n\n  template<std::size_t N, std::size_t... Is>\n  struct gen_seq : gen_seq<N-1, N-1, Is...>{};\n\n  template<std::size_t... Is>\n  struct gen_seq<0, Is...> : seq<Is...>{};\n\n  template<typename T>\n  inline T to_string(T value) {\n    return value;\n  }\n\n  inline std::string to_string(char value) {\n    return \"'\" + std::string(1, value) + \"'\";\n  }\n\n  inline std::string to_string(const char * value) {\n    return \"\\\"\" + std::string(value) + \"\\\"\";\n  }\n\n  inline std::string to_string(const std::string& value) {\n    return \"\\\"\" + value + \"\\\"\";\n  }\n\n  template<class Ch, class Tr, class Tuple, std::size_t... Is>\n  void print_tuple(std::basic_ostream<Ch,Tr>& os, Tuple const& t, seq<Is...>){\n    using swallow = int[];\n    (void)swallow{0, (void(os << (Is == 0? \"\" : \", \") << to_string(std::get<Is>(t))), 0)...};\n  }\n\n}\n\ntemplate<class Ch, class Tr, class... Args>\nauto operator<<(std::basic_ostream<Ch, Tr>& os, std::tuple<Args...> const& t)\n  -> std::basic_ostream<Ch, Tr>& {\n  os << \"(\";\n  pprint::print_tuple(os, t, pprint::gen_seq<sizeof...(Args)>());\n  return os << \")\";\n}\n\n// Enum value must be greater or equals than MAGIC_ENUM_RANGE_MIN. By default MAGIC_ENUM_RANGE_MIN = -128.\n// If need another min range for all enum types by default, redefine the macro MAGIC_ENUM_RANGE_MIN.\n#if !defined(MAGIC_ENUM_RANGE_MIN)\n#  define MAGIC_ENUM_RANGE_MIN -128\n#endif\n\n// Enum value must be less or equals than MAGIC_ENUM_RANGE_MAX. By default MAGIC_ENUM_RANGE_MAX = 128.\n// If need another max range for all enum types by default, redefine the macro MAGIC_ENUM_RANGE_MAX.\n#if !defined(MAGIC_ENUM_RANGE_MAX)\n#  define MAGIC_ENUM_RANGE_MAX 128\n#endif\n\nnamespace magic_enum {\n\n  // Enum value must be in range [-MAGIC_ENUM_RANGE_MAX, MAGIC_ENUM_RANGE_MIN]. By default  MAGIC_ENUM_RANGE_MIN = -128, MAGIC_ENUM_RANGE_MAX = 128.\n  // If need another range for all enum types by default, redefine the macro MAGIC_ENUM_RANGE_MAX and MAGIC_ENUM_RANGE_MIN.\n  // If need another range for specific enum type, add specialization enum_range for necessary enum type.\n  template <typename E>\n  struct enum_range final {\n    static_assert(std::is_enum_v<E>, \"magic_enum::enum_range requires enum type.\");\n    static constexpr int min = std::is_signed_v<std::underlying_type_t<E>> ? MAGIC_ENUM_RANGE_MIN : 0;\n    static constexpr int max = MAGIC_ENUM_RANGE_MAX;\n  };\n\n  static_assert(MAGIC_ENUM_RANGE_MAX > 0,\n    \"MAGIC_ENUM_RANGE_MAX must be greater than 0.\");\n  static_assert(MAGIC_ENUM_RANGE_MAX < std::numeric_limits<int>::max(),\n    \"MAGIC_ENUM_RANGE_MAX must be less than INT_MAX.\");\n\n  static_assert(MAGIC_ENUM_RANGE_MIN <= 0,\n    \"MAGIC_ENUM_RANGE_MIN must be less or equals than 0.\");\n  static_assert(MAGIC_ENUM_RANGE_MIN > std::numeric_limits<int>::min(),\n    \"MAGIC_ENUM_RANGE_MIN must be greater than INT_MIN.\");\n\n  namespace detail {\n\n    template <typename E, typename U = std::underlying_type_t<E>>\n    [[nodiscard]] constexpr int min_impl() {\n      static_assert(std::is_enum_v<E>, \"magic_enum::detail::min_impl requires enum type.\");\n      constexpr int min = enum_range<E>::min > (std::numeric_limits<U>::min)() ? enum_range<E>::min : (std::numeric_limits<U>::min)();\n\n      return min;\n    }\n\n    template <typename E, typename U = std::underlying_type_t<E>>\n    [[nodiscard]] constexpr decltype(auto) range_impl() {\n      static_assert(std::is_enum_v<E>, \"magic_enum::detail::range_impl requires enum type.\");\n      static_assert(enum_range<E>::max > enum_range<E>::min, \"magic_enum::enum_range requires max > min.\");\n      constexpr int max = enum_range<E>::max < (std::numeric_limits<U>::max)() ? enum_range<E>::max : (std::numeric_limits<U>::max)();\n      constexpr auto range = std::make_integer_sequence<int, max - min_impl<E>() + 1>{};\n\n      return range;\n    }\n\n\n    [[nodiscard]] constexpr bool is_name_char(char c, bool front) noexcept {\n      return (!front && c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_';\n    }\n\n    template <typename E, E V>\n    [[nodiscard]] constexpr std::string_view name_impl() noexcept {\n      static_assert(std::is_enum_v<E>, \"magic_enum::detail::name_impl requires enum type.\");\n#if defined(__clang__)\n      std::string_view name{__PRETTY_FUNCTION__};\n      constexpr auto suffix = sizeof(\"]\") - 1;\n#elif defined(__GNUC__) && __GNUC__ >= 9\n      std::string_view name{__PRETTY_FUNCTION__};\n      constexpr auto suffix = sizeof(\"; std::string_view = std::basic_string_view<char>]\") - 1;\n#elif defined(_MSC_VER)\n      std::string_view name{__FUNCSIG__};\n      constexpr auto suffix = sizeof(\">(void) noexcept\") - 1;\n#else\n      return {}; // Unsupported compiler.\n#endif\n\n#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 9) || defined(_MSC_VER)\n      name.remove_suffix(suffix);\n      for (std::size_t i = name.size(); i > 0; --i) {\n        if (!is_name_char(name[i - 1], false)) {\n        name.remove_prefix(i);\n        break;\n      }\n    }\n\n    if (name.length() > 0 && is_name_char(name.front(), true)) {\n      return name;\n      } else {\n        return {}; // Value does not have name.\n      }\n#endif\n    }\n\n    template <typename E, int... I>\n    [[nodiscard]] constexpr decltype(auto) strings_impl(std::integer_sequence<int, I...>) noexcept {\n      static_assert(std::is_enum_v<E>, \"magic_enum::detail::strings_impl requires enum type.\");\n      constexpr std::array<std::string_view, sizeof...(I)> names{{name_impl<E, static_cast<E>(I + min_impl<E>())>()...}};\n\n      return names;\n    }\n\n    template <typename E>\n    [[nodiscard]] constexpr std::string_view name_impl(int value) noexcept {\n      static_assert(std::is_enum_v<E>, \"magic_enum::detail::name_impl requires enum type.\");\n      constexpr auto names = strings_impl<E>(range_impl<E>());\n      const int i = value - min_impl<E>();\n\n      if (i >= 0 && static_cast<std::size_t>(i) < names.size()) {\n        return names[i];\n      } else {\n        return {}; // Value out of range.\n      }\n    }\n\n    template <typename E, int... I>\n    [[nodiscard]] constexpr decltype(auto) values_impl(std::integer_sequence<int, I...>) noexcept {\n      static_assert(std::is_enum_v<E>, \"magic_enum::detail::values_impl requires enum type.\");\n      constexpr int n = sizeof...(I);\n      constexpr std::array<bool, n> valid{{!name_impl<E, static_cast<E>(I + min_impl<E>())>().empty()...}};\n      constexpr int num_valid = ((valid[I] ? 1 : 0) + ...);\n\n      std::array<E, num_valid> enums{};\n      for (int i = 0, v = 0; i < n && v < num_valid; ++i) {\n        if (valid[i]) {\n          enums[v++] = static_cast<E>(i + min_impl<E>());\n        }\n      }\n\n      return enums;\n    }\n\n    template <typename E, std::size_t... I>\n    [[nodiscard]] constexpr decltype(auto) names_impl(std::integer_sequence<std::size_t, I...>) noexcept {\n      static_assert(std::is_enum_v<E>, \"magic_enum::detail::names_impl requires enum type.\");\n      constexpr auto enums = values_impl<E>(range_impl<E>());\n      constexpr std::array<std::string_view, sizeof...(I)> names{{name_impl<E, enums[I]>()...}};\n\n      return names;\n    }\n\n    template <typename E>\n    [[nodiscard]] constexpr std::optional<E> enum_cast_impl(std::string_view value) noexcept {\n      static_assert(std::is_enum_v<E>, \"magic_enum::detail::enum_cast_impl requires enum type.\");\n      constexpr auto values = values_impl<E>(range_impl<E>());\n      constexpr auto count = values.size();\n      constexpr auto names = names_impl<E>(std::make_index_sequence<count>{});\n\n      for (std::size_t i = 0; i < count; ++i) {\n        if (names[i] == value) {\n          return values[i];\n        }\n      }\n\n      return std::nullopt; // Invalid value or out of range.\n    }\n\n    template<typename T>\n    using enable_if_enum_t = typename std::enable_if<std::is_enum_v<T>>::type;\n\n    template<typename T, bool = std::is_enum_v<T>>\n    struct is_scoped_enum_impl : std::false_type {};\n\n    template<typename T>\n    struct is_scoped_enum_impl<T, true> : std::bool_constant<!std::is_convertible_v<T, std::underlying_type_t<T>>> {};\n\n    template<typename T, bool = std::is_enum_v<T>>\n    struct is_unscoped_enum_impl : std::false_type {};\n\n    template<typename T>\n    struct is_unscoped_enum_impl<T, true> : std::bool_constant<std::is_convertible_v<T, std::underlying_type_t<T>>> {};\n\n  } // namespace magic_enum::detail\n\n  // Checks whether T is an Unscoped enumeration type.\n  // Provides the member constant value which is equal to true, if T is an [Unscoped enumeration](https://en.cppreference.com/w/cpp/language/enum#Unscoped_enumeration) type.\n  // Otherwise, value is equal to false.\n  template <typename T>\n  struct is_unscoped_enum : detail::is_unscoped_enum_impl<T> {};\n\n  template <typename T>\n  inline constexpr bool is_unscoped_enum_v = is_unscoped_enum<T>::value;\n\n  // Checks whether T is an Scoped enumeration type.\n  // Provides the member constant value which is equal to true, if T is an [Scoped enumeration](https://en.cppreference.com/w/cpp/language/enum#Scoped_enumerations) type.\n  // Otherwise, value is equal to false.\n  template <typename T>\n  struct is_scoped_enum : detail::is_scoped_enum_impl<T> {};\n\n  template <typename T>\n  inline constexpr bool is_scoped_enum_v = is_scoped_enum<T>::value;\n\n  // Obtains enum value from enum string name.\n  template <typename E, typename = detail::enable_if_enum_t<E>>\n  [[nodiscard]] constexpr std::optional<E> enum_cast(std::string_view value) noexcept {\n    static_assert(std::is_enum_v<E>, \"magic_enum::enum_cast requires enum type.\");\n\n    return detail::enum_cast_impl<E>(value);\n  }\n\n  // Obtains enum value from integer value.\n  template <typename E, typename = detail::enable_if_enum_t<E>>\n  [[nodiscard]] constexpr std::optional<E> enum_cast(std::underlying_type_t<E> value) noexcept {\n    static_assert(std::is_enum_v<E>, \"magic_enum::enum_cast requires enum type.\");\n\n    if (detail::name_impl<E>(static_cast<int>(value)).empty()) {\n      return std::nullopt; // Invalid value or out of range.\n    } else {\n      return static_cast<E>(value);\n    }\n  }\n\n  // Returns enum value at specified index.\n  // No bounds checking is performed: the behavior is undefined if index >= number of enum values.\n  template<typename E, typename = detail::enable_if_enum_t<E>>\n  [[nodiscard]] constexpr E enum_value(std::size_t index) {\n    static_assert(std::is_enum_v<E>, \"magic_enum::enum_value requires enum type.\");\n    constexpr auto values = detail::values_impl<E>(detail::range_impl<E>());\n\n    return assert(index < values.size()), values[index];\n  }\n\n  // Obtains value enum sequence.\n  template <typename E, typename = detail::enable_if_enum_t<E>>\n  [[nodiscard]] constexpr decltype(auto) enum_values() noexcept {\n    static_assert(std::is_enum_v<E>, \"magic_enum::enum_values requires enum type.\");\n    constexpr auto values = detail::values_impl<E>(detail::range_impl<E>());\n\n    return values;\n  }\n\n  // Returns number of enum values.\n  template <typename E, typename = detail::enable_if_enum_t<E>>\n  [[nodiscard]] constexpr std::size_t enum_count() noexcept {\n    static_assert(std::is_enum_v<E>, \"magic_enum::enum_count requires enum type.\");\n    constexpr auto count = detail::values_impl<E>(detail::range_impl<E>()).size();\n\n    return count;\n  }\n\n  // Obtains string enum name from enum value.\n  template <typename E, typename D = std::decay_t<E>, typename = detail::enable_if_enum_t<D>>\n  [[nodiscard]] constexpr std::optional<std::string_view> enum_name(E value) noexcept {\n    static_assert(std::is_enum_v<D>, \"magic_enum::enum_name requires enum type.\");\n    const auto name = detail::name_impl<D>(static_cast<int>(value));\n\n    if (name.empty()) {\n      return std::nullopt; // Invalid value or out of range.\n    } else {\n      return name;\n    }\n  }\n\n  // Obtains string enum name sequence.\n  template <typename E, typename = detail::enable_if_enum_t<E>>\n  [[nodiscard]] constexpr decltype(auto) enum_names() noexcept {\n    static_assert(std::is_enum_v<E>, \"magic_enum::enum_names requires enum type.\");\n    constexpr auto count = detail::values_impl<E>(detail::range_impl<E>()).size();\n    constexpr auto names = detail::names_impl<E>(std::make_index_sequence<count>{});\n\n    return names;\n  }\n\n  namespace ops {\n\n    template <typename E, typename D = std::decay_t<E>, typename = detail::enable_if_enum_t<E>>\n    std::ostream& operator<<(std::ostream& os, E value) {\n      static_assert(std::is_enum_v<D>, \"magic_enum::ops::operator<< requires enum type.\");\n      const auto name = detail::name_impl<D>(static_cast<int>(value));\n\n      if (!name.empty()) {\n        os << name;\n      }\n\n      return os;\n    }\n\n    template <typename E, typename = detail::enable_if_enum_t<E>>\n    std::ostream& operator<<(std::ostream& os, std::optional<E> value) {\n      static_assert(std::is_enum_v<E>, \"magic_enum::ops::operator<< requires enum type.\");\n\n      if (value.has_value()) {\n        const auto name = detail::name_impl<E>(static_cast<int>(value.value()));\n        if (!name.empty()) {\n          os << name;\n        }\n      }\n\n      return os;\n    }\n\n  } // namespace magic_enum::ops\n\n} // namespace magic_enum\n\nnamespace pprint {\n\n  // Some utility structs to check template specialization\n  template<typename Test, template<typename...> class Ref>\n  struct is_specialization : std::false_type {};\n\n  template<template<typename...> class Ref, typename... Args>\n  struct is_specialization<Ref<Args...>, Ref> : std::true_type {};\n\n  template<typename ...>\n  using to_void = void;\n\n  template<typename T, typename = void>\n  struct is_container : std::false_type\n  {};\n\n  template<typename T>\n  struct is_container<T,\n          to_void<decltype(std::declval<T>().begin()),\n              decltype(std::declval<T>().end()),\n              typename T::value_type\n          >> : std::true_type // will  be enabled for iterable objects\n  {};\n\n  class PrettyPrinter {\n  private:\n    std::ostream& stream_;\n    std::string line_terminator_;\n    size_t indent_;\n    bool quotes_;\n    bool compact_;\n\n  public:\n\n    PrettyPrinter(std::ostream& stream = std::cout) :\n      stream_(stream),\n      line_terminator_(\"\\n\"),\n      indent_(2),\n      quotes_(false),\n      compact_(false) {}\n\n    PrettyPrinter& line_terminator(const std::string& value) {\n      line_terminator_ = value;\n      return *this;\n    }\n\n    PrettyPrinter& indent(size_t indent) {\n      indent_ = indent;\n      return *this;\n    }\n\n    PrettyPrinter& compact(bool value) {\n      compact_ = value;\n      return *this;\n    }\n\n    PrettyPrinter& quotes(bool value) {\n      quotes_ = value;\n      return *this;\n    }\n\n    template <typename T>\n    void print(T value) {\n      print_internal(value, 0, line_terminator_, 0);\n    }\n\n    template <typename T>\n    void print(std::initializer_list<T> value) {\n      print_internal(value, 0, line_terminator_, 0);\n    }\n\n    template<typename T, typename... Targs>\n    void print(T value, Targs... Fargs) {\n      print_internal(value, 0, \"\", 0);\n      auto current_quotes = quotes_;\n      quotes_ = false;\n      print_internal(\" \", 0, \"\", 0);\n      quotes_ = current_quotes;\n      print(Fargs...);\n    }\n\n    template <typename T>\n    void print_inline(T value) {\n      print_internal(value, indent_, \"\", 0);\n    }\n\n    template <typename T>\n    void print_inline(std::initializer_list<T> value) {\n      print_internal(value, indent_, \"\", 0);\n    }\n\n    template<typename T, typename... Targs>\n    void print_inline(T value, Targs... Fargs) {\n      print_internal(value, indent_, \"\", 0);\n      auto current_quotes = quotes_;\n      quotes_ = false;\n      print_internal(\" \", 0, \"\", 0);\n      quotes_ = current_quotes;\n      print_inline(Fargs...);\n    }\n\n  private:\n\n    template <typename T>\n    typename std::enable_if<std::is_integral<T>::value == true, void>::type\n    print_internal(T value, size_t indent = 0, const std::string& line_terminator = \"\\n\", size_t level = 0) {\n      stream_ << std::string(indent, ' ') << value << line_terminator;\n    }\n\n    template <typename T>\n    typename std::enable_if<std::is_null_pointer<T>::value == true, void>::type\n    print_internal(T value, size_t indent = 0, const std::string& line_terminator = \"\\n\", size_t level = 0) {\n      stream_ << std::string(indent, ' ') << \"nullptr\" << line_terminator;\n    }\n\n    void print_internal(float value, size_t indent = 0, const std::string& line_terminator = \"\\n\", size_t level = 0) {\n      stream_ << std::string(indent, ' ') << value << 'f' << line_terminator;\n    }\n\n    void print_internal(double value, size_t indent = 0, const std::string& line_terminator = \"\\n\", size_t level = 0) {\n      stream_ << std::string(indent, ' ') << value << line_terminator;\n    }\n\n    void print_internal(const std::string& value, size_t indent = 0, const std::string& line_terminator = \"\\n\",\n      size_t level = 0) {\n      if (!quotes_)\n        print_internal_without_quotes(value, indent, line_terminator, level);\n      else\n        stream_ << std::string(indent, ' ') << \"\\\"\" << value << \"\\\"\" << line_terminator;\n    }\n\n    void print_internal(const char * value, size_t indent = 0, const std::string& line_terminator = \"\\n\",\n      size_t level = 0) {\n      if (!quotes_)\n        print_internal_without_quotes(value, indent, line_terminator, level);\n      else\n        stream_ << std::string(indent, ' ') << \"\\\"\" << value << \"\\\"\" << line_terminator;\n    }\n\n    void print_internal(char value, size_t indent = 0, const std::string& line_terminator = \"\\n\", size_t level = 0) {\n      if (!quotes_)\n        print_internal_without_quotes(value, indent, line_terminator, level);\n      else\n        stream_ << std::string(indent, ' ') << \"'\" << value << \"'\" << line_terminator;\n    }\n\n    void print_internal_without_quotes(const std::string& value, size_t indent = 0,\n      const std::string& line_terminator = \"\\n\", size_t level = 0) {\n      stream_ << std::string(indent, ' ') << value << line_terminator;\n    }\n\n    void print_internal_without_quotes(const char * value, size_t indent = 0,\n      const std::string& line_terminator = \"\\n\", size_t level = 0) {\n      stream_ << std::string(indent, ' ') << value << line_terminator;\n    }\n\n    void print_internal_without_quotes(char value, size_t indent = 0, const std::string& line_terminator = \"\\n\",\n      size_t level = 0) {\n      stream_ << std::string(indent, ' ') << value << line_terminator;\n    }\n\n    void print_internal(bool value, size_t indent = 0, const std::string& line_terminator = \"\\n\", size_t level = 0) {\n      stream_ << std::string(indent, ' ') << (value ? \"true\" : \"false\") << line_terminator;\n    }\n\n    template <typename T>\n    typename std::enable_if<std::is_pointer<T>::value == true, void>::type\n    print_internal(T value, size_t indent = 0, const std::string& line_terminator = \"\\n\", size_t level = 0) {\n      if (value == nullptr) {\n        return print_internal(nullptr, indent, line_terminator, level);\n      }\n      stream_ << std::string(indent, ' ') << \"<\" << type(value) << \" at \"\n              << value << \">\" << line_terminator;\n    }\n\n    std::string demangle(const char* name) {\n#ifdef __GNUG__\n      int status = -4;\n      std::unique_ptr<char, void(*)(void*)> res {\n        abi::__cxa_demangle(name, NULL, NULL, &status),\n        std::free\n      };\n      return (status==0) ? res.get() : name;\n#else\n      return name;\n#endif\n    }\n\n    template <class T>\n    std::string type(const T& t) {\n      return demangle(typeid(t).name());\n    }\n\n    template <typename T>\n    typename std::enable_if<std::is_enum<T>::value == true, void>::type\n    print_internal(T value, size_t indent = 0, const std::string& line_terminator = \"\\n\", size_t level = 0) {\n      auto enum_string = magic_enum::enum_name(value);\n      if (enum_string.has_value()) {\n        stream_ << std::string(indent, ' ') << enum_string.value()\n                << line_terminator;\n      }\n      else {\n        stream_ << std::string(indent, ' ') << static_cast<std::underlying_type_t<T>>(value)\n                << line_terminator;\n      }\n    }\n\n    template <typename T>\n    typename std::enable_if<std::is_class<T>::value == true &&\n        is_to_stream_writable<std::ostream, T>::value == true &&\n        std::is_enum<T>::value == false &&\n        is_specialization<T, std::unique_ptr>::value == false &&\n        is_specialization<T, std::shared_ptr>::value == false &&\n        is_specialization<T, std::weak_ptr>::value == false &&\n        is_specialization<T, std::tuple>::value == false &&\n        is_specialization<T, std::variant>::value == false &&\n        is_specialization<T, std::vector>::value == false &&\n        is_specialization<T, std::list>::value == false &&\n        is_specialization<T, std::deque>::value == false &&\n        is_specialization<T, std::queue>::value == false &&\n        is_specialization<T, std::priority_queue>::value == false &&\n        is_specialization<T, std::stack>::value == false &&\n        is_specialization<T, std::set>::value == false &&\n        is_specialization<T, std::multiset>::value == false &&\n        is_specialization<T, std::unordered_set>::value == false &&\n        is_specialization<T, std::unordered_multiset>::value == false &&\n        is_specialization<T, std::map>::value == false &&\n        is_specialization<T, std::multimap>::value == false &&\n        is_specialization<T, std::unordered_map>::value == false &&\n        is_specialization<T, std::unordered_multimap>::value == false, void>::type\n    print_internal(T value, size_t indent = 0, const std::string& line_terminator = \"\\n\", size_t level = 0) {\n      stream_ << std::string(indent, ' ') << value << line_terminator;\n    }\n\n    template <typename T>\n    typename std::enable_if<std::is_class<T>::value == true &&\n            is_to_stream_writable<std::ostream, T>::value == false &&\n            std::is_enum<T>::value == false &&\n            is_specialization<T, std::unique_ptr>::value == false &&\n            is_specialization<T, std::shared_ptr>::value == false &&\n            is_specialization<T, std::weak_ptr>::value == false &&\n            is_specialization<T, std::tuple>::value == false &&\n            is_specialization<T, std::variant>::value == false &&\n            is_specialization<T, std::vector>::value == false &&\n            is_specialization<T, std::list>::value == false &&\n            is_specialization<T, std::deque>::value == false &&\n            is_specialization<T, std::queue>::value == false &&\n            is_specialization<T, std::priority_queue>::value == false &&\n            is_specialization<T, std::stack>::value == false &&\n            is_specialization<T, std::set>::value == false &&\n            is_specialization<T, std::multiset>::value == false &&\n            is_specialization<T, std::unordered_set>::value == false &&\n            is_specialization<T, std::unordered_multiset>::value == false &&\n            is_specialization<T, std::map>::value == false &&\n            is_specialization<T, std::multimap>::value == false &&\n            is_specialization<T, std::unordered_map>::value == false &&\n            is_specialization<T, std::unordered_multimap>::value == false, void>::type\n            print_internal(T value, size_t indent = 0, const std::string& line_terminator = \"\\n\", size_t level = 0) {\n      stream_ << std::string(indent, ' ') << \"<Object \" << type(value) << \">\"\n              << line_terminator;\n    }\n\n    template <typename T>\n    typename std::enable_if<std::is_member_function_pointer<T>::value == true, void>::type\n    print_internal(T value, size_t indent = 0, const std::string& line_terminator = \"\\n\", size_t level = 0) {\n      stream_ << std::string(indent, ' ') << \"<Object.method \" << type(value)\n              << \" at \" << &value << \">\"\n              << line_terminator;\n    }\n\n    template <typename Container>\n    typename std::enable_if<is_specialization<Container, std::vector>::value, void>::type\n            print_internal(const Container& value, size_t indent = 0, const std::string& line_terminator = \"\\n\",\n            size_t level = 0) {\n      typedef typename Container::value_type T;\n      if (level == 0 && !compact_) {\n        if (value.size() == 0) {\n          print_internal_without_quotes(\"[\", 0, \"\");\n        }\n        else if (value.size() == 1) {\n          print_internal_without_quotes(\"[\", 0, \"\");\n          print_internal(value.front(), 0, \"\", level + 1);\n        }\n        else if (value.size() > 0) {\n          print_internal_without_quotes(\"[\", 0, \"\\n\");\n          print_internal(value.front(), indent + indent_, \"\", level + 1);\n          if (value.size() > 1 && is_container<T>::value == false)\n            print_internal_without_quotes(\", \", 0, \"\\n\");\n          else if (is_container<T>::value)\n            print_internal_without_quotes(\", \", 0, \"\\n\");\n          for (size_t i = 1; i < value.size() - 1; i++) {\n            print_internal(value[i], indent + indent_, \"\", level + 1);\n            if (is_container<T>::value == false)\n              print_internal_without_quotes(\", \", 0, \"\\n\");\n            else\n              print_internal_without_quotes(\", \", 0, \"\\n\");\n          }\n          if (value.size() > 1) {\n            print_internal(value.back(), indent + indent_, \"\\n\", level + 1);\n          }\n        }\n        if (value.size() == 0)\n          print_internal_without_quotes(\"]\", indent, \"\");\n        else if (is_container<T>::value == false)\n          print_internal_without_quotes(\"]\", indent, \"\");\n        else\n          print_internal_without_quotes(line_terminator_ + \"]\", indent, \"\");\n        print_internal_without_quotes(line_terminator_, 0, \"\");\n      }\n      else {\n        if (value.size() == 0) {\n          print_internal_without_quotes(\"[\", indent, \"\");\n        }\n        else if (value.size() == 1) {\n          print_internal_without_quotes(\"[\", indent, \"\");\n          print_internal(value.front(), 0, \"\", level + 1);\n        }\n        else if (value.size() > 0) {\n          print_internal_without_quotes(\"[\", indent, \"\");\n          print_internal(value.front(), 0, \"\", level + 1);\n          if (value.size() > 1)\n            print_internal_without_quotes(\", \", 0, \"\");\n          for (size_t i = 1; i < value.size() - 1; i++) {\n            print_internal(value[i], 0, \"\", level + 1);\n            print_internal_without_quotes(\", \", 0, \"\");\n          }\n          if (value.size() > 1) {\n            print_internal(value.back(), 0, \"\", level + 1);\n          }\n        }\n        print_internal_without_quotes(\"]\", 0, \"\");\n        if (level == 0 && compact_)\n          print_internal_without_quotes(line_terminator_, 0, \"\");\n      }\n\n    }\n\n    template <typename T, unsigned long int S>\n    void print_internal(const std::array<T, S>& value, size_t indent = 0, const std::string& line_terminator = \"\\n\",\n            size_t level = 0) {\n      if (level == 0 && !compact_) {\n        if (value.size() == 0) {\n          print_internal_without_quotes(\"[\", 0, \"\");\n        }\n        else if (value.size() == 1) {\n          print_internal_without_quotes(\"[\", 0, \"\");\n          print_internal(value.front(), 0, \"\", level + 1);\n        }\n        else if (value.size() > 0) {\n          print_internal_without_quotes(\"[\", 0, \"\\n\");\n          print_internal(value.front(), indent + indent_, \"\", level + 1);\n          if (value.size() > 1 && is_container<T>::value == false)\n            print_internal_without_quotes(\", \", 0, \"\\n\");\n          else if (is_container<T>::value)\n            print_internal_without_quotes(\", \", 0, \"\\n\");\n          for (size_t i = 1; i < value.size() - 1; i++) {\n            print_internal(value[i], indent + indent_, \"\", level + 1);\n            if (is_container<T>::value == false)\n              print_internal_without_quotes(\", \", 0, \"\\n\");\n            else\n              print_internal_without_quotes(\", \", 0, \"\\n\");\n          }\n          if (value.size() > 1) {\n            print_internal(value.back(), indent + indent_, \"\\n\", level + 1);\n          }\n        }\n        if (value.size() == 0)\n          print_internal_without_quotes(\"]\", indent, \"\");\n        else if (is_container<T>::value == false)\n          print_internal_without_quotes(\"]\", indent, \"\");\n        else\n          print_internal_without_quotes(line_terminator_ + \"]\", indent, \"\");\n        print_internal_without_quotes(line_terminator_, 0, \"\");\n      }\n      else {\n        if (value.size() == 0) {\n          print_internal_without_quotes(\"[\", indent, \"\");\n        }\n        else if (value.size() == 1) {\n          print_internal_without_quotes(\"[\", indent, \"\");\n          print_internal(value.front(), 0, \"\", level + 1);\n        }\n        else if (value.size() > 0) {\n          print_internal_without_quotes(\"[\", indent, \"\");\n          print_internal(value.front(), 0, \"\", level + 1);\n          if (value.size() > 1)\n            print_internal_without_quotes(\", \", 0, \"\");\n          for (size_t i = 1; i < value.size() - 1; i++) {\n            print_internal(value[i], 0, \"\", level + 1);\n            print_internal_without_quotes(\", \", 0, \"\");\n          }\n          if (value.size() > 1) {\n            print_internal(value.back(), 0, \"\", level + 1);\n          }\n        }\n        print_internal_without_quotes(\"]\", 0, \"\");\n        if (level == 0 && compact_)\n          print_internal_without_quotes(line_terminator_, 0, \"\");\n      }\n\n    }\n\n    template <typename Container>\n    typename std::enable_if<is_specialization<Container, std::list>::value ||\n            is_specialization<Container, std::deque>::value,\n            void>::type print_internal(const Container& value, size_t indent = 0,\n            const std::string& line_terminator = \"\\n\",\n            size_t level = 0) {\n      typedef typename Container::value_type T;\n      if (level == 0 && !compact_) {\n        if (value.size() == 0) {\n          print_internal_without_quotes(\"[\", 0, \"\");\n        }\n        else if (value.size() == 1) {\n          print_internal_without_quotes(\"[\", 0, \"\");\n          print_internal(value.front(), 0, \"\", level + 1);\n        }\n        else if (value.size() > 0) {\n          print_internal_without_quotes(\"[\", 0, \"\\n\");\n          print_internal(value.front(), indent + indent_, \"\", level + 1);\n          if (value.size() > 1 && is_container<T>::value == false)\n            print_internal_without_quotes(\", \", 0, \"\\n\");\n          else if (is_container<T>::value)\n            print_internal_without_quotes(\", \", 0, \"\\n\");\n\n          typename Container::const_iterator iterator;\n          for (iterator = std::next(value.begin()); iterator != std::prev(value.end()); ++iterator) {\n            print_internal(*iterator, indent + indent_, \"\", level + 1);\n            if (is_container<T>::value == false)\n              print_internal_without_quotes(\", \", 0, \"\\n\");\n            else\n              print_internal_without_quotes(\", \", 0, \"\\n\");\n          }\n\n          if (value.size() > 1) {\n            print_internal(value.back(), indent + indent_, \"\\n\", level + 1);\n          }\n        }\n        if (value.size() == 0)\n          print_internal_without_quotes(\"]\", indent, \"\");\n        else if (is_container<T>::value == false)\n          print_internal_without_quotes(\"]\", indent, \"\");\n        else\n          print_internal_without_quotes(line_terminator_ + \"]\", indent, \"\");\n        print_internal_without_quotes(line_terminator_, 0, \"\");\n      }\n      else {\n        if (value.size() == 0) {\n          print_internal_without_quotes(\"[\", indent, \"\");\n        }\n        else if (value.size() == 1) {\n          print_internal_without_quotes(\"[\", indent, \"\");\n          print_internal(value.front(), 0, \"\", level + 1);\n        }\n        else if (value.size() > 0) {\n          print_internal_without_quotes(\"[\", indent, \"\");\n          print_internal(value.front(), 0, \"\", level + 1);\n          if (value.size() > 1)\n            print_internal_without_quotes(\", \", 0, \"\");\n\n          typename Container::const_iterator iterator;\n          for (iterator = std::next(value.begin()); iterator != std::prev(value.end()); ++iterator) {\n            print_internal(*iterator, 0, \"\", level + 1);\n            print_internal_without_quotes(\", \", 0, \"\");\n          }\n\n          if (value.size() > 1) {\n            print_internal(value.back(), 0, \"\", level + 1);\n          }\n        }\n        print_internal_without_quotes(\"]\", 0, \"\");\n        if (level == 0 && compact_)\n          print_internal_without_quotes(line_terminator_, 0, \"\");\n      }\n\n    }\n\n    template <typename Container>\n    typename std::enable_if<is_specialization<Container, std::set>::value ||\n            is_specialization<Container, std::multiset>::value ||\n            is_specialization<Container, std::unordered_set>::value ||\n            is_specialization<Container, std::unordered_multiset>::value, void>::type\n            print_internal(const Container& value, size_t indent = 0, const std::string& line_terminator = \"\\n\",\n            size_t level = 0) {\n      typedef typename Container::value_type T;\n      if (level == 0 && !compact_) {\n        if (value.size() == 0) {\n          print_internal_without_quotes(\"{\", 0, \"\");\n        }\n        else if (value.size() == 1) {\n          print_internal_without_quotes(\"{\", 0, \"\");\n          print_internal(*(value.begin()), 0, \"\", level + 1);\n        }\n        else {\n          print_internal_without_quotes(\"{\", 0, \"\\n\");\n          print_internal(*(value.begin()), indent + indent_, \"\", level + 1);\n          if (value.size() > 1 && is_container<T>::value == false)\n            print_internal_without_quotes(\", \", 0, \"\\n\");\n          else if (is_container<T>::value)\n            print_internal_without_quotes(\", \", 0, \"\\n\");\n\n          typename Container::const_iterator iterator;\n          for (iterator = std::next(value.begin()); (iterator != value.end()) && (std::next(iterator) != value.end()); ++iterator) {\n            print_internal(*iterator, indent + indent_, \"\", level + 1);\n            if (is_container<T>::value == false)\n              print_internal_without_quotes(\", \", 0, \"\\n\");\n            else\n              print_internal_without_quotes(\", \", 0, \"\\n\");\n          }\n\n          if (value.size() > 1) {\n            print_internal(*iterator, indent + indent_, \"\\n\", level + 1);\n          }\n        }\n        if (value.size() == 0)\n          print_internal_without_quotes(\"}\", indent, \"\");\n        else if (is_container<T>::value == false)\n          print_internal_without_quotes(\"}\", indent, \"\");\n        else\n          print_internal_without_quotes(line_terminator_ + \"}\", indent, \"\");\n        print_internal_without_quotes(line_terminator_, 0, \"\");\n      }\n      else {\n        if (value.size() == 0) {\n          print_internal_without_quotes(\"{\", indent, \"\");\n        }\n        else if (value.size() == 1) {\n          print_internal_without_quotes(\"{\", indent, \"\");\n          print_internal(*(value.begin()), 0, \"\", level + 1);\n        }\n        else {\n          print_internal_without_quotes(\"{\", indent, \"\");\n          print_internal(*(value.begin()), 0, \"\", level + 1);\n          if (value.size() > 1)\n            print_internal_without_quotes(\", \", 0, \"\");\n\n          typename Container::const_iterator iterator;\n          for (iterator = std::next(value.begin()); (iterator != value.end()) && (std::next(iterator) != value.end()); ++iterator) {\n            print_internal(*iterator, 0, \"\", level + 1);\n            print_internal_without_quotes(\", \", 0, \"\");\n          }\n\n          if (value.size() > 1) {\n            print_internal(*iterator, 0, \"\", level + 1);\n          }\n        }\n        print_internal_without_quotes(\"}\", 0, \"\");\n        if (level == 0 && compact_)\n          print_internal_without_quotes(line_terminator_, 0, \"\");\n      }\n\n    }\n\n    template <typename T>\n    typename std::enable_if<is_specialization<T, std::map>::value == true ||\n            is_specialization<T, std::multimap>::value == true ||\n            is_specialization<T, std::unordered_map>::value == true ||\n            is_specialization<T, std::unordered_multimap>::value == true, void>::type\n            print_internal(const T& value, size_t indent = 0, const std::string& line_terminator = \"\\n\", size_t level = 0) {\n      typedef typename T::mapped_type Value;\n      if (level == 0 && !compact_) {\n        if (value.size() == 0) {\n          print_internal_without_quotes(\"{\", 0, \"\");\n        }\n        else if (value.size() == 1) {\n          print_internal_without_quotes(\"{\", 0, \"\");\n          for (auto& kvpair : value) {\n            print_internal(kvpair.first, 0, \"\", level + 1);\n            print_internal_without_quotes(\" : \", 0, \"\");\n            print_internal(kvpair.second, 0, \"\", level + 1);\n          }\n        }\n        else if (value.size() > 0) {\n          size_t count = 0;\n          for (auto& kvpair : value) {\n            if (count == 0) {\n              print_internal_without_quotes(\"{\", 0, \"\\n\");\n              print_internal(kvpair.first, indent + indent_, \"\", level + 1);\n              print_internal_without_quotes(\" : \", 0, \"\");\n              print_internal(kvpair.second, 0, \"\", level + 1);\n              if (value.size() > 1 && is_container<Value>::value == false)\n                print_internal_without_quotes(\", \", 0, \"\\n\");\n              else if (is_container<Value>::value)\n                print_internal_without_quotes(\", \", 0, \"\\n\");\n            }\n            else if (count + 1 < value.size()) {\n              print_internal(kvpair.first, indent + indent_, \"\", level + 1);\n              print_internal_without_quotes(\" : \", 0, \"\");\n              print_internal(kvpair.second, 0, \"\", level + 1);\n              if (is_container<Value>::value == false)\n                print_internal_without_quotes(\", \", 0, \"\\n\");\n              else\n                print_internal_without_quotes(\", \", 0, \"\\n\");\n            }\n            else {\n              print_internal(kvpair.first, indent + indent_, \"\", level + 1);\n              print_internal_without_quotes(\" : \", 0, \"\");\n              print_internal(kvpair.second, 0, \"\\n\", level + 1);\n            }\n            count += 1;\n          }\n        }\n        if (value.size() == 0)\n          print_internal_without_quotes(\"}\", indent, \"\");\n        else if (is_container<Value>::value == false)\n          print_internal_without_quotes(\"}\", indent, \"\");\n        else\n          print_internal_without_quotes(line_terminator_ + \"}\", indent, \"\");\n        print_internal_without_quotes(line_terminator_, 0, \"\");\n      }\n\n      else {\n        if (value.size() == 0) {\n          print_internal_without_quotes(\"{\", indent, \"\");\n        }\n        else if (value.size() == 1) {\n          print_internal_without_quotes(\"{\", indent, \"\");\n          for (auto& kvpair : value) {\n            print_internal(kvpair.first, 0, \"\", level + 1);\n            print_internal_without_quotes(\" : \", 0, \"\");\n            print_internal(kvpair.second, 0, \"\", level + 1);\n          }\n        }\n        else if (value.size() > 0) {\n          size_t count = 0;\n          for (auto& kvpair : value) {\n            if (count == 0) {\n              print_internal_without_quotes(\"{\", indent, \"\");\n              print_internal(kvpair.first, 0, \"\", level + 1);\n              print_internal_without_quotes(\" : \", 0, \"\");\n              print_internal(kvpair.second, 0, \"\", level + 1);\n              print_internal_without_quotes(\", \", 0, \"\");\n            }\n            else if (count + 1 < value.size()) {\n              print_internal(kvpair.first, indent + indent_, \"\", level + 1);\n              print_internal_without_quotes(\" : \", 0, \"\");\n              print_internal(kvpair.second, 0, \"\", level + 1);\n              print_internal_without_quotes(\", \", 0, \"\");\n            }\n            else {\n              print_internal(kvpair.first, 0, \"\", level + 1);\n              print_internal_without_quotes(\" : \", 0, \"\");\n              print_internal(kvpair.second, 0, \"\", level + 1);\n            }\n            count += 1;\n          }\n        }\n        print_internal_without_quotes(\"}\", 0, \"\");\n        if (level == 0 && compact_)\n          print_internal_without_quotes(line_terminator_, 0, \"\");\n      }\n    }\n\n    template <typename Key, typename Value>\n    void print_internal(std::pair<Key, Value> value, size_t indent = 0, const std::string& line_terminator = \"\\n\",\n            size_t level = 0) {\n      print_internal_without_quotes(\"(\", indent, \"\");\n      print_internal(value.first, 0, \"\");\n      print_internal_without_quotes(\", \", 0, \"\");\n      print_internal(value.second, 0, \"\");\n      print_internal_without_quotes(\")\", 0, line_terminator, level);\n    }\n\n    template <class ...Ts>\n    void print_internal(std::variant<Ts...> value, size_t indent = 0,\n        const std::string& line_terminator = \"\\n\", size_t level = 0) {\n      std::visit([=](const auto& value) { print_internal(value, indent, line_terminator, level); }, value);\n    }\n\n    template <typename T>\n    void print_internal(std::optional<T> value, size_t indent = 0,\n        const std::string& line_terminator = \"\\n\", size_t level = 0) {\n      if (value) {\n        print_internal(value.value(), indent, line_terminator, level);\n      }\n      else {\n        print_internal_without_quotes(\"nullopt\", indent, line_terminator, level);\n      }\n    }\n\n    template <typename Container>\n    typename std::enable_if<is_specialization<Container, std::queue>::value, void>::type\n            print_internal(const Container& value, size_t indent = 0, const std::string& line_terminator = \"\\n\",\n            size_t level = 0) {\n      auto current_compact = compact_;\n      compact_ = true;\n      typedef typename Container::value_type T;\n      auto local = value;\n      std::vector<T> local_vector;\n      while (!local.empty()) {\n        local_vector.push_back(local.front());\n        local.pop();\n      }\n      print_internal(local_vector, indent, line_terminator, level);\n      compact_ = current_compact;\n    }\n\n    template <typename Container>\n    typename std::enable_if<is_specialization<Container, std::priority_queue>::value, void>::type\n    print_internal(const Container& value, size_t indent = 0, const std::string& line_terminator = \"\\n\",\n            size_t level = 0) {\n      auto current_compact = compact_;\n      compact_ = true;\n      typedef typename Container::value_type T;\n      auto local = value;\n      std::vector<T> local_vector;\n      while (!local.empty()) {\n        local_vector.push_back(local.top());\n        local.pop();\n      }\n      print_internal(local_vector, indent, line_terminator, level);\n      compact_ = current_compact;\n    }\n\n    template <typename T>\n    void print_internal(std::initializer_list<T> value, size_t indent = 0,\n            const std::string& line_terminator = \"\\n\", size_t level = 0) {\n      std::multiset<T> local;\n      for(const T& x : value) {\n        local.insert(x);\n      }\n      print_internal(local, indent, line_terminator_, level);\n    }\n\n    template <typename Container>\n    typename std::enable_if<is_specialization<Container, std::stack>::value, void>::type\n    print_internal(const Container& value, size_t indent = 0, const std::string& line_terminator = \"\\n\",\n            size_t level = 0) {\n      bool current_compact = compact_;\n      compact_ = false; // Need to print a stack like its a stack, i.e., vertical\n      typedef typename Container::value_type T;\n      auto local = value;\n      std::vector<T> local_vector;\n      while (!local.empty()) {\n        local_vector.push_back(local.top());\n        local.pop();\n      }\n      print_internal(local_vector, indent, line_terminator, level);\n      compact_ = current_compact;\n    }\n\n    template<class... Args>\n    void print_internal(const std::tuple<Args...>& value, size_t indent = 0, const std::string& line_terminator = \"\\n\",\n            size_t level = 0) {\n      stream_ << std::string(indent, ' ') << value\n              << line_terminator;\n    }\n\n    template<typename T>\n    void print_internal(const std::complex<T>& value, size_t indent = 0, const std::string& line_terminator = \"\\n\",\n        size_t level = 0) {\n      stream_ << std::string(indent, ' ') << \"(\" <<\n      value.real() << \" + \" << value.imag() << \"i)\"\n                   << line_terminator;\n    }\n\n    template<typename Pointer>\n    typename std::enable_if<is_specialization<Pointer, std::unique_ptr>::value ||\n        is_specialization<Pointer, std::shared_ptr>::value ||\n        is_specialization<Pointer, std::weak_ptr>::value, void>::type\n        print_internal(const Pointer& value, size_t indent = 0, const std::string& line_terminator = \"\\n\",\n        size_t level = 0) {\n      stream_ << std::string(indent, ' ') << \"<\" <<\n      type(value) << \" at \" << &value << \">\"\n                  << line_terminator;\n    }\n\n  };\n\n}"
  },
  {
    "path": "03-Interview Preparation/Docs/.gitkeep",
    "content": "\n"
  },
  {
    "path": "03-Interview Preparation/PDF/.gitkeep",
    "content": "\n"
  },
  {
    "path": "03-Interview Preparation/README.md",
    "content": "⚙️ Under construction ⚙️\n\nAiming to help my fellow coders to clear Technical Interviews.\n\nI have compiled the resources yet again to simplify the work and save time.\n"
  },
  {
    "path": "README.md",
    "content": "# All-Of-Competitive-Programming\n\nThis repo contains all the resources a beginner needs to start competitive programming and an intermediate to excel in it. It is a curated blog of all other blogs that I've found informative while going through several posts for the past some time.\n\n\n\n#### Contents\n\n* [CP - Essentials](#The-essentials-that-every-competitive-programmer-should-have)\n* [Technique](#Technique)\n* [Tools](#Tools-for-Competitive-Programming)\n* [Speed](#Speed)\n\n<br> \n\n> <kbd>Skip</kbd> to <kbd>[setting-up your working environment on your pc](https://github.com/luctivud/All-Of-Competitive-Programming/tree/master/00-Setting-up-local-environment)</kbd> or  <kbd>[CP Materials](https://github.com/luctivud/All-Of-Competitive-Programming/tree/master/01-Material)</kbd>.\n\n<hr> <br>\n\n\n### The essentials that every competitive programmer should have:\n<br>\n\n1. Competitive Programming environment set up on their local machine. \n\n2. CP Books to keep them on track.\n\n3. Habit of reading blogs. \n\n4. Practice! Practice! Practice!\n\n5. Should NOT have a complaining nature. \n\n\n\n<br> <hr> <br>\n\n\n\n### Technique\n<br>\n\nThe everyday schedule that one follows should be very balanced and should not leave a person exhausted in the end. The most appropriate time of reading is said to be in the morning itself and a practice which involves heavy mental exercise should be done at night.\n\nThe following schedule is optimal to be followed by a beginner to make it a second nature. However, it is not mandatory and one can follow a plan in which they feel most comfortable.\n\n* Morning : Read blogs / books / texts.\n\n* Noon : Implement the concepts and solve related problems.\n\n* Evening : Read blogs or watch video tutorials.\n\n* Night : Solve problems based on the concepts learnt.\n\n<br>\n\nThe following practices should be kept in mind as these are also helpful :\n\n* Implementing the concepts after reading it. \n\n* Reading Editorial even if you have solved the problem.\n\n* Reading and understanding other users' solution and implementing the same.\n\n* Elaborating the concepts on your own and thinking about the different ways any concept can be modified and then implementing the same.\n\n* Helping others in understanding the concepts you have learnt so far: This might seem like a waste of time but solving others' doubts and making someone understand a concept will make your concept crystal clear.\n\n* Having a Good Sleep is always necessary to start the next day with zeal.\n\n<br>\n\n* **How much time should we spend on a problem ?**\n\n    The answer depends from person to person and from problem to problem.\n\n    Solving a problem on your own without taking any help from editorial is always a confidence booster but spending a lot of time on probably something you are not aware of yet is not upto the mark.\n\n    In my opinion, you should never take help of any editorial if the problem is simply an implementation as editorials are useless in this case. The problem should be solved by yourself. Consider the editorial only if you're stuck at it and can't bear it anymore. However, this should not be made into habit. \n\n\n\n> Side Note: One should take competitive programming as a sport or hobby. If you really want to improve in cp then you should remove all the unnecessary burden of *placements, etc* from your mind. It will take some time and practice to master cp which can only be achieved when you start to enjoy solving the problems rather than treating them as a task. It is not necessary to extensively keep on solving the problems to improve your skills. Instead you can take a break, relax, and then get to the problem.\n\n> Tip for implementation: To write a good and bug-free code in one-go, you should write your code following the same steps as you would if you were teaching a newbie to do something. (Atleast that's how I've managed a good accuracy so far even in contests.) Your speed will tend to increase once it becomes an habit.\n\n\n\n\n<br> [Back to top](#All-Of-Competitive-Programming) <hr> <br>\n\n\n\n\n### Tools for Competitive Programming\n<br>\n\nCheck out the following tools, these may turn out to be of great use:\n\n* [CP Tracker](http://cptracker.herokuapp.com/) : The current and future cp contests listed from various sites.\n\n* [C List](https://clist.by/) : Similar to CP Tracker but it contains them all in a single list.\n\n- [StopStalk](https://www.stopstalk.com/) : A goto for analysing your daily performance and finding problems based on tags.\n\n* [Codeforces Visualiser](https://cfviz.netlify.app/) : You can track your progress on codeforces and can see the ratings of problems you have currently solved and a complete package for your codeforces profile.\n\n- [Kenkooo Atcoder](https://kenkoooo.com/atcoder) : A visualisation tool for AtCoder, here you can solve problems from different contests, see its ratings and many more. It is basically a problemset for AtCoder. \n\n- [CodeDigger](http://codedigger.tech/practice/topicwise) : Solve codeforces problems based on tags and ladders.\n\n* [Contest Mania](https://contestmania.web.app/) : Past as well as Upcoming contests in a list.\n\n* [Lockout bot for discord](https://codeforces.com/blog/entry/78546) : You can try this tool for competiting with your friend in a one on one contest simulation on a discord server.\n\n* [TLE - Discord Bot](https://github.com/cheran-senthil/TLE) : Another Discord bot centred around CP.\n\n* [Graph Visualizer](https://csacademy.com/app/graph_editor/) : Easily visualize graphs.\n\n* Chrome extensions : There are a variety of extensions available on Chrome as well as Firefox which can be of great use inculcating the start of competitive programming. \n\n\n\n<br> [Back to top](#All-Of-Competitive-Programming) <hr> <br>\n\n\n\n\n### Speed\n<br>\n\n\nSpeed plays a very important role in perfoming well during the live contests. \n\nFor improving the speed, [AtCoder](https://atcoder.jp/) is a great platform. Try attempting the problems and solving them in alloted time which is:\n\n* 1-2 minute for A & B.\n* Approx 5 minutes for C\n* Approx 10 - 15 minutes for D & E.\n\nThis will greatly boost the confidence and enhance the logic building and typing speed, in general.\n\nVirtual Contests can also help in speed as these are simulation of real contest. You can give virtual contests by :\n- Giving a virtual contest on codeforces.\n- Creating a mashup on codeforces.\n- Using [VJudge](https://vjudge.net/) to create a contest of your own from past problems of different OJs.\n- Using [Light OJ](http://lightoj.com/login_main.php?url=index.php) to simulate the same.\n\n\n\n<br> [Back to top](#All-Of-Competitive-Programming) <hr> <br>\n\n\n\n\n> You can now [set-up your working environment on your pc](https://github.com/luctivud/All-Of-Competitive-Programming/tree/master/00-Setting-up-local-environment) or move directly to the [CP Materials](https://github.com/luctivud/All-Of-Competitive-Programming/tree/master/01-Material).\n\n> This repo will keep on updating as new resources are found. \n\n> Note : I don't claim any of the works to be mine. I have just curated them all at one place."
  }
]