akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;

int main(){
    vector<int> a(3);
    rep(i,3) cin >> a[i];
    int count = 0;

    while(true){
        if(a[0] == a[1] && a[1] == a[2])break;
        sort(a.begin(),a.end());
        if(a[2] - a[0] >= 2) a[0] += 2;
        else{
            a[0]++;
            a[1]++;
        }
        count++;
        if(a[0] == a[1] && a[1] == a[2])break;
    }
    print(count);
}

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

using namespace std;

using ll = long long;

int main() {
    int n;
    cin >> n;

    set<string> kuji;
    string s;

    for (int i = 0; i < n; i++) {
        cin >> s;
        kuji.insert(s);
    }

    cout << kuji.size() << endl;

    return 0;
}

Measured memory_bytes: 19180
#include<stdio.h>
int main()
{
  int N,a,b,c;
  scanf("%d",&N);
  if(100<=N<=999)
  {
     a=N/100;
	 b=(N-a*100)/10;
	 c=N-a*100-b*10;
	 if(a==c)
	 {
	   printf("Yes\n");
	 }
	 else
	 {
	   printf("No\n");
	 }
  }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll n;

int main(){
    cin >> n;
    if(n==0){
        cout << 0 << endl;
        return 0;
    }
    if(n%2==1){
        cout << 0 << endl;
        return 0;
    }
    ll count=0;
    ll memo=10;
    while(n>=memo){
        count+=n/memo;
        memo*=5;
    }
    cout << count << endl;
    return 0;
}  


Measured memory_bytes: 3640
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    cout<<n/3<<endl;
    return 0;  
    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n+1);
  for(ll i=0;i<n+1;i++) cin >> a.at(i);
  vector<ll> b(n);
  for(ll i=0;i<n;i++) cin >> b.at(i);
  
  ll ans=0;
  
  for(ll i=0;i<n;i++){
    if(a.at(i)>b.at(i)){
      ans+=b.at(i);
    }
    else if(a.at(i)+a.at(i+1)>b.at(i)){
      ans+=b.at(i);
      a.at(i+1)+=a.at(i);
      a.at(i+1)-=b.at(i);
    }
    else{
      ans+=a.at(i)+a.at(i+1);
      a.at(i+1)=0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

LL change_div_mul_mod(LL divisor, LL mod_minus_2, LL mod){
    if(mod_minus_2 == 0) return 1;
    else if(mod_minus_2 % 2 == 0){
        LL d = change_div_mul_mod(divisor, mod_minus_2/2, mod);
        return (d * d) % mod;
    }else{
        return (divisor * change_div_mul_mod(divisor, mod_minus_2-1, mod)) % mod;
    }
}

//#define int long long

/*************** using variables ***************/
int n;
vector<LL> a;
vector<LL> ruiseki;
/**********************************************/

signed main(){
    cin >> n;
    a.resize(n); ruiseki.resize(n);

    REP(i, n) cin >> a[i];

    VSORT(a);
    
    ruiseki[0] = a[0];
    int cnt = 0;
    FOR(i, 1, n){
        ruiseki[i] = ruiseki[i-1] + a[i];
    }
    
    REP(i, n-1){
        if(ruiseki[i]*2 < a[i+1]) cnt = i+1;
    }
    cout << n - cnt << endl;
}


Measured memory_bytes: 1792
import sys
from collections import defaultdict, deque, Counter
import math

# import copy
from bisect import bisect_left, bisect_right
import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD


def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD


def kaijyo(n):
    ret = [1]
    for i in range(1, n + 1):
        ret.append((ret[-1] * i)% MOD)
    return ret


def solve():
    n = getN()

    if n < 1200:
        print("ABC")
        return
    if n < 2800:
        print("ARC")
        return
    print("AGC")
    return


def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()

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

using namespace std;

typedef long long ll;

int max_N = 10005;
int N;
vector<vector<int>> g(max_N, vector<int>());
vector<ll> v;

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

	cin >> N;

	rep(i, N-1){
		int a, b;
		cin >> a >> b;
		a--;
		b--;

		g[a].push_back(b);
		g[b].push_back(a);
	}

	v.resize(N);
	rep(i, N){
		cin >> v[i];
	}

	sort(v.begin(), v.end(), greater<ll>());


	vector<ll> score(N, -1);
	score[0] = v[0];

	queue<int> q1;
	for(int x : g[0]){
		q1.push(x);
	}

	int cnt = 0;
	ll ans = 0;

	while(!q1.empty()){

		int p = q1.front();
		// cout << "begin:" << p << endl;
		q1.pop();

		if(score[p] == -1){
			// cout << "update:" << cnt+1 << "," << p << endl;
			cnt++;
			score[p] = v[cnt];
			ans += v[cnt];
			for(int y : g[p]){
				if(score[y] == -1){
					// cout <<"pushed:" << y << endl;
					q1.push(y);
				}
			}
		}
	}

	cout << ans << endl;
	cout << score[0];
	rep(i, N-1){
		cout << " " << score[i+1];
	}
	cout << endl;

}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
ll f(ll n){
    return (n*n + 4) / 8;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll w,a,b;
    cin >> w >> a >> b;
    if(a <= b){
        print(max(0LL, b - (a+w)));
    }else{
        print(max(0LL, a - (b+w)));
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n; cin>>n;
    int k,i,j; cin>>k;
    map<int,int> m;
    for(i=0;i<k;i++)
    {
        int x; cin>>x;
        for(j=0;j<x;j++){
            int c; cin>>c;
            m[c]++;
        }
    }
    int l=0;
    for(i=1;i<=n;i++)
    {
        if(m[i]==0) l++;
    }
    cout<<l<<endl;
    return 0;
}

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

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int ans[550][550];

int main() {
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	if (H % h == 0 && W % w == 0) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	ans[0][0] = INF-1;
	ans[h-1][w-1] = -INF;
	rep(i, H) rep(j, W) cout << ans[i%h][j%w] << " \n"[j+1 == W];
	return 0;
}

Measured memory_bytes: 2944
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int main() {
	int h, w;
	while(cin >> w >> h, h) {
		vs field(h);
		REP(i, h) {
			cin >> field[i];
		}
		int fb = 0, fw = 0;
		REP(i, h) {
			REP(j, w) {
				if(field[i][j] == 'B') {
					fb++;
				}
				if(field[i][j] == 'W') {
					fw++;
				}
			}
		}
		REP(i, h) {
			REP(j, w) {
				if(field[i][j] == '.') {
					stack<pii> S;
					S.push(make_pair(i, j));
					vvi visited(h, vi(w, 0));
					bool black = false, white = false;
					while(!S.empty()) {
						pii p = S.top();
						S.pop();
						if(visited[p.first][p.second]) {
							continue;
						}
						visited[p.first][p.second] = 1;
						REP(d, 4) {
							int ny = p.first + dy[d];
							int nx = p.second + dx[d];
							if(ny<0 || h<=ny || nx<0 || w<=nx) {
								continue;
							} else if(field[ny][nx] == 'B') {
								black = true;							
							} else if(field[ny][nx] == 'W') {
								white = true;
							} else {
								S.push(make_pair(ny, nx));
							}
						}
					}
					if(black & white) {
						continue;
					} else if(black) {
						REP(i, h) {
							REP(j, w) {
								if(visited[i][j]) {
									field[i][j] = 'B';
								}
							}
						}
					} else if(white) {
						REP(i, h) {
							REP(j, w) {
								if(visited[i][j]) {
									field[i][j] = 'W';
								}
							}
						}
					}
				}
			}
		}
		int black = 0, white = 0;
		REP(i, h) {
			REP(j, w) {
				if(field[i][j] == 'B') {
					black++;
				}
				if(field[i][j] == 'W') {
					white++;
				}
			}
		}

		cout << black-fb << " " << white-fw << endl;
	}

	return 0;
}

Measured memory_bytes: 1300
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
X = list(map(int, sys.stdin.readline().split()))


def factorial(x):
    ret = 1
    for i in range(2, x + 1):
        ret *= i
        ret %= MOD
    return ret


# 前から1刻みに置ければ、そこまでにいる人は1位になれる
# 前にいる人の数
forwards = 0
# 今ゴールしたら何位になるか
rank = 0
ans = 1
for x in X:
    if x <= forwards * 2:
        # 1 人ゴールさせる
        ans *= forwards + 1
        ans %= MOD
        rank += 1
        continue
    forwards += 1
ans *= factorial(forwards)
print(ans % MOD)


Measured memory_bytes: 24396
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M;
    cin >> N >> M;
    ll A[2010], B[2010];
    vector<ll> tree[1010], tree_inv[1010];
    rep(i,0,M){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
        tree[A[i]].push_back(B[i]);
        tree_inv[B[i]].push_back(A[i]);
    }
    ll ans = INF, idx = -1, last_pos = -1;

    rep(i,0,N){
        queue<lpair> que;
        que.push({i, 0});
        bool visit[1010] = {};
        bool ok = false;
        while(not que.empty()){
            lpair l1 = que.front();
            que.pop();
            if(visit[l1.first]) continue;
            visit[l1.first] = true;
            for(auto &e: tree[l1.first]){
                if(not visit[e]){
                    que.push({e, l1.second+1});
                }else{
                    if(e == i){
                        if(ans > l1.second+1){
                            ans = l1.second+1;
                            idx = i;
                            last_pos = l1.first;
                        }
                        ok = true;
                        break;
                    }
                }
            }
            if(ok) break;
        }
    }

    if(idx == -1){
        print(-1);
        return 0;
    }

    ll dist[1010] = {};
    rep(i,0,N) dist[i] = INF;
    bool visit[1010] = {};
    queue<lpair> que;
    bool ok = false;
    que.push({idx, 0});
    while(not que.empty()){
        lpair l1 = que.front();
        que.pop();
        if(visit[l1.first]) continue;
        visit[l1.first] = true;
        dist[l1.first] = l1.second;
        for(auto &e: tree[l1.first]){
            if(not visit[e]){
                que.push({e, l1.second+1});
            }else{
                if(e == idx){
                    ok = true;
                    break;
                }
            }
        }
        if(ok) break;
    }

    ll pos = last_pos;
    vector<ll> res;
    while(1){
        res.push_back(pos);
        if(pos == idx) break;
        for(auto &e: tree_inv[pos]){
            if(dist[pos] == dist[e]+1){
                pos = e;
                break;
            }
        }
    }
    sort(res.begin(), res.end());
    print(res.size());
    for(auto &e: res) print(e+1);
}

Measured memory_bytes: 384
n,x=map(int,input().split())
a=1
b=1
sou=[a] #各バーガーの層の数
patty=[b] #各バーガーのパティの数
for i in range(49):
    a=(3+2*a)
    b=(1+2*b)
    sou.append(a)
    patty.append(b)
zan=x
total=0 #xまでに含まれるパティの数
ok=0
def check(num): #レベルiバーガーで調べる。
    global zan,total,ok
    if ok==1:
        return
    for i in range(5):
        if i==0 or i==4:
            zan-=1
        elif i==2:
            zan-=1
            total+=1
        else:
            zan-=sou[num-1]
            total+=patty[num-1]
        if zan==0:
            ok=1
            return
        elif zan<0:
            total-=patty[num-1]
            zan+=sou[num-1]
            #print(str(num-1)+" "+str(zan))
            check(num-1)
            if ok==1:
                break
check(n)
print(total)

Measured memory_bytes: 38404
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
string a;
string b; 
inline void read(int &x)
{
	int f=1;char c;
	for(x=0,c=getchar();c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48); x*=f;
}
inline int mx(int _x,int _y)
{
	return _x>_y?_x:_y;
}
inline int mn(int _x,int _y)
{
	return _x<_y?_x:_y;
}
inline int ab(int _x)
{
	return _x<0?-_x:_x;
}
int main()
{
	cin>>a;
	cin>>b;
	if(b.size()-a.size()!=1) 
	{
		puts("No");	
	}
	for(int i=0;i<a.size();i++)
		if(a[i]!=b[i])
		{
			puts("No");
			return 0;
		}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int N,M;
const int mod = 1000000;
int main(){
	cin >> N >> M;
	if(M == 1){
        int result = 1;
		for(int i = 0; i < N; i++)result = (result * 2) % mod;
        cout << result << endl;
	}else{
		int memoA[110], memoB[110], memoC[110], memoD[110], memoE[110];
		memoA[0] = 1;//一番上
		memoB[0] = 0;//真ん中
		memoC[0] = 0;//一番下
		memoD[0] = 0;//一番下(くねくね中、くねくね後)
		memoE[0] = 0;//一番上(くねくね中、くねくね後)
		for(int i = 0; i < N-1; i++){
			memoA[i+1] = (memoA[i] + memoB[i] + memoC[i] + memoE[i])%mod;
			memoB[i+1] = (memoA[i] + memoB[i] + memoC[i])%mod;
			memoC[i+1] = (memoA[i] + memoB[i] + memoC[i] + memoD[i])%mod;
			memoD[i+1] = (memoA[i] + memoD[i])%mod;
			memoE[i+1] = (memoC[i] + memoE[i])%mod;
		}
		//n-1からnを導出
		int result = (4 * memoA[N-1] + 3 * memoB[N-1] + 3 * memoC[N-1] + 2 * memoD[N-1] + memoE[N-1])%mod;
		cout << result << endl;
	}
}




Measured memory_bytes: 3128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  int n,x;
  cin >> n >> x;
  int m[n];
  int i;
  for(i = 0;i < n;++i){
    cin >> m[i];
  }
  for(i = 0;i < n;++i){
    x -= m[i];
  }
  int min = m[0];
  for(i = 1;i < n;++i){
    if(min > m[i]){
      min = m[i];
    }
  }
  cout << n + x/min << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
in ab(in a){
  return a<0?-a:a;
}
void r(in a){
  cout<<a<<endl;
  exit(0);
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in x,y;
  cin>>x>>y;
  in tx=ab(x);
  in ty=ab(y);
  if(tx==ty){
    if(x*y<0)
      r(1);
    r(0);
  }
  if(tx<ty){
    in c=0;
    if(x<0)
      ++c;
    c+=ty-tx;
    if(y<0)
      ++c;
    r(c);
  }
  in c=0;
  if(x>0)
    ++c;
  c+=tx-ty;
  if(y>0)
    ++c;
  r(c);
  return 0;
}


Measured memory_bytes: 256
/*
    Those who cannot remember the past are condemned to repeat it.
                                            - Dynamic Programming
    
    I never lose, I either win or I learn.
                - Competitive Programming

*/

import javax.print.DocFlavor;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        PrintWriter pw = new PrintWriter(System.out);

        st = new StringTokenizer(br.readLine());
        int h = Integer.parseInt(st.nextToken());
        int n = Integer.parseInt(st.nextToken());
        Spell[] s = new Spell[n];
        for(int i=0 ; i<n ; i++) {
            st = new StringTokenizer(br.readLine());
            int u = Integer.parseInt(st.nextToken());
            int v = Integer.parseInt(st.nextToken());
            s[i] = new Spell(u, v);
        }

        int[] dp = new int[h+1];
        for(int i=1 ; i<=h ; i++) dp[i] = (int)1e9+5;


        for(int i=1 ; i<=h ; i++) {
            for(int j=0 ; j<n ; j++) {
                if(i-s[j].x >= 0) {
                    dp[i] = Math.min(dp[i], dp[i-s[j].x] + s[j].y);
                }
                else {
                    dp[i] = Math.min(dp[i], s[j].y);
                }
            }
        }

        pw.println(dp[h]);


        
        
        
        
        
        
        
        pw.flush();
        pw.close();
    }
}

