akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

// long version
long long int GCD(long long int x, long long int y){
    if(x>y){
        long long int swap = x;
        x = y;
        y = swap;
    }
    while(true){
        if(y%x==0){
            return x;
        }else{
            long long int amari = y%x;
            y = x;
            x = amari;
        }
    }
}

int main() {
    ll a,b,c,d;cin >> a >> b >> c >> d;
    ll ans = b-a+1 - (b/c-(a-1)/c) - (b/d-(a-1)/d) + b/(c*d/GCD(c,d)) - (a-1)/(c*d/GCD(c,d));
    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
// Date: 2020-01-22

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define SZ(x) x.size()
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 10;
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int ans[N];
int main() {
	FIO;
	int n, k, s;
	cin >> n >> k >> s;
	rep(i, 1, k) ans[i] = s;
	int mx = 1e9;
	if(s < mx) rep(i, k+1, n) ans[i] = mx;
	else rep(i, k+1, n) ans[i] = 1;
	cout << ans[1];
	rep(i, 2, n) cout << " " << ans[i];

	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
typedef long long LL;
#define FOR(i, a, b) for(LL i=(LL)(a);i<(LL)(b);i++)
#define REP(i,x) for(LL i=0;i<(LL)(x);i++)

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

    string S;
    cin >> S;
    LL Q;
    cin >> Q;

    bool rev_flag = false;

    deque<char> str;
    for(auto x : S)
    {
        str.push_back(x);
    }

    REP(i, Q)
    {
        int T;
        LL F;
        char C;

        cin >> T;
        switch(T)
        {
            case 1:
            {
                rev_flag = !rev_flag;
                break;
            }

            case 2:
            {
                cin >> F >> C;
                if(rev_flag)
                {
                    F = 3 - F;
                }
                if(F == 1)
                {
                    str.push_front(C);
                }
                else
                {
                    str.push_back(C);
                }
                break;
            }
        }
    }
    string s_str;
    if(!rev_flag)
    {
        for(auto it : str)
        {
            // cout << it;
            s_str.push_back(it);
        }
    }
    else
    {
        for(auto it=str.end(); it != str.begin(); it--)
        {
            auto temp = it - 1;
            s_str.push_back(*temp);
            // cout << *temp;
        }
    }
    cout << s_str << endl;
    return 0;
}

Measured memory_bytes: 1368
// time-limit: 2000
// 23
#include <bits/stdc++.h>
using namespace std;
#define coutc "\033[48;5;196m\033[38;5;15m"
#define endc "\033[0m"
#define endl '\n'
#define M(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) \
  M(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep4(_, x, n, s) \
  for (int _ = x; (s < 0) ? _ > n : _ < n; _ += s)
#define rep3(_, x, n) rep4(_, x, n, (x < n ? 1 : -1))
#define rep2(_, n) rep3(_, 0, n)
#define rep1(n) rep2(i, n)
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define len(x) int(x.size())
#define lli __int128_t
#define li long long int
#define ld long double
#ifdef DEBUG
// 3
ostream &operator<<(ostream &o, pair<auto, auto> p) {
  return o << "(" << p.fi << ", " << p.se << ")";
}
// 4
ostream &operator<<(ostream &o, vector<auto> v) {
  rep(i, len(v)) o << setw(7) << right << v[i];
  return o << endc << endl << coutc;
}
// 4
ostream &operator<<(ostream &o, map<auto, auto> m) {
  for (auto &kv : m) o << kv;
  return o;
}
// 7
void debug(const auto &e, const auto &... r) {
  cout << coutc << e;
  ((cout << " " << r), ..., (cout << endc << endl));
}
#else
#define debug(...)
#endif

int sign(li x) { return x < 0 ? -1 : x > 0; }

//         a / b
li ceil(li a, li b) {
  if (sign(a) == sign(b) && a % b) return a / b + 1;
  else return a / b;
}

void _main(int tc) {
    int a, b;
    cin >> a >> b;

    if (b == 1) {
        cout << 0 << endl;
        return;
    }
    
    if (b <= a) {
        cout << 1 << endl;
        return;
    }

    // b = a + (a - 1) * X
    // X = (b - a) / (a - 1)
    // is ceiling because we need to assure that with X pipes we complete "b - a" lines.
    // we add one because after fullfilling "b - a" we still need to complete with "a" lines.
    cout << ceil(b - a, a - 1) + 1 << endl;
}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
//================================================

int a = 0, b = 0, c, d, n, k = 0;
string s, t;



int main()
{
	double t, x;
	cin >> t >> x;
	printf("%.7f\n", t / x);

	return 0;
}

Measured memory_bytes: 256
N = int(input())
A_list = list(map(int,input().split()))

count = 0

while True:
  is_odd = False
  for i in range(N):
    if A_list[i]%2 != 0:
      is_odd = True
  if is_odd == True:
      break
  for i in range(N):
    A_list[i] /= 2
  count += 1
        
print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define LIM 200005
#define ll long long int


using namespace std;

int n;
ll a[LIM], b[LIM], p[LIM], q[LIM];

int main() {
    scanf("%d", &n);
    for(int i=0; i<n; i++) {
        scanf("%d", &a[i]);
        b[i] = i - a[i];
    }

    sort(b, b+n);

    ll ans = 0;
    for(int i=0; i<n; i++) ans += abs(b[i]);

//    cout << ans << endl;

    p[0] = b[0]; for(int i=1; i<n; i++) p[i] = p[i-1] + b[i];
    q[n-1] = b[n-1]; for(int i=n-2; i>=0; i--) q[i] = q[i+1] + b[i];

//    ans = min(ans, i*b[0]- )

    for(int i=0; i<n; i++) {
        ans = min(ans, q[i]-(n-i)*b[i] + (i+1)*b[i]-p[i] );
//        cout << i << ' ' << b[i] << ' ' << p[i] << ' ' << q[i]-(n-i)*b[i] + (i+1)*b[i]-p[i] << endl;
    }

    cout << ans << endl;
}


Measured memory_bytes: 6528
#include<stdio.h>

int dijkstra(int, int, int, int, int[][100]);

int main(void)
{
	int f1, f2, n, m, a, b, ic, ti, k, p, q, r, out, cost[100][100], time[100][100];

	while(scanf("%d %d",&n,&m) && n > 0)
	{

		//線路設計
		for(f1 = 0; f1 < m; f1++)
		{
			for(f2 = 0; f2 < m; f2++)
			{
				cost[f1][f2] = 0;
				time[f1][f2] = 0;
			}
		}
		//線路情報入力
		for(f1 = 0; f1 < n; f1++)
		{
			scanf("%d %d %d %d",&a, &b, &ic, &ti);
			a--;
			b--;
			cost[a][b] = ic;
			cost[b][a] = ic;
			time[a][b] = ti;
			time[b][a] = ti;
		}
		//問い合わせ入力
		scanf("%d",&k);
		for(f1 = 1; f1 <= k; f1++)
		{
			scanf("%d %d %d",&p, &q, &r);
			p--;
			q--;
			if(r == 0)
				out = dijkstra(n, m, p, q, cost);
			else
				out = dijkstra(n, m, p, q, time);

			printf("%d\n",out);
		}
	}
	return 0;
}

int dijkstra(int n, int m, int p, int q, int temp[][100])
{
	int C[100], sum[100], f1, po = p, min;
	//Cの中身　0：出発していない　1：出発した
	//初期化
	for(f1 = 0; f1 < m; f1++)
	{
		C[f1] = 0;
		sum[f1] = 0;
	}
	//ダイクストラ探索
	while(po != q)
	{
		//現在いる地点から次の駅までにかかるコストを計算し次に行く駅の現時点での最小コストを求める
		for(f1 = 0; f1 < m; f1++)
		{
			if(temp[po][f1] > 0)
			{
				if(C[f1] == 0 && (sum[f1] == 0 || temp[po][f1] + sum[po] < sum[f1]))
					sum[f1] = temp[po][f1] + sum[po];
			}
		}
		//出発していない駅の中で最小コストを選択する
		min = 0;
		C[po] = 1;
		for(f1 = 0; f1 < m; f1++)
		{
			if(C[f1] == 0 && sum[f1] != 0 && (min == 0 || sum[f1] < min))
			{
				min = sum[f1];
				po = f1;
			}
		}
	}
	return sum[q];
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>

using namespace std;

int main(void) {
  int H, A;
  cin >> H >> A;
  if (H % A > 0) {
    cout << (H / A) + 1 << endl;
  } else {
    cout << H / A << endl;
  }
  return 0;
}


Measured memory_bytes: 256
N, M, Q = list(map(int, input().split()))
abcd = [list(map(int, input().split())) for _ in range(Q)]
A_cand = []
max_score = 0

def gen(mae):
    global A_cand
    if len(mae)==N:
        A_cand.append(mae)
        return 0
    for one in range(mae[-1], M+1):
        gen(mae+[one])
for i in range(1,M+1):
    gen([i])
for one in A_cand:
    score = 0
    for i in range(Q):
        a,b,c,d = abcd[i]
        if one[b-1]-one[a-1]==c:
            score+=d
    max_score = max(score, max_score)
print(max_score)

Measured memory_bytes: 95808
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int a,b,c;
    cin>>a>>b>>c;
    int ans=max(0,c-(a-b));
    cout << ans << endl;
    return 0;
}

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

int main() {
  int x, y;
  while(1){
    cin >> x >> y;
    if(x == 0 && y == 0){
      break;
    }
    if(x < y){
      cout << x << " " << y << endl;
    } else {
      cout << y << " " << x << endl;
    }
  }
  return 0;
}


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

using namespace std;

typedef long long ll;

string s, t;
int ans = 0;
int main()
{
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> s >> t;
 
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] != t[i])
            ans++;
    }

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


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

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

