akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>

using namespace std;	

int n, m, a, b;
int dx, dy;

char sol[1005][1005];

void print() {
	if (a>0 or b>0) {
		printf("NO\n");
		return ;
	}
	printf("YES\n");
	n += dx;
	m += dy;
	for (int i=0 ; i<n ; i++) {
		for (int j=0 ; j<m ; j++) {
			if (sol[i][j] == '<' and a<0) {
				sol[i][j] = '.';
				sol[i][j+1] = '.';
				a++;
			}
			if (sol[i][j] == '^' and b<0) {
				sol[i][j] = '.';
				sol[i+1][j] = '.';
				b++;
			}
			printf("%c", sol[i][j]);
		}
		printf("\n");
	}
}

int main() {
	scanf("%d%d%d%d", &n, &m, &a, &b);
	for (int i=0 ; i<n ; i++) {
		for (int j=0 ; j<m ; j++) {
			sol[i][j] = '.';
		}
	}
	if (n%2 and m%2 and n>1 and m>1) {
		dx = 3;
		dy = 3;
		n -= 3;
		m -= 3;
		for (int i=0 ; i<n ; i+=2) {
			sol[i][m+2] = '^';
			sol[i+1][m+2] = 'v';
			b--;
		}
		for (int j=0 ; j<m ; j+=2) {
			sol[n+2][j] = '<';
			sol[n+2][j+1] = '>';
			a--;
		}
		for (int i=0 ; i<n+2 ; i+=2) {
			for (int j=0 ; j<m+2 ; j+=2) {
				if (i == n and j == m) break;
				if (a>=b) {
					a-=2;
					sol[i][j] = '<';
					sol[i+1][j] = '<';
					sol[i][j+1] = '>';
					sol[i+1][j+1] = '>';
				} else {
					b-=2;
					sol[i][j] = '^';
					sol[i+1][j] = 'v';
					sol[i][j+1] = '^';
					sol[i+1][j+1] = 'v';
				}
			}
		}
		if (a == b) {
			a-=2;
			b-=2;
			sol[n][m] = '^';
			sol[n+1][m] = 'v';
			sol[n+2][m] = '<';
			sol[n+2][m+1] = '>';
			sol[n+2][m+2] = 'v';
			sol[n+1][m+2] = '^';
			sol[n][m+2] = '>';
			sol[n][m+1] = '<';
		} else if (a>b) {
			a-=3;
			b--;
			sol[n][m] = '<';
			sol[n][m+1] = '>';
			sol[n+1][m] = '<';
			sol[n+1][m+1] = '>';
			sol[n+2][m] = '<';
			sol[n+2][m+1] = '>';
			sol[n][m+2] = '^';
			sol[n+1][m+2] = 'v';
		} else {
			a--;
			b-=3;
			sol[n][m] = '^';
			sol[n][m+1] = '^';
			sol[n+1][m] = 'v';
			sol[n+1][m+1] = 'v';
			sol[n+2][m] = '<';
			sol[n+2][m+1] = '>';
			sol[n][m+2] = '^';
			sol[n+1][m+2] = 'v';
		}
		print();
		return 0;
	}
	if (n%2) {
		dx = 1;
		n--;
		for (int j=0 ; j<m-1 ; j+=2) {
			sol[n][j] = '<';
			sol[n][j+1] = '>';
			a--;
		}
	}
	if (m%2) {
		dy = 1;
		m--;
		for (int i=0 ; i<n-1 ; i+=2) {
			sol[i][m] = '^';
			sol[i+1][m] = 'v';
			b--;
		}
	}
	for (int i=0 ; i<n ; i+=2) {
		for (int j=0 ; j<m ; j+=2) {
			if (a>=b) {
				a-=2;
				sol[i][j] = '<';
				sol[i+1][j] = '<';
				sol[i][j+1] = '>';
				sol[i+1][j+1] = '>';
			} else {
				b-=2;
				sol[i][j] = '^';
				sol[i+1][j] = 'v';
				sol[i][j+1] = '^';
				sol[i+1][j+1] = 'v';
			}
		}
	}
	print();
	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 3;
int n, a[N];
int cntPos(int i, long long val) {
	int lo = i + 1, hi = n - 1, ret = i;
  	while (lo <= hi) {
    	int mid = (lo + hi) / 2;
      	if ((long long) a[i] * a[mid] <= val) {
			ret = mid;
          	lo = mid + 1;
        } else{
        	hi = mid - 1;
        }
    }
	return ret - i;
}
int cntNeg(int i, long long val) {
	int lo = i + 1, hi = n - 1, ret = n;
  	while (lo <= hi) {
    	int mid = (lo + hi) / 2;
      	if ((long long) a[i] * a[mid] <= val) {
			ret = mid;
        	hi = mid - 1;
        } else{
          	lo = mid + 1;
        }
    }
	return n - ret;
}
int main() {
	long long k;
  	cin >> n >> k;
  	for (int i = 0; i < n; ++i)
      	cin >> a[i];
  	sort(a, a + n);
	long long lo = -1e18, hi = 1e18, res = -1; 
	while (lo <= hi) {
		long long mid = (lo + hi) / 2, counter = 0;
		for (int i = 0; i < n; ++i) {
          	if (a[i] > 0)
              counter += cntPos(i, mid);
          	else
            	counter += cntNeg(i, mid);
        }
		if (counter < k) {
			lo = mid + 1;
		} else {
			res = mid;
			hi = mid - 1;
		}
	}
	cout << res << endl;	
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main()
{
	int N,i,p;
	scanf("%d",&N);
	if(1<=N && N<=10000){
	for(i=1; ;i++){
		if(i*1000>=N){
			p=i*1000;
			break;
		}
	}
}
	int c;
	c=p-N;
	printf("%d",c);
	return 0;
 } 

Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

const int mod = 1000000007;
struct mint{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a){
        if((x+=a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a){
        if((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if(!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if(t&1) a *= *this;
        return a;
    }

    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1){
        assert(n < mod);
        fact[0] = 1;
        for(int i = 1; i <= n; i++) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for(int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;  
    }
    mint operator()(int n, int k){
        if(k < 0 || n < k) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main(){
    int n, m, k; cin >> n >> m >> k;
    combination comb(300005);
    mint ans = 0;
    for(int i = 0; i <= m; i++){
        ans += mint(i) * mint(m-i) * mint(n*n);
    }
    for(int j = 0; j <= n; j++){
        ans += mint(j) * mint(n-j) * mint(m*m);
    }
    ans *= comb(m*n-2,k-2);
    cout << ans.x << endl;
}

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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int maxn = 100000;

int n, a, b;
char s[maxn + 5];

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d%d%d", &n, &a, &b);
	scanf("%s", s);
	int cnt0 = 0, cnt1 = 0;
	REP(i, 0, n)
	{
		if (s[i] == 'a' && cnt0 < a + b) ++cnt0, puts("Yes");
		else if (s[i] == 'b' && cnt0 < a + b && cnt1 < b) ++cnt0, ++cnt1, puts("Yes");
		else puts("No");
	}
	return 0;
}


Measured memory_bytes: 768
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const double pi = acos(-1);
const int maxn = 2e6 + 10;
const double eps = 1e-8;
const ll mod = 1e9 + 7;
const ull base = 131;
const ull mod1 = 1e9 + 9;
const ull mod2 = 1610612741;

set<int> s;

int main()
{
    for (int i = 1; i < 4; ++i)
    {
        int x;
        scanf("%d", &x);
        s.insert(x);
    }
    printf("%d\n", s.size());
        
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int dfs(int src,unordered_map<int,list<int> > &m,int *dp){
    if(m[src].empty())return dp[src]=0;
    if(dp[src]!=-1)return dp[src];
    for(int it: m[src]){
        dp[src]=max(dp[src],1+dfs(it,m,dp));
    }
    return dp[src];
}
void solve()
{
    int v,n;
    cin>>v>>n;
    unordered_map<int,list<int> > m;
    while(n--){
        int x,y;
        cin>>x>>y;
        m[--x].push_back(--y);
    }
    int dp[v];
    for(int i=0; i<v ;i++)dp[i]=-1;
    for(int i=0; i<v; i++){
        dfs(i,m,dp);
    }
    int ans=0;
    for(int i=0; i<v; i++)ans=max(ans,dp[i]);
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    while(t--){
        solve();
        cout<<endl;
    }
}


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

int h, w, k;
vector < vector < int > > pref;

int cuts (int mask) {
	int res = 0;
	vector < int > cuts;
	cuts.push_back(h);
	for (int i = h - 2; i >= 0; --i) {
		if (mask >= (1 << i)) {
			cuts.push_back(i + 1);
			mask -= (1 << i);
			++res;
		}
	}
	cuts.push_back(0);
	reverse(cuts.begin(), cuts.end());
	bool fucked_up = 0;
	int last = 0;
	for (int i = 1; i <= w; ++i) {
		for (int j = 1; j < int(cuts.size()); ++j) {
			int r = cuts[j], l = cuts[j - 1];
			int here = pref[r][i] + pref[l][last] - pref[l][i] - pref[r][last];
			if (here > k) {
				if (k < pref[r][i] + pref[l][i - 1] - pref[l][i] - pref[r][i - 1])
					fucked_up = 1;
				else {
					last = i - 1;
					++res;
				}
			}
		}
	}
	if (fucked_up)
		res = 1e5;
	return res;
}

void ckmin (int &x, int a) {
	x = min(x, a);
}

signed main () {
	cin >> h >> w >> k;
	vector < vector < char > > s(h, vector < char > (w));
	pref.assign(h + 1, vector < int > (w + 1, 0));
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			cin >> s[i][j];
			pref[i + 1][j + 1] = pref[i + 1][j] + pref[i][j + 1] - pref[i][j] + (s[i][j] == '1');
		}
	}
	int ans = 1e5;
	for (int mask = 0; mask < (1 << (h - 1)); ++mask) 
		ckmin(ans, cuts(mask));
	cout << ans << '\n';
}


Measured memory_bytes: 256
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j,key;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);

  for(i = 1; i <= n; i++){
    key = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > key){
      A[j+1] = A[j];
      j--;
    A[j+1] = key;
    }
    trace(A,n);
  }

  return 0;
}

Measured memory_bytes: 608
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){
   int n;
   cin >> n;
   int d[110];
   rep(i,n) cin >> d[i];

   set<int> values;
   rep(i,n){
      values.insert(d[i]);
   }

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


   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
char a[20000];
int main(){
	string c,d;
	while(cin>>c>>d){
	for(int i=0;i<20000;i++)
		a[i]='-';
	for(int i=0;i<c.size();i++)
		a[i+10000]=c[i];
	int ans=0;
	for(int first=0;first<20000-d.size();first++){
		int count=0;
		for(int j=0;j<d.size();j++){
			if(a[first+j]==d[j])
				count++;
			else{
				ans=max(ans,count);
				count=0;
			}
		}
		ans=max(ans,count);
	}
	cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,n) for(lli i=0;i<n;i++)
#define repb(i,n) for(lli i=n-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define bg() begin()
#define en() end()
#define ft first
#define sc second
#define vect_lli_it vector<lli>::iterator
#define set_lli_it set<lli>::iterator
#define inf 1e18
#define all(X) X.begin(),X.end()
#define iterate(X) for(it=X.begin();it!=X.end();it++)
lli combi(lli n,lli k)
{
    lli ans=1;
    k=k>n-k?n-k:k;
    lli j=1;
    for(;j<=k;j++,n--)
    {
        if(n%j==0)
        {
            ans*=n/j;
        }else
        if(ans%j==0)
        {
            ans=ans/j*n;
        }else
        {
            ans=(ans*n)/j;
        }
    }
    return ans;
}
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
lli findlcm(vector <lli> arr, lli n)
{
    lli ans = arr[0];
    for (lli i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (gcd(arr[i], ans)));

    return ans;
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n;
    cin>>n;
    vector <lli> arr;
    lli x;
    rep(i,n){
    	cin>>x;
    	arr.pb(x);
	}
	lli count=0;
	for(lli i=1;i<n-1;i++){
		if(arr[i]<arr[i-1] && arr[i]>arr[i+1]){
			//cout<<arr[i]<<" ";
			count++;
		}
		
		else if(arr[i]<arr[i+1] && arr[i]>arr[i-1]){
			//cout<<arr[i]<<" ";
			count++;
		}
	
	}
	cout<<count;
    return 0;
}


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

int main(){
	int n;
	vector<int> lamp;

	cin >> n;
	for(int i=0;i < n;i++){
		int newLamp;
		cin >> newLamp;
		lamp.push_back(newLamp);
	}

	int pos = 1;
	int cnt = 0;
	do{
		pos = lamp[pos-1];
		cnt++;
		pos = (pos==1)?-1:pos;
	}while(pos!=-1 && pos!=2 && cnt<n);
	if(pos == 2){
		printf("%d\n", cnt);
	}else{
		printf("%d\n", -1);
	}
}


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

int ct[26];

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

    string s;
    cin >> s;
    for(auto c : s)
        ct[c - 'A']++;
    for(int i = 0; i < 26; i++) {
        if(ct[i] != 0 && ct[i] != 2) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb		  push_back
#define pairs	  pair<int, int>
#define vi		  vector<int>
#define vb		  vector<bool>
#define vii		  vector<pairs>
#define lb		  lower_bound
#define ub		  upper_bound
#define lli		  long long int
#define endl	  '\n'
#define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define Cases	  cout << "Case " << ++Case << ": ";
#define __test    \
	int tt;       \
	int Case = 0; \
	cin >> tt;    \
	while (tt--)
#define read(x)	 freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define InputArray(a, n)        \
	for (int i = 0; i < n; i++) \
		cin >> a[i];
#define CopyArray(a, temp, n)   \
	for (int i = 0; i < n; i++) \
		temp[i] = a[i];
#define PrintArray(a, n)        \
	for (int i = 0; i < n; i++) \
		cout << a[i] << " ";    \
	cout << endl;
using namespace std;
 
int main() {
#ifdef Niloy
	read("input.txt");
	write("output.txt");
#endif
	FastInput;
 
	int x, n;
	cin >> x >> n;
	vi a;
	if (n == 0) {
		cout << x << endl;
		return 0;
	}
 
	int index = 0;
	for (int i = 0; i < n; i++) {
		int b;
		cin >> b;
		a.pb(b);
		if (b == x) {
			index = i;
		}
	}
 
	sort(a.begin(), a.end());
	int max = x;
	int MIN = x;
	while (true) {
		bool result = binary_search(a.begin(), a.end(), max);
		if (!result) {
			break;
		}
		max++;
	}
 
	while (true) {
		bool result = binary_search(a.begin(), a.end(), MIN);
		if (!result) {
			break;
		}
		MIN--;
	}

	int D = max - x + 1;
	int d = x - MIN;

	if(D > d) {
		cout << MIN << endl;
	} else {
		cout << max << endl;
	}

	cerr << "time = " << (clock() / CLOCKS_PER_SEC) << " sec" << '\n';
	return 0;
}

Measured memory_bytes: 3680
n = int(input())
a = list(map(int,input().split()))

c = 1
ans = 0
for i in range(n):
    if a[i] != c:
        ans += 1
        a[i] = 0
    else:
        c += 1
if ans < n:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 77644
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
 
 
void run_case() {
    int n; cin >> n;
    vector<pii> a(n);
    for(auto &x: a) cin >> x.first >> x.second;
    vector<int> b(n);
    for(int i = 0; i < n; ++i) b[i] = i;
    double sum = 0.0;
    int num = 0;
    do {
        for(int i = 0; i < n-1; ++i) {
            sum += sqrt(sqr(a[b[i]].first-a[b[i+1]].first) + sqr(a[b[i]].second - a[b[i+1]].second));
        }
        num++;
    } while(next_permutation(b.begin(), b.end()));
    cout << sum / (double) num;
}
 
 
int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(9);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3860
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int n;
long long ans;
map<string,int>mp;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        ans+=mp[s];
        mp[s]++;
    }
    cout<<ans<<endl;
}

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

int N;
int A[20];
int x[20][20];
int y[20][20];

int counter(int x) {
    if(x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

void solve() {
    cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >> A[i];
        for(int j = 1; j <= A[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans = 0;
    for(int bits = 1; bits < (1 << N); bits++) {
        bool ok = true;
        for(int i = 1; i <= N; i++) {
            if(!(bits & (1 << (i-1)))) continue;
            for(int j = 1; j <= A[i]; j++) {
                if(((bits >> (x[i][j]-1)) & 1) ^ y[i][j]) ok = false;
            }
        }
        if(ok) ans = max(ans, counter(bits));
    }
    cout << ans << endl;
    return;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int max(int x, int y)
{
    if (x >= y) return x;
    else return y;
}

int min(int x, int y)
{
    if (x <= y) return x;
    else return y;
}

int main()
{
    int x, y;
    scanf("%d%d", &x, &y);
    int ans = x + y/2;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = True
#debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def solve():
    s = SI()
    if s == 'Sunny':
        print('Cloudy')
    elif s == 'Cloudy':
        print('Rainy')
    else:
        print('Sunny')

solve()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using ll=long long;

vector<pair<ll,ll>> G[100010];
ll color[100010]={};
bool checked[100010]={};
void dfs(ll parent, ll from_edge_color=0){
  checked[parent]=true;
  ll c=1;
  for(auto p:G[parent]){
    if(checked[p.first])continue;
    if(from_edge_color==c)c++;
    color[p.second]=c;
    dfs(p.first,c);
    c++;
  }
}

void solve(ll N, std::vector<ll> a, std::vector<ll> b){
  REP(j,N-1){
    ll i1=a[j]-1,i2=b[j]-1;
    G[i1].push_back(make_pair(i2,j));
    G[i2].push_back(make_pair(i1,j));
  }
  ll max_deg=0;
  REP(i,N){
    ll deg=G[i].size();
    max_deg=max(max_deg,deg);
  }
  cout<<max_deg<<endl;
  dfs(0);
  REP(j,N-1){
    cout<<color[j]<<endl;
  }
}

int main(){
  ll N;
  scanf("%lld",&N);
  std::vector<ll> a(N-1);
  std::vector<ll> b(N-1);
  for(int i = 0 ; i < N-1 ; i++){
    scanf("%lld",&a[i]);
    scanf("%lld",&b[i]);
  }
  solve(N, std::move(a), std::move(b));
  return 0;
}


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

int main () {
  int S;
  cin >> S;
  int h = S / (60 * 60);
  int m = (S % (60 * 60)) / 60;
  int s = (S % (60 * 60)) % 60;
  cout << h << ":" << m << ":" << s << endl;
  return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define all(obj) obj.begin(), obj.end()
#define debug(x) cerr << #x << ":" << x << "\n"
#define vdebug(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define vvdebug(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main () {
	int N, Q; cin >> N >> Q;
	string S; cin >> S;
	vi a(N + 1);
	rep2(i, 2, N + 1) {
		if (S.at(i - 2) == 'A' && S.at(i - 1) == 'C') 
			a.at(i) = a.at(i - 1) + 1;
		else a.at(i) = a.at(i - 1);
	}
	// vdebug(a);
	rep(i, Q) {
		int l, r; cin >> l >> r;
		l--; r--;
		int ans = a.at(r + 1) - a.at(l);
		if (l > 0 && S.at(l - 1) == 'A' && S.at(l) == 'C') ans--;
		cout << ans << endl;
	}
}

Measured memory_bytes: 1408
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(N: int, T: "List[int]", A: "List[int]"):
    tmpT = 1
    tmpA = 1
    for i in range(N):
        d = max((tmpT-1)//T[i]+1, (tmpA-1)//A[i]+1)
        tmpT = T[i] * d
        tmpA = A[i] * d
    print(tmpT+tmpA)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    T = [int()] * (N)  # type: "List[int]" 
    A = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        T[i] = int(next(tokens))
        A[i] = int(next(tokens))
    solve(N, T, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5304
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	string N;
	cin >> N;
	int ans = 0;
	for (int i = 0; i < N.length(); i++)if (N[i] == '2')ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    string s,t; cin >> s >> t;
    int n = s.size();
    vector<vector<int> > ss(26,vector<int>(0)),tt(26,vector<int>(0));

    for(int i = 'a';i < 'a' + 26;i ++){
        for(int j = 0;j < n;j ++){
            if(s.at(j) == i) ss.at(i - 'a').push_back(j);
        }
    }

    for(int i = 0;i < 26;i ++){
        if(ss.at(i).size() <= 1) continue;

        for(int j = 0;j < ss.at(i).size();j ++){
            if(t.at(ss.at(i).at(j)) != t.at(ss.at(i).at(0))){
                cout << "No" << endl;
                return 0;
            }
        }
    }

        for(int i = 'a';i < 'a' + 26;i ++){
        for(int j = 0;j < n;j ++){
            if(t.at(j) == i) tt.at(i - 'a').push_back(j);
        }
    }

    for(int i = 0;i < 26;i ++){
        if(tt.at(i).size() <= 1) continue;

        for(int j = 0;j < tt.at(i).size();j ++){
            if(s.at(tt.at(i).at(j)) != s.at(tt.at(i).at(0))){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

}

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

//typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

template<typename T>string join(const v(T)&v)
{stringstream s;REP(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		40010

const ll LINF = (ll)1e18+7;		//
const int INF = 1e9+7;			//2,147,483,647 (Max int)
const ll MOD = 1e9+7;
// テンプレ終了
//====================================================================//




//
int main(){
	int N;cin>>N;
	V H(N);
	REP(i,N)cin>>H[i];


	int maxl=0;
	int now=0;
	REP(i,N-1){
		if(H[i] >= H[i+1]){
			now++;
			maxl = max(maxl,now);
		}else now = 0;
	}

	cout << maxl << endl;

	return 0;
}




Measured memory_bytes: 640
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    P = [0] * N
    for i in range(N):
        P[i] = int(input())

    dp = [0] * (N + 1)
    for i, p in enumerate(P):
        dp[p] = dp[p - 1] + 1

    ans = N - max(dp)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 24596
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#include<string>
#define ll long long
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<ll>
#define el printf("\n")
#define N 100001
#define s second
#define pb(x) push_back(x)
#define f first
using namespace std;
bool visited[1000005]={0};
vector<ll> mp[1000005];
vector <ll> dist; /// distance dans un arbre
vector<ll> dp(1000005,0);
void dfs(ll s)
{
    visited[s]=true;
    for (int i=0;i<mp[s].size();i++)
    {
        if (visited[mp[s][i]]==false)
        {
            dfs(mp[s][i]);
        }
        dp[s]=max(dp[s],1+dp[mp[s][i]]);
    }
}


    int main()
    {   ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(30);
        IOS;
        ll n,m;
        cin >> n >> m;
        memset(visited,false,sizeof visited)
;        for(int i=1;i<=m;i++)
        {
            ll x,y ;
            cin >> x >> y;
            mp[x].push_back(y);
        }
        for(int i=1;i<=n;i++)
        {
            if(visited[i]==false)
                dfs(i);

        }
        ll ans=0;
        for(int i=0;i<=n+1;i++)
            ans=max(ans,dp[i]);
        cout << ans;
        return 0;
    }


Measured memory_bytes: 37632
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
#include <complex>

#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>

#define REP(i,e) for(int i=0;i<(int)(e);i++)
#define FOR(i,b,e) for(int i=(int)(b);i<(int)(e);i++)
#define ALL(c) (c).begin(), (c).end()
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define RALL(c) (c).rbegin(), (c).rend()
#define ALLA(a,n) ((a)+0), ((a)+n)

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstring;
typedef vector<double> vdouble;

template<class T>void pp(T v,int n){ REP(i,n)cout<<v[i]<< ' ' ; cout << endl; }
template<class T>void pp(T v){ EACH(it,v) cout << *it << ' ' ; cout << endl;  }
template<class T>T& ls(T& a,T b){ if(b<a) a=b; return a; }
template<class T>T& gs(T& a,T b){ if(b>a) a=b; return a; }
inline ll to_i(const string& s){ll n;sscanf(s.c_str(),"%lld",&n);return n;}
inline string to_s(ll n){char buf[32];sprintf(buf,"%lld",n);return string(buf);}

struct __scanner__{ bool e; operator bool(){ return e; } } IN = { false };
inline __scanner__& operator>>(__scanner__& in,int &n)
{ in.e = scanf("%d",&n)==1; return in; }
inline __scanner__& operator>>(__scanner__& in,ll &n)
{ in.e = scanf("%lld",&n)==1; return in; }
inline __scanner__& operator>>(__scanner__& in,double &n)
{ in.e = scanf("%lf",&n)==1; return in; }
inline __scanner__& operator>>(__scanner__& in,char &n)
{ in.e = scanf(" %c",&n)==1; return in; }
inline __scanner__& operator>>(__scanner__& in,string &n) // BUFFER SIZE!
{ static char buf[1000000]; in.e = scanf(" %s",buf)==1; n = buf; return in; } 

bool reduce(vint &v, int n, int unit) {
  // cout << "## " << n << ' ' << unit << endl;
  REP(i,v.size()) {
    int cnt = min(n, v[i] / unit);
    n -= cnt;
    v[i] -= cnt * unit;
  }
  return n == 0;
}

int main(){
  int h, w;
  while (cin >> h >> w) {
    vint v(26);
    REP(i,h) REP(j,w) {
      char ch ; cin >> ch;
      v[ch-'a']++;
    }
    int quad = (h / 2) * (w / 2);
    bool ok = true;
    // cout << "# " << h << ' ' << w << endl;
    ok = ok && reduce(v, quad, 4);
    ok = ok && reduce(v, (h / 2) * (w % 2), 2);
    ok = ok && reduce(v, (w / 2) * (h % 2), 2);
    ok = ok && reduce(v, (h % 2) * (w % 2), 1);
    assert(ok xor accumulate(ALL(v), 0));
    cout << (ok ? "Yes" : "No") << endl;
  }
}


Measured memory_bytes: 256
program prob6
    implicit none
    integer(8)::N, i, s, ans
    integer, allocatable::A(:)
    integer::c(100000)
    read(*,*) N
    allocate(A(N))
    read(*,*) A

    c = 0
    s = 0
    ans = 0

    do i = 1, N
        c(A(i)) = c(A(i)) + 1
    end do

    do i = 1, 100000
        if(c(i) > 1)then
            s = s + c(i) - 1
        end if
    end do

    if(mod(s,2) == 1)then
        s = s+1
    end if
    write(*,*) N - s

    deallocate(A)
    stop
end program


Measured memory_bytes: 3740
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>

using namespace std;
using ll = long long;

int main(){
    int n,cnt=0;
    cin >> n;
    string str;
    cin >> str;
    for(int i=0;i<str.size();i++){
        if(str[i]=='R') cnt++;
    }
    if(n-cnt<cnt)   cout << "Yes";
    else    cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<cstdio>
using namespace std;

int main(){
	
	double x=0,y=0;
	double a,b,t=90;
	char cn;
	while(cin>>a>>cn>>b){
	if(a!=b!=0){
		double s=t*M_PI/180;
		x+=a*cos(s);
		y+=a*sin(s);
		t=t-b;
		
	}
	else
		break;
	}
	printf("%d\n%d\n",(int)x,(int)y);
		
	
}

Measured memory_bytes: 1208
/* * * * * * * * * * * **
*                      *
*	   saurabh8522	   *
*	  I will handle	   *
*		   IT.		   *
*                      *
* * * * * * * * * * * **/
#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ld long double
#define zero(a) memset((a),0,sizeof((a)))
#define one(a) memset((a),1,sizeof((a)))
#define minus(a) memset((a),-1,sizeof((a)))
#define all(g) g.begin(),g.end()
#define ppb pop_back
using namespace std;
typedef long long int ll;
#define MOD 1000000007
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
ll numdigit(ll n){return floor(log10(n)) + 1;}
bool isPowerTwo (ll x) { return x && (!(x&(x-1))); } 
int  main(){
	// FastRead;
	ll t=1;
	// cin>>t;
	while(t--){
		ll n;
		cin>>n;
		// cout<<n<<endl;
		int a[n][n];
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				cin>>a[i][j];
			}
			// cout<<i<<" "<<endl;
		}
		ll dp[1<<n];
		// cout<<(1<<n)<<endl;
		zero(dp);
		dp[0]=1;
		for(int i=0;i<(1<<n)-1;i++){
			int mc=__builtin_popcount(i);
			// if(mc==n) contin
			for(int wc=0;wc<n;wc++){
				if(a[mc][wc]&&(!((1<<wc)&i))){
					ll m2=i^(1<<wc);
					dp[m2]+=dp[i];
					dp[m2]%=MOD;
				}
				// cout<<i<<" "<<wc<<endl;
			}
		}
		// for(int i=0;i<(1<<n);i++){
		// 	cout<<i<<" "<<dp[i]<<endl;
		// }
		cout<<dp[(1<<n)-1]<<endl;
	}
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

ll dp[3005][3005];
ll N;
ll a[3030];
ll INF = LLONG_MAX/2;

ll rec(ll i, ll j){
	//cout << i << " " << j << endl;
	if(dp[i][j]>-INF) return dp[i][j];
	if((j-i+1)%2==N%2){
		if(i==j){
			return a[i];
		}else{
			ll cand1 = rec(i+1, j) + a[i];
			ll cand2 = rec(i, j-1) + a[j];
			ll res = max(cand1, cand2);
			dp[i][j] = res;
			return res;
		}
	}else{
		if(i==j){
			return -a[i];
		}else{
			ll cand1 = rec(i+1, j) - a[i];
			ll cand2 = rec(i, j-1) - a[j];
			ll res = min(cand1, cand2);
			dp[i][j] = res;
			return res;
		}
	}
}

int main(){
	cin >> N;
	REP(i, N) cin >> a[i];

	REP(i, 3005)REP(j, 3005) dp[i][j] = -INF;

	cout << rec(0, N-1) << endl;

    return 0;
}

Measured memory_bytes: 70912
#define _USE_MATH_DEFINES
#include <iostream> 
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>
using namespace std; 
int main(){
	string str;
	cin >> str;
	reverse(str.begin(), str.end());
	cout << str << endl;
	return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using vl = vector<ll>;

vl f(const vl &v)
{
    int n = v.size();
    vl r(v);

    r[n-1] -= n;
    rep(i,n-1) ++r[i];
    sort(all(r));
    return r;
}

bool valid(const vl &v)
{
    int n = v.size();
    return v[n-1]<n;
}

void test(const vl &V)
{
    vl v = V;

    int n = v.size();
    int ct = 0;
    while(!valid(v))
    {
        v = f(v);
        int D = v[n-1]-v[0];
        printf("%3d: diff: %3d ", ++ct, D);
        // if(D<n) break;
        dbg(v);
    }
}

ll solve(const vl &V)
{
    vl v = V;
    int n = v.size();

    ll ret = 0;

    for(int i=n-1; i>0; --i)
    {
        if(valid(v)) break;

        ll step = n-i;
        ll dec = i+1;

        ll x = (v[i]-v[i-1])/(step+dec);

        ret += step*x;
        rep(j,i) v[j] += x*step;
        for(int j=i; j<n; ++j) v[j] -= x*dec;
        sort(all(v));
    }

    if(!valid(v))
    {
        while(!valid(v) && v[n-1]-v[0]>=2*n)
        {
            ++ret;
            v = f(v);
        }

        ll LIM = 2*n;
        ll y = v[n-1]-LIM;
        if(y>0)
        {
            ret += y*n;
            rep(i,n) v[i] -= y;
        }

        while(!valid(v))
        {
            ++ret;
            v = f(v);
        }
    }

    return ret;
}

int main()
{
    int n;
    cin >>n;
    vector<ll> a(n);
    rep(i,n) cin >>a[i];

    sort(all(a));

    // test(a);
    cout << solve(a) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(){
  int n,i,j,u,k,v,adj[101][101];

  scanf("%d",&n);

  for(i = 0; i <= n; i++)
    for(j = 0; j <= n; j++)
      adj[i][j] = 0;
  
  for(i = 0; i < n; i++){
    scanf("%d%d",&u,&k);
    for(j = 0; j < k; j++){
      scanf("%d",&v);
      adj[u][v] = 1;
    }
  }

  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){
      printf("%d",adj[i][j]);
      if(j != n) printf(" ");
    }
    printf("\n");
  }

  return 0;
}
  
    
    
      



Measured memory_bytes: 2112
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
#define inf 2333333333333333333LL

ll c1[100010],c2[100010],a[100010],n,m,ans;

inline ll rd()
{
	ll x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline void modify1(int l,int r,ll x)
{
	if (l>r) return;
	c1[l]+=x;c1[r+1]-=x;
}

inline void modify2(int l,int r,ll x)
{
	if (l>r) return;
	c2[l]+=x;c2[r+1]-=x;
}

int main()
{
	n=rd();m=rd();
	for (int i=1;i<=n;i++) a[i]=rd();
	for (int i=1;i<n;i++)
	{
		int x=a[i],y=a[i+1];
		if (x==y) continue;
		if (x<y)
		{
			modify1(1,x,y-x);
			modify1(y+1,m,y-x);
			modify1(x+1,y,y+1);
			modify2(x+1,y,-1);
		}
		else
		{
			swap(x,y);
			modify1(x+1,y,m-y+x);
			modify1(1,x,x+1);
			modify1(y+1,m,m+x+1);
			modify2(1,x,-1);
			modify2(y+1,m,-1);
		}
	}
	ll ans=inf;
	for (int i=1;i<=m;i++)
	{
		c1[i]+=c1[i-1];c2[i]+=c2[i-1];
		ans=min(ans,c1[i]+c2[i]*i);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

using namespace std;

#define MAX_N 100000
#define INF INT_MAX / 2 - 1

int main() {
	int n;
	cin >> n;
	
	int dp[MAX_N];
	fill_n(dp, MAX_N, INF);
	int a;
	for (int i = 0; i < n; i++) {
		cin >> a;
		*lower_bound(dp, dp + n, a) = a;
	}
	cout << lower_bound(dp, dp + n, INF) - dp << endl;
	return 0;
}

Measured memory_bytes: 1552
fun main(args: Array<String>){
    val s = readLine()!!
    val t = readLine()!!

    if(check(s,t) && check(t,s)){
        println("Yes")
    }else{
        println("No")
    }
}

fun check(s:String, t:String): Boolean {
    val map = mutableMapOf<Char, Char>()
    for(i in s.indices){
        if(!map.containsKey(s[i])){
            map[s[i]] = t[i]
        }else{
            if(map[s[i]] == t[i]){
                continue
            }else{
                return false
            }
        }
    }
    return true
}

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

int main()
{
  string str;
  cin >> str;
  
  auto count = 0;
  for( auto ch : str )
  {
    if( ch == '1' )
    {
      count++;
    }
  }
  
  cout << count << endl;
  
  return 0;
}

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


int main(void){
    int r;
    cin >> r;
    string s;
    if(r < 1200){
        s = "ABC";
    }else if(r < 2800){
        s = "ARC";
    }else{
        s = "AGC";
    }
    cout << s << endl;
    
    return 0;
}


Measured memory_bytes: 256
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 19 + 7
EPS = 10 ** -10

N = INT()
A = LIST()

A.sort()
ans = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            a, b, c = A[i], A[j], A[k]
            if a == b or b == c or c == a:
                continue
            if a+b > c:
                ans += 1
print(ans)


Measured memory_bytes: 68536
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n=int(input())
print(a[n-1])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const LL INF=1<<17;


int main(){
    string s;
    int m;
    cin >> s >> m;
    int n=s.length();
    int a=s[0]-'0',b=0;
    for (int i = 1; i < n; i+=2) {
        if(s[i]=='+') a+=s[i+1]-'0';
        else a*=s[i+1]-'0'; 
    }
    bool c=false;
    int t=1;
    for (int i = 1; i < n; i+=2) {
        if(s[i]=='+'){
            if(c) b+=t*(s[i-1]-'0');
            else b+=s[i-1]-'0';
            t=1;
            c=false;
        }
        else{
            c=true;
            t*=s[i-1]-'0';
        }
    }
    if(c) b+=t*(s[n-1]-'0');
    else b+=s[n-1]-'0';
    if(m==a&&m==b) puts("U");
    else if(m==a&&m!=b) puts("L");
    else if(m!=a&&m==b) puts("M");
    else puts("I");
    return 0;
}



Measured memory_bytes: 3228
s = input()
from collections import deque
d = deque()
for i in s:
    d.append(i)
mode = 0
Q = int(input())
for _ in range(Q):
    q = input()
    if q[0]=='1':
        mode+=1
        mode%=2
    else:
        t,f,c = q.split()
        f = int(f)
        if (f+mode)%2==1:
            d.appendleft(c)
        else:
            d.append(c)
if mode==1:
    while(len(d)):
        print(d.pop(),end='')
else:
    while(len(d)):
        print(d.popleft(),end='')

Measured memory_bytes: 7924
N = int(input())
a = list(map(int,input().split()))
l = []
for i in range(N-1):
    if a[i+1]-a[i] != 0:
        l.append(a[i+1]-a[i])
# print(l)
if any(i<=-2 for i in l):
    print("No")
    exit()
# while 0 in l:
#     l.remove(0)
# # print(l)
for i in range(len(l)-1):
    if l[i] == -1 and l[i+1] == -1:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 14396
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine().Select(x => x - '0').ToArray();

        var dp = new int[4][];
        for (int i = 0; i < dp.Length; ++i)
        {
            dp[i] = new int[10];
        }
        dp[0][0] = 1;
        for (int i = 0; i < s.Length; ++i)
        {
            for (int j = Math.Min(dp.Length - 1, i + 1); j > 0; --j)
            {
                dp[j][s[i]] = dp[j - 1].Sum();
            }
        }
        Console.WriteLine(dp[3].Sum());
    }
}


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

main()
{
	queue<int> Q2;
	queue<string> Q1;
	int i,n,q,t,total=0;
	char st[10];
	
	cin >> n;
	cin >> q;
	
	for(i=0;i<=n-1;i++)
	{
		cin >> st;
		Q1.push(st);
		cin >> t;
		Q2.push(t);
	}
	while(Q2.empty()!=1)
	{
		if(Q2.front()-q<=0)
		{
			total+=Q2.front();
			cout << Q1.front() << " ";
			Q1.pop();
			Q2.pop();
			cout << total << endl;
		}
		else
		{
			total+=q;
			Q1.push(Q1.front());
			Q1.pop();
			Q2.push(Q2.front()-q);
			Q2.pop();
		}
	}
	return 0;
}

Measured memory_bytes: 5716
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int a[100005],i,num=0;
    for(i=0;i<n;i++)
    scanf("%d",&a[i]);
    for(i=1;i<n-1;i++)
        if((a[i]>a[i-1]&&a[i]<a[i+1])||(a[i]<a[i-1]&&a[i]>a[i+1]))
        num++;
    printf("%d\n",num);
    return 0;
}


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

int n, k;
set <int> st;

int main() {
    cin >> k;
    int ans = 0;
    while (1){
        ans++;
        n *= 10;
        n += 7;
        n %= k;
        if (n == 0) break;
        else if (st.count(n)){
            ans = -1;
            break;
        }
        else st.insert(n);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 50464
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      Map<Integer,Integer> map = new HashMap<Integer,Integer>();
      int[] a = new int[n];
      for(int i = 0;i < n;i++){
        a[i]=sc.nextInt();
        map.put(a[i],sc.nextInt());
      }
      Arrays.sort(a);
      System.out.println(a[n-1]+map.get(a[n-1]));
    }
}

Measured memory_bytes: 98572
/*
 * 競技プログラミング用テンプレート
 * by yuma140902
 * 2019/12/08
 * ver 0.1.0
 */
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
const int INF = 900000;
const ll INFL = 9000000;

#define vi vector<int>
#define vii vector<vector<int> >
#define vi_def(n) vector<int>((n))
#define vii_def(n,m) vector<vector<int> >((n), vector<int>((m)))
#define vi_def_dflt(n, def) vector<int>((n), (def))
#define vii_def_dflt(n, m, def) vector<vector<int> >((n), vector<int>((m), (def)))

#define rep(i, n) for(int i=0; i < (n); ++i)
#define per(i, n) for(int i=(n)-1; i >= 0; --i)
#define range(i, begin, end) for(int i=(begin); i < (end); ++i)

int main(){
  string S;
  cin >> S;
  for(int i=0; i<S.size(); i+=2){
    if(S[i] != 'h' || S[i+1] != 'i'){
      cout << "No";
      return 0;
    }
  }

  cout << "Yes";
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");
		int a = Integer.parseInt(str[0]);
		int b = Integer.parseInt(str[1]);
		int c = Integer.parseInt(str[2]);
		int x = Integer.parseInt(str[3]);
		int y = Integer.parseInt(str[4]);

		int ab = a * x + b * y;

		int min = 0;
		int max = 0;
		int than = 0;

		if (x > y) {
			min = 2 * y;
			max = 2 * x;
			than = a * (x - y);
		} else {
			min = 2 * x;
			max = 2 * y;
			than = b * (y - x);
		}

		int z = c * min + than;
		int zz = c * max;

		if (ab > z) {
			System.out.println(Math.min(z, zz));
		} else {
			System.out.println(Math.min(ab, zz));
		}
	}
}

Measured memory_bytes: 23380
#define ONLINE_JUDGE
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#define pii pair<int, int>
#define makep make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main0 ();
int main () {
	#ifndef ONLINE_JUDGE
		freopen("C:\\Users\\98497\\Desktop\\code\\file.in", "r", stdin);
	#endif
	ios::sync_with_stdio(false);
	main0();
	#ifndef ONLINE_JUDGE
		fclose(stdin);
	#endif
	return 0;
}

const int INF = 0x3f3f3f3f;
const int N = 1e6;

int a[N];
int dp[N];

int main0 () {
	int n, k;
	cin >> n >> k;
	for (int i = 1;i <= n;i++) {
		cin >> a[i];
	}
	
	memset(dp, INF, sizeof dp);
	dp[1] = 0;
	for (int i = 2;i <= n;i++)
		for (int j = 1;j <= k;j++)
			if (i > j) dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
	cout << dp[n] << endl;
}


Measured memory_bytes: 6400
#include <iostream>
#include <algorithm>
#include <string>
#include <set>

#include <regex>
#include <locale>
#include <iomanip>

using namespace std;
using ll = long long;

#define OVERLOAD3(_1,_2,_3,name,...) name
#define REP(i,n) REPI(i,0,n)
#define REPI(i,a,b) for(int i=int(a),i##_Len=int(b);i<i##_Len;++i)
#define rep(...) OVERLOAD3(__VA_ARGS__,REPI,REP,)(__VA_ARGS__)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())

int main () {
  int a, b, c; cin >> a >> b >> c;
  cout << (a+b<c ? "No" : "Yes") << endl;
}

Measured memory_bytes: 3036