class Spell {
    int x;
    int y;
    Spell(int u, int v) {
        x = u;
        y = v;
    }
}


Measured memory_bytes: 23252
N = int(input())
xy = [[]] * N
for i in range(N):
  A = int(input())
  xy[i] = [list(map(int, input().split())) for j in range(A)]
# print(xy)

def check(a):
  for i in range(N):
    if a[i] == 0:
      continue
    for x, y in xy[i]:
      if a[x-1] != y:
        return -1
  return a.count(1)

r = 0
for i in range(2**N):
  bstr = format(i, '0%db' % N)
  a = tuple(map(int, bstr))
  # print(a)
  t = check(a)
  if t > r:
    r = t 
print(r)


Measured memory_bytes: 3316
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tp3 = tuple<int, int, int>;
using Mat = vector<vector<ll>>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
// ============ template finished ============

int main()
{
    int S, W;
    cin >> S >> W;
    cout << (W >= S ? "unsafe" : "safe") << endl;
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
//#defint mod 1e18
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii unordered_map<int,int>
#define mll unordered_map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi  first

#define se second
#define pb push_back
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}
ll dp[3005][3005];

int main(){
	boost;
	int n;
	cin>>n;
	ll arr[n];
	
	for(int i = 0;i<n;i++){
		cin>>arr[i];
	}
	
	for(int i = n-1;i>=0;i--){
		for(int j = i;j<n;j++){
			if(i==j){
				dp[i][j] = arr[i];
			}else{
				dp[i][j] = max(arr[i] - dp[i+1][j],arr[j] - dp[i][j-1]);
			}
		}
	}
	
	cout<<dp[0][n-1];
	
	return 0;
}

