Skip to content

Latest commit

History

624 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Code-Forces Solutions Repository

A personal collection of competitive programming solutions, primarily targeting Codeforces problems. The repository contains 1,000+ solution files spanning beginner to advanced difficulty levels.


Repository Structure

Code-Forces/
├── *.cpp / *.java # Root-level solutions (56 C++ files, 1 Java file)
├── CFs/ # Main archive of ~954 Codeforces solutions
│ ├── *.cpp # C++ solutions (majority)
│ ├── *.py # Python solutions
│ ├── *.java # Java solutions
│ ├── *.js # JavaScript solutions
│ ├── input.txt # Sample test input
│ └── output.txt # Sample test output
├── Others/
│ └── CPS Contests/ # Solutions from CPS-specific contest series
├── .vscode/ # VSCode editor configuration (C/C++ build & debug)
├── .cph/ # Competitive Programming Helper (CPH) cache
└── .gitignore

Languages Used

LanguageUsage
C++~99% — primary language for all competition problems
PythonOccasional alternative solutions
JavaMinimal (one practice file)
JavaScriptMinimal

Solution Categories

Problems are organized by difficulty level (A = easiest, H = hardest) and cover a wide range of algorithmic topics:

Mathematics & Number Theory

  • Prime generation (Sieve of Eratosthenes, N-th prime)
  • GCD / LCM comparisons
  • Pascal's Triangle
  • Digit manipulation
  • Modular arithmetic

Arrays & Sequences

  • Subarray sums, subset sums, pair sums
  • Difference arrays
  • Sliding window technique
  • Maximum subarray problems

Strings

  • String transformations and mappings
  • Diversity/validity checks
  • Concatenation optimization

Bit Manipulation & XOR

  • XOR on subarrays
  • Reverse XOR
  • XOR game problems

Greedy & Sorting

  • Pair selection under constraints
  • Distribution / assignment problems
  • Inversions

Dynamic Programming & Search

  • Dungeon / path-finding problems
  • Sequence reconstruction
  • Multi-dimensional DP

Common Code Pattern

Nearly every solution follows the standard competitive programming template:

#include<bits/stdc++.h>usingnamespacestd;typedeflonglong ll;
intmain() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// solution logic
}

Some solutions also use GNU Policy-Based Data Structures for ordered sets:

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>usingnamespace__gnu_pbds;typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

Build & Run

Solutions are compiled with g++ (C++17):

g++ -std=c++17 -O2 -o solution solution.cpp
./solution < input.txt

The .vscode/tasks.json provides a one-click build task inside Visual Studio Code.


Key Difficulty Breakdown (Root-Level Files)

LevelCountDescription
A18Easy — brute force / basic math
B15Medium-Easy — simple algorithms
C6Medium — intermediate techniques
D1Hard — advanced algorithms
H1Very Hard — complex problem-solving