Back

Development Tool Usage Guide

Revision History

You may use development tools on your local computer for debugging and convenience when writing code.
In this case, please make sure to read this guide to avoid any disadvantages where the code does not execute or get graded due to differences between your local development environment and the grading environment (especially when using Visual Studio / Visual C++).

Grading Environment

The execution and grading of all code submitted for code submission problems take place in the following environment:

Code that does not operate in this environment will not be graded. Please keep this in mind when using development tools.

Compiler by Language

C20
c20
gcc 13.3.0 (예시 코드)
사용 가능 외부 라이브러리
(없음)
컴파일 명령어
gcc -std=gnu2x -O2 -DONLINE_JUDGE -DNYPC -Wall -Wextra -march=native -mtune=native -o main main.c -lm
실행 명령어
./main NYPC
C++20
cpp20
gcc 13.3.0 (예시 코드)
사용 가능 외부 라이브러리
컴파일 명령어
g++ -std=gnu++20 -O2 -DONLINE_JUDGE -DNYPC -Wall -Wextra -march=native -mtune=native -o main main.cpp -I/opt/boost/gcc/include -L/opt/boost/gcc/lib
실행 명령어
./main NYPC
Python3
python3
Python 3.12.3 (예시 코드)
컴파일 명령어
python3 -m py_compile main.py
실행 명령어
python3 __pycache__/main.cpython-312.pyc NYPC
Pypy3
pypy3
Python 3.9.18 (Pypy 7.3.15) (예시 코드)
사용 가능 외부 라이브러리
컴파일 명령어
pypy3 -m py_compile main.py
실행 명령어
pypy3 __pycache__/main.pypy39.pyc NYPC
Java 21
java21
openjdk 21.0.7 (예시 코드)
사용 가능 외부 라이브러리
(없음)
컴파일 명령어
javac --release 21 -encoding UTF-8 Main.java -d out && jar cfe Main.jar Main -C out .
실행 명령어
java -Xms<memory> -XmX<memory> -DONLINE_JUDGE=1 -DNYPC=1 -jar Main.jar NYPC
Rust 2024
rust2024
rustc 1.88.0 (예시 코드)
사용 가능 외부 라이브러리
컴파일 명령어
cargo rustc -r -q --frozen -- -Copt-level=3 -Ctarget-cpu=native --cfg online_judge --cfg nypc
실행 명령어
./target/release/main NYPC
Node.js
nodejs22
Node.js v22.13.1 (예시 코드)
사용 가능 외부 라이브러리
(없음)
컴파일 명령어
(컴파일하지 않음)
실행 명령어
node main.js NYPC
Typescript 5.8.3
nodets22
Typescript 5.8.3 (Node.js v22.13.1) (예시 코드)
사용 가능 외부 라이브러리
컴파일 명령어
tsc main.ts --target ESNext --moduleResolution node --module commonjs --noEmitOnError
실행 명령어
node main.js NYPC
C# 9
csharp9
dotnet 9.0.104 (예시 코드)
사용 가능 외부 라이브러리
컴파일 명령어
dotnet publish -r linux-x64 -p:PublishSingleFile=true -p:DefineConstants="ONLINE_JUDGE;NYPC" --no-restore -c Release --sc true
실행 명령어
./bin/Release/net9.0/linux-x64/publish/Main NYPC
Go
golang124
go 1.24.2 (예시 코드)
컴파일 명령어
go build -mod vendor -o main main.go
실행 명령어
./main NYPC
LuaJIT
luajit
Lua 5.1 (LuaJIT 2.1.1748459687) (예시 코드)
사용 가능 외부 라이브러리
(없음)
컴파일 명령어
luajit -O3 -b Main.lua Main.out
실행 명령어
luajit Main.out NYPC
Lua 5.4
lua
Lua 5.4.6 (예시 코드)
사용 가능 외부 라이브러리
(없음)
컴파일 명령어
luac5.4 -o Main.out Main.lua
실행 명령어
lua5.4 Main.out NYPC
Kotlin JVM 2.1
kotlinjvm
kotlinc-jvm 2.1.21 (예시 코드)
사용 가능 외부 라이브러리
(없음)
컴파일 명령어
kotlinc -include-runtime -d Main.jar Main.kt
실행 명령어
java -Xms<memory> -XmX<memory> -DONLINE_JUDGE=1 -DNYPC=1 -jar Main.jar NYPC
Kotlin/Native 2.1
kotlinnative
kotlinc-native 2.1.21 (예시 코드)
사용 가능 외부 라이브러리
(없음)
컴파일 명령어
konanc Main.kt -o Main -opt
실행 명령어
./Main.kexe NYPC
C++26
cpp-exp
gcc 15
사용 가능 외부 라이브러리
컴파일 명령어
g++-15 -std=gnu++26 -O2 -DONLINE_JUDGE -DNYPC -Wall -Wextra -march=native -mtune=native -o main main.cpp -I/opt/boost/gcc/include -L/opt/boost/gcc/lib
실행 명령어
./main NYPC
Rust 2024 Nightly
rust-exp
rustc >=1.90.0
사용 가능 외부 라이브러리
컴파일 명령어
cargo rustc -r -q --frozen -- -Copt-level=3 -Ctarget-cpu=native --cfg online_judge --cfg nypc
실행 명령어
./target/release/main NYPC