//Total solved problems:- 13



Measured memory_bytes: 70016
import sys


class Node():

	def __init__(self,id,left,right):
		
		self.id = id
		self.left = left
		self.right = right
		self.parent = -1
		self.sibling = -1
		self.degree = 0
		self.depth = 0
		self.height = 0

def define_depth(Nodes,node):

	if node.left == -1 and node.right == -1: #leaf
		return

	if node.left != -1:
		Nodes[node.left].depth = node.depth + 1
		define_depth(Nodes,Nodes[node.left])
	if node.right != -1:
		Nodes[node.right].depth = node.depth + 1
		define_depth(Nodes,Nodes[node.right])

def define_height(Nodes,node):

	h1 = 0
	h2 = 0

	if node.left != -1:
		h1 += define_height(Nodes,Nodes[node.left]) + 1
	if node.right != -1:
		h2 += define_height(Nodes,Nodes[node.right]) + 1

	return max(h1,h2)

def find_root(Nodes,node):

	if node.parent == -1:
		return node.id

	return find_root(Nodes,Nodes[node.parent])


def test():

	n = int(sys.stdin.readline())
	Nodes = [Node(0,0,0)] * n
	root = 0

	# Reading inputs
	for i in range(n):

		inputs = list(map(int,sys.stdin.readline().split()))
		id = inputs[0]
		left = inputs[1]
		right = inputs[2]

		tmp_node = Node(id,left,right)
		Nodes[id] = tmp_node

	# Defining parent and sibling and root
	for node in Nodes:

		child_count = 0

		# Parent
		if node.right != -1:
			Nodes[node.right].parent = node.id
			child_count += 1
		if node.left != -1:
			Nodes[node.left].parent = node.id
			child_count += 1

		# Degree
		node.degree = child_count

		#Sibling
		if node.right != -1 and node.left != -1:
			Nodes[node.right].sibling = node.left
			Nodes[node.left].sibling = node.right

	# Finding root
	root = find_root(Nodes,Nodes[0])

	# Defining depth
	define_depth(Nodes,Nodes[root])

	# Defining height
	for node in Nodes:
		node.height = define_height(Nodes,node)

	for i in range(n):

		print(f"node {Nodes[i].id}: ",end='')
		print(f"parent = {Nodes[i].parent}, ",end='')
		print(f"sibling = {Nodes[i].sibling}, ",end='')
		print(f"degree = {Nodes[i].degree}, ",end='')
		print(f"depth = {Nodes[i].depth}, ",end='')
		print(f"height = {Nodes[i].height}, ",end='')

		if Nodes[i].parent == -1:
			print(f"root")
		elif Nodes[i].left == -1 and Nodes[i].right == -1:
			print(f"leaf")
		else:
			print(f"internal node")



