akhauriyash/Code-Regression huggingface dataset:
//author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 		first
#define s 		second
#define int     long long
#define ll      int
#define ld 		long double
#define pb 		push_back
#define eb 		emplace_back
#define mk 		make_pair
#define vi 		vector<int>
#define pii 		pair<int,int>
#define pip             pair<int,pii>
#define vpi 		vector<pii>
#define sbcount(x) __builtin_popcountll(x)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define trav(a, x)      for(auto& a : x)
#define all(x)          x.begin(), x.end()
#define fill(a,val)	memset(a,val,sizeof(a))
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); } 
#define test4(x,y,z,a) 		    cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl(){cout<<"Control"<<endl;}
int make_num(string p){stringstream geek(p); int x = 0; geek >> x;return x;}
string make_str(int x){ostringstream str1; str1 << x; string geek = str1.str(); return geek;}

signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0); 
	cin.exceptions(cin.failbit);
	int x,y;
    cin>>x>>y;
    bool flag=0;
    int A[y];
    bool pre[105]={0};
    for(int i=0;i<y;i++){
        cin>>A[i];pre[A[i]]=1;}
    int mx=M2,ans=-1;
    for(int i=0;i<=102;i++)
    {
        if(pre[i]==0)
        {
            //test1(i);
            if(abs(i-x)<mx)
            {
                mx=abs(i-x);
                ans=i;
            }
        }
    }
    if(abs(-1-x)<mx)
    ans=-1;

    cout<<ans;
    

return 0;
}

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

#define YOKO 3
#define TATE 3

int DFS(int P[TATE][YOKO],int,int);
int koukanmae(int,int,int);
void koukan(int P[TATE][YOKO],int irekae2[TATE][YOKO],int,int,int);
int Heuristic(int s[TATE][YOKO]);

int Ans[TATE][YOKO]={1,2,3,4,5,6,7,8,0};//答
int puzzle[TATE][YOKO];//問題
int irekae[TATE][YOKO];//仮puzzle

int clear=100000;
int limit;//深さの限度

int x[4]={0,1,0,-1},y[4]={-1,0,1,0};

/*

＊＊＊x[4],y[4]について＊＊＊

x[4]とy[4]はマスとマスを入れ替える時にセットで用いる。
なぜ配列に入れるかというと、for文でまとめて入替作業ができるからである。

くわしくは関数をみよ。

*/


int main()
{
  int i,j;

  /*問題のパズルを代入*/
  
  for(i=0;i<TATE;i++)
    {
      for(j=0;j<YOKO;j++)
	{
	  scanf("%d",&puzzle[i][j]);
	}
    }

  while(1)
    {
      if(DFS(puzzle,-1,0)==1)break;
      limit++;
    }

  printf("%d\n",clear);

  return 0;
}

int DFS(int P[TATE][YOKO],int not,int hukasa)
{

  int i,j,a,b;
  int zx,zy;//０の位置特定
  int hantei=1;
  int OK;
  int irekae2[TATE][YOKO];
  int H;
  int hata=0;
  
  /*puzzleがAnsとあっているか判定*/

  for(i=0;i<TATE;i++)
    {
      for(j=0;j<YOKO;j++)
	{
	  if(P[i][j]!=Ans[i][j])
	    {
	      hantei=0;
	    }
	   if(P[i][j]==0)
		{
		  zy=i;
		  zx=j;
		}
	}
    }

  if(hantei==1)
    {
      clear=hukasa;
      return 1;//あっていたら1返す。
    }
  else
    {
      for(i=0;i<4;i++)
	{
	  if((i+2)%4==not)continue;
	  
	  if(koukanmae(zx,zy,i)==1)
	    {
	      koukan(P,irekae2,zx,zy,i);
		  
	      H=Heuristic(irekae2);

	      if(hukasa+H<=limit)
		{		
		  hata=DFS(irekae2,i,hukasa+1);
		  if(hata==1)return 1;
		}
	    }
	  
	}
    }
  return 0;
}


int koukanmae(int zx,int zy,int i)
{
  if( zx+x[i]>=YOKO || zx+x[i]<0
      || zy+y[i]>=TATE || zy+y[i]<0 )
    {
      return 0;
    }
  else
    {
      return 1;
    }
}


void koukan(int P[TATE][YOKO],int irekae2[TATE][YOKO],int zx,int zy,int i)
{
  int j,k,koukan;
  
  for(j=0;j<TATE;j++)
    {
      for(k=0;k<YOKO;k++)
	{
	  irekae2[j][k]=P[j][k];
	}
    }
  
  koukan = irekae2[ zy +y[i] ][ zx+x[i] ];
  irekae2[zy][zx]=koukan;
  irekae2[ zy +y[i] ][ zx+x[i] ]=0;

  }


int Heuristic(int s[TATE][YOKO])
{
  int i,j,k=0,H2=0,cell[9],kyori=0;

  for(i=0;i<TATE;i++)
    {
      for(j=0;j<YOKO;j++)
	{
	  cell[k]=s[i][j];
	  k++;
	}
    }
  for(i=0;i<9;i++)
    {
      if(cell[i]!=0)
	{
	  kyori+=abs((cell[i]-1)%3-i%3);

	  kyori+=abs((cell[i]-1)/3-i/3);
	}
    }
  

  return kyori;
}