long long cob(long long a, long long b){
  long long over = 1;
  long long under = 1;
  for(int i = 0; i < b; i++){
    over *= a - i;
    over %= 1000000007;
  }
  for(int i = 1; i < b + 1; i++){
    under *= i;
    under %= 1000000007;
  }
  return over * modinv(under, 1000000007) % 1000000007;
}

int main(){
  long long n, k; cin >> n >> k;
  vector<long long> out(k);
  for(int i = 1; i < k + 1; i++){
    if(n - k < i - 1){
      cout << 0 << endl;
      continue;
    }
    long long b = cob(k - 1, i - 1);
    long long r = cob(n - k + 1, i);
    cout << b * r % 1000000007 << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();

        int r = in.nextInt();
        int c = in.nextInt();

        int[] rSum = new int[c + 1];

        for (int i = 0; i < r; i++) {
            int cSum = 0;
            for (int j = 0; j < c; j++) {
                int num = in.nextInt();
                cSum += num;
                rSum[j] += num;
                sb.append(num).append(" ");
            }
            sb.append(cSum).append("\n");
        }
        for (int i = 0; i < c; i++) {
            sb.append(rSum[i]).append(" ");
            rSum[c] += rSum[i];
        }
        sb.append(rSum[c]).append("\n");

        System.out.print(sb.toString());
    }
}

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

#define FAST_IO                       \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);
#define SIZE(arr) ((int)arr.size())
#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;

using namespace std;

