akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

#define imp { cout << "Impossible" << endl; return 0; }
#define pos { cout << "Possible" << endl; return 0; }


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

    int n;
    cin>>n;
    int a[n];
    int d = 0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        d = max(d,a[i]);
    }
    sort(a,a+n);
    int low = (d+1)/2;
    if(a[0] != low) imp;
    int now = 1;
    for(int i=low;i<=d;i++){
        int cnt = 0;
        while(now<n && a[now] == i){
            cnt++;
            now++;
        }
        if(i==low){
            if(d%2 && cnt!=1) imp;
            if(d%2==0 && cnt!=0) imp;
            continue;
        }
        if(cnt<2) imp;
    }
    pos;



}

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

int main() {
  string input;
  map<string, int> mp;
  mp["SUN"] = 0;
  mp["MON"] = 1;
  mp["TUE"] = 2;
  mp["WED"] = 3;
  mp["THU"] = 4;
  mp["FRI"] = 5;
  mp["SAT"] = 6;
  cin >> input;
  cout << 7 - mp[input] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 998244353 
#define pb push_back
#define mb make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main(){
	IOS;
	int n,k; cin >> n >> k;
	int inp[n]; for(int i=0;i<n;i++) cin >> inp[i];
	int dp[n];
	dp[0]=0;
	dp[1]=abs(inp[1]-inp[0]);
	for(int i=2 ; i<n;i++){
		int mn = INT_MAX;
		for(int j = i-1; j >= max(0,i-k) ;j--){
			mn = min(abs(inp[i]-inp[j]) + dp[j] , mn);
			// cout << mn << " ";
		}
		// cout << endl;
		dp[i]=mn;
		// cout << mn << endl;
	}
	cout << dp[n-1] << endl;

	return 0;
}




Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define ll long long
#define lld long double
#define MOD 1000000007LL
#define inf 1000000000000000000ll
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll power(ll x,ll y, ll md=MOD){ll res = 1;x%=md;while(y){if(y&1)res = (res*x)%md;x *= x; if(x>=md) x %= md; y >>= 1;}return res;}
 
using namespace std;

#define endl '\n'
// #define int ll


signed main() {
	fast;

	int h,w,k;
	cin>>h>>w>>k;

	int x1,y1,x2,y2;
	cin>>x1>>y1>>x2>>y2;
	x1--; y1--;
	x2--; y2--;

	vector<vector<char>> mat(h,vector<char>(w,'.'));
	vector<vector<int>> vis(h,vector<int>(w,-1));
	vector<vector<bool>> touch(h,vector<bool>(w,false));

	for(int i=0;i<h;i++) {
		for(int j=0;j<w;j++) cin>>mat[i][j];
	}

	queue<pair<pii,int>> q;
	q.push({{x1,y1},0});

	while(!q.empty()) {
		pii cell;
		int d;
		tie(cell,d) = q.front();
		q.pop();

		if(vis[cell.f][cell.s]!=-1) continue;
		else vis[cell.f][cell.s] = d;

		if(x2==cell.f && y2==cell.s) {
			cout<<d;
			return 0;
		}

		for(int i=1;i<=k;i++) {
			if(cell.f-i < 0) break;
			if(mat[cell.f-i][cell.s]=='@') break;
			if(vis[cell.f-i][cell.s]!=-1) break;
			if(!touch[cell.f-i][cell.s]) q.push({{cell.f-i,cell.s},d+1});
			touch[cell.f-i][cell.s] = 1;
		}

		for(int i=1;i<=k;i++) {
			if(cell.f+i >= h) break;
			if(mat[cell.f+i][cell.s]=='@') break;
			if(vis[cell.f+i][cell.s]!=-1) break;
			if(!touch[cell.f+i][cell.s]) q.push({{cell.f+i,cell.s},d+1});
			touch[cell.f+i][cell.s] = 1;
		}

		for(int i=1;i<=k;i++) {
			if(cell.s-i < 0) break;
			if(mat[cell.f][cell.s-i]=='@') break;
			if(vis[cell.f][cell.s-i]!=-1) break;
			if(!touch[cell.f][cell.s-i]) q.push({{cell.f,cell.s-i},d+1});
			touch[cell.f][cell.s-i] = 1;
		}

		for(int i=1;i<=k;i++) {
			if(cell.s+i >= w) break;
			if(mat[cell.f][cell.s+i]=='@') break;
			if(vis[cell.f][cell.s+i]!=-1) break;
			if(!touch[cell.f][cell.s+i]) q.push({{cell.f,cell.s+i},d+1});
			touch[cell.f][cell.s+i] = 1;
		}
	}

	cout<<vis[x2][y2];

}

