Skip to content

Instantly share code, notes, and snippets.

@anhkind
Created June 16, 2026 06:54
Show Gist options
  • Select an option

  • Save anhkind/4e80a41d6487a09bbb49ef9b6da939e3 to your computer and use it in GitHub Desktop.

Select an option

Save anhkind/4e80a41d6487a09bbb49ef9b6da939e3 to your computer and use it in GitHub Desktop.
python main template with input parsing
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")
def parse_int():
return int(input())
def parse_string():
return input()
def parse_list():
return list(map(int, input().split()))
def parse_map():
return map(int, input().split())
def solve():
"""
Write your problem-solving logic here.
"""
# Example 1: Reading a single integer N (e.g., array size)
# n = parse_int()
# Example 2: Reading space-separated variables (e.g., n, k)
# n, k = parse_map()
# Example 3: Reading a full line array of numbers
# arr = parse_list()
# Example 4: Reading a string line
# s = parse_string()
pass
def main():
# Set recursion limit higher for DFS/tree problems if needed
sys.setrecursionlimit(200000)
# Check if Codeforces specifies a single testcase or multiple
# Most Codeforces problems start with the number of testcases (t)
try:
t = parse_int()
for _ in range(t):
solve()
except (IOError, ValueError):
# Fallback if the problem has only 1 single global testcase
solve()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment