akhauriyash/Code-Regression huggingface dataset:
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
// r#","# => r#" "#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        x: usize,
    }

    if x >= 1200 {
        "ARC"
    } else {
        "ABC"
    }.to_string()
}

Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<vector>

int main() {
	int N;
	long long answer = 0;

	std::cin >> N;

	std::vector <long long> A(N);

	for (int i = 0; i < N; i++) {
		std::cin >> A[i];
		A[i] -= (1 + i);
	}

	std::sort(A.begin(), A.end());

	long long b = 0;

	b = A[N / 2];

	for (int j = 0; j < N; j++)
	{
		answer += std::abs(A[j] - b);
	}

	std::cout << answer << std::endl;

	return 0;
}

Measured memory_bytes: 1792
n, x = map(int, input().split())
l = list(map(int, input().split()))
bl = [0]*n

for i in range(len(l)):
    if i == 0:
        bl[i] = l[i]
    else:
        bl[i] = l[i] + bl[i-1]

bl = list(filter(lambda i: i<=x, bl))
print(len(bl)+1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;
const int INF=1001001001;

int main(){
  int N,M;
  cin>>N>>M;
  map<int,int>k;
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    k[a]++;k[b]++;
  }
  for(auto c:k){
    if(c.second%2!=0){cout<<"NO"<<endl;return 0;}
  }
  cout<<"YES"<<endl;
  return 0;  
}

Measured memory_bytes: 7692
#include <iostream>
using namespace std;
using ll = long long;

int N, K;
int A[100010];
ll B[100010];