if __name__ == "__main__":
	test()


Measured memory_bytes: 5656
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (ll i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL) 
const int mod = 1e9 + 7, mxn = 1e5 + 1;

int solve(){
    ll x, k, d;
    cin>> x>> k>> d;
    x = abs(x);
    ll tmp = x/d;
    tmp = min(k, tmp);
    x -= tmp*d;
    k -= tmp;
    if(k%2)
        x -= d;
    x = abs(x);
    cout<< x<< "\n";
    return 0;
}
//Counting problems: Sometimes easier to find complement of the answer
 
int main()
{
    fast;
    int t = 1;
    //cin>> t;
    while(t--){  
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);
 
/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/
        
// lower bound   >=  
// upper bound   >
// vector<int>().swap(vec); //free memory from vec


Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <sstream>

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define C(x) cout << x << endl //テスト出力

//関数
//nCkの計算の関数(呼び出しは[cbn])
ll cbn(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}
// a^n mod を計算する
ll powmod(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}
//２つの最大公約数
int gcb(int a, int b){
    if(a < b){
        int x = a;
        a = b;
        b = x;
    }
    int amari = a % b;
    if(amari == 0) return b;

    return gcb(b, amari);
}
//３つの最大公約数
int gcb_3(int a, int b, int c){
    return gcb(gcb(a, b), c);
}

/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;
vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))*/