Measured memory_bytes: 11964
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery

#define eps 1e-12
#define M_PI 3.141592653589793
#define bsize 300

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 200031;

long long A[3031][3031];
int n,tests,ar[N];
int last_mod[N];
long long pw[N];
int T;

long long inv2;

void eval(int id){
	for (int i=1;i<=n;i++){
		A[id][i]=A[id][i]*pw[T-last_mod[id]];
		A[id][i]%=bs;
	}
	last_mod[id]=T;
}

long long P(long long a,long long b){
	if (b==0)
		return 1;
	if (b%2)
		return a*P(a,b-1)%bs;
	return P(a*a%bs,b/2);
}

long long inv(long long x){
	return P(x,bs-2);
}

int main(){
//    freopen("apache.in","r",stdin);
//    freopen("apache.out","w",stdout);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    //cin.tie(0);

    pw[0]=1;
    for (int i=1;i<N;i++){
    	pw[i]=pw[i-1]*2%bs;
    }

    inv2=inv(2);

    cin>>n>>tests;
    for (int i=1;i<=n;i++){
    	cin>>ar[i];
    }

    for (int i=1;i<=n;i++){
    	for (int j=1;j<=n;j++){
    		if (ar[i]>ar[j])
    			A[i][j]=1;
    	}
    }

    for (int i=1;i<=n;i++){
    	last_mod[i]=0;
    }

    for (int test=1;test<=tests;test++){
    	int a,b;
    	cin>>a>>b;
    	for (int i=1;i<=n;i++){
    		if (i!=a&&i!=b){
    			long long here=A[a][i]+A[b][i];
    			here=here*inv2;
    			here%=bs;
    			A[a][i]=A[b][i]=here;
    			here=A[i][a]+A[i][b];
    			here=here*inv2;
    			here%=bs;
    			A[i][a]=A[i][b]=here;
    		}
    	}
    	long long here=A[a][b]+A[b][a];
    	here=here*inv2;
    	here%=bs;
    	A[a][b]=A[b][a]=here;
    }


    long long ans=0;

    for (int i=1;i<=n;i++){
    	for (int j=i+1;j<=n;j++){
    		long long here=A[i][j]*pw[tests];
    		here%=bs;
    		ans+=here;//    		cout<<A[i][j]*pw[tests]%bs<<" ";
    		ans%=bs;
    	}
//    	cout<<endl;
    }

    cout<<ans<<endl;

//    cin.get(); cin.get();
    return 0;
}


Measured memory_bytes: 73984
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    ll n;
    cin >> n;
    vector<ll>a(n);
    for(int i=0;i<n;i++){
        cin >> a.at(i);
    }
    ll ans = 1000, kabu =0;
    for(int i=1;i<n;i++){
        if(a.at(i-1)<a.at(i)){
            kabu+= ans/a.at(i-1);
            ans-= ans/a.at(i-1)*a.at(i-1);
        }
        else{
            ans+= kabu*a.at(i-1);
            kabu =0;
        }
    }
    ans+=kabu*a.at(n-1);
    cout<<ans<<endl;
}
    



Measured memory_bytes: 3644
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        long n = in.ni(),  m = in.ni();
        out.println(Math.max(comb(n, 2),0)+Math.max(+comb(m, 2),0));
    }
    public static long comb(long a, long b){
        if(a < b) return -1;
        long res = 1;
        long inv = pow(fact(Math.min(b, a-b)), mod-2);
        for(long i = a; i > a - Math.min(b, a-b); i--) {
            res *= i;
            res %= mod;
        }
        res *= inv;
        res %= mod;
        return res;
    }
    public static long pow(long x, long n){
        long res = 1;
        while(n > 0){
            if ((n & 1) == 1) {
                res *= x;
                res %= mod;
            }
            x *= x;
            x %= mod;
            n >>= 1;
        }
        return res;
    }
    public static long fact(long n){
        long res = 1;
        while(n > 0){
            res *= n;
            res %= mod;
            n--;
        }
        return res;
    }
    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

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

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

    int n;
    cin >> n;
    multimap<ll, ll> m;
    rep(i,n){
        ll a,b;
        cin >> a >> b;
        m.insert(make_pair(b,a));
    }
    
    ll sum = 0;
    bool flag = true;
    
    for(auto itr=m.begin(); itr!=m.end(); itr++){
      auto key = itr->first;
      auto value = itr->second;
        sum += value;
        
        if(sum > key){
            flag = false;
        }
    }
    
    cout << ((flag)? "Yes" : "No") << endl;;

    return 0;
}

Measured memory_bytes: 12800
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <math.h>
using namespace std;

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

	if (R < 1200)
		cout << "ABC" << endl;
	else if (R < 2800)
		cout << "ARC" << endl;
	else
		cout << "AGC" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll INF = 1LL<<60;
