{"id":13619560,"url":"https://github.com/dragonslayerx/Competitive-Programming-Repository","last_synced_at":"2025-04-14T16:31:50.423Z","repository":{"id":44337605,"uuid":"75975826","full_name":"dragonslayerx/Competitive-Programming-Repository","owner":"dragonslayerx","description":"Competitive Programming templates that I used during the past few years.","archived":false,"fork":false,"pushed_at":"2020-09-30T18:54:46.000Z","size":150,"stargazers_count":437,"open_issues_count":4,"forks_count":153,"subscribers_count":25,"default_branch":"master","last_synced_at":"2024-11-08T05:39:32.343Z","etag":null,"topics":["algorithms","algorithms-implemented","bellman-ford-algorithm","biginteger","bipartite-graphs","competitive-programming","data-structures","dijkstra","disjoint-sets","dynamic-programming","fft","floyd-warshall","graphs","hashing","lca","matching","matrix-exponentiation","recurrence","segment-tree","string"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dragonslayerx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-08T21:16:37.000Z","updated_at":"2024-10-23T12:40:49.000Z","dependencies_parsed_at":"2022-09-01T16:51:33.680Z","dependency_job_id":null,"html_url":"https://github.com/dragonslayerx/Competitive-Programming-Repository","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dragonslayerx%2FCompetitive-Programming-Repository","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dragonslayerx%2FCompetitive-Programming-Repository/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dragonslayerx%2FCompetitive-Programming-Repository/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dragonslayerx%2FCompetitive-Programming-Repository/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dragonslayerx","download_url":"https://codeload.github.com/dragonslayerx/Competitive-Programming-Repository/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248916686,"owners_count":21182848,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithms","algorithms-implemented","bellman-ford-algorithm","biginteger","bipartite-graphs","competitive-programming","data-structures","dijkstra","disjoint-sets","dynamic-programming","fft","floyd-warshall","graphs","hashing","lca","matching","matrix-exponentiation","recurrence","segment-tree","string"],"created_at":"2024-08-01T21:00:44.787Z","updated_at":"2025-04-14T16:31:45.413Z","avatar_url":"https://github.com/dragonslayerx.png","language":"C++","readme":"# Competitive-Programming-Repository\nCollection of algorithms and data structures in C++ used widely in Competitive programming contests. \n\n### The following topics are covered:\n\n#### Range Updates and Queries\n* **Range Aggregate Queries** :\n  * *Binary Indexed Trees (BIT)* :\n    * [Point Update Range Query](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/binary_indexed_tree.cpp)\n    * [Range Update Range Query](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/binary_indexed_tree_range_query_range_update.cpp)\n    * [Order Statistic Query](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/binary_indexed_tree_order_stat.cpp)\n    * [2D Binary Indexed Trees](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/binary_indexed_tree_2D.cpp)\n  * *Segment Trees (SegTree)* :\n    * [Point Update Range Query](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/segment_tree_range_query_point_update.cpp) \n    * [Fast Iterative Segtrees](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/segment_trees_interative_fast.cpp)\n    * [Range Update Point Query - Lazy Propogation](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/segment_tree_range_query_range_update_lazy_propogation.cpp)\n    * [Max subsegment sum in range](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/segment_tree_custom_merge_function.cpp)\n    * [2D Segment Trees](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/segment_tree_2D.cpp)\n    * [Dynamic Segment Trees - Insertion/Deletion between elements](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/segment_tree_dynamic_using_treaps.cpp)\n    * [Dynamic Segment Trees - Reverse a segment](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/segment_tree_dynamic_reverse_subarray_using_treap.cpp)\n  * *Merge Sort Trees* :\n    * [Merge sort trees](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/merge_sort_trees.cpp)\n    * [Merge sort trees - Order Statistics](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/merge_sort_trees_order_stat_query.cpp)  \n  * *Sparse Table* :\n    * [Range Minimum Query](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/range_minimum_query_sparse_table.cpp)\n  * *Mo Algorithm* :\n    * [Mo Algorithm - Arrays](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/mo_algorithm_offline_range_query.cpp)\n* **Dynamic Programming** :\n  * *Dynamic Programming Templates* :\n    * [Digit DP / Bitwise DP](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/dynamic_programming_templates.cpp)\n  * *Standard DP Problems* :\n    * [Longest Increasing Subsequence](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/longest_increasing_subsequence_lis_binary_search.cpp)\n    * [Longest Palindromic Subsequence](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/palindrome_longest_subsequence.cpp)\n    * [Levenstein Distance / Edit Distance](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/edit_distance_levenstein_dynamic_programming.cpp)\n* **Graphs** :\n  * *Single Source Shortest Path Algorithms* :\n    * [Dijkstra in dense graphs](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/dijsktra_dense_graphs.cpp)\n    * [Dijkstra using priority queue](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/dijkstra_using_priority_queue.cpp)\n    * [Kth Shortest Path between Nodes using Dijkstra](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/kth_shortest_path_between_nodes_graph.cpp)\n    * [Bellman Ford Negative cycle detection](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/bellman_ford.cpp)\n  * *All Pair shortest path* :\n    * [Using Binary exponentiation](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/all_pair_shortest_path_binary_exponentation.cpp)\n    * [Floyd Warshall](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/all_pair_shortest_path_floyd_warshall.cpp)\n  * *Cycle Detection* :\n    * [Cycle detection in Undirected/Directed Graphs](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/cycle_detection_in_graph.cpp)\n  * *Minimum Spanning tree* :\n    * [Kruskal Algorithm](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/kruskal_min_spanning_tree.cpp)\n  * *Topological Sort / Strongly Connected Component* :\n    * [Topological Sort](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/topological_sort_kosaraju.cpp)\n    * [Strongly Connected Component](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/strongly_connected_components_kosaraju.cpp) \n  * *Maxflow/Matching* :\n    * [Hopkroft Karp Max Matching](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/max_bipartite_matching_hopcroft_karp.cpp)\n    * [Dinic Max Flow](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/max_flow_network_dinic_algorithm.cpp)\n  * *Misc* :\n    * [Bridges in Graph](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/bridges_in_graph.cpp)\n    * [Connectivity](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/isConnected_using_bfs.cpp)\n    * [Bipartite Check](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/non_bipartite_check.cpp)\n* **Trees** :\n    * *Ancestor queries* :\n        * [Lowest Common Ancestor](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/lowest_common_ancestor_lca.cpp)\n        * [Kth Ancestor](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/kth_ancestor_tree.cpp)\n    * *Path queries* :\n        * [Sparse Table *](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/trees_path_query_sparse_tables.cpp)\n        * [Heavy Light Decomposition Weighted Nodes](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/heavy_light_decomposition_wieghted_vertices(hld).cpp)\n        * [Heavy Light Decomposition Weighted Edges](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/heavy_light_decomposition_weighted_edges%20(hld).cpp)\n    * *Misc* :\n        * [Diameter of Tree](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/tree_diameter.cpp)\n        * [Preorder/Postorder stamps, Is it in Subtree?](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/tree_dfs_preorder_postorder_isInSubtree.cpp) \n* **Binary Exponentiation** :\n   * [Calculate n^m using Binary exponentiation](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/power_binary_exponentiation.cpp)\n   * [Solving Linear Recurrences](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/linear_recurrence_matrix_exponentiation.cpp)\n* **Strings** :\n   * *String Algorithms* :\n       * [Z Algorithm](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/Z_algorithm_max_prefix_match.cpp)\n       * [KMP algorithm](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/KMP.cpp)\n       * [Rolling String Hashing](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/string_hashing.cpp)\n       * [Rolling String Hashing for Dynamic Strings](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/string_hashing_dynamic_segment_trees.cpp)\n   * *String Data Structures* :\n       * [Suffix Array *](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/untested-codes/suffix_array.cpp)\n* **Sorting** :\n  * [Merge Sort](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/merge_sort_count_inversion.cpp)\n  * [Quick Select](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/quick_select_order_stat_linear.cpp)\n* **Fast Input/Output, String/Integer Conversion** :\n   * [Fast Input/Output](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/fast_readInt_writeInt_function.cpp)\n   * [String/Integer Conversion](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/int2string_string2int.cpp)\n* **Misc. Data Structures** :\n   * [Disjoint Set](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/disjoint_set.cpp)\n   * [Disjoint Set (Supports Undo Operation)](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/disjoint_set_with_undo_operation.cpp)\n   * [Max/Min Priority Queue with update](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/heap_using_multiset_max_min_insert_erase_update.cpp)\n   * [Binary Trie for xor maximization/minimization](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/binary_trie_max_xor.cpp)\n   * [Bigint *](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/bigint_library.cpp)\n   * [Augmented Binary Tree for order statistics and rank query](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/orderstat_rank_query_augmented_bst.cpp)\n   * [Monotone Priority Queue](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/monotone_priority_queue.cpp)\n   * [Trie](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/trie_insertion_deleteion.cpp)\n* **Persistent Data Structures** :\n  * *Persistent Segment Trees (SegTree)* :\n    * [Persistent Segment Tree](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/segment_tree_persistent.cpp)\n    * [Persistent Segment Tree - Order Statistics](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/segment_tree_persistent_order_stat.cpp)\n* **Number Theory Algorithms** :\n  * *Primality Check* :\n      * [Fermat's Primality Check](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/primality_check_fermat.cpp)\n  * *Sieve* :\n      * [Sieve of Eratosthenes](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/prime_sieve.cpp)\n      * [Segmented Sieve for large primes](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/segmented_sieve_large_primes.cpp)\n      * [Counting Prime Factors](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/prime_factor_count.cpp)\n  * *Polynomial Multiplication* :\n      * [Fast Fourier Tranform](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/fast_fourier_transform_fft.cpp)\n      * [Karatsuba](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/karatsuba_polynomial_multiplication.cpp)\n  * *Misc* :\n      * [Combinatorial and Catalan - Factorial preprocessing](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/factorial_preprocessing.cpp)\n      * [Mobeius Function](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/mobeius_function.cpp)\n      * [Euler Totient Function](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/euler_phi_euler_totient_function.cpp)\n      * [Lucas Theorm - Combinatorics](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/lucas_combinatorics.cpp)  \n* **Computational Geometry** :\n  * [Convex Hull](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/convexhull.cpp)\n* **Misc** :\n  * [Sum of floor(x) with x=1:n](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/aggreate_sqrt_distinct_values.cpp)\n  * [Sum of cyclic functions *](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/aggregate_cyclic_function.cpp)\n  * [Closest larger element before/after every element](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/closest_max_element_before_after_index_using_stack.cpp)\n  * [Multiply Long Long Integers](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/multiply_longlong_integers.cpp)\n  * [Multiply Long Long Integers - Overflow detection](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/multiply_detect_overflow.cpp)\n  * [Scanline - Merge intersecting intervals](https://github.com/dragonslayerx/Competitive-Programming-Repository/blob/master/src/scanline_merge_overlapping_intervals.cpp)\n  \n  \n      \n      \n  \n  \n   \n   \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","funding_links":[],"categories":["C++"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdragonslayerx%2FCompetitive-Programming-Repository","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdragonslayerx%2FCompetitive-Programming-Repository","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdragonslayerx%2FCompetitive-Programming-Repository/lists"}