/*-----------------------------ここから-----------------------------*/

int main() {
cin.tie(0);
ios::sync_with_stdio(false);
string n; cin>>n;
if(n[n.size()-1]=='s') cout<<n+"es";
else cout<<n+'s';
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<long long> a(n, 0);
    vector<long long> b(n, 0);
    
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i)
    {
        cin >> b[i];
    }
    
    long long numa = 0;
    long long numb = 0;
    
    bool flag = 0;
    
    for (int i = 0; i < n; ++i)
    {
        if (a[i] < b[i])
        {
            if ((b[i] - a[i]) % 2 == 0)
            {
                numb += (b[i] - a[i]);
            }
            else
            {
                numb += (b[i] - a[i] - 1);
            }
        }
        else if (a[i] > b[i])
        {
            numa += ((long long)2 * (a[i] - b[i]));
        }
        
    }
    
    if (numb < numa)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 384
//AnkitCode99 here....
#include<bits/stdc++.h>
#define endl "\n"
typedef long long int ll;
#define MOD 1000000007
#define mp make_pair
#define pll pair<ll,ll>
#define pb push_back
//max xor btw range of two numbers..
#define max_XOR(a,b) (1 << int(log2(a ^ b) + 1)) - 1
#define vl vector<ll>
#define inf ll(1e18)
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define nrep(i,a,b) for(long long int i=a;i>=b;i--)
#define ceil(a,b) a/b+((a%b ==0 )?0:1)
using namespace std;

const ll sz=100005;
const ll szz=1000006;

