Saves sample test cases from Competitive Companion directly into input.txt.
How It Works
- Make sure you have the Competitive Companion browser extension installed.
- Open your code file or folder in VS Code.
- Click the Competitive Companion button on any problem page (Codeforces, AtCoder, CSES, LeetCode, etc.).
- The test case inputs are automatically written to
input.txt next to your active file.
Features
- Saves where you work: Writes
input.txt in the folder of your currently active file (or workspace root).
- Run code with Ctrl+Enter: Press
Ctrl+Enter (Cmd+Enter on macOS) to instantly compile and run your code with input fed directly from input.txt in the terminal.
- Terminal Colors & ANSI Styling: Highlights
--- INPUT --- in Bold Cyan, --- EXPECTED OUTPUT --- in Deep Blue, and --- YOUR OUTPUT --- in Bold Green.
- Automated Verdict & Diffing: Automatically matches your output with
output.txt (ignoring trailing whitespace) and displays ✔ [Verdict: ACCEPTED] in green or ✗ [Verdict: WRONG ANSWER] in red with the exact mismatched line!
- Execution Time Measurement: Measures and prints program execution duration in milliseconds along with exit code status.
- Multi-language support: Built-in support for C++, C, Python, Java, Rust, Go, JavaScript, TypeScript, and Kotlin, with customizable commands.
- Flexible format: Combine all sample test cases or save only the first test case.
- Automatic expected output: Saves sample outputs into
output.txt by default.
- Status bar & menu: Click the status bar item to run code, toggle the listener, open/clear
input.txt or output.txt.
When working on a problem, press Ctrl+Enter (Cmd+Enter on macOS) inside your code file (or while editing input.txt / output.txt):
- Automatically saves any unsaved changes in your solution,
input.txt, and output.txt.
- Compiles (if necessary) and runs the code in a dedicated terminal (
CP Input TXT).
- Formats the terminal output with clear ANSI sections, timing, and automated verdict:
--- INPUT ---
4 6
10 1
-------------
--- EXPECTED OUTPUT ---
2
9
-----------------------
--- YOUR OUTPUT ---
2
9
-------------------
✔ [Verdict: ACCEPTED] (Finished in 3.4ms)
If the output differs:
✗ [Verdict: WRONG ANSWER] (Finished in 3.2ms)
Line 2 mismatched:
Expected: 9
Your output: 10
Supported Placeholders in Commands
You can customize run commands for any language in settings using these placeholders:
${file}: Full path to the active code file
${fileBasename}: File name with extension (e.g. solution.cpp)
${fileBasenameNoExtension}: File name without extension (e.g. solution)
${fileDirname}: Directory containing the file
${fileExtname}: File extension (e.g. .cpp)
${inputFile}: Full path to the input file
${inputFileName}: Name of the input file (e.g. input.txt)
${outputFile}: Full path to the expected output file
${outputFileName}: Name of the expected output file (e.g. output.txt)
Settings
| Setting |
Default |
Description |
cpInputTxt.runOnCtrlEnter |
true |
Run code with input.txt in the terminal when pressing Ctrl+Enter |
cpInputTxt.showInputAndExpectedOutput |
true |
Display --- INPUT --- and --- EXPECTED OUTPUT --- sections before code output in the terminal |
cpInputTxt.checkVerdict |
true |
Compare code output against expected output, report verdict (ACCEPTED / WRONG ANSWER / RUNTIME ERROR), highlight mismatches, and measure execution time |
cpInputTxt.saveExpectedOutput |
true |
Save sample testcase outputs to output.txt |
cpInputTxt.runCommands |
(built-in defaults) |
Custom compile and run command templates per language ID (cpp, python, java, etc.) |
cpInputTxt.customRunCommand |
"" |
Global custom command override for all languages |
cpInputTxt.saveBeforeRun |
true |
Automatically save files before running |
cpInputTxt.clearTerminalBeforeRun |
false |
Clear the terminal before executing run commands |
cpInputTxt.port |
10045 |
Port to receive data from Competitive Companion |
cpInputTxt.fileName |
input.txt |
Target file name for inputs |
cpInputTxt.saveLocation |
activeFolder |
Where to save (activeFolder or workspaceRoot) |
cpInputTxt.testCaseFormat |
all |
Save all test cases (all) or first only (first) |
cpInputTxt.openOnSave |
false |
Automatically open input.txt after receiving test cases |
cpInputTxt.outputFileName |
output.txt |
Target file name for expected outputs |
License
This project is licensed under the MIT License.
| |