Precautions

Please be careful not to write code that only works on specific platforms (especially Windows or Visual C++), as shown in the examples below.

Prohibited ExampleRemarks
void main()Must be int main according to the standard
getch()Use getchar() instead
fflush(stdin)Use of non-standard function
GetTickCount()Windows API cannot be used
CStringCString is not standard and cannot be used. Use std::string instead
#include <stdafx.h>stdafx.h is a Visual C++ exclusive precompiled header

Java Precautions

The class name must be Main.

Using Standard Input/Output

In all code submission problems, you must receive input via standard input according to the given input format and produce output via standard output according to the given output format.
If there is a problem that requires receiving two integers and outputting their product as in the example below, the methods for handling standard input and standard output by language are as follows.

Input Example

8 4

Output Example

32

Code Examples by Language

C20
#include <stdio.h>

int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	printf("%d\n", a * b);
	return 0;
}
C++20
#include <iostream>

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
	return 0;
}
Python3
a, b = map(int, input().split())
print(a * b)
Pypy3
a, b = map(int, input().split())
print(a * b)
Java 21
import java.util.Scanner;
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(a * b);
    }
}
Rust 2024
use std::io;
fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let nums: Vec<i32> = input.trim().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    println!("{}", nums[0] * nums[1]);
}
Node.js
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const [a, b] = input.split(' ').map(Number);
console.log(a * b);
Typescript 5.8.3
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const [a, b] = input.split(' ').map(Number);
console.log(a * b);
C# 9
using System;
class Program {
    static void Main() {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        Console.WriteLine(a * b);
    }
}
Go
package main
import (
    "fmt"
)
func main() {
    var a, b int
    fmt.Scanf("%d %d", &a, &b)
    fmt.Println(a * b)
}
LuaJIT
a, b = io.read("*n", "*n")
print(a * b)
Lua 5.4
a, b = io.read("*n", "*n")
print(a * b)
Kotlin JVM 2.1
fun main() {
    val (a, b) = readLine()!!.split(" ").map { it.toInt() }
    println(a * b)
}
Kotlin/Native 2.1
fun main() {
    val (a, b) = readLine()!!.split(" ").map { it.toInt() }
    println(a * b)
}

Binary Files

In the NYPC <CODE BATTLE/> grading environment, you can submit binary files in addition to source code. The binary file is provided under the name data.bin in the directory where the source code is executed. This file is provided only during code execution and is not provided during compilation.
The following is code that outputs all bytes of data.bin to standard output.