int main()
{
	fast;
    
	ll n,k;
	cin>>n>>k;
	ll ar[n];
	rep(i,0,n)
	{
		cin>>ar[i];
	}
	sort(ar,ar+n);
	ll i=n-1;
	ll sum=0;
	while(i>=0)
	{
		if(k>0)
		{
			k--;
		}
		else
		{
			sum+=ar[i];
		}
		i--;
	}
	cout<<sum<<endl;
}
//Goodbye...

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main() {
	int i, j,ans;
	for (i = 1; i <= 9; i++) {
		for (j = 1; j <= 9; j++) {
			ans = j*i;
			cout << i << "x" << j << "=" << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2996
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

type Data struct {
	a int
	b int
}

// Datas :
type Datas []Data

func (p Datas) Len() int {
	return len(p)
}

func (p Datas) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Datas) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}

func main() {
	sc.Split(bufio.ScanWords)
	h := getInt()
	w := getInt()
	n := getInt()
	P := make(Datas, n*10)
	for i := 0; i < n; i++ {
		P[i].b = getInt() - 1
		P[i].a = getInt() - 1
	}

	x := [8]int{-1, 0, 1, -1, 1, -1, 0, 1}
	y := [8]int{-1, -1, -1, 0, 0, 1, 1, 1}
	idx := n
	for i := 0; i < n; i++ {
		for j := 0; j < 8; j++ {
			px := P[i].a + x[j]
			py := P[i].b + y[j]
			if (px < w) && (px >= 0) && (py < h) && (py >= 0) {
				P[idx].a = px
				P[idx].b = py
				idx++
			}
		}
	}
	P = P[:idx]

	sort.Sort(P)
	//out(P)
	ans := make([]int, 10)

	xx := -1
	yy := -1
	cnt := 0
	for i := 0; i < len(P); {
		if (P[i].a == 0) || (P[i].a == w-1) || (P[i].b == 0) || (P[i].b == h-1) {
			i++
			continue
		}
		xx = P[i].a
		yy = P[i].b
		cnt = 0
		for ; ; i++ {
			if i >= len(P) {
				break
			}
			if (xx == P[i].a) && (yy == P[i].b) {
				cnt++
			} else {
				break
			}
		}
		ans[cnt]++
	}

	sum := 0
	for i := 1; i < 10; i++ {
		sum += ans[i]
	}
	ans[0] = (w-2)*(h-2) - sum

	for i := 0; i < 10; i++ {
		out(ans[i])
	}
}


Measured memory_bytes: 18816
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}*/

int n, z, w;
vector<int> a(2010);

int memo[2010][2];

int rec(int id, int turn, int x, int y) {
	if (id == n) return abs(x - y);

	if (memo[id][turn] >= 0) return memo[id][turn];

	// Xさんが引く
	if (turn == 0) {
		// 差が最大になるように引く
		int ma = -1;
		Rep(i, id, n) {
			ma = max(ma, rec(i + 1, 1 - turn, a[i], y));
		}
		return memo[id][turn] = ma;
	}
	else { // Yさんが引く
		// 差が最小になるように引く
		int mi = inf;
		Rep(i, id, n) {
			mi = min(mi, rec(i + 1, 1 - turn, x, a[i]));
		}
		return memo[id][turn] = mi;
	}
}


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

	cin >> n >> z >> w;
	rep(i, n) cin >> a[i];

	rep(i, n) {
		rep(t, 2) {
			memo[i][t] = -1;
		}
	}

	cout << rec(0, 0, z, w) << endl;

	return 0;
}

Measured memory_bytes: 384
for _ in [0]*int(input()):
    h,m=map(int,input().split(":"))
    s=l=.0
    l=m*6
    s=30*(h+(m/60))
    if l<s:l,s=s,l
    if l-s>180:d=360-l+s
    else:d=l-s
    b='safe'
    if d<30:b='alert'
    elif d<90: b='warning'
    print(b)

Measured memory_bytes: 7668
#include <stdio.h>

int main(void){
    int p1,p2,p3,j1,j2,pmin,jmin;
    scanf("%d%d%d%d%d",&p1,&p2,&p3,&j1,&j2);
    if (p1 < p2 && p1 < p3){
        pmin = p1;
    }
    else if (p2 < p1 && p2 < p3){
        pmin = p2;
    }
    else{
        pmin = p3;
    }
    if (j1 < j2){
        jmin = j1;
    }
    else{
        jmin = j2;
    }
    printf("%d\n",pmin + jmin - 50);
    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
 int n,m;
 cin >> n >> m;
 int sum=m*1900+(n-m)*100;
 int luck=pow(2,m);
 int ans=sum*luck;
 cout << ans << endl;
}



