akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,m,d;
	cin>>n>>m>>d;
	vs in(1010,string(1010,' '));
	if(d%2){
		rep(i,n)rep(j,m)if((i+j)%2)in[i][j]='R';
		else in[i][j]='Y';
	}else{
		int q=1;
		rep(i,1010){
			if(i%d==0)q^=1;
			int cnt=1+(i/2)%(d/2);
			int p=0;
			int x=0,y=i;
			if(!q){
				while(y>=0){
					if(!p)in[x][y]='R';
					else in[x][y]='Y';
					cnt--;
					if(cnt==0){
						cnt=d/2;
						p^=1;
					}
					x++;y--;
				}
			}else{
				while(y>=0){
					if(!p)in[x][y]='B';
					else in[x][y]='G';
					cnt--;
					if(cnt==0){
						cnt=d/2;
						p^=1;
					}
					x++;y--;
				}
			}
			i++;
		}
	}
	rep(i,n)rep(j,m)if(in[i][j]==' ')in[i][j]=in[i+1][j];
	rep(i,n)cout<<in[i].substr(0,m)<<endl;
	
}








Measured memory_bytes: 1536
#include <iostream>

using namespace std;

const int MAX_N = 100;

void printArr(int arr[], int n) {
	for(int i = 0; i < n - 1; i ++) {
		cout << arr[i] << " ";
	}
	cout << arr[n - 1] << endl;
}

void insertionSort(int arr[], int n) {
	printArr(arr, n);

	for(int i = 1; i < n; i ++) {
		int e = arr[i];
		int j = i;
		for(; j > 0; j --) {
			if(e < arr[j - 1]) {
				arr[j] = arr[j - 1];
			} else {
				break;
			}
		}
		arr[j] = e;

		printArr(arr, n);		
	}
}



int main(){
	int n;
	int arr[MAX_N];
	cin >> n;
	for(int i = 0; i < n; i ++) {		
		cin >> arr[i];
	}
	insertionSort(arr, n);
}

Measured memory_bytes: 3072
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
long long a[400005];
long long aabs(long long x) {
    return max(x, -x);
}
char s[1000000];
int main() {
    int w;
    scanf("%s%d", s + 1, &w);
    int len = strlen(s + 1);
    for (int i = 1; i <= len; i += w) {
        cout << s[i];
    }
    return 0;
}

Measured memory_bytes: 256
n=int(input())
lst=[list(map(int,input().split())) for _ in range(n)]
dp=[[0]*3 for i in range(n+1)]      #dpテーブル（二次元）

for i in range(1,n+1):
    for j in range(3):      #jはi-1における遊び方
        for k in range(3):      #kはiにおける遊び方
            if(j==k):           #i-1→iに移るとき，j=kは制限により除外
                continue
            dp[i][k]=max(dp[i][k],dp[i-1][j]+lst[i-1][k])       #dp[i]におけるそれぞれのkについて，i-1のそれぞれのjから移り，最大値を更新していく
print(max(dp[n]))       #dp[i]はそれぞれみっつ（各遊び方に対応）あるので，最大値を出力


Measured memory_bytes: 74072
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    int ans = 0;
    int next = 1;
    REP(i,n) {
        int a; cin >> a;
        if (a == next) {
            next++;
        } else {
            ans++;
        }
    }
    if (next == 1) OUT(-1)
    else OUT(ans)

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
 
#define IS_DEBUG true
 
#define DEBUG_OUTPUT(X) if (IS_DEBUG) cout << X << endl
#define RESULT_OUTPUT(X) cout << X << endl
 
int main()
{
	int H, W;
	cin >> H >> W;
 
	vector<string> S;
	for (int i = 0; i < H; i++)
	{
		string s;
		cin >> s;
		S.push_back(s);
	}
 
	for (int i = 0; i < H; i++)
	{
      for (int j = 0; j < W; j++)
      {
        if (S[i][j] == '#')
        {
          if ((i > 0 && S[i - 1][j] == '#') ||
              (j > 0 && S[i][j - 1] == '#') ||
              (j + 1 < W && S[i][j + 1] == '#') ||
              (i + 1 < H && S[i + 1][j] == '#'))
            continue;
          RESULT_OUTPUT("No");
          return 0;
        }
      }
    }
 
  	RESULT_OUTPUT("Yes");
 
	if (IS_DEBUG)
	{
		int end;
		cin >> end;
	}
	return 0;
}

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

map<long long,int> mp;

int main()
{
    int n;

    cin >> n;

    long long sum = 0 , ans = 0;

    for(int i = 1 ; i<=n ; i++)
    {
        int x;

        cin >> x;

        sum+=x;

        ans+=mp[sum];

        mp[sum]++;
    }

    cout << ans+mp[0];

    return 0;
}


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

using namespace std; 

const int maxn=2e5+1e2;
const int maxm=2e9;
map <int,int> mp;

int a[maxn],cur[maxn]={0},num[maxn],link[maxn];

int cmp(int a,int b)
{
	return a>b;
}

