7 releases

0.1.6 May 20, 2023
0.1.5 May 18, 2023

#70 in Template engine

Download history 2/week @ 2024-03-27 2/week @ 2024-04-03

98 downloads per month

MIT license

112 lines

Template Code Generator

Generate template code for competitive programming.

Lightweight Rust based command line utility to automate the creation of problem files for competitive programming or practice. It generates problem files based on customs templates.


  • Cargo package manager should be installed on your system.
  • Make sure to have ~/.cargo/bin/ as a PATH variable.


The program expects the following command-line arguments:

tcg <name> -t <template>

Optionally provide an input output file

tcg <name> -t <template> -i <input> -o <output>
  • <name>: The name of the problem. This will be used to create a directory with the same name to store the problem files.
  • -i, --input: The input file of the problem solution. You can use % as a placeholder to be replaced with the problem name.
  • -o, --output: The output file of your problem solution. You can use % as a placeholder to be replaced with the problem name.
  • -h, --help: Print the help screen, which displays the program's usage and available options.


To generate problem files for a problem named "example" with the language extension "py", an input file named "example.in", and an output file named "example.out", you would run the following command:

tcg example -t io.py -i %.in -o %.out

This command will create a directory named "example" and generate the necessary problem files inside it.


All template files are customizable. Use %input% and %output% as placeholders for input and output files. It will search for these template files in the .config/tcg/templates directory if you are on linux. Here are some examples


with open("%input%","r") as f:
    case = f.read()

with open("%output%","w") as f:


case = input()



This program is licensed under the MIT License.


~59K SLoC