ll buy(ll L) {
    ll val = 0;
    for (int i = 0; i < N; ++i) {
        if (((L ^ A[i]) | L) == L) {
            val += B[i];
        }
    }

    return val;
}

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; ++i) {
        cin >> A[i] >> B[i];
    }

    ll ans = buy(K);
    for (int b = 0; b < 30; ++b) {
        if ((K >> b) & 1) {
            ll L = (K ^ (1 << b));
            L |= (1 << b) - 1;
            ans = max(ans, buy(L));
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> pair_t;
using Graph = vector<vector<ll>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 3.1415926535897932;
const ll INF = 1 << 29;
/****** define constant end ********/

/****** define variable start ******/
ll n, m;
/******* define variable end *******/
ll solve()
{
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
    return 0;
}
int main()
{
    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */

    return (int)end_solve;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
#define PR(x) cout << (x) << "\n"
#define PS(x) cout << (x) << " "
const long long INF = numeric_limits<long long>::max();
int main() {
    ll N;
    string S;
    cin >> N >> S;

    ll count = 0;
    REP2(i, 1, N) {
        string s1 = S.substr(0, i);
        string s2 = S.substr(i, N - i);
        sort(s1.begin(), s1.end());
        sort(s2.begin(), s2.end());
        s1.erase(unique(s1.begin(), s1.end()), s1.end());
        s2.erase(unique(s2.begin(), s2.end()), s2.end());

        ll c = 0;
        REP(j, s1.size()) {
            if (s2.find(s1[j]) != std::string::npos) {
                c++;
            }
        }

        count = max(count, c);
    }

    PR(count);
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;

int N, a[10010], sum = 0;

int main(){
    cin >> N;
    for(int i = 0; i < N; ++i){
        cin >> a[i];
        while(a[i] % 2 == 0){
            a[i] /= 2;
            ++sum;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
G = [[0 for j in range(N)] for i in range(N)]


def dfs(u):
    if is_visited[u]:
        return
    is_visited[u] = 1
    for i in range(N):
        if G[u][i]:
            dfs(i)


A = []
B = []
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    A.append(a)
    B.append(b)
    G[a][b] = 1
    G[b][a] = 1

ans = 0

# print(G)
# print(A, B)
for i in range(M):
    is_visited = [0] * N
    a, b = A[i], B[i]
    G[a][b] = 0
    G[b][a] = 0
    dfs(0)
    # print(is_visited)
    if is_visited.count(1) != N:
        ans += 1
    G[a][b] = 1
    G[b][a] = 1

print(ans)



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for (ll i = a; i < b; ++i)
#define FORR(i,a,b) for (ll i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

//#define DEBUG_MODE


int main() {
	int N, M;
	cin >> N >> M;

	vector<vector<int>> conn(N+1, vector<int>(0));
	REP(i, M) {
		ll A, B;
		cin >> A >> B;
		conn[A].push_back(B);
		conn[B].push_back(A);
	}

#ifdef DEBUG_MODE
	FOR(i, 1, N+1) {
		cout << i << ": ";
		REP(j, conn[i].size()) {
			cout << conn[i][j] << " ";
		}
		cout << endl;
	}
#endif

	vector<int> ans(N+1, 0);
	queue<int> search_list;

	REP(i, conn[1].size()) {
		search_list.push(conn[1][i]);
		ans[conn[1][i]] = 1;
	}

	while (!search_list.empty()) {
		int n = search_list.front();
		search_list.pop();

		REP(i, conn[n].size()) {
			int m = conn[n][i];
			if (ans[m] != 0) continue;
			search_list.push(m);
			ans[m] = n;
		}

#ifdef DEBUG_MODE
		cout << "search for " << n << endl;
		FOR(i, 2, N+1) {
			cout << i << ": " << ans[i] << endl;
		}
#endif
	}

	cout << "Yes" << endl;
	FOR(i, 2, N+1) cout << ans[i] << endl;

	return 0;
}

Measured memory_bytes: 10108
def get(a, b, c, d, dp):
    return dp[c][d]-dp[a][d]-dp[c][b]+dp[a][b]

n, m, q = map(int, input().split())
s = [list(map(int, list(input()))) for _ in range(n)]
vers = [[0]*(m+1) for i in range(n+1)]
edges = [[0]*(m+1) for i in range(n+1)]
tate = [[0]*(m+1) for i in range(n+1)]
yoko = [[0]*(m+1) for i in range(n+1)]

for i in range(n):
    for j in range(m):
        if s[i][j] == 0:
            continue
        vers[i+1][j+1] = 1
        nx, ny = i+1, j
        if 0<=nx<n and 0<=ny<m and s[nx][ny] == 1:
            edges[i+1][j+1]+=1
            edges[i+2][j+1]+=1
            tate[i+1][j+1]+=1
        nx, ny = i, j+1
        if 0<=nx<n and 0<=ny<m and s[nx][ny] == 1:
            edges[i+1][j+1]+=1
            edges[i+1][j+2]+=1
            yoko[i+1][j+1]+=1


for i in range(1, n+1):
    for j in range(1, m+1):
            vers[i][j]+=vers[i][j-1]
            edges[i][j]+=edges[i][j-1]
            tate[i][j]+=tate[i][j-1]
for j in range(1, m+1):
    for i in range(1, n+1):
            vers[i][j]+=vers[i-1][j]
            edges[i][j]+=edges[i-1][j]
            yoko[i][j]+=yoko[i-1][j]
for _ in range(q):
    a, b, c, d = map(int, input().split())
    a-=1
    b-=1
    vcnt = get(a, b, c, d, vers)
    ecnt = get(a, b, c, d, edges)
    ecnt-=(yoko[c][b]-yoko[a][b])
    ecnt-=(tate[a][d]-tate[a][b])
    ecnt-=(yoko[c][d]-yoko[a][d])
    ecnt-=(tate[c][d]-tate[c][b])
    ecnt//=2
    print(vcnt-ecnt)


                



Measured memory_bytes: 211464
import bisect
from collections import deque
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
# mod = 10 ** 9 + 7
mod = 998244353

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]



def main():
    N, X, M = read_values()
    F = [-1] * (M + 1)

    A = X
    t = 0
    while F[A] < 0:
        F[A] = t
        A = pow(A, 2, M)
        t += 1
    
    if t == 1:
        print(X * N)
        return
    d = (N - F[A]) // (t - F[A])
    r = ((N - F[A]) % (t - F[A])) + F[A]

    K = 0
    for _ in range(F[A], t):
        K += A
        A = pow(A, 2, M)
    
    K *= d

    A = X
    for _ in range(r):
        K += A
        A = pow(A, 2, M)

    print(K)


if __name__ == "__main__":
    main()



Measured memory_bytes: 69764
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n = onem()
po = lcm(360,n)
print(po//n)



Measured memory_bytes: 68212
#include<iostream>
#include<vector>
#include<string>

// YE BEKAR CODE H MAP USE KRKE FREQ NIKAAL LE BLUE KI, RED SUBS KRDE 
using namespace std;
int main(){
	int a,b,ans=0;
	string s1[100],s2[100];
	cin>>a;
	for(int i=0;i<a;i++){
		cin>>s1[i];
	}
	cin>>b;
	for(int i=0;i<b;i++){
		cin>>s2[i];
	}
	for(int i=0;i<a;i++){
		int sum=0;
		for(int j=0;j<a;j++){
			if(s1[i]==s1[j])
				sum++;
		}
		for(int j=0;j<b;j++){
			if(s1[i]==s2[j])
				sum--;
		}
		if(sum>ans)
			ans=sum;
	}
	cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;

int main(){

    string s;
    cin >> s;

    for (int i=0; i<3; i++){
        if (s.at(i) == s.at(i + 1)){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define plll pair<pll,ll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;


int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
        
    string str;
    ll len;
    cin>>len>>str;
    ll count[len+1];
    count[0]=0;
    for(ll i=1;i<=len;i++)
    {
        count[i]=count[i-1];
        if(str[i-1]=='.')
        {
            count[i]++;
        }
    }
    ll ans=INF,store;
    for(ll i=0;i<=len;i++)
    {
        store=i-count[i];
        store+=(count[len]-count[i]);
        ans=min(ans,store);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 2196
#include <stdio.h>
int n, a, b;
int x, y, z, s;
int main(){
	scanf("%d%d%d", &n, &a, &b);
	for (int i = 0; i < n; i++) {
		scanf("%d", &s);
		if (s <= a)x++;
		else {
			if (s <= b)y++;
			else z++;
		}
	}
	if (y < x)x = y;
	if (z < x)x = z;
	printf("%d\n", x);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

inline int modul(int x) {
    if (x < 0) return -x;
    else return x;
}

int main() {
    int x, y;
    cin >> x >> y;

    int ans = 0;

    if (x == 0) {
        if (y < 0) ans = modul(y) + 1;
        else ans = y;
    }else if (y == 0) {
        if (x <= 0) ans = modul(x);
        else ans = modul(x) + 1;
    }else if (x < y) {
        ans = y - x;
        if (x < 0 && y > 0) {
            if (modul(x) < modul(y)) ans = min(ans, modul(y) - modul(x) + 1);
            else ans = min(ans, modul(x) - modul(y) + 1);
        }
    } else if (x > y) {
        if (x < 0) ans = 2 + modul(y) - modul(x);
        else if (y > 0) ans = 2 + modul(x) - modul(y);
        else if (modul(x) <= modul(y)) ans = modul(y) - modul(x) + 1;
        else ans = 1 + modul(x) - modul(y);
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string.h>

using namespace std;

int main(){
    long a;
    long b;
    long k;

    cin >> a;
    cin >> b;
    cin >> k;
    
    if(a >= k){
        a = a-k;
    }
    else if(a < k){
        if(b >= k - a) b = b- k + a;
        else b = 0;
        a = 0;
    }
    cout << a << " " << b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, c, a[404] = {}, b[404] = {};
    ll d[404][404] = {1}, p[404][404] = {};
    cin >> n >> c;
    for (int i = 0; i <= 400; i++) p[i][0] = 1;
    for (int i = 0; i <= 400; i++) for (int j = 1; j <= 400; j++) p[i][j] = p[i][j - 1] * i % mod;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) cin >> b[i];
    for (int i = 1; i <= n; i++) {
        ll e[404] = {};
        for (int j = 0; j <= c; j++) {
            for (int k = a[i]; k <= b[i]; k++) e[j] += p[k][j];
            e[j] %= mod;
        }
        for (int j = 0; j <= c; j++) {
            for (int k = 0; k <= j; k++) {
                d[i][j] = (d[i][j] + d[i - 1][j - k] * e[k]) % mod;
            }
        }
    }
    cout << d[n][c];
    /*
     2 3 5 9
     ? ? ? 9*2+5*3+3*5+2*9
     */
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n);

	std::vector<i64> pow(10, 1);
	for(int i = 1; i < 10; i++) pow[i] = pow[i - 1] * 10L;

	auto calc_head = [&](i64 n) {
		while(true) {
			if(n < 10) return n;
			n /= 10;
		}
	};

	auto calc = make_v<i64>(10, 10);
	for(int i = 1; i <= n; i++) {
		int tail = i % 10, head = calc_head(i);
		calc[head][tail] += 1;
	}

	i64 ans = 0;
	for(int i = 1; i <= n; i++) {
		int tail = i % 10, head = calc_head(i);
		ans += calc[tail][head];
	}
	
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
n = int(input())
txy = [list(map(int,input().split())) for _ in range(n)]
t = txy[0][0]
go = txy[0][1] + txy[0][2]
if t < go or t%2 != go%2:
    print("No")
    exit()
for i in range(n-1):
    t = txy[i+1][0] - txy[i][0]
    go = abs(txy[i+1][1] - txy[i][1]) + abs(txy[i+1][2] - txy[i][2])
    if t < go or t%2 != go%2:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 27160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

typedef pair<int,int> pii;
#define fi first
#define se second
#define mp make_pair

int main(){
  int n, m; cin >> n >> m;
  vector<vector<pii> > a(n, vector<pii>());
  rep(i, m){
    int p, y; cin >> p >> y; p--;
    a[p].push_back(mp(y, i));
  }

  vector<pii> b(m);
  rep(i, n){
    sort(all(a[i]));
    rep(j, a[i].size()){
      int y, num;
      tie(y, num) = a[i][j];
      b[num] = mp(i, j);
    }
  }

  rep(i, m){
    int p, yy;
    tie(p, yy) = b[i];
    printf("%06d%06d\n", p+1, yy+1);
  }

  return 0;
}


Measured memory_bytes: 7680
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main() {
  int n;
  cin >> n;
  unordered_set<int> u;
  rep(i, n){
    int a;
    cin >> a;
    u.insert(a);
  }
  cout << u.size() << endl;
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
    int n;
    cin >> n ;
    string s;
    int a=0;
    int b=0;
    int c=0;
    int d=0;
    for(int i=0;i<n;i++){
        cin >> s ;
        if(s=="AC"){
            a += 1;
        }
        else if(s=="WA"){
            b += 1;
        }
        else if(s=="TLE"){
            c += 1;
        }
        else{
            d += 1;
        }
    }
    cout << "AC x " << a <<endl;
    cout << "WA x " << b <<endl;
    cout << "TLE x " << c <<endl;
    cout << "RE x "<< d << endl;
    return 0;
}



Measured memory_bytes: 3604
fun main(args: Array<String>){
    val num = readLine()!!.toInt()
    if(num % 2 == 0) {
        val a = num / 2
        println(a*a)
    }
    else{
        val b = num / 2
        val c = b + 1
        println(b*c)
    }
}


Measured memory_bytes: 29836
#include <bits/stdc++.h>
using namespace std;

using P = pair<double, int>;

struct edge {
    int to;
    double weight;
};

constexpr double INF = 1e10;

int main() {
    int n;
    while(cin >> n, n) {
        vector<int> x(n), y(n);
        for(int i=0; i<n; ++i) {
            int b;
            cin >> b;
            b--;
            cin >> x[b] >> y[b];
        }

        vector<vector<edge>> g(n);
        for(int i=0; i<n; ++i) {
            for(int j=0; j<n; ++j) {
                if(i != j && (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) <= 2500) {
                    g[i].push_back((edge){j, sqrt(hypot(x[i]-x[j], y[i]-y[j]))});
                }
            }
        }

        int m;
        cin >> m;
        for(int i=0; i<m; ++i) {
            int s, t;
            cin >> s >> t;
            s--; t--;
            vector<double> d(n, INF), prev(n, -1);
            d[s] = 0;
            priority_queue<P, vector<P>, greater<P>> que;
            que.push(make_pair(0, s));
            while(!que.empty()) {
                P p = que.top();
                que.pop();
                int v = p.second;
                if(d[v] < p.first) {
                    continue;
                }
                for(auto& e : g[v]) {
                    if(d[e.to] > d[v] + e.weight) {
                        d[e.to] = d[v] + e.weight;
                        prev[e.to] = v;
                        que.push(make_pair(d[e.to], e.to));
                    }
                }
            }
            if(d[t] == INF) {
                cout << "NA" << endl;
            } else {
                vector<int> path = {t+1};
                while(prev[t] != -1) {
                    path.push_back(prev[t]+1);
                    t = prev[t];
                }
                for(int i=path.size()-1; i>=0; --i) {
                    cout << path[i] << " \n"[i == 0] << flush;
                }
            }
        }
    }
}


Measured memory_bytes: 3144
import 'dart:convert';
import 'dart:io';
import 'dart:async';

Future main() async {
  List nm = stdin.readLineSync().split(" ").map((x) => int.parse(x)).toList();
  Stream<String> abLines =
      stdin.transform(utf8.decoder).transform(LineSplitter()); // ここ大事（複数行入力）
  int lineNum;
  lineNum = 1;
  List ab = [];
  List abi = [];
  await for (String line in abLines) {
    lineNum = lineNum + 1;

    abi = line.split(" ").map((x) => int.parse(x)).toList();
    ab.add(abi);

    if (lineNum > nm[1]) break; // ここの場所！
  }
  // print(ab[ab.length - 1]);
  List bucket = [];
  for (int i = 0; i < nm[0]; i++) {
    bucket.add(0);
  }
  // print(ab.length);
  // for (int i = 0; i < ab.length; i++) {
  //   print(ab[i][0]);
  //   print(ab[i][1]);
  // }
  for (int i = 0; i < nm[1]; i++) {
    if ([ab[i][0]] == [ab[i][1]]) continue;
    bucket[ab[i][0] - 1]++;
    bucket[ab[i][1] - 1]++;
  }
  // print(bucket);
  for (int i = 0; i < nm[0]; i++) {
    print(bucket[i]);
  }
}


Measured memory_bytes: 13228
#!/usr/bin/env python3
import sys
#sys.setrecursionlimit(150000)


def solve(A: int, B: int):
    print(-(-(B-1)//(A-1)))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

int main(){
	string s;
	cin >> s;
	ll n = s.size();
	ll count = 0;
	vector<int> id;
	rep(i,n){
		if(s[i] == 'B') {
			count++;
			id.push_back(i);
		}
	}
	sort(id.rbegin(),id.rend());
	ll ans = 0;
	ll temp = n-1;
	rep(i,count){
		ans += ll(temp - id[i]);
		temp--;
	}
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1532
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>

int cal_1000() {
	int count = 0;
	for (int i = 1; i < 1000; i++) {
		for (int j = 1; j <= 10; j++) {
				if (i % 3 == 0) {
					count+=20;
				}
				else {
					if (j % 2 == 0) {
						count += 19;
					}
					else {
						count += 20;
					}
				}
		}
	}
	return count + 1;
}

int cal(int y, int m, int d) {
	int count = 0;
	for (int i = 1; i < y; i++) {
		for (int j = 1; j <= 10; j++) {
			if (i % 3 == 0) {
				count += 20;
			}
			else {
				if (j % 2 == 0) {
					count += 19;
				}
				else {
					count += 20;
				}
			}
		}
	}

	for (int i = 1; i < m; i++) {
		if (y % 3 == 0) {
			count += 20;
		}
		else {
			if (i % 2 == 0) {
				count += 19;
			}
			else {
				count += 20;
			}
		}
	}

	return count + d;
}

int main() {
	int n;
	int y, m, d;
	int ans[100];

	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		scanf("%d %d %d", &y, &m, &d);
		ans[i] = cal_1000() - cal(y, m, d);
	}

	for (int i = 0; i < n; i++) {
		printf("%d\n", ans[i]);
	}

	//printf("%d",cal(2,2,10));

	return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <vector>
 
using namespace std;
int main() {
    string s;
    int cnt = 0;
    cin >> s;
    for(int i = 0, j = s.size() - 1; i < s.size() / 2; i++, j--){
        if(s[i] != s[j]){
            if(s[i] == 'x' && s[j] != 'x'){
                s.insert(s.begin() + j + 1, 'x');
                cnt++;
                j++;
            }
            if(s[i] != 'x' && s[j] == 'x'){
                s.insert(s.begin() + i, 'x');
                cnt++;
                j++;
            }
            if(s[i] != 'x' && s[j] != 'x'){
                cout << "-1" << endl;
                return 0;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 640
import collections
A = list(input())
B = list(input())
A_c = collections.Counter(A)
B_c = collections.Counter(B)
A_c = A_c.values()
B_c = B_c.values()
A_c = list(A_c)
B_c = list(B_c)
A_c.sort()
B_c.sort()
if A_c == B_c:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 6960
// --------------
// Tejas Pandey  |
// 14 - 06 - 20  |
// Atcoder BC 170|
// --------------

#include <bits/stdc++.h>
using namespace std;
     
#define mod 1000000007
#define vi vector<int>
typedef long long int ll;
     
int main (void){
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int x,y;
  cin >> x >> y;
  int tur = (y - 2*x)/2;
  int cra = x - tur;
  if(cra > - 1 && tur > -1 && 2*cra + 4*tur == y) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


Measured memory_bytes: 3652
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-21 16:17:12
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template <class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '(' << p.first << ", " << p.second << ')'; }
template <class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { int flag = 0; for (auto e : vec) os << (flag++ ? ", " : "{") << e; return os << '}'; }
template <class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { int flag = 0; for (auto e : st) os << (flag++ ? ", " : "{") << e; return os << '}'; }
template <class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { int flag = 0; for (auto e : mp) os << (flag++ ? ", " : "{") << e; return os << '}'; }
template <class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { for (T& e : vec) is >> e; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

inline unsigned long long fast_gcd(unsigned long long x, unsigned long long y) {
  int shift;
  if (x == 0) return y;
  if (y == 0) return x;
  shift = __builtin_ctzll(x | y);
  x >>= __builtin_ctzll(x);
  do {
    y >>= __builtin_ctzll(y);
    if (x > y) {
      unsigned long long t = y;
      y = x;
      x = t;
    }
    y -= x;
  } while (y);
  return x << shift;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int k; cin >> k;
 
  int64 ans = 0;
 
  for (int a = 1; a <= k; ++a) {
    for (int b = 1; b <= k; ++b) {
      for (int c = 1; c <= k; ++c) {
        ans += fast_gcd(a, fast_gcd(b, c));
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int test[200001];
int main() {
	long long n = 0; string s; cin >> s;
	for (int h = 0; h < 6; h++) {
		if (s[h] == '1') {
			n++;
		}
	}
	cout << n << endl;
	cin >> n;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main()
{
    float a,b;
    while(scanf("%f %f",&a,&b)==2){
        int i;
        for(i=1;i<=10000;i++){
            if(floor(i*0.08)==a&&floor(i*0.1)==b){
                cout<<i<<'\n';
                break;
            }
        }
            if(i>10000) cout<<"-1\n";
    }
}


Measured memory_bytes: 256
main = getLine >> getContents >>= print . length . filter isPrime . map read . lines

isPrime :: Integer -> Bool
isPrime x = not $ any (\n -> (x `mod` n) == 0) (takeWhile ((sfloor x) >=) [2..])
    where sfloor :: Integer -> Integer
          sfloor x = round (sqrt (fromIntegral x :: Double))


Measured memory_bytes: 5624
N = int(input())
t, a = [int(x) for x in input().split()]
for i in range(N - 1):
    T, A = [int(x) for x in input().split()]
    t_T = t // T + (t % T != 0)
    a_A = a // A + (a % A != 0)
    b = max(t_T, a_A)
    t, a = T * b, A * b

print(t + a)


Measured memory_bytes: 2940
def euclid(diff_list):
    n = len(diff_list)
    gcd_ = gcd(diff_list[0], diff_list[1])
    for i in range(2, n):
        gcd_ = gcd(gcd_, diff_list[i])
    return gcd_
def gcd(a, b):
    a_min, a_max = min(a,b), max(a,b)
    r = 1
    while (r != 0):
        r = a_max % a_min
        a_max, a_min = a_min, r
    return a_max

n, x = map(int, input().split())
x_list = [int(i) for i in input().split()]
x_list.append(x)
x_list = sorted(x_list)
diff_list = [x_list[i+1] - x_list[i] for i in range(len(x_list)-1)]
if n > 1:
    ans = euclid(diff_list)
    print(ans)
else:
    ans = abs(x_list[0] - x_list[1])
    print(ans)

Measured memory_bytes: 14480
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=666;
ll a[N],base[N];
int n,_;
char s[N];
bool solve() {
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%lld",a+i);
	scanf("%s",s+1);
	rep(i,0,60) base[i]=0;
	bool valid=1;
	per(i,1,n+1) {
		ll x=a[i];
		if (s[i]=='1') {
			per(j,0,60) {
				if ((x&(1ll<<j))) {
                  if(base[j]==0){
                   	return 0;
                  }else{
                    x = x^base[j]; 
                  }
				}
				
			}
		} else {
			per(j,0,60) {
				if ((x&(1ll<<j))) {
                  if(base[j]==0){
					base[j]=x;
					break;
                  }else{
                   	x = x^base[j]; 
                  }
				}
              
			}
		}
	}
	return 1;
}

int main() {
	for (scanf("%d",&_);_;_--) {
		puts(solve()?"0":"1");
	}
}


Measured memory_bytes: 3740
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	scanf("%d%d",&a,&b);
	
	if (a < b)
	{
		printf("a < b\n");
	}

	if (a == b)
	{
		printf("a == b\n");
	}

	if (a > b)
	{
		printf("a > b\n");
	}

	return 0;
}

Measured memory_bytes: 580
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

vector<int> t_parent;
vi t_ord;

void tree_getorder(const vector<vi> &g, int root) {
	int n = g.size();
	t_parent.assign(n, -1);
	t_ord.clear();

	vector<int> stk; stk.push_back(root);
	while(!stk.empty()) {
		int i = stk.back(); stk.pop_back();
		t_ord.push_back(i);
		for(int j = (int)g[i].size() - 1; j >= 0; j --) {
			int c = g[i][j];
			if(t_parent[c] == -1 && c != root)
				stk.push_back(c);
			else
				t_parent[i] = c;
		}
	}
}

vector<vector<int> > g;
int K;
vector<vi> memo;
vector<int> height;
vector<vi> remh;
int rec(int i, int j, int h) {
	if(h < 0) return -INF;
	amin(h, height[i]);
	amin(h, remh[i][j]);
	if(g[i].size() == j)
		return 1;
	int c = g[i][j];
	int &r = memo[c][h];
	if(r != -1) return r;
	r = -INF;
	amax(r, rec(i, j + 1, h));
	if(h > 0) amax(r, rec(i, j, h - 1));
	//a = K - h - 1
	// <= min(h, K - (a + 1))
	int t = remh[i][j + 1];
	//K - 1 - t <= a
	rer(a, h <= t ? 0 : K - t - 1, min(h - 1, height[c]))
		amax(r, rec(c, 0, a) + rec(i, j + 1, min(h, K - (a + 1))));
	if(h > 0)
		amax(r, rec(c, 0, h - 1) + rec(i, j + 1, min(h, K - h)));
	return r;
}

int main() {
	int N;
	while(~scanf("%d%d", &N, &K)) {
		g.assign(N, vi());
		for(int i = 0; i < N - 1; ++ i) {
			int u, v;
			scanf("%d%d", &u, &v), -- u, -- v;
			g[u].push_back(v);
			g[v].push_back(u);
		}
		tree_getorder(g, 0);
		reu(i, 1, N)
			g[i].erase(find(g[i].begin(), g[i].end(), t_parent[i]));
		height.assign(N, 0);
		for(int ix = (int)t_ord.size() - 1; ix > 0; -- ix) {
			int i = t_ord[ix], p = t_parent[i];
			amax(height[p], height[i] + 1);
		}
		remh.assign(N, vi());
		rep(i, N) {
			for(int j : g[i])
				remh[i].push_back(height[j] + 1);
			remh[i].push_back(0);
			for(int j = (int)remh[i].size() - 2; j >= 0; -- j)
				amax(remh[i][j], remh[i][j + 1]);
		}
		memo.assign(N, vi(N + 1, -1));
		int ans = 0;
		rep(i, N)
			amax(ans, rec(i, 0, K));
		printf("%d\n", N - ans);
	}
	return 0;
}


Measured memory_bytes: 16384
#include <stdio.h>
int main(void){
  
  int n;
  int m;
  int a[10000];
  int i;
  int va;
  int sum=0;
  
  scanf("%d %d",&n,&m);
  for(i=0;i<m;i++){
    scanf("%d ",&a[i]);
    sum=sum+a[i];
  }
  
  va=n-sum;
  
  if(va>=0)
    printf("%d",va);
  else
    printf("%d",-1);
  
  return 0;
}
  
  

Measured memory_bytes: 1716
#include <bits/stdc++.h>

using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
#define FOR(i,j,k) for(int i=j;i<=k;i++)
#define REV(i,j,k) for(int i=j;i>=k;i--)
#define FORR(i,j,k,l) for(int i=j;i<=k;i+=l)
#define inf         freopen("in.txt", "r", stdin)
#define outf        freopen("out.txt", "w", stdout)
#define pf          printf
#define sf(n)       scanf("%d", &n)
#define sff(a,b)    scanf("%d %d", &a, &b)
#define sfff(a,b,c)    scanf("%d %d %d", &a, &b, &c)
#define clean(mat,n)   FOR(i,0,n) mat[i].clear()
#define minn          (long long)-1000000000000000000
#define maxx          (long long) 1000000000000000000
#define mod          1000000007
#define M_PI           3.14159265358979323846  /* pi */
#define LL           long long
#define NL '\n'
#define cnd tree[idx]
#define lnd (idx<<1)
#define rnd ((idx<<1)+1)
#define PB push_back
#define F first
#define S second
#define MAX 100010
#define MP make_pair
#define valid(nx,ny)  ((nx >= 0) && (nx < row) && (ny >= 0) && (ny < col))
typedef pair<int,int> PR;

LL ara[MAX], prin;

int main()
{
    ios::sync_with_stdio(false);
    //inf;
    //outf;

    LL n, x;

    cin >> n >> x;
    FOR(i,0,n-1) cin >> ara[i];
    sort(ara, ara + n);

    FOR(i,0,n-1)
    {
        x -= ara[i];
        if(x < 0) break;

        prin++;
        if(i == n-1 && x) prin--;
    }

    cout << prin << endl;

    return 0;
}



Measured memory_bytes: 256
N,a,b=map(int,input().split())
m = 10**9+7

M = pow(2, N, m)

def nCr(n,r):
    if r*2>n:
        return nCr(n,n-r)
    else:
        a = b = 1
        for i in range(r):
            a = a * (n - i) % m
            b = b * (r - i) % m
        return (a * pow(b,m-2,m)) % m
 
ans = M - 1 - nCr(N,a) - nCr(N,b)
print(ans%m)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <utility>
using namespace std;
typedef pair<int,int> D;
int P[100005];
vector<int> G[100005];
int arrived[100005];
D dd[100005];
D dfs( int v, int st, int n, int th )
{
  arrived[v]++;
  if( th > 1 ){
    int nst = dd[v].first;
    int nn = dd[v].second;
    if( st < nst ){
      n -= (nst-st)/2;
      st = nst;
    } else if( st > nst ){
      nn -= (st-nst) / 2;
    }
    if( n > nn ) n = nn;
  }
  if( P[v] >= 0 ){
    if( P[v] < st ) return D(0,0);
    if( P[v] > st + (n-1) * 2 ) return D(0,0);
    if( ( P[v] - st ) % 2 != 0 ) return D(0,0);
    st = P[v];
    n = 1;
  }
  for( int i=0; i<G[v].size(); i++ ){
    int vv = G[v][i];
    if( arrived[vv] < th ){
      D d = dfs( G[v][i], st-1, n+1, th );
      if( d.second == 0 ) return D(0,0);
      int nst = d.first - 1;
      int nn = d.second + 1;
      if( st < nst ){
        n -= (nst-st)/2;
        st = nst;
      } else if( st > nst ){
        nn -= (st-nst) / 2;
      }
      if( n > nn ) n = nn;
    }
  }
  dd[v] = D(st, n);
  return dd[v];
}
int main()
{
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  for( int i=0; i<N-1; i++ ){
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int K;
  for( int i=0; i<=N; i++ ) P[i] = -1;
  cin >> K;
  int vv;
  for( int i=0; i<K; i++ ){
    int v, p;
    cin >> v >> p;
    P[v] = p;
    if( i == 0 ) vv = v;
  }
  D d = dfs( vv, P[vv], 1, 1 );
  if( d.second == 0 ){
    cout << "No" << endl;
    return 0;
  }
  dfs( vv, P[vv], 1, 2 );
  cout << "Yes" << endl;
  for( int i=1; i<=N; i++ ){
    cout << dd[i].first << endl;
  }
}

Measured memory_bytes: 15744
import sys
input = sys.stdin.readline

class CHT: #追加される直線の傾きと最小値クエリのxが単調と仮定
    def __init__(self, N): #N:直線数
        self.deq = [0]*N
        self.l = 0
        self.r = 0
        
    def f(self, j, x): #fj(x)
        return -2*h[j]*h[x]+dp[j]+h[j]**2
        
    def check(self, j1, j2, j3): #fj2を削除して良いか判定
        a1, b1 = -2*h[j1], dp[j1]+h[j1]**2
        a2, b2 = -2*h[j2], dp[j2]+h[j2]**2
        a3, b3 = -2*h[j3], dp[j3]+h[j3]**2
        
        return (a2-a1)*(b3-b2)>=(b2-b1)*(a3-a2)
    
    def add(self, j): #直線群にfjを追加
        while self.l+1<self.r and self.check(self.deq[self.r-2], self.deq[self.r-1], j):
            self.r -= 1
        
        self.deq[self.r] = j
        self.r += 1
    
    def get(self, x): #fj(x)の最小値
        while self.l+1<self.r and self.f(self.deq[self.l], x)>=self.f(self.deq[self.l+1], x):
            self.l += 1
        
        return self.f(self.deq[self.l], x)

N, C = map(int, input().split())
h = list(map(int, input().split()))
dp = [0]*N
cht = CHT(N)
cht.add(0)

for i in range(1, N):
    dp[i] = h[i]**2+C+cht.get(i)
    cht.add(i)
    
print(dp[N-1])


Measured memory_bytes: 77260
#include <iostream>
#include <cmath>
#include <string>
using namespace std;

int main(){
  int t;
  cin >> t;
  string s;
  if(t<1200){
    s = "ABC";
  }else if(t<2800){
    s = "ARC";
  }else{
    s = "AGC";
  }

  cout << s <<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n); for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
typedef pair<int, int> P;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}


//cout<<""<<endl;
int main(){
  int X,Y,N;cin>>N>>X>>Y;X--;Y--;
  int cnt=0;
  map<int,int  > mp;
  rep(i,N-1){
   for(int j=i+1;j<N;j++){
     mp[min(j-i,abs(X-i)+1+abs(Y-j)) ]++;
   }
  }
  for(int i=1;i<N;i++){
    cout<<mp[i]<<endl;
  }
  

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

vector<ll> so;
int main() {
	ll n;
	cin>>n;
	so.push_back(2);
	ll cnt=0;
	for(int i=3;i<55555;i+=2){
		ll now=i;
		bool ans=true;
		for(int j=0;j<so.size();j++){
			if(now%so[j]==0){
				ans=false;
				break;
			}
		}
		if(ans){
			so.push_back(i);
			if(i%5==1){
			cout << i<< " ";
			cnt++;
			}
		}
		if(cnt==n){
			return 0;
		}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;


int main(){
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << (H-h)*(W-w) << endl;
    return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// for loop
#define REP(i, n) for ((i) = 0;(i) < (ll)(n);(i)++)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

int solve() {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	
	ll res;
	if (k <= a) {
		res = k;
	}
	else if (k <= a + b) {
		res = a;
	}
	else {
		res = a - (k - a - b);
	}

	cout << res << endl;

	return 0;
}

//main function
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;
}


Measured memory_bytes: 3612
#include<iostream>
using namespace std;

int main(){
	int a, b, ans;

	cin >> a >> b;
	if(a > b) ans = 2 * a - 1;
	else if(a == b) ans = 2 * a; 
	else ans = 2 * b - 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
using namespace std;
int main(){
    int n; cin>>n;
    int a=n/100;
    int ans1=a*100+a*10+a;
    int ans2=(a+1)*100+(a+1)*10+a+1;
    if(ans1>=n) cout<<ans1<<endl;
    else cout<<ans2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m,ans,l[210];
inline int read(int &xx){
	xx=0;
	int f=0;char ch=getchar();
	for(;!isdigit(ch);f|=ch=='-',ch=getchar());
	for(;isdigit(ch);xx=(xx<<1)+(xx<<3)+ch-'0',ch=getchar());
	xx=f?-xx:xx;
}
void print1(int xx){
	if(xx>=10)print1(xx/10);
	putchar(xx%10+'0'); 
}
inline void print(int xx){
	if(xx<0){
		putchar('-');
		xx=-xx;
	}
	print1(xx);
	putchar('\n');
}
int main(){
	read(n);
	for(int i=1;i<=2*n;++i)cin>>l[i];
	sort(l+1,l+2*n+1);
	for(int i=1;i<=n;++i)ans+=l[2*i-1];
	print(ans);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
d = [list(map(int, input().split())) for i in range(n)]
ans = 0
flg = False
for i in d:
    if i[0] == i[1]:
        ans += 1
    else:
        ans = 0
    if ans >= 3:
        flg = True
if flg:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long k, a, b, m;
	scanf("%lld %lld %lld", &k, &a, &b);
	if(b - 1 <= a)
		printf("%lld\n", 1 + k);
	else{
		m = 0;
		if(k <= a){
			m = k + 1;
		}
		else{
			m = b;
			k -= (a + 1);
		
			if(k){
				m = (k + 2) / 2 * b - ((k + 2) / 2 - 1) * a;
				if(k % 2)
					m++;
			}
		}
		printf("%lld\n", m);
	}
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
h = [int(i) for i in input().split()]
h[0] -= 1
if len(h) == 1:
    print('Yes')
else:
    for i in range(1, n):
        if h[i] > h[i - 1]:
            h[i] -= 1
        elif h[i] < h[i - 1]:
            print('No')
            exit()
    print('Yes')


Measured memory_bytes: 14252
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long 
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
const ll mod=998244353;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> data_struct;

vector<ll> gr[200010];
ll h[200010],c=0;


int main()
{
	ll n,m;
	cin>>n>>m;
	for(ll i=0;i<n;i++)
		cin>>h[i];
	ll x,y,f=0;
	map<pair<ll,ll>,ll> mp;
	for(ll i=0;i<m;i++)
	{
		cin>>x>>y;
		x--;
		y--;
		// if(mp[{x,y}] || mp[{y,x}])
		// 	continue;
		gr[x].push_back(y);
		gr[y].push_back(x);
		mp[{x,y}]=1;
	}
	for(ll i=0;i<n;i++)
	{
		f=0;
		for(ll j:gr[i])
			if(h[j]>=h[i])
			{
				f=-1;
				break;
			}
		if(f==0 || gr[i].size()==0)
		{
			// cout<<i;
			c++;
		}
	}
	cout<<c;
}

Measured memory_bytes: 18772
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1){r=(r*a)%m;}
        b=b>>1;
        a=(a*a)%m;
    }
    return r%m;
}
int main(){
    ll a,b,c; cin>>a>>b>>c;
    if(a+b+c>=22)cout<<"bust\n";
    else cout<<"win\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

int main(void) {

	ll  M, N;
	ll sum = 0;

	cin >> N >> M;
	vector<int> A(M);
	rep(i, M) {
		cin >> A[i];
		sum += A[i];
	}

	cout << (sum <= N ? N - sum : -1) << endl;

	return 0;
}

Measured memory_bytes: 3636