C20
#include <stdio.h>

int main()
{
    FILE *f = fopen("data.bin", "rb");
    int byte;
    while ((byte = fgetc(f)) != EOF)
    {
        printf("%d ", byte);
    }
    fclose(f);
    printf("\n");
}
C++20
#include <fstream>
#include <iostream>

using namespace std;

int main()
{
    ifstream file("data.bin", ios::binary);

    unsigned char byte;
    while (file.read((char *)&byte, 1))
    {
        cout << (int)byte << " ";
    }
    cout << endl;

    file.close();
    return 0;
}
Python3
with open("data.bin", "rb") as f:
    bytes_read = f.read()
    for byte in bytes_read:
        print(byte, end=" ")
    print()
Pypy3
with open("data.bin", "rb") as f:
    bytes_read = f.read()
    for byte in bytes_read:
        print(byte, end=" ")
    print()
Java 21
import java.io.FileInputStream;
import java.io.IOException;

public class Main {
    public static void main(String[] args) {
        try (FileInputStream fis = new FileInputStream("data.bin")) {
            int byteRead;
            while ((byteRead = fis.read()) != -1) {
                System.out.print(byteRead + " ");
            }
            System.out.println();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
Rust 2024
use std::{fs::File, io::Read};

fn main() {
    let mut file = File::open("data.bin").unwrap();
    let mut buffer = [0u8; 1];
    while let Ok(n) = file.read(&mut buffer) {
        if n == 0 {
            break;
        }
        print!("{} ", buffer[0]);
    }
    println!();
}
Node.js
const fs = require("fs");

fs.readFile("data.bin", (_, data) => {
  data.forEach(byte => process.stdout.write(byte + " "));
  console.log();
});
Typescript 5.8.3
const fs = require("fs");

fs.readFile("data.bin", (_, data) => {
  data.forEach(byte => process.stdout.write(byte + " "));
  console.log();
});
C# 9
using System;
using System.IO;

class Program {
    static void Main() {
        using (FileStream fs = new FileStream("data.bin", FileMode.Open, FileAccess.Read)) {
            int byteRead;
            while ((byteRead = fs.ReadByte()) != -1) {
                Console.Write(byteRead + " ");
            }
            Console.WriteLine();
        }
    }
}
Go
package main

import (
"fmt"
"os"
)

func main() {
  file, _ := os.Open("data.bin")
  defer file.Close()

  buf := make([]byte, 1)
  for {
    n, _ := file.Read(buf)
    if n == 0  {
      break
    }
    fmt.Printf("%d ", buf[0])
  }
  fmt.Println()
}
LuaJIT
local file = assert(io.open("data.bin", "rb"))

while true do
  local byte = file:read(1)
  if not byte then break end
  io.write(string.byte(byte), " ")
end

file:close()
print()
Lua 5.4
local file = assert(io.open("data.bin", "rb"))

while true do
  local byte = file:read(1)
  if not byte then break end
  io.write(string.byte(byte), " ")
end

file:close()
print()
Kotlin JVM 2.1
import java.io.File

fun main() {
    val bytes = File("data.bin").readBytes()
    for (b in bytes) {
        print("${b.toInt() and 0xFF} ")
    }
    println()
}
Kotlin/Native 2.1
import kotlinx.cinterop.*
import platform.posix.*

@OptIn(ExperimentalForeignApi::class)
fun main() {
    fopen("data.bin", "rb")?.let { file ->
        while (true) {
            val b = fgetc(file)
            if (b == EOF) break
            print("$b ")
        }
        fclose(file)
    }
    println();
}

Program Exit Code

The exit code of the written program must always be 0 (normal termination). If it does not terminate with 0, the program may not be graded even if it outputs the correct answer.
In particular, even if you submit code that sets the exit code to 0, it may terminate with a non-zero code depending on whether a runtime error occurs in the written program.