Measured memory_bytes: 2148
#include<iostream>
#include<string>

using namespace std;

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

    string S;
    cin >> S;

    if(S[K - 1] == 'A') S[K - 1] = 'a';
    if(S[K - 1] == 'B') S[K - 1] = 'b';
    if(S[K - 1] == 'C') S[K - 1] = 'c';

    cout << S << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int n;
  cin >> n;
  vector<int> d(n);
  vector<int> c(101, 0);
  for (int i=0; i<n; i++) {
    cin >> d.at(i);
  	c.at(d.at(i))++;
  }
  int cnt = 0;
  for (int i=0; i<101; i++)
    if (c.at(i) != 0) cnt++;
  cout << cnt << endl;
}

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

void f(int a[][15], int n, int &x, int &y, int i)
{
    if(0 <= x && x < n && 0 <= y && y < n && a[x][y] == 0) {
        a[x][y] = i;
        x++; y++;
        return;
    }
    
    if(x < 0){
        x = n-1;
    }
    if(n <= x){
        x = 0;
    }
     if(y < 0){
        y = n-1;
    }
    if(n <= y){
        y = 0;
    }
    
    if(a[x][y] != 0){
        x--;
        y++;
    }
    
    f(a, n, x, y, i);
}

int main()
{
    int n;
    while(scanf("%d", &n), n){
        int a[15][15] = {};
        
        int x = n / 2, y = n / 2 + 1;
        a[x][y] = 1;
        x++; y++;
        for(int i = 2; i <= n * n; ++i){
            f(a, n, x, y, i);
        }
        
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < n; ++j){
                printf("%4d", a[j][i]);
            }
            puts("");
        }
    }
}

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