int main()
{
	int n,ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++)
	{
		bool flag=false;
		for(int j=30;j>=1;j--)
		{
			if(mp[(1<<j)-a[i]]>0)
			{
				mp[(1<<j)-a[i]]--;
				ans++;
				flag=true;
				break;
			}
		}
		if(!flag)mp[a[i]]++;
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> clear(n+1),wrong(n+1);
    int ac=0,wa=0;
    rep(i,m){
        int num;
        string s;
        cin >> num >> s;
        if(s == "AC"){
            if(clear.at(num)==0){
                clear.at(num)=1;
                ac++;
                wa += wrong.at(num);
            }
        }else{
            if(clear.at(num)!=1){
                wrong.at(num)++;
            }
        }
    }
    cout << ac << " " << wa << endl;
}


Measured memory_bytes: 4036
#include <iostream>
using namespace std;
int main(void){
    int a, min, ans;
    ans = 0;
    min = 10;
    for(int i=0; i < 5; i++){
        cin >> a;
        if(a%10 == 0){
            ans += a;
        }else{
            if(a%10 < min){
                min = a%10;
                ans += a+10-a%10;
            }else{
                ans += a+10-a%10;
            }
        }
    }
    cout << ans-10+min << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n,m,x[100010],d[100010]={0};
int a[100010]={0},b[100010]={0};

void solve(){
    cin >> n >> m;
    rep(i,n){
        cin >> x[i];
        d[x[i]]+=1;
    }
    rep(i,100001){
        a[i%m]+=d[i];
        b[i%m]+=2*(d[i]/2);
    }
    ll ans=0;
    rep(i,m){
        //cout << a[i]<< " " << b[i] << endl;
    }
    for (int k=0;m-k>=k;k++){
        if ((m-k)%m==k) {
            ans+=a[k]/2;
            //cout << k << " " << a[k]/2 << endl;
        }
        else{
            int s=min(a[k],a[m-k]);
            int l1=max(0,s-(a[k]-b[k])),l2=max(0,s-(a[m-k]-b[m-k]));
            ans+=s+(b[k]-l1)/2+(b[m-k]-l2)/2;
            //cout << k << " " <<  m-k << " " << s+(b[k]-l1)/2+(b[m-k]-l2)/2 << " " << endl;

        }
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 1792
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))
typedef long long ll;
const int INF = 1e9;
const ll LLINF = 1e18;
ll mod = 1e9+7;

long long power(long long x, long long c) {
    if(c==0) return 1;
    if(c==1) return x;
    if (c%2==1) return (power( (x*x)%mod, c/2)*x)%mod;
    else return power( (x*x)%mod, c/2)%mod;
}

int main() {
    int N;
    cin>>N;
    
    int nums[100009];
    mem(nums,0); nums[0]++;
    
    rep(i,N){
        int d;scnd1(d);
        nums[d]++;
    }
    
    int p = N%2==0 ? 1:0;
    while(p<N){
        if(nums[p]!=2){
            cout1(0);
            return 0;
        }
        p += 2;
    }
    cout1(power(2,N/2));
}

Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<queue>
#include<string.h>
using namespace std;
struct Y{
int hx,hy,rx,ry,t;
};
int c[51][51][51][51],mp[52][52];
int main(){
int w,h,i,j,a[2]={1,-1},b[2];
Y e;
while(1){
queue<Y> q;
cin>>w>>h;
if(w==0&&h==0)break;
cin>>e.hx>>e.hy>>e.rx>>e.ry;
e.t=0;
q.push(e);
memset(c,0,sizeof(c));
memset(mp,-1,sizeof(mp));
for(i=1;i<=h;i++){
for(j=1;j<=w;j++){
cin>>mp[i][j];
}
}
while(!q.empty()){
e=q.front();
q.pop();
c[e.hy][e.hx][e.ry][e.rx]=1;
if(e.t>=100||e.hx==e.rx&&e.hy==e.ry)break;
e.t++;
for(i=0;i<2;i++){
if(mp[e.hy+a[i]][e.hx]==0&&c[e.hy+a[i]][e.hx][e.ry-a[i]][e.rx]==0&&mp[e.ry-a[i]][e.rx]==0){
b[0]=0;
b[1]=0;
if(mp[e.hy+a[i]][e.hx]==0){
e.hy+=a[i];
b[0]=1;
}
if(mp[e.ry-a[i]][e.rx]==0){
e.ry-=a[i];
b[1]=1;
}
c[e.hy][e.hx][e.ry][e.rx]=1;
q.push(e);
if(b[0]==1)e.hy-=a[i];
if(b[1]==1)e.ry+=a[i];
}
if(mp[e.ry-a[i]][e.rx]==0&&c[e.hy][e.hx][e.ry-a[i]][e.rx]==0&&mp[e.hy+a[i]][e.hx]!=0){
b[0]=0;
b[1]=0;
if(mp[e.hy+a[i]][e.hx]==0){
e.hy+=a[i];
b[0]=1;
}
if(mp[e.ry-a[i]][e.rx]==0){
e.ry-=a[i];
b[1]=1;
}
c[e.hy][e.hx][e.ry][e.rx]=1;
q.push(e);
if(b[0]==1)e.hy-=a[i];
if(b[1]==1)e.ry+=a[i];
}
if(mp[e.hy+a[i]][e.hx]==0&&mp[e.ry-a[i]][e.rx]!=0&&c[e.hy+a[i]][e.hx][e.ry][e.rx]==0){
b[0]=0;
b[1]=0;
if(mp[e.hy+a[i]][e.hx]==0){
e.hy+=a[i];
b[0]=1;
}
if(mp[e.ry-a[i]][e.rx]==0){
e.ry-=a[i];
b[1]=1;
}
c[e.hy][e.hx][e.ry][e.rx]=1;
q.push(e);
if(b[0]==1)e.hy-=a[i];
if(b[1]==1)e.ry+=a[i];
}

if(mp[e.hy][e.hx+a[i]]==0&&mp[e.ry][e.rx-a[i]]==0&&c[e.hy][e.hx+a[i]][e.ry][e.rx-a[i]]==0){
b[0]=0;
b[1]=0;
if(mp[e.hy][e.hx+a[i]]==0){
e.hx+=a[i];
b[0]=1;
}
if(mp[e.ry][e.rx-a[i]]==0){
e.rx-=a[i];
b[1]=1;
}
c[e.hy][e.hx][e.ry][e.rx]=1;
q.push(e);
if(b[0]==1)e.hx-=a[i];
if(b[1]==1)e.rx+=a[i];
}
if(mp[e.hy][e.hx+a[i]]==0&&c[e.hy][e.hx+a[i]][e.ry][e.rx]==0&&mp[e.ry][e.rx-a[i]]!=0){
b[0]=0;
b[1]=0;
if(mp[e.hy][e.hx+a[i]]==0){
e.hx+=a[i];
b[0]=1;
}
if(mp[e.ry][e.rx-a[i]]==0){
e.rx-=a[i];
b[1]=1;
}
c[e.hy][e.hx][e.ry][e.rx]=1;
q.push(e);
if(b[0]==1)e.hx-=a[i];
if(b[1]==1)e.rx+=a[i];
}
if(mp[e.ry][e.rx-a[i]]==0&&mp[e.hy][e.hx+a[i]]!=0&&c[e.hy][e.hx][e.ry][e.rx-a[i]]==0){
b[0]=0;
b[1]=0;
if(mp[e.hy][e.hx+a[i]]==0){
e.hx+=a[i];
b[0]=1;
}
if(mp[e.ry][e.rx-a[i]]==0){
e.rx-=a[i];
b[1]=1;
}
c[e.hy][e.hx][e.ry][e.rx]=1;
q.push(e);
if(b[0]==1)e.hx-=a[i];
if(b[1]==1)e.rx+=a[i];
}

}
}
if(e.hy==e.ry&&e.hx==e.rx)cout<<e.t<<endl;
else cout<<"NA"<<endl;
}
return 0;
}

Measured memory_bytes: 29620
#!/usr/bin/env python
import math
N, M = map(int, input().split())
ans = 0
for a in range(1, int(math.sqrt(M))+1):
    if M % a != 0:
        continue
    b = int(M / a)
    if a * N <= M:
        ans = max(ans, a)
    if b * N <= M:
        ans = max(ans, b)
print(ans)


Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#include<ctype.h>

int main(){
	int n, m = 0;
	scanf("%d", &n);
	int temp = n;
	while(temp>0){
		m*=10;
		m += temp%10;
		temp/=10;
	}
	if(n==m) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

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

    string ans[100];
    inc(i, 0, 50){
        inc(j, 0, 100){
            ans[i].pb('#');
            ans[i+50].pb('.');
        }
    }

    // in
    int a, b;cin >> a >> b;

    //cout << "hoge" << endl;

    inc(i, 0, a-1){
        ans[i*2/100*2][i*2%100] = '.';
    }
    inc(i, 0, b-1){
        ans[100-i*2/100*2-1][i*2%100] = '#';
    }

    //cout << "hoge" << endl;

    // out
    cout << "100 100" << endl;
    inc(i, 0, 100){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

int main() {
	int X, Y;
    cin>>X>>Y;
	cout <<  X+Y/2 << endl;
}


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

typedef long long ll;
string s;

int main()
{
    register ll k;
    cin >> s >> k;
    register ll len = s.length();
    register ll ls = 0, rs = len - 1;
    while (ls < len && s[ls] == s[rs]) ++ls;
    if (ls > 0) --ls;
    while (rs >= 0 && s[rs] == s[ls]) --rs;
    if (rs < len) ++rs;
    register ll num = 1, ans = 0;
    for (register int i = ls + 1; i <= rs; ++i) {
        if (s[i] == s[i - 1]) {
            ++num;
        } else {
            ans += (num / 2) * k;
            num = 1;
        }
    }
    ++ls, ++rs;
    // cerr << ls << " " << rs << endl;
    if (s[0] == s[len - 1]) {
        if (ls < rs) {
            num = len - rs + 1 + ls;
            ans += (num / 2) * (k - 1);
            ans += ls / 2;
            ans += (len - rs + 1) / 2;
        } else {
            ans = len * k / 2;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
import math
import bisect
import numpy as np
from collections import defaultdict, deque
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
# INF = float("inf")


def main():
    n = int(input())
    l = list(map(int, input().split()))
    m = max(l)
    s = sum(l) - m
    if m < s:
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()


Measured memory_bytes: 20380
#!/usr/bin/env python3
from collections import deque

N = int(input().split()[0])

# ノードの情報
node_dict = {i + 1: dict(parent=None, children=[]) for i in range(N)}

a_list = []
b_list = []
edge_dict = {}
edge_list = []

# エッジの情報
for _ in range(N - 1):
    a, b = list(map(int, input().split()))
    edge_list.append((a, b))
    edge_dict[(a, b)] = dict(a=a, b=b, color=None)
    a_list.append(a)
    b_list.append(b)

    node_dict[a]["children"].append(b)
    node_dict[b]["parent"] = a

# ルートを探す
root = list(set(a_list) - set(b_list))[0]

max_color_degree = -float("inf")

# 最悪で10 ** 5
for k, v in node_dict.items():
    d = len(v["children"])
    # 親がいない場合は、親の数も含める
    d = d + 1 if v["parent"] else d
    max_color_degree = max(max_color_degree, d)

COLOR_LIST = list(range(max_color_degree))


def color_edge(parent):
    next_node_list = node_dict[parent]["children"]
    parent_parent = node_dict[parent]["parent"]
    parent_edge_color = edge_dict[(parent_parent, parent)]["color"]
    ng_color = parent_edge_color

    # 最悪で10 ** 5
    color_index = 0
    for child in next_node_list:
        color = COLOR_LIST[color_index]
        if color == ng_color:
            color_index += 1
            color = COLOR_LIST[color_index]

        edge_dict[(parent, child)]["color"] = color
        color_index += 1
    return


parent = root
next_node_list = node_dict[root]["children"]
next_next_node_list = []

# 最悪で10 ** 5
color_index = 0
for node in next_node_list:
    color = COLOR_LIST[color_index]
    color_index += 1
    edge_dict[(parent, node)]["color"] = color

# 最悪で10 ** 5
while next_node_list:
    next_parent_list = []
    # 最悪で10 ** 5
    for node in next_node_list:
        color_edge(node)
        next_parent_list += node_dict[node]["children"]
    # コピーはO(N)
    next_node_list = next_parent_list

color_list_str = ""
for edge in edge_list:
    a, b = edge
    color_list_str += str(edge_dict[(a, b)]["color"] + 1) + "\n"

print(max_color_degree)
print(color_list_str)


Measured memory_bytes: 120184
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		String s = sc.next();
		sc.close();
		int ans=101;
		for(char c = 'a'; c<='z';c++) {
			String[] ss = s.split(String.valueOf(c));
			int mx=0;
			for (i = 0; i < ss.length; i++) {
				if(mx<ss[i].length()) mx = ss[i].length(); 
			}
			if(mx<ans)ans=mx;
		}
		out.println(ans);
	}
}


Measured memory_bytes: 20564
#include<iostream>
using namespace std;
#define MAX 2000000

int H, A[MAX + 1];

void maxHeapify(int i) {
	int l, r, largest;
	l = 2 * i;
	r = 2 * i + 1;

	if (l <= H && A[l] > A[i])largest = l;
	else largest = i;
	if (r <= H && A[largest] < A[r])largest = r;

	if (largest != i) {
		swap(A[i], A[largest]);
		maxHeapify(largest);
	}
}

int main() {
	cin >> H;

	for (int i = 1; i <= H; i++)cin >> A[i];

	for (int i = H / 2; i >= 1; i--)maxHeapify(i);

	for (int i = 1; i <= H; i++) {
		cout << " " << A[i];
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 4956
#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
typedef long long int lli;
typedef pair<lli, lli> pii;
#define dbg(x) cout << #x << " has a value of: " << x << "\n";
#define usize(x) (int)(x.size())
#define plist(x)                       \
    for (int i = 0; i < usize(x); i++) \
        cout << "eleman " << i << " = " << x[i] << "\n";
#define foreach(x) for (auto item : x)
#define fill(s, x)              \
    for (int i = 0; i < x; i++) \
        cin >> s[i];
#define in(veriler, a) (veriler.find(a) != veriler.end())
#define btw(x, y, z) x >= y&& x <= z;
std::ostream& operator<<(std::ostream& os, pair<int,int> p) {
    os << p.first << ", " << p.second;
    return os;
}
#ifdef ONLINE_JUDGE
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#else
#define fio //a
#endif
int main(){
	int n;
	cin>>n;
	vector<pii> rts;
	double sm=0;
	for (int i = 0; i < n; i++)
	{
		int a,b;
		cin>>a>>b;
		foreach(rts){
			sm+=sqrt((item.first-a)*(item.first-a)+(item.second-b)*(item.second-b));
		}
		rts.push_back(pii(a,b));
		
	}
	cout<<setprecision(13)<<sm*2/n<<"\n";
	return 0;
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a;
  for (int i = 0 ; i < n; i++) {
    int num;
    cin >> num;
    a.push_back(num);
  }
  sort(a.begin(), a.end(), greater<int>());

  int sum_a = 0;
  int sum_b = 0;
  for (int i = 0; i < n; i++) {
    int num = a.front();
    a.erase(a.begin());
    if (i % 2 == 0) {
      sum_a += num;
    } else {
      sum_b += num;
    }
  }
  cout << sum_a - sum_b << endl;
}


Measured memory_bytes: 888
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=50;
const int MOD=1000000007;
void inc(int &a,int b) { if((a+=b)>=MOD) a-=MOD; }
typedef int Mat[MAXN][MAXN];

int n; ll steps;

void printmat(const Mat &A) { REP(i,n) { REP(j,n) { if(j!=0) printf(" "); printf("%d",A[i][j]); } puts(""); } }

void mmult(Mat &A,Mat &B) {
	//printf("multiplying\n"); printmat(A); printf("and\n"); printmat(B); 
	static Mat X; REP(i,n) REP(j,n) { int cur=0; REP(k,n) cur=(cur+(ll)A[i][k]*B[k][j])%MOD; X[i][j]=cur; } REP(i,n) REP(j,n) A[i][j]=X[i][j];
	//printf("resulting in\n"); printmat(A);
}

void mpow(Mat &A,Mat &B,ll k) {
	static Mat X; REP(i,n) REP(j,n) X[i][j]=A[i][j]; //printf("A\n"); printmat(A); printf("X\n"); printmat(A);
	REP(i,n) REP(j,n) B[i][j]=i==j?1:0;
	while(true) { if(k&1) mmult(B,X); if((k>>=1)==0) return; mmult(X,X); }
}

Mat A;
Mat B;

int solve() {
	//printf("start\n"); printmat(A);
	mpow(A,B,steps);
	int ret=0; REP(i,n) REP(j,n) inc(ret,B[i][j]); return ret;
}

void run() {
	scanf("%d%lld",&n,&steps);
	REP(i,n) REP(j,n) scanf("%d",&A[i][j]);
	printf("%d\n",solve());
}

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P2;
const int inf=1000000000;

int main() {
	ll n,a,b;
	cin>>n>>a>>b;
	ll h[100009]={};
	a-=b;
	for(ll i=0;i<n;++i)cin>>h[i];
	ll ub=1000000001,lb=0;
	while((ub-lb)>1){
		ll mid=(ub+lb)/2;
		ll r=0;
		for(ll i=0;i<n;i++){
			ll le=h[i]-b*mid;
			if(le>0){
				r+=le/a+(le%a!=0);
			}
		}
		if(r<=mid){
			ub=mid;
		}else{
			lb=mid;
		}
	}

	cout<<ub<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define forA(i,a,n,x) for(auto i=a;i<n;i+=x)
#define forD(i,a,n,x) for(auto i=n-1;i>=0;i-=x)
#define ranit(it,n) for(auto it:n)
#define testCases ll t;cin>>t;while(t--)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define init(a,x) memset(a,x,sizeof(a))

int main()
{
	ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
	string s; cin>>s; ll sum=0;
	forA(i,0,s.size(),1)
	{
		sum+=(s[i]-'0');
	}
	if(sum%9==0)cout<<"Yes"; else cout<<"No";
	return 0;
}

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


int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if (A + B > C + D) cout << "Left" << endl;
    else if (A + B < C + D) cout << "Right" << endl;
    else cout << "Balanced" << endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int cnt=0;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    if(a%2==1)cnt++;
  }
  if(cnt==0)cout<<"second"<<endl;
  else cout<<"first"<<endl;
  return(0);
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto&e:c)
#define iter(i,c) for(auto i(begin(c));i!=end(c);++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
template<class C>string to_string(vector<C> c,string d=" "){stringstream s;iter(i,c)s<<*i<<(next(i)==end(c)?"":d);return s.str();}
template<class C>ostream&operator<<(ostream&os,vector<C>const& v){return os<<to_string(v);}
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" (at "<<__LINE__<<")"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif

typedef vector<string> vs;
int h,w;
vs g;
bool valid(int x, int y){
    return 0<=x && 0<=y && x<w && y<h;
}

int solve(){
    vector<pii> space;
    rep(i,h)rep(j,w)if(g[i][j]=='.') space.emplace_back(j,i);
    int ans = 0;
    while(1){
        bool finish = true;
        for(auto p : space){
            map<char,vector<pii>> s;
            int x,y;
            tie(x,y)=p;
            int dx[]={1,0,-1,0};
            int dy[]={0,1,0,-1};
            rep(d,4){
                int cx,cy;
                tie(cx,cy)=tie(x,y);
                while(valid(cx+dx[d],cy+dy[d]) && g[cy][cx]=='.'){
                    cx+=dx[d]; cy+=dy[d];
                }
                if(valid(cx,cy) && g[cy][cx]!='.'){
                    s[g[cy][cx]].emplace_back(cx,cy);
                }
            }
            for(auto & ps : s){
                if(ps.second.size()>=2){
                    for(auto & p : ps.second){
                        int x,y;
                        tie(x,y) = p;
                        g[y][x] = '.';
                        ans++;
                        finish = false;
                        space.emplace_back(x,y);
                    }
                }
            }
        }
        if(finish) break;
    }
    return ans;
}

int main(){
    while(cin>>h>>w){
        g.clear();
        rep(i,h){
            string s;cin>>s;
            g.push_back(s);
        }
        cout << solve() << endl;
    }
}

Measured memory_bytes: 3412
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define WMAX 10000
#define HMAX 10000
#define NMAX 100005

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

ll A[NMAX],N,ans = 0,B[NMAX] = {};
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};


void solve(){
	for (int i = 0; i < N; ++i)
	{
		B[A[i]]++;
		if(B[A[i]] > 1){
			ans++;
		}
	}
}

void debug(){

}

void answer(){
	if(ans%2){
		cout << N-ans-1 << "\n";
	}else{
		cout << N-ans << "\n";
	}
}

int main(){
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i];
	}
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

Measured memory_bytes: 1792
import java.util.*;
public class Main {

		public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
			// 整数の入力
			int A = sc.nextInt();
			// スペース区切りの整数の入力
			int B = sc.nextInt();
			int ans = 0;
			if(A>=13){
				ans = B;
			}else if(6<=A && A<=12)
				ans = B/2;
			else if (5>=A){
				ans = 0;
			}
			System.out.println(ans);
		}

	}

Measured memory_bytes: 23252
s = list(input())
K = int(input())
n = len(s)
for i in range(n-1):
    m = ord('z') - ord(s[i]) + 1
    if not s[i] == 'a' and m <= K:
        s[i] = 'a'
        K -= m
s[n-1] = chr((ord(s[n-1])+K%26-97)%26+97)
print(''.join(s))

Measured memory_bytes: 4152
from heapq import*
import sys
r=sys.stdin.readline
def g(n,E,S,G):
 F=[1e7]*-~n;F[S],H=0,[(0,S)]
 while H:
  c,u=heappop(H)
  if u==G:return print(c)
  for f,v in E[u]:
   t=c+f
   if t<F[v]:F[v]=t;heappush(H,(t,v))
 return print(-1)
def s(n,k):
 E=[[]for _ in[0]*-~n]
 for _ in[0]*k:
  f=r();p=map(int,f[2:].split())
  if'0'==f[0]:g(n,E,*p)
  else:c,d,e=p;E[c]+=[(e,d)];E[d]+=[(e,c)]
for e in iter(r,'0 0\n'):s(*map(int,e.split()))


Measured memory_bytes: 6312
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
 
int A, B, C, D;
 
void Solution() {
 
    while(true) {
        C -= B;
        if (C < 1) break;
        A -= D;
        if (A < 1) break;
    }
 
    if (A >= 1) cout << "Yes" << endl;
    else if (A < 1) cout << "No" << endl;
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    cin >> A >> B >> C >> D;
    Solution();
 
    return 0;
}

Measured memory_bytes: 3652
import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input = br.readLine().split(" ");
        int a = Integer.parseInt(input[0]);
        int b = Integer.parseInt(input[1]);

        System.out.println(GCD(a, b));
    }

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

Measured memory_bytes: 24296
#include<stdio.h>
int main(void){
    int n,k;
    char val;
    char s[1000010];
    scanf("%d",&n);
    scanf("%s",&s);
    scanf("%d",&k);
    val=s[k-1];
    int i;
    
    for(i=0;i<n;i++)
    {
        if(s[i]!=val)
        {
            s[i]='*';
        }
    }
    
    printf("%s",s);
    
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,x;
    cin>>a>>b>>x;
    if(x>a+b || x<a)
    {
        cout<<"NO"<<endl;
    }
    else
    {
       cout<<"YES"<<endl;
    }
    return 0;
}

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

const int N = 101;
int n, m, a[N], sum = 0, tot = 0;

int main()
{
  fastio;
  cin >> n >> m;
  for (int i = 1; i <= n; i++){
    cin >> a[i]; sum += a[i];
  }
  for (int i = 1; i <= n; i++){
    tot += (a[i] * 4 * m >= sum);
  }
  cout << (tot >= m ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
using namespace std;

int main(){
  int A,B,C;
  cin>>A>>B>>C;
  cout<<min(A*B,C)<<endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define si(a) scanf("%d",&a)
#define sll(a) scanf("%lld",&a)
#define sl(a) scanf("%ld",&a)
#define pi(a) printf("%d\n",a)
#define pl(a) printf("%ld\n",a)
#define pll(a) printf("%lld\n",a) 
#define sc(a) scanf("%c",&a)a
#define pc(a) printf("%c",a)
#define ll long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define INF INT_MAX
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define VI vector<int>
#define VL vector<ll>
#define PI pair<int,int>
#define PL pair<ll,ll>
long double PIE=acos(-1);
//////////////////////////////////////////////////////////////
const ll N=1e5+5;
ll Ans=1;
bool done[1000009];
vector < ll > primes;

void FindPrime(ll N)
{
    done[1] = 1;
    for(int i=2;i<=N;i++)
	{
        if(done[i]) continue;
        for(int j=i*2;j<=N;j+=i)
		{
            done[j] = 1;
        }
        primes.push_back(i);
    }
}

ll solve(ll Num)
{
    for(int i=0;i<primes.size();i++)
	{
    	int p=primes[i];
        if(p*p*p > Num) break;
        ll Count = 1;
        while(Num%p == 0)
		{
            Num /= p,Count++;
        }
        Ans *= Count;
    }
    ll sq = (ll)sqrt(Num);
    if(!done[Num]) 
	Ans *= 2;
    else if(sq*sq == Num && !done[sq]) 
	Ans *= 3;
    else if(Num != 1) 
	Ans *= 4;
    return Ans;
}


ll fact[N], invfact[N];



ll pow(ll a, ll b, ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

ll modinv(ll k)
{
	return pow(k, mod-2, mod);
}


ll nCr(ll x, ll y)
{
	if(y>x)
		return 0;
	ll num=fact[x];
	num*=invfact[y];
	num%=mod;
	num*=invfact[x-y];
	num%=mod;
	return num;
}

void initinv()
{
	fact[0]=1;
	fr(i,1,N)
	{
		fact[i]=(i*fact[i-1])%mod;
	}
	invfact[N]=modinv(fact[N]);
	for(int i=N-1;i>=1;i--)
	{
		invfact[i]=((i+1)*invfact[i+1])%mod;
	}
}
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////

int main()
{
	double x;
	cin>>x;
	if(x>=30)
	cout<<"Yes\n";
	else
	cout<<"No\n";
	return 0;
}



//eVTWvt22KTVSm@v

Measured memory_bytes: 3708
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define V vector
template <typename T> bool chmin(T &a, const T &b) {if(a > b){a = b; return true;} return false;}
template <typename T> bool chmax(T &a, const T &b) {if(a < b){a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill (A (&array)[N], const T & val) {fill ((T*)array, (T*)(array+N), val);}
V<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
V<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

const ll INF = 1e18;

bool srt (P a, P b) {
    return a.first + a.second < b.first + b.second;
}

int main () {
    int n; cin >> n;
    V<P> v(n);
    rep(i, n) cin >> v[i].first >> v[i].second;
    sort(all(v), srt);
    V<ll> dp(n+1, INF);//dp[i]:i人積んだ時のpの総和のmin
    dp[0] = 0;
    rep(i, n) {//(i+1)人目が積む;h[i], p[i] 
        for (int j = i; j >= 0; j--) {
            if (dp[j] <= v[i].first) chmin(dp[j+1], dp[j] + v[i].second);
        }
    }
    for (int i = n; i >= 0; i--) {
        if (dp[i] != INF) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n; 0 <= i; --i)
#define FOR(i, start, end) for (int i = start; i < end; ++i)
#define RFOR(i, start, end) for (int i = start; end <= i; --i)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
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; }

double dis(double x1, double y1, double x2, double y2) {
    return sqrt(pow(x1-x2, 2) + pow(y1-y2, 2));
}

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

    ll N; cin >> N;
    double x[N], y[N]; REP (i, N) cin >> x[i] >> y[i];
    double ans = 0.0;
    REP (i, N) {
        REP (j, N) {
            if (i>=j) continue;
            ans += dis(x[i], y[i], x[j], y[j]);
        }
    }

    ans = ans * 2.0 / double(N);
    cout << std::setprecision(12) << ans << '\n';
    return 0;
}


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

int main() {
  int A,B;
  cin >>A >>B;
  
  if((A+B)%2==1){
    cout <<"IMPOSSIBLE" <<endl;
    return 0;
  }
  else{
    cout <<(A+B)/2 <<endl;
  return 0;
  }
} 

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i, n) for (int i = 0; i < int(n); i++)
#define FOR1(i, m, n) for (int i = int(m); i < int(n); i++)
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))

int main(int argc, char *argv[])
{
  int N;
  set<int> input;
  int w = 0, h = 0;

  scanf("%d", &N);

  FOR(i, N) {
    int a;

    scanf("%d", &a);

    if (input.find(a) != input.end()) {
      if (a > w) {
        h = w;
        w = a;
      } else if (a > h) {
        h = a;
      }
      input.erase(a);
    } else {
      input.insert(a);
    }
  }

  ll area = (ll)w * (ll)h;

  printf("%lld\n", area);
  
  return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main(){

  int a;
  set<int> s;
  for(int i=0;i<28;i++){
    cin >> a;
    s.insert(a);
  }
  
  for(int i=1;i<=30;i++){
    if(s.find(i) == s.end()) cout << i << endl;
  }
  return (0);
}

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

using namespace std;

using int64 = long long;

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

  int n, k;
  cin >> n >> k;
  string str;
  cin >> str;
  str[k - 1] = str[k - 1] + 32;
  cout << str << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
#define   Y            imag()
#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
//#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
//#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
//#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(double a,double b){   return fabs(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(int num, int idx) {return ((num >> idx) & 1) == 1;}
ll setBit1(ll num, int idx) {return num | (1ll<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(int num, int idx) {return num ^ (1<<idx);}
void FS(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int N=200009,mod=1e9+7;
string st;
char B[N];
int n;
void fin()
{
    cout<<"0"<<endl;
    exit(0);
}
int main()
{

    cin>>n>>st;
    if(st[0]=='W')
    {
        fin();
    }

    B[0]='L';
    for(int i=1;i<n*2;i++)
    {
        if(st[i]==st[i-1])
        {
            if(B[i-1]=='L')
                B[i]='R';
            else
                B[i]='L';
        }
        else
        {
            B[i]=B[i-1];
        }
    }
    ll ans=1,cnt=0;
    for(int i=0;i<n+n;i++)
    {
        if(B[i]=='L')
        {
            cnt++;
        }
        else
        {
            ans=(ans*cnt)%mod;
            cnt--;
        }

        if(cnt>n||cnt<0)
            fin();
    }

    if(cnt!=0)
        fin();
    ll F=1;
    for(int i=2;i<=n;i++)
        F=(F*i)%mod;
    cout<<(ans*F)%mod<<endl;
}




















Measured memory_bytes: 772
#include<stdio.h>
int main(){
	int N;
	scanf("%d",&N);
	
	if(N<105) printf("0");
	else if(N<135) printf("1");
	else if(N<165) printf("2");
	else if(N<189) printf("3");
	else if(N<195) printf("4");
	else printf("5");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define f(x,n) for (int i=x;i<n;i++)

void lcs(string a,string b,int la,int lb)
{
  int tab[la+1][lb+1];

  for(int i=0;i<=la;i++)
  {
    for(int j=0;j<=lb;j++)
    {
      if(i==0 || j==0 )
        tab[i][j]=0;
      else if(a[i-1]==b[j-1])
        tab[i][j]=1+tab[i-1][j-1];
      else
        tab[i][j]=max(tab[i-1][j],tab[i][j-1]);

    }
  }


  int len=tab[la][lb];
   char ans[len+1];
   ans[len]='\0';

  int i=la,j=lb;
  while(i>0 && j>0)
  {
    if(a[i-1]==b[j-1])
    {
      ans[len-1]=a[i-1];
      len--,i--,j--;
    }
    else if(tab[i-1][j]>tab[i][j-1])
      i--;
    else
      j--;
  }

  cout<<ans;
  
}
int main()
{
 string a,b;
 cin>>a;
 cin>>b;
 int n,m;
 n=a.length();
 m=b.length();

lcs(a,b,n,m);


return 0;
  
}

Measured memory_bytes: 38832
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquest;
typedef priority_queue<string,vector<string>,greater<string>> rpriquest;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000007;
int exp(int x,int y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x)%big;
    int t=exp(x,y/2);
    return (t*t)%big;
}
void chmin(ll a,ll b){
    if(a>b)a=b;
    return;
}

bool ok(vector<int> &d,int i){
    while(i>0){
        int k=i%10;
        rep(j,d.size())if(k==d[j])return false;
        i/=10;
    }
    return true;
}

int main(){
    int n,k;cin >> n >> k;
    vector<int> d(k);
    rep(i,k)cin >> d[i];
    rep2(i,n,1000000){
        if(ok(d,i)){cout << i << endl;return 0;}
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n,m;
   cin >> n >> m;
   vector<int> H(n+1);
   vector<vector<int>> G(n+1);
   f(i,1,n+1){
      cin >> H[i];
   }
   f(i,1,m+1){
      int a,b;
      cin >> a >> b;
      G[a].pb(H[b]);
      G[b].pb(H[a]);
   }

   int R = 0;
   f(i,1,n+1){
      int h = H[i],chk = 1;
      for(auto v : G[i]){
         if(v>=h){
            chk = 0;
            break;
         }
      }
      R += chk;
   }
   cout << R << '\n';
   return 0;
}

Measured memory_bytes: 9800
//-------------------------------------------
//-               Train Fare                -
//-                                         -
//-       autumn_eel niha katemasen!        -
//-------------------------------------------

#include<iostream>
#include<functional>
#include<queue>
#include<deque>
#include<vector>
#include<algorithm>
using namespace std;

void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (true) {
		k = getchar_unlocked();
		if (k < '0') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
inline void writeln(int x) {
	int s = 0; char f[7];
	while (x) {
		f[s++] = x % 10;
		x /= 10;
	}
	if (!s) f[s++] = 0;
	while (s--) putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}
#pragma warning(disable:4996)
int n, m, q, a[200003], b[200003], c[200003], d[200003], e[100003], f[100003], g[100003], dist[100003], E[200003];
vector<pair<int, int> > z[100003]; vector<int> x[100003];
vector<int>D[100003];
int main() {
	reader(&n); reader(&m); reader(&q);
	fill(d, d + m + 1, 1 << 30);
	for (int i = 1; i <= m; i++) { reader(&a[i]), reader(&b[i]); f[a[i]]++; f[b[i]]++; }
	for (int i = 1; i <= q; i++) reader(&c[i]), d[c[i]] = i;
	for (int i = 1; i <= n; i++) { x[i].resize(f[i]); }
	for (int i = 1; i <= m; i++) {
		x[a[i]][g[a[i]]] = b[i]; g[a[i]]++;
		x[b[i]][g[b[i]]] = a[i]; g[b[i]]++;
	}
	fill(dist, dist + n + 1, -1); dist[1] = 0;
	queue<int> Q1; Q1.emplace(1);
	while (!Q1.empty()) {
		int a1 = Q1.front(); Q1.pop();
		for (int i : x[a1]) {
			if (dist[i] == -1) {
				dist[i] = dist[a1] + 1;
				Q1.emplace(i);
			}
		}
	}
	for (int i = 1; i <= m; i++) {
		if (dist[a[i]] > dist[b[i]]) z[a[i]].emplace_back(make_pair(b[i], d[i]));
		if (dist[b[i]] > dist[a[i]]) z[b[i]].emplace_back(make_pair(a[i], d[i]));
	}
	for (int i = 1; i <= n; i++) D[dist[i]].push_back(i);
	e[1] = (1 << 30);
	for (int i = 1; i < n; i++) {
		for (int j : D[i]) {
			for (pair<int, int>k : z[j]) {
				e[j] = max(e[j], min(e[k.first], k.second));
			}
		}
	}
	for (int i = 2; i <= n; i++) {
		if (e[i] < 300000) E[e[i]]++;
	}
	for (int i = 1; i <= q; i++) {
		E[i] += E[i - 1];
		writeln(E[i]);
	}
	return 0;
}

Measured memory_bytes: 23496
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.Yahoo2019
{
    class A
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] nk = ReadInts();
            if (nk[0] % 2 == 0)
            {
                if (nk[0] / 2 >= nk[1]) Console.WriteLine("YES");
                else Console.WriteLine("NO");
            }
            else
            {
                if (nk[0] / 2 + 1 >= nk[1]) Console.WriteLine("YES");
                else Console.WriteLine("NO");
            }
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cmath>

using namespace std;
typedef long long LL;

int main() {
    LL N, K;
    cin >> N >> K;
    if (N <= K) {
        cout << min(N, abs(N - K)) << endl;
    } else {
        cout << min(N - N / K * K, (N / K + 1) * K - N) << endl;
    }
    return 0;
}

Measured memory_bytes: 256