My C++ practice solutions for Codeforces problems, along with a reusable contest template. Each solution is a standalone program with its own main() function.
Problem links come from the local Competitive Programming Helper records. This is a practice archive; inclusion does not indicate a verified accepted submission.
Use a GNU C++ compiler with C++17 support. The programs use the GCC header <bits/stdc++.h>.
Windows PowerShell, from this repository:
g++ -std=c++17 -O2 -Wall -Wextra A_Halloumi_Boxes.cpp -o solution.exe
.\solution.exeEnter the problem's input after starting the program. To use a local input file:
Get-Content .\input.txt | .\solution.exeLinux or macOS with GCC installed as g++:
g++ -std=c++17 -O2 -Wall -Wextra A_Halloumi_Boxes.cpp -o solution.out
./solution.out < input.txtCompile one solution at a time. Compiling all files together would produce multiple definitions of main().
Copy Template.cpp when starting a new problem. Implement solve() and adjust whether main() reads a test-case count to match the problem's input format.
The .gitignore keeps compiled executables, build output, editor settings, CPH records, Test.cpp, and local input.txt / output.txt files out of Git. These files can still be used locally.
From this repository's folder:
git status
git add Your_New_Solution.cpp
git diff --cached
git commit -m "Add solution for problem name"
git pushgit statusshows new, modified, and staged files.git addstages the file's current contents for the next commit. Run it again if you edit the file afterward.git diff --cachedlets you review the staged changes.git commitrecords a snapshot in local history.git pushuploads local commits to the configured GitHub branch.
Use git add . to stage all non-ignored changes in the current directory after reviewing git status.