using ll = long long;

const int MOD = 1e9 + 7;


int main()
{
	//	#ifndef ONLINE_JUDGE
	//		(void)freopen("input.txt", "r", stdin);
	//		(void)freopen("output.txt", "w", stdout);
	//	#endif
	FAST_IO;
	ll n, ans = 0;
	cin >> n;
	ans = (n / 500) * 1000;
	n %= 500;
	ans += (n / 5) * 5;
	cout << ans;
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#define INF 10000000
#define REP(i, n) for(int i = 0;i < (n);i++)
#define all(n) n.begin(),n.end()

using namespace std;

typedef long long int ll;
typedef pair<int, int> PII;

const int MAX_N = 51;

int X1[MAX_N], X2[MAX_N], Y1[MAX_N], Y2[MAX_N], Z1[MAX_N], Z2[MAX_N];
int fld[2*MAX_N][2*MAX_N][2*MAX_N];
int n, k;
ll res = 0;
vector<int> xs, ys, zs;

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

	REP(i, 2*MAX_N) REP(j, 2*MAX_N) REP(k, 2*MAX_N) fld[i][j][k] = 0;

	REP(i, n){
		cin >> X1[i] >> Y1[i] >> Z1[i] >> X2[i] >> Y2[i] >> Z2[i];
		xs.push_back(X1[i]);
		xs.push_back(X2[i]);
		ys.push_back(Y1[i]);
		ys.push_back(Y2[i]);
		zs.push_back(Z1[i]);
		zs.push_back(Z2[i]);
	}
	sort(all(xs));
	sort(all(ys));
	sort(all(zs));
	xs.erase(unique(all(xs)), xs.end());
	ys.erase(unique(all(ys)), ys.end());
	zs.erase(unique(all(zs)), zs.end());
	REP(i, n){
		X1[i] = find(all(xs), X1[i])-xs.begin();
		X2[i] = find(all(xs), X2[i])-xs.begin();
		Y1[i] = find(all(ys), Y1[i])-ys.begin();
		Y2[i] = find(all(ys), Y2[i])-ys.begin();
		Z1[i] = find(all(zs), Z1[i])-zs.begin();
		Z2[i] = find(all(zs), Z2[i])-zs.begin();
	}

	REP(i, n){
		for(int x = X1[i];x < X2[i];x++){
			for(int y = Y1[i];y < Y2[i];y++){
				for(int z = Z1[i];z < Z2[i];z++){
					fld[x][y][z]++;
				}
			}
		}
	}

	REP(x, xs.size()){
		REP(y, ys.size()){
			REP(z, zs.size()){
				if(fld[x][y][z] >= k){
					res += ll(xs[x+1]-xs[x])*ll(ys[y+1]-ys[y])*ll(zs[z+1]-zs[z]);
				}
			}
		}
	}
	cout << res << endl;

}

Measured memory_bytes: 7228
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std;
typedef long long ll;


ll mod = 1000000007;
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int C(ll a, ll b) {
    ll bunbo=1;
    ll bunshi=1;

    for (int i=0;i<b;i++)
    {
        bunshi *= (a-i);
        bunshi %= mod;
    }
    for (int i=1;i<=b;i++)
    {
        bunbo *= i;
        bunbo %= mod;
    }

    return (bunshi * modinv(bunbo, mod)) % mod;
}

int main() {
    ll n,a,b;
    cin >> n >> a >> b ;
    ll ans = modpow(2, n, mod) - C(n, a) - C(n, b)  -1;
    while (ans < 0) ans +=mod;
    cout << ans<< endl;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

#define FOR(i,f,t) for(int i=(int)f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=(int)f; i>(int)t; i--)
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define pb push_back
#define SYNC ios_base::sync_with_stdio(false)
#define inf 2248012
#define mp make_pair
#define F first
#define S second
#define ri(x) scanf("%d",&x)
#define rii(x,y) scanf("%d %d",&x,&y)
#define riii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define lri(x) scanf("%lld",&x)
#define lrii(x,y) scanf("%lld %lld",&x,&y)
#define lriii(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> ii;

const int MAXN = 5e6+3; //AREGLAAAAAAAAR!!!!
int m[103][103],a[10352],ans[303][234];
int main(){
	int h,w,n;
	riii(h,w,n);
	FOR(i,0,n) ri(a[i]);
	int inic=0,finc=w,inif=1,finf=h-1,color=1,count=a[0],y=0,y2=w-1,y3=h-1,y4=0;
	while(color<=n){
		int ci=inic,cf=finc,fi=inif,ff=finf;
		FOR(i,ci,cf){
			if(y>=h || color>n) break;
			ans[y][i]=color;
			count--;
			if(!count){
				count=a[color];
				color++;
			}
		}
		
		FOR(i,fi,ff){
			if(y2<0 || color>n) break;
			ans[i][y2]=color;
			count--;
			if(!count){
				count=a[color];
				color++;
			}
		}
		
		FORR(i,cf-1,ci-1){
			if(y4<0 || color>n) break;
			ans[y3][i]=color;
			count--;
			if(!count){
				count=a[color];
				color++;
			}
		}
		
		FORR(i,ff-1,fi-1){
			if(y4>=w || color>n) break;
			ans[i][y4]=color;
			count--;
			if(!count){
				count=a[color];
				color++;
			}
		}
		y++; y2--; y3--; y4++;
		inic++; finc--; inif++; finf--;
	}
	FOR(i,0,h){
		FOR(j,0,w){
			printf("%d ",ans[i][j]);
		}
		printf("\n");
	}
}


Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		
		
		Scanner sc = new Scanner(System.in);
		
		Integer A = sc.nextInt();
		Integer B = sc.nextInt();
		Integer K = sc.nextInt();
		
		List<Integer>e=new ArrayList<>();
		
		
		for(int i= 1; i<=Math.max(A, B); i++){
			if(A%i==0&&B%i==0){
				e.add(i);
			}
		}
		
		System.out.println(e.get(e.size()-K));
 
	}
 
 
}