/////////////////////////////////
int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll A, B, C, D;
    A = a * c;
    B = a * d;
    C = b * c;
    D = b * d;
    A = max(A, max(B, max(C, D)));
    cout << A << endl;
}

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-

n = int(input())
al = list(map(int, input().split()))

m = 10**10
c = 0
s = 0
for a in al:
    m = min(m, abs(a))
    s += abs(a)
    if a<0:
        c += 1

if c%2==0:
    print(s)
else:
    print(s-2*m)


Measured memory_bytes: 14412
h,w = map(int,input().split())
n = int(input())
a = list(map(int,input().split()))

ans = []
for i,ai in enumerate(a,1):
    ans += [i]*ai

for i in range(h):
    tmp = ans[i*w:(i+1)*w]
    if(i%2==0):
        print(' '.join(map(str,tmp)))
    else:
        print(' '.join(map(str,tmp[::-1])))

Measured memory_bytes: 71208
package main

import "fmt"

func main() {
	nums := make([]int, 4)
	for i:=0; i<len(nums); i++{
		fmt.Scan(&nums[i])
	}

	max := -1000000000000000000
	for i:=0; i<2; i++{
		if max <= nums[i] * nums[2]{
			max = nums[i] * nums[2]
		}
		if max <= nums[i] * nums[3]{
			max = nums[i] * nums[3]
		}
	}
	fmt.Println(max)
}

Measured memory_bytes: 1768
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <cassert>
#include <queue>
#include <ctime>
#include <string>
#include <cstring>
#include <random>
#define mp make_pair
#define pb push_back
#define NAME ""
#define y1 y1_423
#define list lista

using namespace std;

typedef long long ll;
typedef long double ld;

template<typename T>
ostream& operator << (ostream& cout, const vector<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "()");
	}
	cout << "(" << a[0];
	for (int i = 1; i < (int)a.size(); i++) {
		cout << "; " << a[i];
	}
	return (cout << ")");
}

template<typename T>
ostream& operator << (ostream& cout, const set<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T>
ostream& operator << (ostream& cout, const multiset<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T1, typename T2>
ostream& operator << (ostream& cout, const pair<T1, T2> &a) {
	return cout << "(" << a.first << "; " << a.second << ")";
}

random_device gen;
mt19937 rnd(gen());

const int nmax = 2000 * 1000;
const int inf = 2000 * 1000 * 1000;
const ll infl = 1000ll * 1000ll * 1000ll * 1000ll * 1000ll * 1000ll;
const int mod = 1000 * 1000 * 1000 + 7;
const ld pi = acos(-1.0);

int n;
ll a[nmax];

int main() {
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	//freopen(NAME".in", "r", stdin);freopen(NAME".out", "w", stdout);
	cin >> n;
	ll s1 = 0, s2 = 0;
	for (int i = 0; i < n; i++) {
		scanf("%lld", a + i);
		s2 += a[i];
	}
	ll answer = infl;
	for (int i = 0; i < n - 1; i++) {
		s1 += a[i];
		s2 -= a[i];
		answer = min(answer, abs(s1 - s2));
	}
	cout << answer << endl;
	return 0;
}


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

int main()
{
    int n;
    cin>>n;
    vector <int> v(n+1,0);
    long long ans =0;
    for(int i =1;i<=n;i++)
    {   for(int j = 0;j<=n;j+=i)
        v[j]++;
    }
    for(int i = 1;i<=n;i++)
    ans+=i*(long long)v[i];
    cout<<ans<<endl;
    return 0;   
}

Measured memory_bytes: 42332
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-9;
const ll MOD=1000000007LL;
int main(){
    int h,w,k;cin>>h>>w>>k;
    vector<vector<ll>> dp(h+10,vector<ll>(w+10,0));
    vector<ll> dp2(w+10,0);
    dp2[0]=1;
    dp2[1]=2;
    for(int i=2;i<=w;i++)dp2[i]=dp2[i-1]+dp2[i-2];
    dp[0][1]=1;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(j>1)dp[i][j]+=dp[i-1][j-1]*(j==2?1:dp2[j-3])%MOD*(j==w?1:dp2[w-j-1])%MOD;
            if(j<w)dp[i][j]+=dp[i-1][j+1]*(j==1?1:dp2[j-2])%MOD*(j==w-1?1:dp2[w-j-2])%MOD;
            dp[i][j]+=dp[i-1][j]*(j==1?1:dp2[j-2])%MOD*(j==w?1:dp2[w-j-1])%MOD;
            dp[i][j]%=MOD;
        }
    }
    cout<<dp[h][k]<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<complex>
#include<vector>

using namespace std;

int nx[]={0,1,0,-1};
int ny[]={0,1,0,-1};
//*****************************************


int main(void){

    int a,b,c;
    scanf("%d",&a);
    scanf("%d",&b);

    int coin=max({a*2-1,a+b,b*2-1});

    cout << coin<<endl;

    return 0;
}





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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int n;
    string s, t;
    cin >> n;
    cin >> s >> t;

    for(int i=0; i<n; i++){
        cout << s[i] << t[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

while True:
    n = int(raw_input())
    island = []
    if n == 0:
        break
    for i in range(n):
        g,b = map(int,raw_input().split())
        island.append((g,b))
    island = sorted(island,key = lambda x:(x[1],x[0]))
    
    gem = 0
    for g,b in island:
        gem += g
        if b < gem:
            break
    else:
        print 'Yes'
        continue
    print 'No'
        

Measured memory_bytes: 4224
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;
string X;
string Y;
int lcs[1002][1002];
int calLcs() {
	int i = 1;
	int j = 1;
	int m = Y.size();
	int n = X.size();
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= m; j++) {
			if (X[i - 1] == Y[j - 1]) {
				lcs[i][j] = lcs[i - 1][j - 1] + 1;
			}
			else {
				lcs[i][j] = max(lcs[i - 1][j], lcs[i][j - 1]);
			}
		}
	}
	return lcs[n][m];
}
int main() {
	int n;
	cin >> n;
	while (n--) {
		cin >> X;
		cin >> Y;
		cout << calLcs() << endl;
	}
}




Measured memory_bytes: 7112
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	/*int s, w;
	cin >> s >> w;
	if (w >= s)puts("unsafe");
	else puts("safe");*/


	/*int a, b, c, d;
	cin >> a >> b >> c >> d;
	if ((c + b - 1) / b <= (a + d - 1) / d)puts("Yes");
	else puts("No");*/


	int n;
	string s;
	set<string> st;
	cin >> n;
	rep(i, n) {
		cin >> s;
		st.insert(s);
	}
	cout << st.size();
	return 0;
}