Measured memory_bytes: 3984
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int dp[20];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  string n;
  cin >> n;

  int m = n.length(), ans = 0;
  rep(i, m) {
    dp[i + 1] = dp[i] + n[i] - '0';
    if (n[i] != '0') chmax(ans, dp[i + 1] - 1 + 9 * (m - 1 - i));
  }
  chmax(ans, dp[m]);
  cout << ans << '\n';






  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include <algorithm>
using namespace std;

int main()
{
  int n, m, c;
  cin >> n >> m>> c;
  int judge = c, count = 0;
  int B[m];
  for (int i=0; i<m; i++) cin >> B[i];
  int A[m];
  for (int i=0; i<n; i++){
    judge = c;
    for (int k=0; k<m; k++) {
      cin >> A[k];
      judge += A[k] * B[k];
    }
    if (judge >0) count++;
  }
  cout << count << endl;
}

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

// 型名の省略
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> P;
typedef pair<lint, lint> Plint;
 
const int MOD = 1e9+7;
const int INF = 1<<18;
const lint INFLINT = 1LL<<60;
const double PI=acos(-1.0);
 
// cinとcoutの高速化
#define endl "\n"
struct cinacc{cinacc(){cin.tie(0);ios::sync_with_stdio(false);}}cinaccc;
struct coutacc{coutacc(){cout.setf(ios::fixed);cout.precision(12);}}coutaccc;
 
// 繰り返し
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define reps(i,n) for(lint i=0;i<=(lint)(n);i++)
#define rrep(i,n) for(lint i=(lint)(n)-1;i>0;i--)
#define rreps(i,n) for(lint i=(lint)(n)-1;i>=0;i--)

#define pb push_back

#define ALL(s) s.begin(), s.end()
#define SZ(s) s.size()

template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T&a,const T&b){if(b<a){a=b;return true;}return false;}

// Union-Find-Tree
class UnionFind {
	vector<int> par;
	UnionFind(int n):par(n){rep(i,n)par[i]=i;}
	int root(int x){if(par[x]==x)return x;return par[x]=root(par[x]);}
	void unite(int x,int y){int rx=root(x);int ry=root(y);if(rx==ry)return;par[rx]=ry;}
	bool same(int x,int y){return root(x)==root(y);}
};

// Final Weapon!
// #define int lint

int main() {
    int x;
    cin >> x;
    
    int n = 100003;
    vector<bool> isPrime(n + 1, true);
    vector<int> P;
    for(int i = 2; i <= n; i++) {
        if(isPrime[i]) {
            for(int j = 2 * i; j <= n; j += i) {
                isPrime[j] = false;
            }
            P.emplace_back(i);
        }
    }
    
    for(auto e : P) {
        if(x <= e) {
            cout << e;
            break;
        }
    }
    
    return 0;
}


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

int main() {
	 int a,b;
	 char op; 
	 cin>>a >>op >> b;
	  
	 if(op=='+')
	 {
	     cout<< a+b;
	 }
	 else
	 {
	     cout << a-b;
	 }
	return 0;
}


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

struct StronglyConnectedComponents
{
	int V;
	const vector<vector<int>> &g;
	int num_of_comp;
	vector<int> comp;
	vector<vector<int>> dag;
	vector<vector<int>> group_set;

	vector<vector<int>> rg;
	vector<int> order;
	vector<bool> used;

	StronglyConnectedComponents(const vector<vector<int>> &g) : V(g.size()), g(g) {}

	void calc() {
		num_of_comp = 0;
		comp.assign(V, -1);
		used.assign(V, false);
		order.reserve(V);
		rg.resize(V);
		for (int i = 0; i < V; i++) {
			for (int e : g[i]) {
				rg[e].push_back(i);
			}
		}
		for (int i = 0; i < V; i++) {
			if (!used[i]) dfs1(i);
		}
		for (int i = V-1; i >= 0; i--) {
			const int v = order[i];
			if (comp[v] == -1) {
				dfs2(v);
				num_of_comp++;
			}
		}
		dag.resize(num_of_comp);
		group_set.resize(num_of_comp);
		for (int i = 0; i < V; i++) group_set[comp[i]].push_back(i);
		for (int i = 0; i < V; i++) {
			for (int e : g[i]) {
				const int x = comp[i], y = comp[e];
				if (x != y) dag[x].push_back(y);
			}
		}

	}

	void dfs1(int v) {
		used[v] = true;
		for (int nv : g[v]) {
			if (used[nv]) continue;
			dfs1(nv);
		}
		order.push_back(v);
	}