Measured memory_bytes: 21712
n = int(input())
s = input()
if n%2 == 0:
    cnt = 0
    for i in range(n//2):
        if s[i] == s[i + n//2]:
            cnt += 1
            if cnt == n//2:
                print("Yes")
                break
        else:
            print("No")  
            break
else:
    print("No")

Measured memory_bytes: 9132
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
int main(){
    ll a, b; cin >> a >> b;
    ll GCD = gcd(a, b);

    map<ll,ll> factor;
    for(ll i = 2; i * i <= GCD; i++){
        while(GCD % i == 0){
            factor[i]++;
            GCD /= i;
        }
    }
    if(GCD != 1) factor[GCD] = 1;

    cout << factor.size() + 1 << endl; 
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	a = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,k;
	cin >> n >> k;
	cout << (n-k+1) << endl; 
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
const int INF = 0x3f3f3f3f;
const int NIL = -1;
const int MAXN = 100005;

struct Node{ int p, l, r;}T[MAXN];

void preParse(int u){
	if(u == NIL)	return;
	cout << " " << u;
	preParse(T[u].l);
	preParse(T[u].r);
}

void inParse(int u){
	if(u == NIL)	return;
	inParse(T[u].l);
	cout << " " << u;
	inParse(T[u].r);
}

void postParse(int u){
	if(u == NIL)	return;
	postParse(T[u].l);
	postParse(T[u].r);
	cout << " " << u;
}

int main(){
	int n, p, l, r, loc;
	cin >> n;
	for(int i = 0; i < n; i++)	T[i].p = NIL;	
	for(int i = 0; i < n; i++){
		cin >> p >> l >> r;
		T[p].l = l;
		T[p].r = r;
		if(l != NIL)	T[l].p = p;
		if(r != NIL)	T[r].p = p;
	}
	for(int i = 0; i < n; i++)
		if(T[i].p == NIL)
			loc = i;
	cout << "Preorder" << endl;
	preParse(loc);
	cout << endl;
	cout << "Inorder" << endl;
	inParse(loc);
	cout << endl;
	cout << "Postorder" << endl;
	postParse(loc);
	cout << endl;
	return 0;
}

Measured memory_bytes: 3080
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

int n, s[1010], c[1010], f[1010];

int main() {
	cin >> n;
	for (int i = 1; i < n; i++) {
		cin >> c[i] >> s[i] >> f[i];
	}
	for (int i = 1; i < n; i++) {
		LL num = s[i];
		num += c[i];
		for (int j = i + 1; j < n; j++) {
			if (num < s[j])num = s[j];
			else {
				LL amari = (num - s[j]) % f[j];
				if (amari != 0) {
					num += (f[j] - amari);
				}
			}
			num += c[j];
		}
		cout << num << endl;
	}
	cout << 0 << endl;
	//system("pause");
}

Measured memory_bytes: 256
#include <iostream>

#ifdef _MSC_VER
#define getchar_unlocked _getchar_nolock
#endif

int * vec;
int n;
long long ans = 0;

bool check_mon_up(int * start, int * end)
{
	/*if (end - start <= 1)
		return true;*/
	
	for (auto i = start; i < end - 1; i++)
		if (*i >= *(i + 1))
			return false;
	return true;
}

bool chec_mon_do(int * start, int * end)
{
	/*if (end - start <= 1)
		return true;*/

	for (auto i = start; i < end - 1; i++)
		if (*i <= *(i + 1))
			return false;
	return true;
}

int * m_find_max(int * start, int * end)
{
	int max = -1;
	int * numb = nullptr;
	for (int * i = start; i < end; i++)
		if (max < *i) max = *i, numb = i;
	return numb;
}

//void m_find_two_max(int * start, int * end, int *& max, int *& tax)
//{
//	int mm = -1, mt = -1;
//	for (int * i = start; i < end; i++)
//	{
//		if (*i > mm)
//		{
//			mt = mm;
//			mm = *i;
//			tax = max;
//			max = i;
//		}
//		else if (*i > mt)
//		{
//			mt = *i;
//			tax = i;
//		}
//	}
//}

void m_find_tax(int * start, int * end, int * max, int *& tax)
{
	int mm = *max, mt = -1;
	for (int * i = start; i < end; i++)
		if (*i > mt)
			if (i != max)
			{
				tax = i;
				mt = *i;
			}
}

void fu(int * start, int * end, int * max)
{
	if (end - start == 1)
		return;
	static int * tax = 0;
	m_find_tax(start, end, max, tax);
	if (tax == max)
		return;
	if (tax > max)
	{
		ans += (long long)(*tax) * (max - start + 1) * (end - tax);
		fu(start, tax, max);
	}
	else
	{
		ans += (long long)(*tax) * (tax - start + 1) * (end - max);
		fu(tax + 1, end, max);
	}
	return;
}

void func(int * start, int * end)
{
	/*if (end - start <= 1)
		return;*/
	if (end - start == 2)
	{
		ans += (long long)(*(end - 1) > *start) ? *start : *(end - 1);
		return;
	}
	if (check_mon_up(start, end))
	{
		for (int i = 0; i < end - start - 1; i++)
			ans += (long long)(*(start + i)) * (i + 1);
		return;
	}
	if (chec_mon_do(start, end))
	{
		for (int i = 1; i < end - start; i++)
			ans += (long long)(*(start + i)) * (end - start - i);
		return;
	}
	int * max = m_find_max(start, end);
	fu(start, end, max);
	func(start, max);
	func(max + 1, end);
	return;
}

void read_int_unlocked(int * out)
{
	static int c;
	*out = 0;
	c = getchar_unlocked();
	for (; '0' <= c && c <= '9'; c = getchar_unlocked())
		*out = (*out) * 10 + c - '0';
}

int main()
{
	std::ios::sync_with_stdio(false);
	read_int_unlocked(&n);
	vec = new int[n];
	int * const start = vec;
	int * const end = vec + n;
	for (int * i = start; i < end; i++)
		read_int_unlocked(i);
	func(start, end);
	std::cout << ans;
	//system("pause");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)

int main() {
  ll n; cin >> n;
  map <ll, ll> score;
  ll sum = 0;
  rep(i, n) {
    ll a; cin >> a;
    if (score.count(a)) score.at(a)++;
    else score[a] = 1;
    sum += a;
  }
  ll q; cin >> q;
  rep(i, q) {
    ll b, c; cin >> b >> c;
    if (score.count(b)) {
      sum -= b*score.at(b);
      sum += c*score.at(b);
      if (score.count(c)) score.at(c) += score.at(b);
      else score[c] = score.at(b);
      score.at(b) = 0;
    }
    cout << sum << endl;
  }
}

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

using namespace std;

typedef long long int ll;

struct Cake {
  ll x,y,z;
};

ll solve(int N, int M, const vector<Cake> &cakes, int dx, int dy, int dz) {

  ll result = 0;
  vector<int> flag(N,0);
  for(int i=0;i<M;i++){

    ll max_cake_value;
    int max_cake_index=-1;

    for(int j=0;j<N;j++){

      if(flag[j]==0) {
        const Cake& cake = cakes[j];
        ll cake_value;
        cake_value  = cake.x * dx;
        cake_value += cake.y * dy;
        cake_value += cake.z * dz;

        if(max_cake_index==-1||cake_value>max_cake_value) {
          max_cake_value = cake_value;
          max_cake_index = j;
        }
      }
    }

    flag[max_cake_index] = 1;
    result += max_cake_value;
  }

  return result;
}

int main(){
  int N,M;
  cin>>N>>M;
  vector<Cake> cakes(N);

  for(size_t i=0; i<N;i++) {
    Cake& cake = cakes[i];
    cin>>cake.x>>cake.y>>cake.z;
  }


  ll result = 0;

  for(int dx=-1;dx<=1;dx+=2)
    for(int dy=-1;dy<=1;dy+=2)
      for(int dz=-1;dz<=1;dz+=2)
        {
          ll value = solve(N,M,cakes,dx,dy,dz);
          if(value > result)
            result = value;
        }

  cout << result <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mem(a, b) memset(a, b, sizeof(a))
#define inf (1e9 + 7)
#define eps 0.000001
using namespace std;

int n, num[500005], l, r;

int main()
{
    l = 250001;
    r = 250000;
    scanf("%d", &n);
    for(int i = 1, a;i <= n;i++)
    {
        scanf("%d", &a);
        if(i % 2)
            l--, num[l] = a;
        else
            r++, num[r] = a;
    }
    if(n % 2)
    {
        for(int i = l;i <= r;i++)
        {
            if(i == l)
                printf("%d", num[i]);
            else
                printf(" %d", num[i]);
        }
        puts("");
    }
    else
    {
        for(int i = r;i >= l;i--)
        {
            if(i == r)
                printf("%d", num[i]);
            else
                printf(" %d", num[i]);
        }
        puts("");
    }
    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#define MAX_N 8
#define MAX_M 28
using namespace std;
int N,M;

bool g[MAX_N][MAX_N] = {false};

int dfs(int v, int N, bool visited[MAX_N]){
    bool is_complete = true;
    for(int i = 0; i < N;i++){
        if(visited[i] == false) is_complete = false;
    }

    if(is_complete) return 1;
    int ret = 0;

    for(int i = 0; i < N; i++){
        if(g[v][i] == false) continue;
        if(visited[i]) continue;

        visited[i] = true;
        ret += dfs(i,N,visited);
        visited[i] = false;
    }
    return ret;
}

int main(){
    cin >> N >> M;
    int f,t;
    for(int i = 0; i < M; i++){ 
        cin >> f >> t;
        g[f-1][t-1] = true;
        g[t-1][f-1] = true;
    }

    bool visited[MAX_N];
    for(int d = 0; d < N; d++) visited[d] = false;

    visited[0] = true;
    cout << dfs(0,N,visited) << endl;
    return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
belong=list()
group=list()

def init(X):
  global belong,group
  belong=list(range(X))
  group=[[i] for i in range(X)]

def unite(x,y):
  global belong,group
  if len(group[belong[x]])<len(group[belong[y]]):
    x,y=y,x
  if belong[x]==belong[y]:
    return True
  z=belong[y]
  for i in range(len(group[z])):
    belong[group[z][-1]]=belong[x]
    group[belong[x]].append(group[z][-1])
    del group[z][-1]
  return False

init(N+M)
L=[]
for i in range(N):
  L=list(map(int,input().split()))
  for j in range(L[0]):
    unite(i,L[j+1]+N-1)
if len(set(belong[:N]))==1:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 102708
#include<iostream>
#include<cstring>
using namespace std;
int i,k=0,p=0;
int main(){
	string s;
	cin>>s;
	if(s[0]!='A'){
		cout<<"WA";
		return 0;
	}
	else{
	    for(i=2;i<s.length()-1;i++){
	    	if(s[i]=='C'){
	    		k++;
	    	}
    	}
    }
    if(k!=1){
    	cout<<"WA";
    	return 0;
	}
	k=0;
	for(i=0;i<s.length();i++){
		if(s[i]!='A'&&s[i]!='C'&&s[i]!='a'&&s[i]!='c'&&(s[i]<'a'||s[i]>'z')){
			p=1;
			break;
		}
	}
	if(p==1){
		cout<<"WA";
		return 0;
	}
	cout<<"AC";
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int price[] = new int[N];
		int total = 0;
		for (int i = 0; i < N; i++) {
			int p = sc.nextInt();
			price[i] = p;
		}

		Arrays.sort(price);

		for (int i = 0; i < N - 1; i++) {
			total += price[i];
		}

		total += price[N - 1] / 2;

		System.out.println(total);
	}
}


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

int main(){
  long long N, K;
  cin >> N >> K;
  vector<pair<long long, long long>> td(N);
  for (int i=0; i<N; i++) {
    cin >> td[i].first >> td[i].second;
    td[i].first--;
  }
  long long ans = 0;
  vector<long long> vari(N,0);
  sort(td.begin(), td.end(), [](const auto& a, const auto& b){return a.second>b.second;});
  priority_queue<long long, vector<long long>, greater<long long> > pque;
  long long vnum = 0;
  for (int i=0; i<K; i++){
    if (vari[td[i].first]==0){
      vari[td[i].first]++;
      ans += vnum*2 + 1;
      vnum++;
      ans += td[i].second;
    }
    else {
      ans += td[i].second;
      pque.push(td[i].second);
    }
  }
  long long fans = ans;
  for (int i=K; i<N; i++){
    if (pque.empty()) break;
    if (vari[td[i].first]>0) continue;
    vari[td[i].first]++;
    ans -= pque.top();
    pque.pop();
    ans += vnum*2 + 1;
    ans += td[i].second;
    vnum++;
    fans = max(ans, fans);
  }
  cout << fans << endl;
}


Measured memory_bytes: 3196
#include <iostream>                                             
#include <vector>                                               
#include <numeric>                                              
#include <cmath>                                                
#include <iomanip>                                              
using namespace std;                                            
                                                                
int main(void) {                                                
  int n, x;                                                     
  double m;                                                     
  while (true) {                                                
    cin >> n;                                                   
    if (n==0) {                                                 
      break;                                                    
    }                                                           
    vector <double> s;                                          
    for (int i=0; i<n; i++) {                                   
      cin >> x;                                                 
      s.push_back((double)x);                                   
    }                                                           
    m = accumulate(s.begin(),s.end(),0.0)/s.size();             
    double a = 0;                                               
    for (int i=0; i<s.size(); i++) {                            
      a += (pow(s[i]-m,2));                                     
    }                                                           
    a = sqrt(a/n);                                              
    cout << fixed << setprecision(8) << a << endl;              
  }                                                             
  return 0;                                                     
}                                                               
                                                                
                          

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

using namespace std;
const int N = 3e6 + 10;
long long a[N] , avail[N] , b[N] , c[N] , V[N];
int n , q;
int cnt = 0;
void compress(){
    for (int i = 1; i <= n; i++) V[++cnt] = a[i];
    for (int i = 1; i <= q; i++){
        V[++cnt] = b[i];
        V[++cnt] = c[i];
    }
    sort(V + 1,V + cnt + 1);
    for (int i = 1; i <= n; i++) a[i] = lower_bound(V + 1,V + cnt + 1,a[i]) - V;
    for (int i = 1; i <= q; i++){
        b[i] = lower_bound(V + 1,V + 1 + cnt,b[i]) - V;
        c[i] = lower_bound(V + 1,V + 1 + cnt,c[i]) - V;
    }
}   
int main(){
    //freopen("thaythe.inp","r",stdin);
    //freopen("thaythe.out","w",stdout);
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    cin >> q;
    for (int i = 1; i <= q; i++) cin >> b[i] >> c[i];
    compress();
    long long sum = 0;
    for (int i = 1; i <= n; i++){
        sum = sum + V[a[i]];
        avail[a[i]]++;
    }
    for (int i = 1; i <= q; i++){
        if (b[i] != c[i]){
            sum = sum - V[b[i]] * avail[b[i]];
            sum = sum + V[c[i]] * avail[b[i]];
            avail[c[i]] += avail[b[i]];
            avail[b[i]] = 0;
        }
        cout << sum << "\n";
    }
    //for (int i = 1; i <= cnt; i++) cout << V[i] << " ";
    return 0;
}

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

int main(){
    int A,B;
    cin >> A >> B;

    if(A<6){
        cout << 0 << endl;
    }else if(A <= 12){
        cout << B/2 << endl;
    }else{
        cout << B << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/*
A0408.c Cave of cats
 */
#include <stdio.h>
int stack[100];
int used[100];
int sp;

int main()
{
  int l,i,c,er;
  scanf("%d",&l);
  sp=0;er=0;
  for(i=1;i<=l;i++)
  { scanf("%d",&c);
    //printf("c=%d usd[%d]er[%d]\n",c,used[c],er);
    if(er==0)
    { if(c>0)
      {  if(used[c]>0)
	  er=i;
        else
        { stack[sp]=c;
	  used[c]=1;
	  sp++;
        }
      }
      if (c<0)
      { if(stack[sp-1]==-c)
        { sp--;
	  used[-c]=0;
        }
        else
	  er=i;
      }
   }
  }   
  if(er>0)
    printf("%d\n",er);
  else
    printf("OK\n");
  return 0;
}



Measured memory_bytes: 2088
#include<stdio.h>
int main()
{
    int N,A,j,k,l;
    scanf("%d ",&N);
    scanf("%d",&A);
    j = N / 500;
    k = j * 500;
    if (k == N){
        printf("Yes");
     }
 else {
        int l = N - k;

      if(l <= A){
        printf("Yes");
      }
        else{
            printf("No");
}

}
return 0;
}

Measured memory_bytes: 1688
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 998244353;
const ll INF = 1e18;
const int MX = 100001;

template<int SZ> struct Combo {
    ll fac[SZ+1], ifac[SZ+1];
    
    Combo() {
        fac[0] = ifac[0] = 1;
    	FOR(i,1,SZ+1) {
    	    fac[i] = i*fac[i-1] % MOD;
    	    ifac[i] = inv(fac[i]);
    	}
    }
    
    ll po (ll b, ll p) { return !p?1:po(b*b%MOD,p/2)*(p&1?b:1)%MOD; }
    ll inv (ll b) { return po(b,MOD-2); }
    
    ll comb(ll a, ll b) {
        if (a < b || b < 0 || a < 0) return 0;
        ll tmp = fac[a]*ifac[b] % MOD;
        tmp = tmp*ifac[a-b] % MOD;
        return tmp;
    }
};

ll ad(ll a, ll b) { return (a+b)%MOD; }
ll mul(ll a, ll b) { return a*b%MOD; }

Combo<300001> C;
ll N,A,B,K,ans;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> A >> B >> K;
    F0R(i,N+1) if ((K-A*i) % B == 0) {
        ll des = (K-A*i)/B;
        ans = ad(ans,mul(C.comb(N,i),C.comb(N,des)));
    }
    cout << ans;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 4992
#include <iostream>

using namespace std;

int main(int argc, const char * argv[]) {
 
    string S,T;
    
    cin>>S>>T;
    
    for(int i=0;i<S.size();i++){
        S+=S.at(0);
        S.erase(0,1);
        
        if(S==T){
            cout<<"Yes"<<endl;return 0;
        }
    }
    
cout<<"No"<<endl;
return 0;
}


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

const int MAX_N = 1000005;
int fa[MAX_N], dis[MAX_N];

int find(int x) {
  if (fa[x] == x) return x;
  int par = find(fa[x]);
  dis[x] += dis[fa[x]];
  return fa[x] = par;
}


bool add(int L, int R, int D) {
  if (find(L) == find(R)) {
    if (dis[L] - dis[R] != -D) {
      puts("No");
      return 0;
    }
    return 1;
  }
  int faR = fa[R], faL = fa[L];
  fa[faR] = fa[faL];
  dis[faR] = dis[L] + D - dis[R];
  return 1;
}


int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) fa[i] = i;
	
  for (int i = 1; i <= m; ++i) {
    int L, R, D;
    scanf("%d%d%d", &L, &R, &D);
    if (!add(L, R, D)) {
      return 0;
    }
  }
  puts("Yes");
  return 0;
}




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

int main(){
  string n;
  int ans = 0;
  cin >> n;
  for(char c : n){
    ans += (c - '0');
  }
  ans %= 9;
  if(ans == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

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

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  vector<vector<int>> G(N);
  vector<pair<int,int>> vp;
  REP(i,N-1){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
    vp.emplace_back(a,b);
  }

  int cnt=0;
  map<pair<int,int>,int> mp;
  vector<int> colors(N,0);

  vector<bool> used(N,0);
  queue<int> q;
  used[0]=true;
  q.push(0);
  while(!q.empty()){
    int v=q.front();q.pop();
    chmax(cnt,(int)G[v].size());
    int color=1;
    for(int u:G[v]){
      if(used[u]) continue;
      if(color==colors[v]) color++;
      colors[u]=mp[make_pair(u,v)]=mp[make_pair(v,u)]=color;
      color++;
      used[u]=true;
      q.emplace(u);
    }
  }

  cout<<cnt<<endl;
  for(auto p:vp) cout<<mp[p]<<endl;
}


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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define size(a) int(a.size())

const ll mod = 1e9 + 7;
const ll inf = ll(1e18);
const double PI = acos(-1);

ll modexp(ll x, ll n, int md) {
    if (n == 0)return 1;
    if (n % 2 == 0)return modexp((x * x) % md, n / 2, md);
    return (x * modexp((x * x) % md, n / 2, md)) % md;
}

int main(){
    fastio;
    //clock_t tm = clock();
    ll s,n=0;
    ll ans=0;
    vl fc(2001,1);
    f(i,1,2001)fc[i]=(i*fc[i-1])%mod;
    cin>>s;
    while(s>=3){
        s-=3;++n;
        ll temp = (((fc[s+n-1]*modexp(fc[s],mod-2,mod))%mod)*modexp(fc[n-1],mod-2,mod))%mod;
        ans=(ans+temp)%mod;
    }
    cout<<ans<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	long long n, k, i, j, ans, x;
	bool breached = false, prefer1;
	vector<long long> ct(60, 0);

	cin >> n >> k;
	for (i = 0; i < n; i++) {
		cin >> x;
		for (j = 0; j < 60; j++) {
			if (x & (1LL << j)) ct[j]++;
		}

	}
		
	ans = 0;
	for (i = 59; i >= 0; i--) {
		x = 1LL << i;
		prefer1 = (ct[i] < n - ct[i]);

		if (prefer1 && (breached || (x & k))) 
			ans += x * (n- ct[i]);
		else {
			if (!breached && (x & k)) breached = true;
			ans += x * ct[i];
		}
	}
	cout << ans << "\n";
	
	return 0;
}

Measured memory_bytes: 256
import itertools

while True:
    item_n, money = [int(i) for i in input().split()]
    if item_n == money == 0:
        break
 		
    value_lst = [int(i) for i in input().split()]
 	
    max_value = -1
    can_buy = False
 	
    for i1, i2 in itertools.combinations(value_lst, 2):
        if i1 + i2 > max_value and i1 + i2 <= money:
        	max_value = i1 + i2
        	can_buy = True
        	
    if(can_buy):	
        print(max_value)
    else:
    	print('NONE')


Measured memory_bytes: 5776
a, b, c, k = gets.chomp.split(' ').map(&:to_i)

choices = [0, 0, 0]
[a, b, c].each_with_index do |count, i|
  break if k.zero?
  choices[i] =
    if count >= k
      kk = k
      k = 0
      kk
    else
      k -= count
      count
    end
end

puts choices[0] - choices[2]

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

#define all(x)        (x).begin(),(x).end()
#define eb            emplace_back
#define mp            make_pair
#define pb            push_back
#define fi            first
#define se            second
#define sz(x)         ((int)(x).size())
#define rep(x,y,z)    for(int x=y;x<z;x++)
#define per(x,z,y)    for(int x=z-1;x>=y;x--)
#define trav(y,x)     for(auto& y:x)
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define vi            vector<int>
#define vpi           vector<pii>

int dbg = 0;
#define cri           if(0)
#define shame         cri cerr<<(++dbg)<<"\n\n";

// aaaaaaaaaaaaaaaa
void solve() {
  int a, b, c, d;
  scanf("%d%d%d%d", &a, &b, &c, &d);

  int x = 0;
  while (1) {
    if (!x) {
      c -= b;
      if (c <= 0) {
        puts("Yes");
        return;
      }
    }
    else {
      a -= d;
      if (a <= 0) {
        puts("No");
        return;
      }
    }
    x ^= 1;
  }
}

int main() {
  // int _; scanf("%d", &_); while (_--)
  // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // int _; cin >> _; while(_--)
  solve();
	return 0;
}



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

int main() {
  int i, n;
  int a[200010] = { 0 };
  int buka[200010] = { 0 };

  cin >> n;
  
  for(i = 2; i <= n; i++)
    cin >> a[i];
  
  for(i = 2; i <= n; i++)
      buka[a[i]]++;
  
  for(i = 1; i <= n; i++)
    cout << buka[i] << endl;
}

Measured memory_bytes: 5204
#include<stdio.h>
#include<string.h>
#include<math.h>
#include <stdlib.h>
#include<ctype.h>

//qsort
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

//比較
int max(int a, int b){
	if (a>b) return a;
	else return b;
}

int min(int a,int b) {
	if(a>b) return b;
	else return a;
}


//main関数
int main() {
	int A,B;
	scanf("%d %d",&A,&B);
	printf("%d",A*B);
	return 0;
}

Measured memory_bytes: 1700
#include<iostream>
#include<string.h>
using namespace std;

int main(){
	string A,B,E;
	int c,d;
	
	cin >> A >> B;
	cin >> c >> d;
	cin >> E;
	
	if(c<1 || 10<c || d<1 || 10<d)exit(1);
	
	if(E == A)c -= 1;
	if(E == B)d -= 1;
	
	cout << c <<" " << d << endl;

return 0;
}


Measured memory_bytes: 256
N = int(input())
src = [tuple(map(int,input().split())) for i in range(N)]

nt = nx = ny = 0
for t,x,y in src:
    d = abs(nx-x) + abs(ny-y)
    if d <= t-nt and (t-nt)%2 == d%2:
        nt,nx,ny = t,x,y
    else:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 17308
N, W = map(int, input().split())
items = sorted([list(map(int, input().split())) for i in range(N)])

dp = [[0]*(N + 1) for i in range(W + 1)]
for i in range(W + 1):
    for j in range(N):
        k = i - items[j][0]
        dp[i][j + 1] = max(dp[i][j + 1], dp[i][j])
        if k < 0:
            break
        else:
            dp[i][j + 1] = max(dp[i][j + 1], dp[k][j] + items[j][1])

print(max(dp[-1]))


Measured memory_bytes: 131036
//minamoto
#include<bits/stdc++.h>
#define R register
#define fi first
#define se second
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=2e5+5;
typedef pair<int,int> pi;
int fac[N],ifac[N],fa[N],mn[N],cnt[N];pi c[N];
int n,x,y,pos,sz,res;
inline int find(R int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
int main(){
	scanf("%d%d%d",&n,&x,&y);
	fp(i,1,n)scanf("%d%d",&c[i].se,&c[i].fi);
	sort(c+1,c+1+n);
	pos=2;
	while(pos<=n&&c[pos].se==c[1].se)++pos;
	if(pos>n)return puts("1"),0;
	fd(i,n,1)mn[c[i].se]=i,fa[i]=i;
	fd(i,n,1){
		if(i!=mn[c[i].se]&&c[i].fi+c[mn[c[i].se]].fi<=x)
			fa[find(i)]=find(mn[c[i].se]);
		else if(c[i].se!=c[1].se&&c[i].fi+c[1].fi<=y)
			fa[find(i)]=find(1);
		else if(c[i].fi+c[pos].fi<=y)
			fa[find(i)]=find(pos);
	}
	fac[0]=ifac[0]=1;fp(i,1,n)fac[i]=mul(fac[i-1],i);
	ifac[n]=ksm(fac[n],P-2);fd(i,n-1,1)ifac[i]=mul(ifac[i+1],i+1);
	fp(i,1,n)if(find(i)==find(1))++sz,++cnt[c[i].se];
	res=fac[sz];
	fp(i,1,n)res=mul(res,ifac[cnt[i]]);
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 5760