Measured memory_bytes: 15724
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();

		String str = Integer.toString(r) + Integer.toString(g) + Integer.toString(b);

		System.out.println(Integer.parseInt(str) % 4 == 0 ? "YES" : "NO");
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int main() {
    int N = 1407;
    int K = 38;
    vector<vector<int>> ret(N,vector<int>(K));
    for(int i = 0;i < K;i++) {
        ret.at(0).at(i) = i + 1;
    }
    for(int i = 1;i < N;i++) {
        ret.at(i).at(0) = (i + (K - 1) - 1) / (K - 1);
    }
    int A = K + 1;
    for(int i = 1;i < N;i++) {
        for(int j = 1;j < K;j++) {
            ret.at(i).at(j) = A;
            A++;
        }
        if(A == N + 1) {
            break;
        }
    }
    A = K + 1;
    for(int i = 1;i < K;i++) {
        vector<int> vec(K - 1);
        for(int j = 0;j < K - 1;j++) {
            vec.at(j) = A;
            A++;
        }
        for(int j = 0;j < K - 1;j++) {
            int B = K;
            int C = j;
            for(int k = 0;k < K - 1;k++) {
                ret.at(B + C).at(i) = vec.at(j);
                C = (C + i - 1) % (K - 1);
                B += K - 1;
            }
        }
    }
    cout << N << " " << K << endl;
    for(int i = 0;i < N;i++) {
        for(int j = 0;j < K;j++) {
            cout << ret.at(i).at(j) << " ";
        }
        cout << endl;
    }
}

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

int main() {
    int N;
    std::cin >> N;

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

    std::sort(A.begin(), A.end(), [](auto &lhs, auto &rhs) { return lhs < rhs; });
    std::sort(B.begin(), B.end(), [](auto &lhs, auto &rhs) { return lhs > rhs; });

    if (N % 2 == 0) {
        int idx0 = N / 2 - 1;
        int idx1 = idx0 + 1;
        std::cout << ((B[idx0] + B[idx1]) - (A[idx0] + A[idx1])) + 1 << std::endl;
    } else {
        int idx = (N - 1) / 2;
        std::cout << (B[idx] - A[idx]) + 1 << std::endl;
    }
}