	void dfs2(int v) {
		comp[v] = num_of_comp;
		for (int nv : rg[v]) {
			if (comp[nv] != -1) continue;
			dfs2(nv);
		}
	}
};

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> g(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		g[a].push_back(b);
	}
	StronglyConnectedComponents scc(g);
	scc.calc();
	cout << scc.num_of_comp << endl;
	for (int i = 0; i < scc.num_of_comp; i++) {
		int l = scc.group_set[i].size();
		printf("%d", l);
		for (int j = 0; j < l; j++) {
			printf(" %d", scc.group_set[i][j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 101220
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.Remoting.Contexts;
using System.Security.Cryptography.X509Certificates;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }
        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private int A, B, K;
        private void Scan()
        {
            var sc = new Scanner();
            A = sc.NextInt();
            B = sc.NextInt();
            K = sc.NextInt();

        }

        public void Solve()
        {
            Scan();
            if (B - A + 1 >= K * 2)
            {
                for (int i = A; i < A + K; i++)
                {
                    Console.WriteLine(i);
                }

                for (int i = B - K + 1; i <= B; i++)
                {
                    Console.WriteLine(i);
                }
            }
            else
            {
                for (int i = A; i <= B; i++)
                {
                    Console.WriteLine(i);
                }
            }
        }


        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll T1,T2,A1,A2,B1,B2;cin>>T1>>T2>>A1>>A2>>B1>>B2;
    
    if(T1*A1+T2*A2==T1*B1+T2*B2){
        cout<<"infinity"<<endl;
        return 0;
    }
    
    if(T1*A1+T2*A2>T1*B1+T2*B2){
        swap(A1,B1);
        swap(A2,B2);
    }
    
    if(A1<B1){
        cout<<0<<endl;
        return 0;
    }
    
    ll diff=(T1*B1+T2*B2)-(T1*A1+T2*A2);
    if((T1*A1-T1*B1)%diff!=0){
        cout<<(T1*A1-T1*B1)/diff*2+1<<endl;
    }else cout<<(T1*A1-T1*B1)/diff*2<<endl;
}


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

using namespace std;

typedef long long ll;

int main() {
    ll N; cin>>N;
    vector<ll> An(N);
    for (int i=0;i<N;i++) {
        cin>>An[i];
    }

    bool hasChanged=true;
    while (hasChanged) {
        sort(An.begin(), An.end());
        int start=0;
        for (int i=0;i<N;i++) {
            if (An[i] != 0) {
                start=i;
                break;
            }
        }

        hasChanged=false;
        for (int i=start+1;i<N;i++) {
            ll a = An[i] % An[start];
            // cout << a << endl;
            if (An[i] != a) hasChanged=true;
            An[i] = a;
        }
    }

    cout << An[N-1] << endl;

    return 0;
}

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

int main (){
  ll N,K;cin>>N>>K;
  ll INF = 1e9 + 7,ans= 0;
  ll s = K*(K-1)/2, g=(2*N-K+1)*K/2;
    for (ll i = K; i < N + 2; i++) {
      ans += g - s + 1;
      ans %= INF;
      s += i;
      g += N - i;
      if (ans < 0) {
        ans = i;
        break;
      }
    }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>
#include <functional>

using namespace std;
using ll = long long;
using ld = double;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>; //(x, y, dx, dy)
const ll INF = 1e17;
const ld eps = 1e-10;
const ll MOD = 1e9 + 7;

const double pi = acos(-1.0);

vector<string> area;
map<P, ll> mp;

ll dx[] = { -1, 0, 1, 0 };
ll dy[] = { 0, 1, 0, -1 };

P diam(vector<vector<ll>> &es, vector<int> &visited, ll now) {
	if (visited[now])
		return P(-10, -1);
	visited[now] = true;
	P ret = P(-1, now);
	for (auto &e : es[now]) {
		ret = max(ret, diam(es, visited, e));
	}
	ret.first += 1;
	return ret;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll H, W;
	cin >> H >> W;
	vector<string> area(H);
	for (int i = 0;i < H;i++)
		cin >> area[i];
	vector<vector<ll>> dist(H, vector<ll>(W, INF));
	queue<T> que;
	for (int y = 0;y < H;y++)
		for (int x = 0;x < W;x++)
			if (area[y][x] == '#') {
				que.push(T(y, x, 0));
				dist[y][x] = 0;
			}
	while (!que.empty()) {
		ll y, x, d;
		tie(y, x, d) = que.front();
		que.pop();
		for (int k = 0;k < 4;k++) {
			if (y + dy[k] < 0 || y + dy[k] >= H || x + dx[k] < 0 || x + dx[k] >= W)
				continue;
			if (dist[y + dy[k]][x + dx[k]] > d + 1) {
				que.push(T(y + dy[k], x + dx[k], d + 1));
				dist[y + dy[k]][x + dx[k]] = d + 1;
			}
		}
	}
	ll ans = 0;
	for (int y = 0;y < H;y++)
		for (int x = 0;x < W;x++)
			ans = max(ans, dist[y][x]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 33332