int main(){
  int r;
  cin >> r;
  r *= r;
  cout << r << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

int main() {
  int n;
  scanf("%d", &n);
  vector<vector<int>> table(2, vector<int>(n));
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < n; ++j)
      scanf("%d", &table[i][j]);

  int top_sum = 0;
  int bottom_sum = accumulate(table[1].begin(), table[1].end(), 0);
  int result = INT_MIN;
  for (int i = 0; i < n; ++i) {
    top_sum += table[0][i];
    if (i - 1 >= 0)
      bottom_sum -= table[1][i - 1];
    result = max(result, top_sum + bottom_sum);
  }
  printf("%d\n", result);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

#define mod 1000000007

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;

P A[200010];
map<P, int> S;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x);
		y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; 
			data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int main()
{
	int n, k, l, p, q, r, s;
	cin >> n >> k >> l;
	UnionFind X(n + 10), Y(n + 10);
	rep(i, k) {
		cin >> p >> q;
		p--; q--;
		X.unionSet(p, q);
	}
	rep(i, l) {
		cin >> r >> s;
		r--; s--;
		Y.unionSet(r, s);
	}
	rep(i, n) {
		A[i] = { X.root(i), Y.root(i) };
		if (S.find(A[i]) != S.end()) S[A[i]]++;
		else S.insert({ A[i], 1 });
	}
	rep(i, n) {
		cout << S[A[i]];
		if (i != n - 1) cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 15104
#include<iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <math.h>
//1147
using namespace std;
int a,b,maxa=0,mina=10000,tot=0;
double ans;
	int main(){
		while(cin>>a){
			if(a==0){
			break;}
			for(int i=0;i<a;i++){
			cin>>b;
			tot+=b;
			if(maxa<b){maxa=b;}
			if(mina>b){mina=b;}}
			ans=(tot-maxa-mina)/(a-2);
		cout<<floor(ans)<<endl;
		tot=0;mina=10000;maxa=0;}
		return 0;}


Measured memory_bytes: 1228
#include <stdio.h>

int main(){
	int n;
	int temp = 0;
	int ans[10010] = {0};
	
	scanf("%d", &n);
	
	for(int x = 1; x <= 100; x++){
		for(int y = 1; y <= 100; y++){
			for(int z = 1; z <= 100; z++){
				temp = x*x + y*y + z*z + x*y + y*z + x*z;
				if(temp <= 10000){
					ans[temp]++;
				}
			}
		}
	}
	for(int i = 1; i <= n; i++){
		printf("%d\n", ans[i]);
	}
}

Measured memory_bytes: 1616
N, Y = map(int,input().split())
x, y, z = -1, -1, -1
k = 0
for i in range(N+1):
    for j in range(0,N-i+1):
        k = N - i - j
        if 10000*i + 5000*j + 1000*k == Y and 0 <= k <= 2000:
            x, y, z = i, j, k
            break
print(x, y, z)        

Measured memory_bytes: 66220
#include <cstdio>
#define F(i,x,y) for(int i=x;i<=y;++i)
using namespace std;
int f[100005],n,m,k,a,b,c[100005],d[100005],ans[100005];
int r[100005],sum[100005],t;
int find(int x){
	if(f[x]==x)return x;
	else return f[x]=find(f[x]);
}
int main(){
	F(i,0,100004)f[i]=i;
	scanf("%d%d%d",&n,&m,&k);
	F(i,1,n)ans[i]=n;
	F(i,1,m){
		scanf("%d%d",&a,&b);
		--ans[a];
		--ans[b];
		f[find(a)]=find(b);
	}
	F(i,1,n){
		find(i);
	}
	F(i,1,n){
		if(r[f[i]]==0)r[f[i]]=++t;
		++sum[r[f[i]]];
	}
	F(i,1,k){
		scanf("%d%d",c+i,d+i);
	}
	F(i,1,n){
		ans[i]-=n-sum[r[f[i]]];
	}
	F(i,1,k){
		if(r[f[c[i]]]==r[f[d[i]]]){
			--ans[c[i]];
			--ans[d[i]];
		}
	}
	F(i,1,n){
		printf("%d ",ans[i]-1);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    int n; cin >> n;
    vector<pii> red(n), blue(n);
    rep(i, n) cin >> red[i].first >> red[i].second;
    rep(i, n) cin >> blue[i].first >> blue[i].second;
    sort(blue.begin(), blue.end());

    int ans = 0;
    rep(i, n) {
        int maxY = -1, idx = -1;
        rep(j, red.size()) {
            if (red[j].first < blue[i].first && red[j].second < blue[i].second) {
                if (red[j].second > maxY) {
                    maxY = red[j].second;
                    idx = j;
                }
            }
        }
        if (idx >= 0) {
            ans++;
            red.erase(red.begin() + idx);
        }
    }
    cout << ans << endl;
}



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

int main() {
    string s;
    cin >> s;
    if(s == "A") cout << "T" << endl;
    else if(s == "T") cout << "A" << endl;
    else if(s == "G") cout << "C" << endl;
    else cout << "G" << endl;
}


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

int main() {
  int N,Y;
  cin >> N >> Y;
  bool otoshidama = false;

  for(int i = 0;i <= N;i++){
    for(int j = 0;j <= N - i;j++){
      int k = N - ( i + j );
      if(k < 0)break;
      if(10000 * i + 5000 * j + 1000 * k == Y){
        otoshidama = true;
        cout << i << " " << j << " " << k << endl;
        break;
      }
    }
    if(otoshidama == true)break;
  }

  if(otoshidama == false)cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=998244353;

int N;
char buf[214514];
LL thr = 1;
LL two = 1;
LL dp[214514][3][3];
LL tot[3];

int main(){
  scanf("%s", buf);
  N = strlen(buf);

  bool adj = false;
  set<char> sig;
  rep(i, N-1) {
    adj |= (buf[i] == buf[i+1]);
    thr = thr * 3 % MOD;
    two = two * 2 % MOD;
  }

  int mod = 0;
  rep(i, N) {
    sig.insert(buf[i]);
    mod = (mod + buf[i] - 'a') % 3;
  }

  rep(i, 3) {
    dp[0][i][i] = 1;
  }

  reps(i, 1, N) {
    rep(j, 3) { // mod
      rep(k, 3) { // last
        rep(l, 3) { // c
          if (k == l) continue;
          int nm = (j+l) % 3;
          dp[i][nm][l] = (dp[i][nm][l] + dp[i-1][j][k]) % MOD;
        }
      }
    }
  }

  if (sig.size() == 1) {
    puts("1");
    return 0;
  }

  if (N == 3 && sig.size() == 3) {
    puts("3");
    return 0;
  }

  rep (i, 3) {
    rep(j, 3) {
      tot[i] = (tot[i] + dp[N-1][i][j]) % MOD;
    }
  }

  /*rep(i, 3) {
    printf("dp[%d]: %lld\n", i, tot[i]);
  }*/

  if (N%3/* || N == 3*/) {
    printf("%lld\n", (MOD+(thr-two+!adj)%MOD)%MOD);
  } else if (mod == 0) {
    if (!adj) {
      printf("%lld\n", (MOD+(1+thr-tot[mod])%MOD) % MOD);
    } else {
      printf("%lld\n", (MOD+(thr-tot[mod])%MOD) % MOD);
    }
  } else {
    if (!adj) {
      printf("%lld\n", (MOD+(1+thr-tot[mod])%MOD) % MOD);
    } else {
      printf("%lld\n", (MOD+(thr-tot[mod])%MOD) % MOD);
    }
  }
}


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

#define rep(i, n) for (int i = 1; i < n+1; i++)

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

    int cnt = 0;
    rep(i, N) {
        cnt += i;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3480
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back
#define st first
#define N 200005
#define nd second
#define ii pair<int,int>
#define fr freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
vector <vector<pair<int,int> > > v(20);
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	//fr
	int n;
	cin>>n;
	for(int i=0,a;i<n;i++){
		cin>>a;
		for(int j=0,c,b;j<a;j++){
			cin>>c>>b;
			v[i].pb({c-1,b});
		}
	}
	int ans=0;
	for(int i=0;i<(1<<n);i++){
		int t=i;
		bool is=1;
		while(t && is){
			for(int j=0;j<v[(int)log2(t&(-t))].size();j++){
				if(!!((1<<v[(int)log2(t&(-t))][j].st)&i)!=v[(int)log2(t&(-t))][j].nd){
					is=0;
					break;
				}
			}
			t-=t&(-t);
		}
		if(is){
			ans=max(ans,__builtin_popcount(i));
		}
	}
	cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

int64_t root(vector<int64_t>& g, int64_t a) {
    if (g[a] != a) {
        g[a] = root(g, g[a]);
    }

    return g[a];
}

void merge(vector<int64_t>& g, int64_t a, int64_t b) {
    g[root(g, a)] = root(g, b);
}

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

    constexpr auto M = 100000L;

    vector<pair<int64_t, int64_t>> p(n);
    vector<int64_t> g(2 * M + 1);
    iota(g.begin(), g.end(), 0);
    for (auto i : irange(0L, n)) {
        auto&& pp = p[i];
        cin >> pp.first >> pp.second;
        merge(g, pp.first, M + pp.second);
    }

    unordered_map<int64_t, pair<int64_t, int64_t>> m;
    for (auto i : irange(1L, M + 1)) {
        ++m[root(g, i)].first;
        ++m[root(g, M + i)].second;
    }

    int64_t ans = 0;
    for (auto kv : m) {
        auto v = kv.second;
        ans += v.first * v.second;
    }

    ans -= n;

    cout << ans << endl;
}

Measured memory_bytes: 14664
import sys

def bubble_sort(size, numbers):
    for i in range(size):
        sorted = True
        for j in range(size - 1, i, -1):
            if numbers[j][1] < numbers[j - 1][1]:
                numbers[j], numbers[j - 1] = numbers[j - 1], numbers[j]
                sorted = False

        if sorted:
            break


def selection_sort(size, numbers):
    for i in range(size):
        minindex = i
        for j in range(i, size):
            if numbers[minindex][1] > numbers[j][1]:
                minindex = j
        if minindex != i:
            numbers[minindex], numbers[i] = numbers[i], numbers[minindex]


def write_result(stdout, sorted_array, original_array):
    stable = True
    for i in range(1, len(sorted_array)):
        if (sorted_array[i - 1][1] != sorted_array[i][1]):
            continue

        index_a = original_array.index(sorted_array[i - 1])
        index_b = original_array.index(sorted_array[i])

        if index_a > index_b:
            stable = False

    stdout.write(" ".join([str(x) for x in sorted_array]) + "\n")
    if stable:
        stdout.write("Stable\n")
    else:
        stdout.write("Not stable\n")


def main(stdin=None, stdout=None):
    if stdin is None:
        stdin = sys.stdin
    if stdout is None:
        stdout = sys.stdout

    size = int(stdin.readline().strip())
    _numbers = stdin.readline().strip().split(" ")

    numbers = _numbers[::]
    swap_count = bubble_sort(size, numbers)
    write_result(stdout, numbers, _numbers)

    numbers = _numbers[::]
    swap_count = selection_sort(size, numbers)
    write_result(stdout, numbers, _numbers)

main()


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,a[202];
string s;
vi basis;
void add(int x){
    for(auto i:basis){
        x=min(x,x^i);
    }
    if(x) basis.pb(x);
}
int check(int x){
    for(auto i:basis){
        x=min(x,x^i);
    }
    return x==0;
}
void solve(){
    basis.clear();
    cin>>n;
    rep(i,0,n) cin>>a[i];
    cin>>s;
    for(int i=n-1;i>=0;i--){
        if(s[i]=='0') add(a[i]);
        else if(check(a[i]));
        else{
            cout<<1<<endl;
            return;
        }
    }
    cout<<0<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3620
using System;
class Program
{
	static void Main(string[] args)
	{
		// スペース区切りの整数の入力
		string[] input = Console.ReadLine().Split(' ');
		long a = long.Parse(input[0]);
		long b = long.Parse(input[1]);
        long n = long.Parse(input[2]);
        double ans = Math.Floor((double)a * (n < b-1 ? n : b-1) / b);
        Console.WriteLine(ans);
	}
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int n,r;
	while(cin>>n>>r,(n!=0&&r!=0)){
		vector<P> h(r);
		rep(i,r)cin>>h[i].first>>h[i].second;

		stack<int> s;
		repi(i,1,n+1)s.push(i);

		rep(i,r){
			stack<int> p,c;
			rep(j,h[i].first-1){
				int x=s.top();s.pop();
				p.push(x);
			}
			rep(j,h[i].second){
				int x=s.top();s.pop();
				c.push(x);
			}
			rep(j,h[i].first-1){
				int x=p.top();p.pop();
				s.push(x);
			}
			rep(j,h[i].second){
				int x=c.top();c.pop();
				s.push(x);
			}
		}
		cout<<s.top()<<endl;
	}
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    int ans = 0;
    for(int a=1; a<n; a++) {
        for(int b=1; b<n; b++) {
            if(a*b<n) ans++;
            else break;
        }
    }
    cout << ans << endl;
}

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

int main() {
    int n,r=0,w=0,f_w=200001,l_r=0;
    ll ans=0;
    string s;
    cin>>n>>s;
    
    rep(i,0,n){
        if(s[i]=='R'){
            r++;
            l_r=max(l_r,i);
        }else{
            w++;
            f_w=min(f_w,i);
        }
    }
    
    if(w==0 || r==0 || l_r<f_w){
        cout<<"0"<<endl;
        return 0;
    }

    int le=0,ri=n-1;

    while(true){
        while(s[le]=='R'){
            le++;
        }
        while(s[ri]=='W'){
            ri--;
        }
        if(le<ri){
            s[le]='R';
            s[ri]='W';
            ans++;
        }else{
            break;
        }
    }
    cout<<ans<<endl;
}



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

int main() {
	ll n;
	cin>>n;ll j=0;ll sum=0;
	while(n>sum){
		j++;
		sum+=j;
	}
	cout << j;
	return 0;
}

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

using namespace std;

typedef long long ll;

int main(){

	int n;
	while(cin>>n&&n!=0){
//		vector<pair<int,int> > v;
		ll info[4001];
		bool appeared[4001];
		fill(info,info+4001,0);
		fill(appeared,appeared+4001,false);
		vector<int> numList;
		for(int i = 0; i < n; i++){
			int num;
			int val;
			int ko;
			cin>>num>>val>>ko;
			if(!appeared[num]){
				appeared[num]=true;
				numList.push_back(num);
			}

			info[num]+=((ll)val)*ko;
		}

		bool f=false;
		for(int i = 0; i < numList.size(); i++){
			if(info[numList[i]]>=1000000){
				cout<<numList[i]<<endl;
				f=true;
			}
		}
		if(!f)
			cout<<"NA"<<endl;
	}

	return 0;
}

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

int main(){
  int A,B,H,M;
  cin >> A >> B >> H >> M;
  long double pi = 3.1415926535897932384626433832795028841971693993;
  long double angle_A = (60*H+M)*pi/360;
  long double angle_B = M*pi/30;
  long double angle = angle_A - angle_B;
  
  long double x = sqrt(A*A+B*B-2*A*B*cos(angle));
  cout << fixed << setprecision(20) << x << endl;
}

Measured memory_bytes: 4160
using System;
using System.Text;

public class Test
{
	static public void Main( )
	{
		StringBuilder output = new StringBuilder();
		int[] rc = Array.ConvertAll( Console.ReadLine().Split( ' ' ), int.Parse );
		int r = rc[0];
		int c = rc[1];
		
		int[] total = new int[ c+1 ];
		int t = 0;
		for( var i=0; i<r; i++ ) {
			string[] nums = Console.ReadLine().Split( ' ' );
			int sum = 0;
			for( var j=0; j<c; j++ ) {
				int x = int.Parse( nums[j] );
				sum += x;
				t += x;
				total[j] += x;
			}
			output.AppendLine( string.Join( " ", nums )+" "+sum.ToString() );
		}
		total[c]= t;
		output.AppendLine( string.Join( " ", Array.ConvertAll( total, Convert.ToString ) ) );
		
		Console.Write( output );
	}
}

Measured memory_bytes: 20164
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;
#[derive(Clone, Debug, Default)]
struct Struct;


// [l,h) の中でもっとも手前のfalseになる場所を探す. 全てのtrueはfalseより手前にある必要がある.
fn partition_point<F>(l0: usize, h0: usize, f: F) -> usize
where
    F: Fn(usize) -> bool,
{
    let mut l = l0;
    let mut h = h0;

    while h - l > 0 {
        let m = l + (h - l) / 2;
        if f(m) {
            l = m + 1;
        } else {
            h = m;
        }
    }
    return l;
}





fn is_possible(
    score: i64,
    n: usize,
    m: usize,
    v: usize,
    p: usize,
    a: &Vec<i64>,
    asum: &Vec<i64>,
) -> bool {
    if a[n - p] <= score {
        true
    } else if (score + m as i64) < a[n - p] {
        false
    } else {
        // 点数がscore以下の問題low個全てに、全員が1票を入れる
        // high=n-(p-1)以降の問題全てに、全員が1票を入れる
        // 間のhigh-low個の問題に、スコアがscore+m を超えないように残りの票(v-low-(p-1))*mを振り分けることができるか?
        let low = partition_point(0, n, |i| a[i] <= score);
        let high = n - (p - 1);
        let remain_votes_per_judge = v as i64 - low as i64 - (p - 1) as i64;
        if remain_votes_per_judge <= 0 {
            true
        } else {
            let capacity = (score + m as i64) * ((high - low) as i64) - (asum[high] - asum[low]);
            remain_votes_per_judge * m as i64 <= capacity
        }
    }
}

//#[proconio::fastout]
fn main() {
    input! {
        n:usize,
        m:usize,
        v:usize,
        p:usize,
        a_:[i64;n],
    }

    let mut a: Vec<i64> = a_;
    a.sort();
    let mut sum: i64 = 0;
    let mut asum = Vec::with_capacity(n + 1);
    asum.push(0);
    for x in &a {
        sum += *x as i64;
        asum.push(sum);
    }

    
    let mut ok: i64 = 1000000000i64;
    let mut ng: i64 = -1;


    while ok - ng > 1 {
        let middle = ng + (ok - ng) / 2;
        if is_possible(middle, n, m, v, p, &a, &asum) {
            ok = middle;
        } else {
            ng = middle;
        }
        //println!("ok={}, ng={}", ok, ng);
    }

    let l = partition_point(0, n, |i| a[i] < ok);
    println!("{}", n - l);
}


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

long long gcd(long long a, long long b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

long long lcm(long long a, long long b)
{
   return a * b / gcd(a, b);
}

int main()
{
  long long a, b;
  cin >> a >> b;
  
  cout <<  lcm(a, b) << endl;  
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

int main(void) {
  cout.precision(12);
  long N, K;
  cin >> N >> K;
  double ans = 0;
  for (long i = 1; i <= N; i++) {
    double tmp = 1.0 / N;
    long current = i;
    while (current < K) {
      current *= 2;
      tmp /= 2;
    }
    ans += tmp;
  }
  cout << ans << endl;
  return 0;
}


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

typedef struct pp {
  char name[100];
  int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue (P x) {
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue () {
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a, int b) {return a < b ? a : b;}

int main() {
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);
  
  for (i = 1; i <= n; i++) {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;
  
  while (head != tail) {
    u = dequeue();
    c = min(q, u.t);
    u.t -=c;
    elaps +=c;
    if(u.t > 0) enqueue(u);
    else {
      printf("%s %d\n", u.name, elaps);
    }    
  }
  
  return 0;
}
    
    



Measured memory_bytes: 13360
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 8080
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;

typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

long long int MOD = 1000000007;
int N;
vector<ll> a;
ll Z,W;
int main(){
	cin>>N;
	cin>>Z>>W;
	for(int i=0;i<N;i++){
		ll hoge;
		cin>>hoge;
		a.pb(hoge);
	}
	if(N==1)cout<<abs(a[N-1]-W)<<endl;
	else cout<<max(abs(a[N-1]-W),abs(a[N-1]-a[N-2]))<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();    
    double ad = (double)a / d;
    double cd = (double)c / b;
    int ansa = 0;
    int ansc = 0;
    if(ad % 1 != 0){
      ad++;
      ansa = (int)ad;
    }else{
      ansa = (int)ad;
    }
    
    if(cd % 1 != 0){
      cd++;
       ansc = (int)cd;
    }else{
      ansc = (int)cd;
    }  
    if(ansa >= ansc){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 35940
#include <cstdio>
#include <map>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

int main(){
    int N;
    scanf("%d", &N);
    vector<int> cnt(100010, 0);
    int temp;
    for(size_t i=0; i<N; i++){
        scanf("%d", &temp);
        cnt[temp]++;
        cnt[temp+1]++;
        cnt[temp+2]++;
    }

    printf("%d\n", *std::max_element(cnt.begin(), cnt.end()));
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))
const ll INF = 1e9 + 1e6 + 1e3 + 1;


int main(){
  ll n, d, a;
  cin >> n >> d >> a;
  P monster[200200];
  rep(i, n){
    ll x, h;
    cin >> x >> h;
    monster[i] = P(x, h);
  }
  sort(monster, monster + n);
  ll hp[200200], x[200200];
  fill(x, x + 200200, INF);
  rep(i, n){
    hp[i] = (monster[i].second + a - 1) / a;
    x[i] = monster[i].first;
  }
  ll ans = 0;
  ll damage[200200];
  int pos = 0;
  fill(damage, damage + 200200, 0);
  for(int i = 0; i < n; i++){
    while(pos < i){
      pos++;
      damage[pos] += damage[pos-1];
      hp[pos] += damage[pos];
    }
    if(hp[i] <= 0) continue;
    ans += hp[i];

    damage[i] -= hp[i];
    int idx = lower_bound(&x[i], x + n, x[i] + 2*d+1) - x;
    damage[idx] += hp[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 11416
import Control.Applicative ((<$>))
import Control.Monad (replicateM, unless)

import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B

import Data.List (unfoldr)

main :: IO ()
main = do
  n <- readLn
  unless (n == 0) $ do
    getLine
    solve n <$> B.getLine >>= print
    main

solve :: Int -> ByteString -> Int
solve n = sum . map f . unfoldr ioi
  where f p = max 0 (p - n + 1)

ioi :: ByteString -> Maybe (Int, ByteString)
ioi bs = f 0 (B.drop 1 bs1)
  where (_, bs1) = B.break (== 'I') bs
        f ct s | B.null s = Nothing
               | B.take 2 s == oi = f (ct+1) (B.drop 2 s)
               | otherwise = Just (ct, s)
        oi = B.pack "OI"



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

using namespace std;
vector<long long> factors;
#define ll long long




#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

template<typename T>
int BS(vector<T>& mas,T val){
	int l,r;
	l = 0;
	r = mas.size() - 1;
	while(r - l > 1){
		int mid = l + (r - l)/2;
		if(mas[mid] < val){
			l = mid;
		} else
			r = mid;
	}
	if(mas[r] == val)
		return r;
	if(mas[l] == val)
		return l;
	return -1;
}

ll mod(ll a, ll m)
{ return (a + (abs(a) / m) * m + m) % m; }



int main()
{
	IOS

	int n;
	cin >> n;
	string a,b,c;
	cin >> a >> b >> c;
	int count = 0;
	for(int i = 0;i < n; ++i){
		if(!(a[i] == b[i] && b[i] == c[i])){
			if(a[i] == b[i]){
				c[i] = a[i];
				++count;
			}
			else if(a[i] == c[i]){
				b[i] = a[i];
				++count;
			}
			else if(c[i] == b[i]){
				a[i] = c[i];
				++count;
			}else{
				a[i] = c[i];
				b[i] = c[i];
				count += 2;
			}
		}
	}
	cout << count;
	return 0;
}
/*
4
 F
 F
 F
 F
 */
/*
4
 C
 C
 3
 3
 */
/*
 12
 FC0
 FC0
 FC0
 FC0
 FC0
 FC0
 FC0
 FC0
 FC0
 FC0
 FC0
 FC0

 */

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)	
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long
#define pb(a) push_back(a)
const ll INF = 0x3f3f3f3f;
const ll inf = pow(10,18);
ll modulo = pow(10,9)+7  ;
#define ld long double
#define MAX (int)(pow(10,5)+ 10)

ll dp[110][MAX];
 
void deal(){
	ll n , w;
	cin>>n>>w;
	forj(MAX)
		dp[0][j] = inf;
	dp[0][0] = 0;
	for(ll i =1; i<=n; i++){
		ll ed , vi;
		cin>>vi>>ed;
		forj(MAX)
			dp[i][j] = inf;
		for(ll j = ed; j<MAX; j++)
			dp[i][j] = dp[i-1][j-ed] + vi;
		forj(MAX)
			dp[i][j] = min(dp[i][j], dp[i-1][j]);
	}
	for(ll j = MAX-1; j>-1; j--){
		if(dp[n][j] <= w){
			cout<<j;
			return;
		}
	}
}
 
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}
 
/*
 
5 1
1 2 3 4 5


*/

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

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

    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22) cout << "bust\n";
    else cout << "win\n";
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = 1
B = 2
C = 1
mod = 10**9+7
for i in range(N):
  A *= 10
  A %= mod
  B *= 9
  B %= mod
  C *= 8
  C %= mod
ans = (A-B+C)%mod
print(ans)

Measured memory_bytes: 63348
#include <iostream>
using namespace std;
int main(void){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3, y3, x4, y4;
     
    x3 = x2 - (y2 - y1);
    y3 = y2 + (x2 - x1);
    x4 = x1 - (y2 - y1);
    y4 = y1 + (x2 - x1);
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < N; i++)
#define vec vector<int>
using namespace std;
int main()
{

    int N, M;
    cin >> N >> M;
    vec A(N), B(N);
    vector<pair<int, int>> AB(N);

    rep(i, N)
    {
        cin >> A[i] >> B[i];
    }
    rep(i, N)
    {
        AB[i] = make_pair(A[i], B[i]);
    }
    sort(AB.begin(), AB.end());
    long long sum = 0;
    rep(i, N)
    {
        long long m = min(M, AB[i].second);
        sum += m * AB[i].first;
        M -= m;
    }
    cout << sum << endl;
}


Measured memory_bytes: 1792
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
A = iil()

#ここから解説見る
ans = 0
d = {}
for i,item in enumerate(A):
    ans += d.get(i-item,0)
    d[i+item] = d.get(i+item,0)+1

print(ans)

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

int main() {
  int s; cin >> s;
  vector<bool> check(5, false);
  int ans = 1;

  while (true) {
    if (s <= 4) {
      if (check[s]) break;
      else check[s] = true;
    }

    if (s % 2 == 1) s = 3 * s + 1;
    else s /= 2;
    ans++;
  }
  
  cout << ans << endl;
}

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

using namespace std;

//#define FILE_IO

typedef pair<int, int> pii;

int N, K;
vector <int> edg[2005];
vector <pii> edges;
int d[2005];
queue <int> q;

int solve(int nod1, int nod2)
{
    for(int i = 1; i <= N; i++)
        d[i] = 1 << 30;
    q.push(nod1);   d[nod1] = 0;
    q.push(nod2);   d[nod2] = 0;
    while(!q.empty())
    {
        int x = q.front();
        q.pop();

        for(auto nxt: edg[x])
            if(d[nxt] > d[x] + 1)
            {
                d[nxt] = d[x] + 1;
                q.push(nxt);
            }
    }
    int cnt = 0;
    for(int i = 1; i <= N; i++)
        if( d[i] > K / 2 )
            cnt++;
    return cnt;
}

int solve(int nod)
{
    return solve(nod, 0);
}


int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d%d", &N, &K);
    for(int i = 1; i < N; i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        edg[x].push_back(y);
        edg[y].push_back(x);
        edges.push_back({x, y});
    }

    int ans = 1 << 30;

    if(K % 2 == 0)
        for(int i = 1; i <= N; i++)
        {
            int sol = solve(i);
            ans = min(ans, sol);
        }
    else
        for(auto e: edges)
        {
            int sol = solve(e.first, e.second);
            ans = min(ans, sol);
        }

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vdouble = vector<double>;

int gcd(int a, int b) {
    if (b==0) return a;
   	else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}



int main(){
	ll a,b;
	cin>>a>>b;
	
	REP(i,max(a,b))cout<<min(a,b);
	
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define mod 1000000007
typedef long long ll;
using namespace std;

int GCD(int a, int b){
    if(a == 0) return b;
    if(b == 0) return a;
    else return GCD(b, a%b);
}

int main(){
    int N; cin >> N;
    int A[100005];
    int GCD_for[100005]; // GCD_for[i] := [0,i)のGCD
    int GCD_back[100005]; // GCD_back[i] := [i,N)のGCD
    for(int i=0;i<N;i++) cin >> A[i];
    GCD_for[0] = 0;
    GCD_back[N] = 0;
    for(int i=0;i<N;i++){
        GCD_for[i+1] = GCD(GCD_for[i], A[i]);
        GCD_back[N-1-i] = GCD(GCD_back[N-i], A[N-1-i]);
    }

    int ans = 1;
    for(int i=0;i<N;i++){
        ans = max(ans, GCD(GCD_for[i], GCD_back[i+1]));
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	int a,b;
	cin>>a>>b;
	if(b%2!=0){
		cout<<"No"<<endl;
	}
	else{
		int x=4*a;
		int y=2*a;
		if(b>=y && b<=x){
			cout<<"Yes"<<endl;
		}
		else{
			cout<<"No"<<endl;
		}
	}
}

Measured memory_bytes: 3588
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7

n, a, b = map(int, input().split())

ans = pow(2, n, mod) - 1

def fur(n,r):
    p,q = 1,1
    for i in range(r):
        p = p*(n-i)%mod
        q = q*(i+1)%mod
    return p * pow(q,mod-2,mod) % mod

print((ans - fur(n, a) - fur(n, b)) % mod)

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 1e5;
int n, x, m;
vi a, b, t, d;
ll k, p;
void merge(vi&x, vi&y, vi&z){
  FOR(i, 0, n-1) t[i] = y[x[i]];
  FOR(i, 0, n-1) z[i] = t[i];
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> x;
  p = x;
  FOR(i, 0, n-1){
    int _x;
    cin >> _x;
    d.pb(_x-x);
    x = _x;
    a.pb(i);
    b.pb(i);
  }
  t.resize(n-1);
  cin >> m >> k;
  FOR(i, 0, m){
    int s;
    cin >> s;
    swap(a[s-2], a[s-1]);
  }
  while(k > 0){
    if(k%2) merge(b, a, b);
    merge(a, a, a);
    k >>= 1;
  }
  FOR(i, 0, n){
    printf("%lld\n", p);
    if(i == n-1) break;
    p += d[b[i]];
  }
  return 0;
}

Measured memory_bytes: 3052
#include<cstdio>
using namespace std;
bool suan(int N){
	if(N==1)	return true;
	for(int i=2,n;i*i<=N;i++){
		if(N % i == 0&&N!=i){
			n=N;
			while(n % i == 0)	n/=i;
			if(n==1)	return true;
		}
	}
	return false;
}
int N;
int main(){
	scanf("%d",&N);
	while(N){
		if(suan(N)){
			printf("%d",N);
			return 0;
		}
		--N;
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int maxn = 300;
int n, a[maxn][2], acnt, d1, d2;
int co[maxn * 2][maxn * 2][2];

void dfs(int x, int y, int d) {
	for (int i = -1; i <= 1; i += 2)
		for (int j = -1; j <= 1; j += 2)
			for (int k = 1; k <= acnt; ++k) {
				int xx = x + i * a[k][0], yy = y + j * a[k][1];
				if (xx >= 0 && xx < n * 2 && yy >= 0 && yy < n * 2 && !co[xx][yy][d]) {
					co[xx][yy][d] = 3 - co[x][y][d]; dfs(xx, yy, d);
				}
			}
}


void add(int v, int d) {
	acnt = 0;
	for (int i = 0; i * i <= v; ++i) {
		int d = v - i * i, dd = sqrt(d) + 0.5;
		if (dd * dd == d) {
			a[++acnt][0] = i; a[acnt][1] = dd;
		}
	}
	for (int i = 0; i < n * 2; ++i)
		for (int j = 0; j < n * 2; ++j) {
			if (!co[i][j][d]) {
				co[i][j][d] = 1; dfs(i, j, d);
			}
		}
}

int main() {
	scanf("%d%d%d", &n, &d1, &d2);
	add(d1, 0); add(d2, 1);
	for (int i = 1; i <= 2; ++i)
		for (int j = 1; j <= 2; ++j) {
			int cnt = 0;
			for (int k = 0; k < n * 2; ++k)
				for (int l = 0; l < n * 2; ++l)
					if (co[k][l][0] == i && co[k][l][1] == j) ++cnt;
			if (cnt >= n * n) {
				cnt = 0;
				for (int k = 0; k < n * 2; ++k)
					for (int l = 0; l < n * 2; ++l)
						if (co[k][l][0] == i && co[k][l][1] == j) {
							printf("%d %d\n", k, l);
							if (++cnt == n * n) return 0;
						}
			}
		}
}


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

const int INF = 10000000;

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

  double s = INF;
  int ans;
  for(int i = 0; i < n; i++) {
    double u = max((double)a, t - h[i] * 0.006) - min((double)a, t - h[i] * 0.006);
    if (s > u) {
      s = u;
      ans = i + 1;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256