Measured memory_bytes: 4844
/**
	������������ Author : Avi J Patel ������������
	������������ University : DA-IICT ������������
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair 
#define mt make_tuple
#define N 100000
#define ff first
#define ss second
#define si size()
#define MOD 1000000007
#define large 10000000000000001

#define For(i,m,n) for(long long i=m;i<n;i++)
#define st(x) sort(x.begin(),x.end())
#define re(x,i) reverse(x.begin()+i,x.end())
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

/*bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} */
/*void calc()
{
	for(int i=0;i<2005;i++)
	{
		a[i][0]=1;
		a[i][i]=1;
		for(int j=1;j<i;j++)
		{
			a[i][j]=(a[i-1][j-1]+a[i-1][j])%MOD;	
		}
	}
}*/
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=n-1;i>=0;i--)
	{
		cout<<k-i<<" ";
	}
	for(int i=1;i<n;i++)
	{
		cout<<k+i<<" ";
	}
	return 0;
}











Measured memory_bytes: 256
import math
A, B, K = map(int, input().split())
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
divisors = make_divisors(math.gcd(A, B))
divisors.sort(reverse=True)
print(divisors[K-1])

Measured memory_bytes: 9216
/*
*          Name : chaitanya
*
*     Institute : ANITS,Visakhapatnam
*
*/
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1e9+1
#pragma GCC optimization ("O3")
using namespace std;
const long long int N = 6999999;
#define all(x) begin(x),end(x)
int main()
{
 
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 int n;
 cin >> n;
 vector <int> v(n);
 int ans = 0;
 for (int i = 0; i < n; ++i)
 {
  cin >> v[i];
 }
 sort(v.begin(),v.end());
 ans = v[n/2]-v[(n-1)/2];
 cout << ans;
  return 0;
}


Measured memory_bytes: 768
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<ll> P(A), Q(B), R(C);
    rep(i, A) cin >> P[i];
    rep(i, B) cin >> Q[i];
    rep(i, C) cin >> R[i];
    priority_queue<pll> pq;
    rep(i, A) pq.push(MP(P[i], 1));
    rep(i, B) pq.push(MP(Q[i], 2));
    rep(i, C) pq.push(MP(R[i], 3));
    int xcnt = 0, ycnt = 0, zcnt = 0;
    ll res = 0;
    while(1) {
        if(xcnt + ycnt + zcnt == X + Y) {
            break;
        }
        pll p = pq.top();
        pq.pop();
        if(p.second == 1) {
            if(xcnt < X) {
                res += p.first;
                xcnt++;
            }
        } else if(p.second == 2) {
            if(ycnt < Y) {
                res += p.first;
                ycnt++;
            }
        } else {
            res += p.first;
            zcnt++;
        }
    }
    cout << res << endl;
    return 0;
}

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

ll n, m, ans;

inline ll read(){
	ll s = 0, w = 1;
	char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

inline void work(){
	n = read(), m = 101;
	for (ans = 1; m < n; ++ans, m += m * 0.01 * 1ll);
	printf("%lld\n", ans);
}

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

Measured memory_bytes: 3764
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
	while (true) {
		int a, b;
		cin >> a >> b;
		if (cin.eof()) break;
		int sum = a + b;
		int res = 1;
		while (sum >= 10) {
			res ++;
			sum /= 10;
		}
		cout << res << "\n";
	}
    return 0;
}

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

