- This template is accepted on both Codeforces and Codechef.
- For Codechef, simply remove
public final
before the class name to ensure compatibility.
- Visual Studio Code
Installation Guide - Amit Thinks - Java
Installation Guide - Amit Thinks - Git (Optional but recommended)
Installation Guide - Amit Thinks
Note : Always look for latest version available.
-
Download
.vscode
folder,Template.java
,input.txt
andoutput.txt
files from this repository.
There are two ways to do it:-
Download the files directly from repository.
Extract the files to the location where you want to keep your Java files. -
Using Git (Recommended):
- Navigate to the folder where you want to keep your Java files and open the terminal in that folder.
- Run the following commands.
git init
git clone https://github.com/Somanshu-Mahajan/java-competitive-programming-template.git
-
-
Open that folder in Visual Studio Code.
-
Open all the three files
Template.java
,input.txt
andoutput.txt
in the folder and keep selectedTemplate.java
.
-
Type your code in while loop of main function.
Example: Addtion of two numbers
-
To run the file press
Ctrl+Shift+B
. You will get a dropdown at top. Selectcompile and run
.
- No need of
Scanner
class for I/O operations. - Simply use
in.
for any input andout.
for printing. - Refer to the example shared above.