int main(){
	int a,b;
	cin>>a>>b;

	int df = b-a;

	for(int i = 2;i <= 999;i++){
		int tdf = i*(i+1)/2 - i*(i-1)/2;
		if(df == tdf){
			int tmp = i*(i-1)/2;
			cout<<tmp - a;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main(void) {
    int N;
    int64_t D;
    cin >> N >> D;

    int ans = 0;
    while(N--) {
        int64_t X, Y;
        cin >> X >> Y;
        if(X*X + Y*Y <= D*D) ++ans;
    }

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


Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int get_digit(int m)
{ 
  int key=0;
  while(m>0)
  {
      key++;
      m=m/10;
  }
  return key;
}
int main()
{
  int n;
  cin>>n;
  int sum=0;
  for(int i=1;i<=n;i++)
  {
     int j = get_digit(i);
    if(j%2 == 1)
    {
      sum++;
    }
      
  }
  cout <<sum<<endl;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    a = map(int, input().split())
    ans = 0
    for i in a:
        while i % 2 == 0:
            i //= 2
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 40688
#include <iostream>
#include <iostream>
#include <cstdlib>
#include <string>
#include <typeinfo>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
typedef struct{
  double x;
  double y;
} P;
void kock(int n, P p1, P p2){
  P s,t,u;
  if (n == 0) return;
  s.x = ((2*p1.x)+(1*p2.x))/3;
  s.y = ((2*p1.y)+(1*p2.y))/3;
  t.x = ((1*p1.x)+(2*p2.x))/3;
  t.y = ((1*p1.y)+(2*p2.y))/3;
  u.x = (t.x - s.x)*cos(M_PI/3)-(t.y - s.y)*sin(M_PI/3)+s.x;
  u.y = (t.x - s.x)*sin(M_PI/3)+(t.y - s.y)*cos(M_PI/3)+s.y;
  kock(n-1,p1,s);
  cout << s.x << " " << s.y << endl;
  kock(n-1,s,u);
  cout << u.x << " " << u.y << endl;
  kock(n-1,u,t);
  cout << t.x << " " << t.y << endl;
  kock(n-1,t,p2);
}
int main(){
  int n;
  P p1 = {0,0};
  P p2 = {100,0};
  cin >> n;
  cout << p1.x << " " << p1.y << endl;
  kock(n,p1,p2);
  cout << p2.x << " " << p2.y << endl;
  return 0;
}


Measured memory_bytes: 3292
n,k = map(int, input().split())
mod = 10**9 + 7

nums = set()
d = {}
for i in range(1,10**6):
    a = n//i
    b = 1 + n//(i+1)
    d[i] = a
    nums.add(i)
    nums.add(a)
    if(i >= b):
        break
    d[b] = i
    nums.add(b)

d = sorted(d.items())

dic_en = {}
dic_de = {}
nums = sorted(list(nums))
cnt = [0] * len(nums)
done = 0
for i,num in enumerate(nums):
    dic_en[num] = i
    dic_de[i] = num
    cnt[i] = num - done
    done = num

d = []
for num in nums:
    d.append((dic_en[num],  dic_en[n//num]))

op = cnt[::]

def update(op):
    n = len(nums)
    res = [0] * (n+1)
    for a,b in d:
        res[0] += op[a]
        res[b+1] -= op[a]
    res[0] %= mod
    for i in range(1,n):
        res[i] += res[i-1]
        res[i] %= mod
    for i in range(n):
        res[i] *= cnt[i]
        res[i] %= mod
    return res[:-1]

for i in range(k-1):
    op = update(op)

ans = sum(op) % mod

print(ans)

Measured memory_bytes: 136088
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
signed main()
{
   SPEED;
   int n;
   cin>>n;
   vector <string> s(n);
   vector <pair <int,int> > s1,s2;
   for(int i=0;i<n;i++)
   {
       cin>>s[i];
   }
   int a[n][2];
   memset(a,0,sizeof(a));
   for(int i=0;i<n;i++)
   {
       int c6=0,c9=0;
       for(int j=0;j<s[i].size();j++)
       {
           if(s[i][j]=='(')
           {
               ++c6;
           }
           else
           {
               ++c9;
           }
           a[i][0]=max(a[i][0],c9-c6);
       }
   }
   for(int i=0;i<n;i++)
   {
       int c6=0,c9=0;
       for(int j=s[i].size()-1;j>=0;j--)
       {
           if(s[i][j]=='(')
           {
               ++c6;
           }
           else
           {
               ++c9;
           }
           a[i][1]=max(a[i][1],c6-c9);
       }
   }
   int dif=0;
   for(int i=0;i<n;i++)
   {
       if(a[i][1]-a[i][0]>=0)
       {
           s1.push_back({a[i][0],a[i][1]});
       }
       else
       {
           s2.push_back({a[i][1],a[i][0]});
       }
   }
   sort(s1.begin(),s1.end());
   sort(s2.rbegin(),s2.rend());
   for(int i=0;i<s1.size();i++)
   {
       dif-=s1[i].first;
       if(dif<0)
       {
           cout<<"No";
           return 0;
       }
       dif+=s1[i].second;
   }
   for(int i=0;i<s2.size();i++)
   {
       dif-=s2[i].second;
       if(dif<0)
       {
           cout<<"No";
           return 0;
       }
       dif+=s2[i].first;
   }
   if(dif==0)
   cout<<"Yes";
   else
   cout<<"No";
}

Measured memory_bytes: 65960
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define print(x) cout << x << endl;
using namespace std;
typedef long long ll;

int main()
{
    int N;
    double A;
    cin >> N;

    double div = 0.0;

    rep(i, N) {
        cin >> A;
        div += 1.0 / A;
    }

    cout << setprecision(16) << 1.0 / div << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/ruby
#http://www.checkio.org/mission/spaceship-landing-strip/ verifier.

def checkio(data)
	y=data.size
	x=data[0].size
	m=Array.new(y){[0]*x}
	y.times{|j|
		r=0
		x.times{|i|
			#if data[j][i,1]=='.'
			if data[j][i]==1
				r+=1
			else
				r=0
			end
			m[j][i]=r
		}
	}
	r=0
	x.times{|i|
		y.times{|j|
			ma=9999999
			j.step(y-1){|k|
				ma=[ma,m[k][i]].min
				r=[r,ma*(k-j+1)].max
			}
		}
	}
	r
end

if $0==__FILE__
	if false
		while(y,x=gets.split.map(&:to_i))!=[0,0]
			data=y.times.map{gets.chomp}
			puts checkio(data)
		end
	else
		gets.to_i.times{
			data=5.times.map{gets.split.map(&:to_i)}
			puts checkio(data)
			gets
		}
	end
end

Measured memory_bytes: 6124
s=input()
t=input()
l=len(s)
sl=[]
tl=[]
slist=[0]*26
tlist=[0]*26
flag=0
sabc=''
tabc=''
for i in range(l):
    sb=not s[i] in sabc
    tb=not t[i] in tabc
    if sb:
        sabc+=s[i]
    else:
        slist[sabc.find(s[i])]+=1
    if tb:
        tabc+=t[i]
    else:
        tlist[tabc.find(t[i])]+=1
    
    if slist!=tlist:
        flag=1
        break
if flag==1:
    print('No')
else:
    print('Yes')

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    int add = a + b;
    int ans = 6 - add;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
spl = ""
cnt1 = 0
cnt2 = 0

for i in range(len(s)):
    if i % 2 == 0:
        spl += "1"
    else:
        spl += "0"
    
    if s[i] == spl[i]:
        cnt1 += 1

cnt2 = len(s) - cnt1

if cnt1 < cnt2: print(cnt1)
else: print(cnt2)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int N, A;
	cin >> N;
	cin >> A;
	int five = N / 500;
	if (N - five * 500 <= A)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = list(map(int, input().split()))
    BUKA = [0]*N
    for i in range(N-1):
        BUKA[A[i]-1] += 1
    for i in BUKA:
        print(i)

if __name__ == '__main__':
    main()


Measured memory_bytes: 91392
S = input()

count = 0

if S[0] == "A":
    count += 1
    
count_c = 0
for i in range(2, len(S)-1):
    if S[i] == "C":
        count_c += 1
if count_c == 1:
    count += 1
    
count_upper = 0
for i in range(len(S)):
    if S[i].isupper() == True:
        count_upper += 1
if count_upper == 2:
    count += 1
    
if count == 3:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3064
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	s := scanString()

	c := map[rune]int{}
	for _, e := range s {
		c[e]++
	}

	f := true
	for _, e := range c {
		if len(s)/3 < e {
			if (len(s)+2)/3 >= e {continue}
			f = false
		}
	}

	if f {
		fmt.Fprintln(wr, "YES")
	} else {
		fmt.Fprintln(wr, "NO")
	}
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N,M;
    cin >> N >> M;
    vector<bool> ok(N);
    vector<int> cnt(N,1);
    ok[0] = true;
    for(int i = 0; i < M; i++) {
        int x,y;
        cin >> x >> y;
        x--;y--;
        if(cnt[x] == 1) {
            if(ok[x] == true) {
                ok[x] = false;
                ok[y] = true;
            }
        }
        else {
            if(ok[x] == true) {
                ok[y] = true;
            }
        }
        cnt[x]--;
        cnt[y]++;
    }
    int ans = 0;
    for(int i = 0; i < N; i++) {
        if(ok[i]) {
            ans++;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

const int N = 5e5 + 10;

int n, k, a[N], pos[N], deg[N], ans[N];
vector<int> g[N];

#define LD (t << 1)
#define RD (t << 1 | 1)

int val[N << 2];

void build(int t, int l, int r) {
  val[t] = n + 1;
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(LD, l, mid);
  build(RD, mid + 1, r);
}

void insert(int t, int l, int r, int pos, int vl) {
  val[t] = min(val[t], vl);
  if (l == r) return;
  int mid = (l + r) >> 1;
  if (pos <= mid) insert(LD, l, mid, pos, vl);
  else insert(RD, mid + 1, r, pos, vl);
}

int query(int t, int l, int r, int  ql, int qr) {
  if (ql > qr) return n + 1;
  if (ql <= l && r <= qr) return val[t];
  int mid = (l + r) >> 1, res = n + 1;
  if (ql <= mid) res = min(res, query(LD, l, mid, ql, qr));
  if (qr > mid) res = min(res, query(RD, mid + 1, r, ql, qr));
  return res;
}

int main() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    pos[a[i]] = i;
  }
  build(1, 1, n);
  // for (int i = 1; i <= n; i++) {
  //   printf("%d ", pos[i]);
  // }
  // puts("");
  for (int i = n; i >= 1; i--) {
    int l = query(1, 1, n, max(1, pos[i] - k + 1), pos[i] - 1);
    int r = query(1, 1, n, pos[i] + 1, min(n, pos[i] + k - 1));
    // cout<<i<<" "<<l<<" "<<r<<endl;
    if (r <= n) {
      g[pos[i]].push_back(pos[r]);
      deg[pos[r]]++;
    }
    if (l <= n) {
      g[pos[i]].push_back(pos[l]);
      deg[pos[l]]++;
    }
    insert(1, 1, n, pos[i], i);
  }
  int cur = 0;
  priority_queue<int, vector<int>, greater<int> > q;
  for (int i = 1; i <= n; i++) {
    if (!deg[i]) {
      q.push(i);
    }
  }
  while (q.size()) {
    int u = q.top(); q.pop();
    ans[u] = ++cur;
    for (auto v : g[u]) {
      if (!(--deg[v])) {
        q.push(v);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}

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

int main(){
    int N, M, X;
    cin >> N >> M >> X;
    int a[M];
    for(int i = 1; i <= M; i++){
        cin >> a[i];
    }

    int count = 0;
    int ans = 0;
    for(int i = 1; i <= M; i++){
        if(a[i] > X){
            count++;
        }
        if(a[i] < X){
            ans++;
        }
    }

    cout << min(count, ans) << endl;

}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;



Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}



void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){

    y=x;
    if(z->key<x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }
  else{
    if(z->key<y->key){
      y->left=z;
    }
    else{
      y->right=z;
    }
  }
}

void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

void preorder(Node u){
  if(u==NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25140
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;cin>>s;
  int a=0,z=0;
  for(int i=0;i<s.size();i++)if(s[i]=='A'){a=i;break;}
  for(int i=0;i<s.size();i++)if(s[i]=='Z')z=i;
cout<<z-a+1;
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 100010
/*------------------------------------------------------------*/
int n,m;
int main(){
	in(n);
	int m=n;
	int ans=0;
	while(m){
		ans+=m%10;
		m/=10;
	}
	if(n%ans==0)outy;
	 else outn;
}
	

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

	int h, w, a, b;
	while(1){
		scanf("%d %d", &h, &w);
		if(h == 0 && w == 0){
			break;
		}
		
		for(a = 0; a < h; a++){
			for(b = 0; b < w; b++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

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

#define PI 3.14159265359

using namespace std;

int main(void){
	double a,b,x;
	cin >> a >> b >> x;
	double c,s,t;
	double ans;
	double p = 180.0/PI;
	x = x/a;
	if( a*b/2 == x){
		ans = 45.0;
	}
	else if(a*b/2 > x){
		//cout<<"-------------------"<<endl;
		t = b*b/2/x;
		//cout<<"t = "<<t<<endl;
		ans = atan(t);
		ans = ans * p;
	}
	else{
		//cout<<"^^^^^^^^^^^^^^^^^^^"<<endl;
		t = 2*(a*b - x)/a/a;
		//cout<<"t = "<<t<<endl;
		ans = atan(t);
		ans = ans*p;
	}
	
	printf("%lf\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long LL;

int n;
LL a, b, ans;

int main() {
	scanf("%d%lld%lld", &n, &a, &b);
	
	int lst, now;
	scanf("%d", &lst);
	for (int i = 2; i <= n; i ++) {
		scanf("%d", &now);
		ans += min(1ll * a * (now - lst), b);
		lst = now;
	}
	printf("%lld", ans);
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

vi ans;
ll n;

void solve(ll ind,ll x,ll d)
{
	if(ans.size()>=n)
		return;
	if(ind==0)
	{
		return;
	}
	if(ind==1)
	{
		x=x*10+d;
		ans.pb(x);
		return;
	}
	x=x*10+d;
	if(d==0)
	{
		solve(ind-1,x,0);
		solve(ind-1,x,1);
		return;
	}
	if(d==9)
	{
		solve(ind-1,x,8);
		solve(ind-1,x,9);
		return;
	}
	else
	{
		solve(ind-1,x,d-1);
		solve(ind-1,x,d);
		solve(ind-1,x,d+1);
	}
}

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
    	ll i,j,k,l,m;
    	cin>>n;
    	for(i=1;i<=20;i++)
    	{
    		if(ans.size()>=n)
    			break;
    		for(j=1;j<=9;j++)
    		{
    			solve(i,0,j);
    		}
    	}
    	// cout<<ans;
    	cout<<ans[n-1];
    }
    return 0;
}

Measured memory_bytes: 1400
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    let r: i64 = buf.trim().parse().ok().unwrap();
    solve(r);
}

fn solve(r: i64) {
    if r < 1200 {
        println!("ABC");
    } else if r < 2800 {
        println!("ARC");
    } else {
        println!("AGC");
    }
}


Measured memory_bytes: 4352