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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }


lli N;
vector<lli> V,W;
const lli border = 10;
lli dp[(1LL<<border)][100100];
bool vis[(1LL<<border)][100100];

void calc(lli now,lli from){

    if(now >= (1LL<<border)||now>N )return;

    REP(i,0,100100){
        if(!vis[from][i])continue;
        lli nextW = i+W[now-1];
        lli nextV = dp[from][i]+V[now-1];
        chmax(dp[now][i],dp[from][i]);
        vis[now][i]=true;

        if(nextW > 100000)continue;
        chmax(dp[now][nextW],nextV);
        vis[now][nextW]=true;
    }

    calc(2*now,now);
    calc(2*now+1,now);

    //create DP table for query
    REP(i,0,100099)chmax(dp[now][i+1],dp[now][i]);
}

void func(long long Q, std::vector<long long> v, std::vector<long long> L){

    vis[0][0]=true;
    dp[0][0]=0;
    calc(1,0);

    REP(i,0,Q){
        if(v[i]<(1LL<<border)){
            cout<<dp[v[i]][L[i]]<<endl;
        }
        else{
            lli ans = -INF;
            lli needBit = 0;
            lli tmp = v[i];
            while(tmp>=(1LL<<border)){
                needBit++;
                tmp/=2;
            }
            REP(bit,0,(1LL<<needBit)){
                lli nowB = 0;
                lli sumW=0,sumV=0;
                lli from = v[i];
                while(from>=(1LL<<border)){
                    if(bit&(1LL<<nowB)){
                        sumW += W[from-1];
                        sumV += V[from-1];
                    }
                    from/=2;
                    nowB++;
                }
                if(sumW > L[i])continue;
                LOG4(v[i],bit,sumW,sumV);
                LOG3(from,ans,dp[from][L[i]-sumW]+sumV);
                chmax(ans,dp[from][L[i]-sumW]+sumV);
            }
            cout<<ans<<endl;
        }
    }
}

int main(){
    // cout << fixed << setprecision(5);

    scanf("%lld",&N);
    V.resize(N);
    W.resize(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&V[i]);
        scanf("%lld",&W[i]);
    }
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> v(Q);
    std::vector<long long> L(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&v[i]);
        scanf("%lld",&L[i]);
    }
    func(Q, std::move(v), std::move(L));
    return 0;
}


Measured memory_bytes: 835224
package main

import (
	"fmt"
	"math"
)

func main() {
	var w float64
	var h float64
	var x float64
	var y float64

	fmt.Scan(&w, &h, &x, &y)

	centerX := w / 2.0
	centerY := h / 2.0

	var flag int
	if math.Abs(centerX-x) < 1e-9 && math.Abs(centerY-y) < 1e-9 {
		flag = 1
	} else {
		flag = 0
	}

	area := w * h / 2.0

	fmt.Println(area, flag)
}


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

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

    int cnt_white = 0;
    for (int i = 0; i < N; i++)
    {
        if (S[i] == '.') cnt_white++;
    }

    // 「白白白・・・白白黒黒・・・黒黒黒」
    int change_left = 0, change_right = cnt_white;
    int ans = change_left + change_right;
    for (int i = 0; i < N; i++)
    {
        if (S[i] == '.') change_right--;
        else change_left++;

        ans = min(ans, change_left + change_right);
    }

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

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
using ll=long long;
typedef pair<int,int> P;
string s;
int k;
ll INF=10000000000000000;

set<ll> a;

void dfs(int n,int &count){
    a.insert(n);
    count++;
    if(count==k) return;
    int d=n%10;
    if(d!=9) dfs(n*10+d+1,count);
    dfs(n*10+d,count);
    if(d!=0) dfs(n*10+d-1,count);
}

int main(){
    cin>>k;
    int count=0;
    queue<ll> que;
    bool flag=false;
    ll ans;
    rep(i,1,10){

        que.push(i);

        }
    while(!flag){
        ll a=que.front();que.pop();
        count++;
        if(count==k){
            ans=a;
            break;
        }
        int d=a%10;
        if(d!=0){
            que.push(a*10+d-1);
        }
        que.push(a*10+d);
        if(d!=9){
            que.push(a*10+d+1);
        }
    }
    cout<<ans<<endl;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    ll X,K,D; cin >> X >> K >> D;
    X = abs(X);

    ll N = X/D;
    if(N>=K) cout << abs(X - K*D) << endl;
    else{
        if((K-N)%2 == 0) cout << abs(X-N*D) << endl;
        else cout << abs(X-N*D-D) << endl;
    }
    return 0;
}

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

typedef long long ll;
typedef vector<int> VI;
#define rep(i,n) for(int i=0;i<(n);++i)

//example rep(i,n) cin >> h[i];

int main (){

ll s,t,a,b;
  cin>>s;
ll ans=1e18;
 for(ll i=1; i*i<=s;i++){
   if(s%i!=0)continue;
   ll j=s/i;
   ans=min(ans,i+j-2);
 }
  //sort(vec.begin(),vec.end());
  //reverse(vec.begin(),vec.end());
cout<<ans<<endl;
   
  
 return 0; 
}


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

using namespace std;

int main() {
	long long n;
	long long D = 998244353;
	cin >> n;
	vector<long long>d(n);
	vector<long long>d2(n);
	vector<long long>count(n);
	int cou = 0;
	long long ans = 1;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
		d2[i] = d[i];
		count[i] = 0;
	}
	sort(d.begin(), d.end());
	for (long long i = 0; i < n - 1; i++) {
		if (d[i] == 0) {
			cou++;
		}
		if (d[i] != d[i + 1] && d[i] + 1 != d[i + 1]) {
			d[0]=1;
		}
	}
	if (d[0] != 0||d2[0]!=0||cou!=1) {
		cout << 0 << endl;
	}
	else {
		for (long long i = 1; i < n; i++) {
			count[d[i]]++;
		}
		
		for (long long i = 1; i < n; i++) {
			if (count[i] != 0) {
				for (long long j = 1; j < count[i + 1] + 1; j++) {
					ans = (long long)ans * count[i] % D;
				}
			}
		}
		cout << ans%D<< endl;
	}
}

Measured memory_bytes: 2560
n,m,r=map(int,input().split())
a,b,c=[0]*m,[0]*m,[0]*m
INF=10**18
for i in range(m):
  a[i],b[i],c[i]=map(int,input().split())
d=[INF]*n
d[r]=0
for _ in range(n-1):
  for i in range(m):
    if d[a[i]]==INF:continue
    d[b[i]]=min(d[b[i]],d[a[i]]+c[i])
for _ in range(n):
  for i in range(m):
    if d[a[i]]==INF:continue
    if d[b[i]]>d[a[i]]+c[i]:
      print('NEGATIVE CYCLE')
      exit()
for i in d:
  print([i,'INF'][i==INF])


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

using namespace std;

int main() {
    int dict[26] = {};
    string s;
    cin >> s;
    for (auto i : s) {
        dict[i - 'a']++;
    }
    for (int i = 0; i < 26; i++) {
        if (dict[i] == 0) {
            cout << char('a' + i) << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n, k;
  cin >> n >> k;
  vector<int> x(n);
  vector<int> xp, xm;
  int me = 0;
  for(int i = 0; i < n; i++) {
    cin >> x[i];
    if(x[i] == 0){
      
      me = i;
    } else if(x[i] < 0) {
      me++;
      xm.push_back(-x[i]);
    } else {
      xp.push_back(x[i]);
    }
  }
  if(k == 0){
    cout << 0 << endl;
    return 0;
  }
  if(k == 1){
    ll ans = 1001001001001001;
    for(int i = 0; i < n; i++){
      ans = min(ans, (ll)abs(x[i]));
    }
    cout << ans << endl;
    return 0;
  }
  vector<ll> ans(n, 1001001001001001001);
  for(int i = 0; i + k - 1 < n; i++){
    ll cost = 0;
    if(x[i] < 0 && x[i + k - 1] < 0) {
      cost = - x[i];
    }else if(x[i] <= 0 && x[i + k - 1] >= 0){
      cost = min(-x[i] * 2 + x[i + k - 1], -x[i] + x[i + k - 1] * 2);
    }else{
      cost = x[i + k - 1];
      ans[i] = cost;
      break;
    }
    ans[i] = cost;
    //cout << ans[i] << " ";
  }
  //cout << endl;
  cout << *min_element(ans.begin(), ans.end()) << endl;
  /*
  vector<ll> costM(k), costP(k);
  for(int i = 0; i < k; i++) {
    if(xm.size() < i){
      costP[i] = xp[k - 1];
      break;
    }else if(xp.size() < k - i){
      costM[i] = xm[xm.size() - k];
      continue;
    }
    if(xm.size() + i < k){
      costM[i] = xp[k - (i + xm.size())] * 2 + xm[i];
    }else{
      costM[i] = xp[i] * 2 + xm[i];
    }
    if(xp.size() < i){
      costP[i] = xm[i - xp.size()] * 2 + xp[i];
    }else{
      costP[i] = xm[i] * 2 + xp[i];
    }
    cout << xm[i] << " " << xp[i] << " ";
  }
  ll ans = min(*min_element(costM.begin(), costM.end()),
               *min_element(costP.begin(), costP.end()));
  cout << me << endl;
  */

  return 0;
}

Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
int n,m;
const int N = 1e5 + 7;
vector<int> g[N];
vector<int> used;
vector<int> dp;
void dfs(int v) {
  	used[v] = true;
	for (int i = 0; i < g[v].size(); i ++) {
    	int x = g[v][i];
      	if (!used[x]) {
      		dfs(x);
        }
        dp[v] = max(dp[v], dp[x] + 1);	
  		// cout << "currently in " << v << endl;
  		// cout << "was in " << x << " val : " << dp[x] << endl;
  		// cout << "curr val : " << dp[v] << endl;
    }
}
int main() {
	cin >> n >> m;
  	for (int i = 0; i < m; i ++) {
    	int x, y; cin >> x >> y;
      	g[x].push_back(y);
    }
  	used.resize(n + 1, 0);
  	dp.resize(n + 1, 0);
  	for (int i = 1; i <= n; i ++) {
    	if (!used[i]) {
        	dfs(i);
        }
    }
  	int maxv = 1;
  	for (int i = 1; i <= n; i ++) {
    	maxv = max(maxv, dp[i]);
    }
    cout << maxv << endl;
}

Measured memory_bytes: 8576
#include<stdio.h>
int main()
{
    int i,c=0;
    char arr[4];
    scanf("%s",arr);
    for(i=1; i<4; i++)
    {
        if(arr[i]==arr[i-1])
            c=1;
    }
    if(c==1)
        printf("Bad\n");
    else
        printf("Good\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main()
{
  map<string, int> M;
  string A[100];
  string B[100];
  int n,m;
  int max = 0;

  cin >> n;
  while(n--)
  {
    string s;
    cin >> s;
    if ( M.find(s) != M.end() ) ++M[s];
    else M[s] = 1;
  }

  cin >> m;
  while(m--)
  {
    string s;
    cin >> s;
    if ( M.find(s) != M.end() ) --M[s];
    else M[s] = -1;
  }

  for ( auto it = M.begin(); it != M.end(); ++it )
  {
    if ( it->second > max ) max = it->second;
  }

  cout << max << "\n";
}


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

int main() {
    int N;
    cin >> N;
    vector<int> loc(N);
    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        x--;
        loc[x] = i;
    }

    int max_len = 0;
    for (int i = 0; i < N; i++) {
        int start = i;
        while (i+1 < N && loc[i] < loc[i+1]) {
            i++;
        }
        max_len = max(max_len, i-start+1);
    }
    cout << N - max_len << endl;
}


Measured memory_bytes: 1024
import sys,math,copy
from fractions import gcd
input = sys.stdin.readline

N=int(input().strip())
A=[int(x) for x in input().strip().split()]
# def gcd(a,b):
#     if b==0:
#         return a
    
#     return gcd(b,a%b)

ANS=[]
L=[0]
R=[0]
for i in range(len(A)):
    L.append(gcd(A[i],L[-1]))
    R.append(gcd(A[-1-i],R[-1]))

R.reverse()
for i in range(len(L)-1):
    ANS.append(gcd(L[i],R[i+1]))

print(max(ANS))


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

int main() {
	int i;
	int t = 0;
	cin >> i;
	vector<int> d1(i);
	vector<int> d2(i);
	for (int a = 0; a < i; ++a) {
		cin >> d1[a];
		cin >> d2[a];
	}
	for (int a = 0; a < i; ++a) {
		if (d1[a] == d2[a]) {
			++t;
			if (t >= 3){
				break;
			}
		}
		else {
			t = 0;
		}
	}
	if (t >= 3) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

const int INF = 1<<30;

int main() {
  int n, m;
  string s;
  cin >> n >> m >> s;
  vector<int> dp(n+1,INF);
  dp[n] = 0;
  queue<int> q;
  q.push(0);
  for (int i = n-1; i >= 0; --i) {
    while (1) {
      if (q.size() == 0) {
        puts("-1");
        return 0;
      }
      if (q.front() != INF && q.size() <= m) break;
      q.pop();
    }
    if (s[i] == '0') dp[i] = q.front()+1;
    q.push(dp[i]);
  }

  vector<int> ans;
  int x = 0;
  int rest = dp[0];
  while (x < n) {
    --rest;
    int i = 1;
    while (dp[x+i] != rest) ++i;
    ans.push_back(i);
    x += i;
  }
  rep(i,ans.size()) {
    printf("%d%c", ans[i], i==int(ans.size())-1?'\n':' ');
  }
  return 0;
}


Measured memory_bytes: 1528
#include "bits/stdc++.h"

#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define ffor(i,a,b) for(ll i=(a);i<(ll)(b);++i)
#define rep(i, n) ffor(i,0,n)
#define All(obj) (obj).begin(),(obj).end()
#define INF ((ll)1e9+7)
#define c(a) cout<<a<<"\n";
using namespace std;
const int N = 100005;

int main() {
	speed;
	int r;
	cin >> r;
	cout << 3 * r*r;
	ed;
	return 0; 
}



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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

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




int n, m;

int main(){
	cin >> n >> m;
	
	for(int i = m/n; i > 0; i--){
		if(m % i == 0){
			cout << i << endl;
			break;
		}
	}
	
	return 0;
}

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


void solve(std::vector<std::string> c){
  cout << c[0].substr(0, 1) + c[1].substr(1,1)+c[2].substr(2,1) << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
  std::vector<std::string> c(3);
  for(int i = 0 ; i < 3 ; i++){
    std::cin >> c[i];
  }
  solve(std::move(c));
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repeat(i,a,b) for(int i=(a),_=(b);i<_;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,_=(a);i>=_;i--)
#define mst(a,x) memset(a,x,sizeof(a))
#define vector basic_string
#define fi first
#define se second
#ifndef qwq
int cansel_sync=(ios::sync_with_stdio(0),cin.tie(0),0);
#endif
//mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int N=200010; const double err=1e-11; typedef long long ll; const int inf=~0u>>2; const ll INF=~0ull>>2; ll read(){ll x; if(scanf("%lld",&x)==-1)exit(0); return x;} typedef double lf; typedef long double llf; const lf pi=acos(-1.0); lf readf(){lf x; if(scanf("%lf",&x)==-1)exit(0); return x;} template<typename T> T sqr(const T &x){return x*x;} typedef pair<int,int> pii; template<typename A,typename B> ostream &operator<<(ostream &o,const pair<A,B> &x){return o<<'('<<x.fi<<','<<x.se<<')';}
const int mod=(1?1000000007:998244353); ll mul(ll a,ll b,ll m=mod){return a*b%m;} ll qpow(ll a,ll b,ll m=mod){ll ans=1; for(;b;a=mul(a,a,m),b>>=1)if(b&1)ans=mul(ans,a,m); return ans;} ll getinv(ll v,ll m=mod){return qpow(v,m-2,m);}
//#define int ll
int a,b,c;
signed main(){
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<' '<<b<<' '<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<utility>
#include<vector>
#include<queue>
#include<algorithm>
#define MAX_V 100001
#define INF 1000000000000000
using namespace std;
struct edge{int to;long cost;};
typedef pair<long,int> P;

int V;
vector<edge> G[MAX_V][2];
long d[MAX_V][2];

void dijkstra(int s,int b){
    priority_queue<P,vector<P>,greater<P> > que;
    for(int i=0;i<=V;i++){
        d[i][b]=INF;
    }
    d[s][b]=0;
    que.push(P(0,s));

    while(!que.empty()){
        P p=que.top(); que.pop();
        int v=p.second;
        if(d[v][b]<p.first) continue;
        for(int i=0;i<G[v][b].size();i++){
            edge e=G[v][b][i];
            if(d[e.to][b]>d[v][b]+e.cost){
                d[e.to][b]=d[v][b]+e.cost;
                que.push(P(d[e.to][b],e.to));
            }
        }
    }
}

int main(){
    int m,s,t,v,u;
    long a,b,ans[100000]={};
    scanf("%d%d%d%d",&V,&m,&s,&t);
    for(int i=0;i<m;i++){
        scanf("%d%d%ld%ld",&v,&u,&a,&b);
        G[u][0].push_back({v,a});
        G[u][1].push_back({v,b});
        G[v][0].push_back({u,a});
        G[v][1].push_back({u,b});
    }
    dijkstra(s,0);
    dijkstra(t,1);
    ans[V]=INF-(d[V][0]+d[V][1]);
    for(int i=V-1;i>=0;i--){
        ans[i]=INF-(d[i][0]+d[i][1]);
        ans[i]=max(ans[i],ans[i+1]);
    }
    for(int i=1;i<=V;i++){
        printf("%ld\n",ans[i]);
    }
}

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


long long int gcd(long long int a, long long int b)
{
    long long int temp;

    if(a > b){
        temp = a;
        a = b;
        b = temp;
    }

    while(a != 0){
        b = b % a;
        if(a > b){
            temp = a;
            a = b;
            b = temp;
        }
    }

    return b;
}


long long int count(long long int a, long long int b, long long int q){
    long long int num, num_div, num_a, num_b;

    num_b = b / q;
    num_a = a / q;

    num = num_b - num_a;

    if((a%q) == 0){
        num = num + 1;
    }

    return num;
}

long long int minp(long long int a, long long int b)
{
    long long int temp;
    long long int ans;

    ans = gcd(a, b);
    temp = a / ans;

    return temp * b;
}


int main()
{
    long long int a, b, c, d;
    long long int num, temp;

    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;

    num = b - a + 1;
    num -= count(a, b, c);
    num -= count(a, b, d);
    num += count(a, b, minp(c, d));

    cout << num;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int count[4][3][10]={{{}}};
    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                count[i][j][k]==0;
            }
        }
    }
    for(int i=0;i<n;i++){
        int b,f,r,v;
        cin>>b>>f>>r>>v;
        count[b-1][f-1][r-1]+=v;
       }

    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                cout<<" "<<count[i][j][k];
            }
            cout<<endl;
        }
        if(i!=3)
        cout << "####################" << endl;
    }
    
    
}


Measured memory_bytes: 3128
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

bool eq(char a, char b) {
    return a == '?' || b == '?' || a == b;
}

void main()
{
    auto a = readln.chomp.to!(char[]);
    auto b = readln.chomp.to!(char[]);
    auto c = readln.chomp.to!(char[]);
    auto A = a.length.to!int;
    auto B = b.length.to!int;
    auto C = c.length.to!int;
    bool[20000] ab, ac, bc;
    ab[] = true;
    ac[] = true;
    bc[] = true;
    foreach (i; 0..A) foreach (j; 0..B) if (!eq(a[i], b[j])) ab[i-j + 10000] = false;
    foreach (i; 0..A) foreach (j; 0..C) if (!eq(a[i], c[j])) ac[i-j + 10000] = false;
    foreach (i; 0..B) foreach (j; 0..C) if (!eq(b[i], c[j])) bc[i-j + 10000] = false;

    auto r = int.max;
    foreach (i; -4000..4001) foreach (j; -4000..4001) {
        if (ab[i+10000] && ac[j+10000] && bc[j-i+10000]) {
            r = min(r, max(A, i+B, j+C)-min(0, i, j));
        }
    }
    writeln(r);
}

Measured memory_bytes: 380
# coding: utf-8
# Your code here!

while True:
   try:
      A = list(input())
      B = list(input())
      
      for i in range(A.count(' ')):
         A.remove(' ')
      for i in range(B.count(' ')):
         B.remove(' ')
      #print(A, B)
      
      h = 0 #ブロー数
      b = 0 #ヒット数
      for i in range(4):
         for j in range(4):
            if A[i] == B[j]:
               if i == j:
                  h += 1
               else:
                  b += 1
      print(h, b)

   except EOFError:
      break



Measured memory_bytes: 5560
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


struct UF
{
    long         num;
    vector<long> par;
    vector<long> rank;

    UF(long n): num(n) {
        par.resize(n);
        rank.resize(n);
        long i;
        for(i=0; i<n; i++) {
            par[i]=i;  rank[i]=1;
        }
    }
	
    long find(long x) {
        if(x==par[x]) return x;
        return par[x] = find(par[x]);
    }

    void unite(long x, long y) {
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]) {
            par[x]=y;
        }
        else {
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(long x, long y) {
        return find(x)==find(y);
    }
};

int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    vector<pair<long, long> > xx(n);
    vector<pair<long, long> > yy(n);
    long i;
    for(i=0; i<n; i++) {
        long x, y;
        scanf("%ld%ld", &x, &y);
        xx[i]=make_pair(x,i);
        yy[i]=make_pair(y,i);
    }
    sort(xx.begin(), xx.end());
    sort(yy.begin(), yy.end());

    vector<pair<long, pair<long,long> > > zz(2*n-2);
    for(i=0; i<n-1; i++) {
        zz[i]=( make_pair( xx[i+1].first-xx[i].first, make_pair(xx[i].second, xx[i+1].second) ));
    }
    for(i=0; i<n-1; i++) {
        zz[n-1+i]=( make_pair( yy[i+1].first-yy[i].first, make_pair(yy[i].second, yy[i+1].second) ));
    }
    sort( zz.begin(), zz.end() );

    UF uf(n);

    ll sum=0;
    for(i=0; i<2*n-2; i++) {
        long p = zz[i].second.first;
        long q = zz[i].second.second;
        if( !uf.same(p, q) ) {
            sum += zz[i].first;
            uf.unite(p, q);
        }
    }
    printf("%lld\n", sum);

    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#endif


typedef long long ll; 
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
 
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

const int INF = (int)1e9;
const int maxN = 111;

void solve() {
  int n, k;
  cin >> n >> k;
  vector<bool> has(maxN);
  for (int i = 0 ; i < k ; i++) {
    int d;
    cin >> d;
    for (int j = 0 ; j < d ; j++) {
      int x;
      cin >> x;
      has[x] = true;
    }
  }
  int ans = 0;
  for (int i = 1 ; i <= n ; i++) {
    if (!has[i]) ans++;
  }
  cout << ans;
}
 
int 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: 3656
#include<bits/stdc++.h>

using namespace std;

vector<string> input(int N){
    vector<string> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void count(vector<string>& square){
    for(int i=0; i < square.size(); i++){
        for(int j=0; j < square.at(i).size(); j++){
            if(square.at(i).at(j) != '#'){
                // count the number of mines
                int num=0;
                for(int y=-1; y<=1; y++){
                    for(int x=-1; x<=1; x++){
                        int pY = i+y, pX = j+x;
                        // avoid null
                        if(0 <= pY && pY < square.size() && 0 <= pX && pX < square.at(i).size()){
                            if(square.at(pY).at(pX) == '#'){
                                num++;
                            }
                        }
                    }
                }
                square.at(i).at(j) = '0' + num;
            }
        }
    }
}

int main(){
    int X, Y;

    cin >> Y >> X;
    
    vector<string> square(Y);
    for (int i = 0; i < Y; i++) {
        cin >> square.at(i);
    }

    count(square);

    for(int i=0; i<Y; i++){
        cout << square.at(i) << "\n";
    }
}


Measured memory_bytes: 256
mod = int(1e9) + 7
def solve():
    n, m = map(int, input().split())
    li = [1, 1] + [-1] * n
    for a in (int(input()) for _ in range(m)):
        li[a] = 0
    for i in range(2, n + 1):
        if li[i]:
            li[i] = (li[i - 2] + li[i - 1]) % mod
    print(li[n])
solve()


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

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

    int k, x;
    cin >> k >> x;
    int min_x, max_x;
    min_x = x - k + 1;
    max_x = x + k - 1;
    for (int i = min_x; i <= max_x; ++i) {
        cout << i << ' ';
    }
    cout << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	vector<int>a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a.begin(),a.end());
	int i=0;
	int b[2]={0,0};
	while(i<n){
		int cnt=0;
		int x=a[i];
		int j=i;
		while(j<n&&a[j]==x){
			cnt++;
			j++;
		}
		i=j;
		cnt%=2;
		b[cnt]++;
	}
	cout<<b[0]+b[1]-b[0]%2<<endl;
	return 0;
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

_min = 10 ** 7
ans = None
for i, v in enumerate(h):
    c = abs((t - 0.006 * v) - a)
    if c < _min:
        _min = c
        ans = i + 1
print(ans)


Measured memory_bytes: 62456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=5e5+5;
const ll mod=1e9+7;
ll a[maxn],num[64];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    for(ll i=1; i<=n; i++)
        cin>>a[i];
    for(ll i=1; i<=n; i++)
    {
        for(ll j=0; j<64; j++) if(a[i]>>j&1) num[j]++;
    }
    ll ans=0;
    for(ll i=1; i<=n; i++)
    {
        for(ll j=0; j<64; j++) if(a[i]>>j&1) num[j]--;
        for(ll j=0; j<64; j++)
        {
            if(a[i]>>j&1ll) ans=(ans+(1ll<<j)%mod*(n-i-num[j])%mod)%mod;
            else  ans=(ans+(1ll<<j)%mod*num[j]%mod)%mod;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include <cstdio> 
#include <cstdlib> 
#include <cmath> 
#include <cstring> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <numeric>
#include <cassert>

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

int main(void)
{
    int N, M;
    cin >> N >> M;
    REP(i, M) {
        int a;
        cin >> a;
        N -= a;
    }
    if (N < 0)
        cout << -1 << endl;
    else
        cout << N << endl;
    return 0;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long int64;
const int maxn = 100005;
vector<int> adj[maxn];
int egs[maxn][2];

int visited[maxn];
int dist[maxn];
int main()
{
  int n, m; scanf("%d %d", &n, &m);
  for (int i = 0; i < m; ++i)
  {
    int u, v; scanf("%d %d", &u, &v);
    egs[i][0] = u, egs[i][1] = v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  queue<int> q;
  q.push(1);
  visited[1] = 1;
  dist[1] = 0;
  int64 a = 1, b = 0;
  while (!q.empty())
  {
    int curr = q.front(); q.pop();
    for (auto& x: adj[curr])
    {
      if (visited[x]) continue;
      visited[x] = 1;
      q.push(x);
      dist[x] = dist[curr] ^ 1;
      if (dist[x] == 0) ++a; else ++b;
    }
  }
  //for (int i = 1; i <= n; ++i)
  //  cerr << i << " " << dist[i] << endl;
  int dirty = 0;
  for (int i = 0; i < m; ++i)
    if (dist[egs[i][0]] == dist[egs[i][1]])
    {dirty = 1; break;}
  if (dirty)
  {
    cout << (int64)n * (n - 1) / 2 - m << endl;
  }
  else
  {
    cout << a * b - m << endl;
  }
  return 0;
}


Measured memory_bytes: 7424
N,X =  map(int, input().split())
m = [int(input()) for i in range(N)]

a = 0
c = -1
for i in range(N):
     a += m[i]
     c += 1
    
b = min(m)

while X >= a:
     a += b
     c += 1
print(c)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  if(n<10){
    cout<<n<<'\n';
  }else if(n>=10 && n<100){
    cout<<9<<'\n';
  }else if(n>=100 && n<1000){
    cout<<n-90<<'\n';
  }else if(n>=1000 && n<10000){
    cout<<909<<'\n';
  }else if(n>=10000 && n<100000){
    cout<<n-9090<<'\n';
  }else if(n==100000){
    cout<<90909<<'\n';
  }
 return(0);
}

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

using namespace std;

int main()
{
	int n;
	string str;

	cin >> n >> str;

	int ans = 0;
	int t;
	int k;
	unsigned int j;

	for (int i = 0; i < 1000; i++) {
		t = 0;
		k = i;
		
		for (j = 0; j < str.length(); j++) {
			if ((int)(str[j] - 48) == k / 100) {
				t++;
				break;
			}
		}
		j++;
		k %= 100;
		for (; j < str.length(); j++) {
			if ((int)(str[j] - 48) == k / 10) {
				t++;
				break;
			}
		}
		j++;
		k %= 10;
		
		for (; j < str.length(); j++) {
			if ((int)(str[j] - 48) == k) {
				t++;
				break;
			}
		}
		if (t == 3) {
			ans++;
		}
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;

#define _GLIBCXX_DEBUG
#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end())

void Add(ll &a, ll b){
    a=(a+b)%mod;
    return;
}

void Pro(ll &a, ll b){
    a=(a*b)%mod;
    return;
}

ll N,X,M; 


ll ruijou(ll n, ll k){
    if(!k) return 1;
    ll a=ruijou(n,k/2);
    a=(a*a)%M;
    return k%2 ? (a*n)%M : a;
}

ll memo[100010];
ll ans[100010];
ll ANS;

void SOLVE(ll i, ll bef){
    if(i>N) return;
    ll A;
    if(i==1) A=X;
    else A=(bef*bef)%M;
    if(!memo[A]) {
        memo[A]=i;
        ans[i]=ans[i-1]+A;
        ANS=ans[i];
        SOLVE(i+1,A);
        return;
    }
    ans[i]=ans[i-1]+A;
    ll p=memo[A];
    ll K=ans[i]-ans[p], F=i-p;
    ll yy=(N-i)/F;
    ANS=ans[i]+(yy*K);
    ll zahyo=i+(F*yy);
    zahyo=N-zahyo;
    ANS+=(ans[zahyo+p]-ans[p]);
    return;
}


ll Solve(){
    cin>>N>>X>>M;
    if(!X) return 0;
    if(N==1) return X;

    SOLVE(1,1);
    return ANS;
    
    
}
int main(){
    cout<<Solve()<<endl;

}

Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=200005;
int n;
vector <int> e[N];
int depth[N],I[N],O[N],fa[N],Time=0;
int s[N];
void dfs(int x,int pre){
	fa[x]=pre,I[x]=++Time,depth[x]=depth[pre]+1;
	for (auto y : e[x])
		if (y!=pre)
			dfs(y,x);
	O[x]=Time;
}
int ST[N],top=0,d[N];
void solve(int x,int pre,int m1,int m2){
	if (x>m1)
		m2=m1,m1=x;
	else if (x>m2)
		m2=x;
	ST[d[x]=++top]=x;
	if (x>1){
		int f=depth[m1]>depth[m2]?m1:ST[d[m1]+1];
		s[I[f]]++,s[O[f]+1]--;
	}
	for (auto y : e[x])
		if (y!=pre)
			solve(y,x,m1,m2);
	top--;
}
int main(){
	n=read();
	for (int i=1;i<n;i++){
		int x=read(),y=read();
		e[x].push_back(y);
		e[y].push_back(x);
	}
	dfs(1,0);
	solve(1,0,0,0);
	for (int i=1;i<=n;i++)
		s[i]+=s[i-1];
	for (int i=2;i<=n;i++)
		printf("%d ",s[I[i]]);
	return 0;
}

Measured memory_bytes: 30464
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace kyopro
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] aaa = Console.ReadLine().Split();
            int a = int.Parse(aaa[0]);
            int b = int.Parse(aaa[1]);
            b = a * 3 + b;
            Console.WriteLine(b / 2);
        }
    }
 }


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  string s;
  cin>>s;
  for (int i(0);i<int(s.size());i+= 2){
    if (s[i] == 'h' && s[i+1] == 'i'){
    }else{
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}



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

public class Main {

		public static void main(String[] args) throws java.lang.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]);
		      int p = 0;
		      for(int i = 1; i < 1251 ; i++) {
		    	  double tax1 = (i * 0.08);
		    	  double tax2 = (i * 0.1);
		    	  if(a == (int)tax1 && b == (int)tax2 ) {
		    		  p = i;
		    		  break;
		    	  }
		      }
		      if(p == 0)
		    	  System.out.println("-1");
		      else
		    	  System.out.println(p);
		}
}

Measured memory_bytes: 22612
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits>


int main(){
    std::string S;
    std::cin >> S;
    if(S[0]=='R' && S[1]=='R' && S[2]=='R'){
        std::cout << 3 << std::endl;
    }else if(S[0]=='R' && S[1]=='R' && S[2]!='R'){
        std::cout << 2 << std::endl;
    }else if(S[0]!='R' && S[1]=='R' && S[2]=='R'){
        std::cout << 2 << std::endl;
    }else if(S[0]!='R' && S[1]!='R' && S[2]!='R'){
        std::cout << 0 << std::endl;
    }else{
        std::cout << 1 << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3180
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();

        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int x = scanner.nextInt();
            if (!map.containsKey(x))map.put(x, 1);
            else map.put(x, map.get(x) + 1);
        }

        int remove = 0;
        for (Integer k: map.keySet()){
            if (map.get(k) < k) remove += map.get(k);
            else remove += (map.get(k) - k);
        }
        System.out.println(remove);
    }
}


Measured memory_bytes: 63896
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void 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;
		}
	}
	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)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}
int to_num(char c) {
	if (c >= '0' && c <= '9')return (c - '0');
	else return -1;
}

int main() {
	IOS;
	int ans = 3;
	string s, t;
	cin >> s >> t;
	if (s.size() == t.size()) {
		ans = 2;
		REP(i, s.size()) {
			if (to_num(s[i]) > to_num(t[i])) {
				ans = 0;
				break;
			}
			if (to_num(s[i]) < to_num(t[i])) {
				ans = 1;
				break;
			}
		}
	}
	else if (s.size() > t.size())ans = 0;
	else if (s.size() < t.size())ans = 1;

	switch (ans)
	{
	case 0:cout << "GREATER" << endl;
		break;
	case 1:cout << "LESS" << endl;
		break;
	case 2:cout << "EQUAL" << endl;
		break;
	default:
		break;
	}
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t,c;
    string s;
    cin>>s;
    ll ans=0;
    for(i=0;i<s.size();i++) ans+=s[i]-'0';
    if(ans%9==0) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3720
import numpy as np
n = int(input())
x = np.array(list(map(int, input().split())))
p = np.min(x)
e = np.sum((x-p)**2)
for i in range(p+1, np.max(x)):
    tmp = np.sum((x-i)**2)
    if(e > tmp):
        e = tmp
print(e)

Measured memory_bytes: 21292
def main():
    from collections import deque
    from bisect import bisect_left

    n = int(input())
    l = sorted(map(int, input().split()))
    ld = deque(l)
    cnt = 0
    for a in range(n - 2):
        l_a = ld.popleft()
        for b in range(a + 1, n - 1):
            cnt += bisect_left(l, l_a + l[b]) - b - 1
    print(cnt)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9544
parseInt(x) = parse(Int, x)
parseFloat(x) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    x=parseInt(readline())
    dp=[0 for i in 1:100010]
    for i in 1:6
        dp[100+i]=1
    end
    for i in 201:100010
        for j in 0:5
            if dp[i-(100+j)]>0
                dp[i]=1
            end
        end
    end
    println(dp[x+1])
end
main()

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

using namespace std;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int a,b,c,d;
    cin>>a>>b>>c>>d;
    long long int s1=1,s2=1,s3=1,s4=1,p1=1,p2=1,ans=0;
    s1=a*c;
    s2=b*d;
    s3=a*d;
    s4=b*c;
    p1=max(s1,s2);
    p2=max(s3,s4);
    ans=max(p1,p2);
    cout<<ans<<endl;
    
	
	return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;string s;int l;int main(){cin>>s;l=s.size();for(register int i=0;i<l;i++){if(s[i]=='C')for(register int j=i+1;j<l;j++)if(s[j]=='F'){cout<<"Yes"<<endl;return 0;}}cout<<"No"<<endl;return 0;}

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


void solve(double a, double b, double x){
    double rad;
    double s = x/a;
    if(s <= a*b/2){
        rad = atan2(b, 2*s/b);
    }else
    {
        rad = atan2((2*(a*b-s)/a), a);
    }
    double PI = acos(-1);
    double deg = rad/(2*PI) * 360;
    printf("%.10f\n", deg);
    return;
}

int main(){
    double a, b, x;
    cin >> a >> b >> x;
    solve(a, b, x);
    return 0;
}


Measured memory_bytes: 4128
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#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()
using namespace std;
typedef long long ll;

int main(){
    int n, m;
    cin >> n >> m;
    vector< pair<int , ll> > V(n, make_pair(0,0));
    REP(i, n) cin >> V[i].first >> V[i].second;
    sort(ALL(V));
    // REP(i,n) cout <<i << " "<< V[i].first << " " << V[i].second << endl;

    int now_at=0;
    ll cost = 0LL;
    while(m>=1){
        if(V[now_at].second >= m){
            cost += V[now_at].first * m;
            m -= m;
        }
        else{
            m -= V[now_at].second;
            cost += V[now_at].first * V[now_at].second;
            now_at++;
        }
    }
    cout << cost << endl;
    return 0;
}

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

#define SZ(x) ((int)(x).size())
#define FOR(i, j, n) for (int i(j); i < (n); ++i)
#define FORR(v, c) for (auto &v : (c))
#define F first
#define S second
#define SQ(x) (x)*(x)
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define pnl(x) cout << x << '\n'
#define pns(x) cout << x << ' '
#define read(x) cin >> x
#define read2(x,y) cin >> x >> y
#define read3(x, y, z) cin >> x >> y >> z
#define read4(a, b, c, d) cin >> a >> b >> c >> d
#define readv(v) FORR(c,v) read(c)

typedef	vector<int>	vi;
typedef vector<long long>	vl;
typedef	long long ll;

void solve(void)
{
	int N;
	cin >> N;
	vector<int> deg(N);
	FOR(i,1,N)
	{
		int u;
		read(u);
		deg[u-1]++;
	}
	FOR(i,0,N)
		cout<<deg[i]<<'\n';
	cout<<endl;
}

int main(void)
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int __t(1);	
	while (__t--)
		solve();
}



Measured memory_bytes: 3964
#include <iostream>
using namespace std;
int main(){
  long long n,m;cin>>n>>m;
  long long ret = 0;
  if(n < m/2){
    ret += n;
    m -= (long long)(n*2);
    n = 0;
    ret += m/4;
  }else{
    ret = m/2;
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
n = int(input())
a = [int(v) for v in input().split()]

x = a[0]
y = sum(a[1:])
ans = abs(x - y)

for i in range(1, n - 1):
    x += a[i]
    y -= a[i]
    diff = abs(x - y)
    if diff < ans:
        ans = diff

print(ans)

Measured memory_bytes: 24832
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"



int main() {
	int n,p=0,i;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	
	for(i=1;i<n-1;i++)
	{
		if((a[i]>a[i-1]&&a[i]<a[i+1])||(a[i]<a[i-1]&&a[i]>a[i+1]))
		p++;
	}
	cout<<p;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        int ans = 0;
        int max = 0;
        for(int i = 0; i < n; i++) {
        	int h = sc.nextInt();
        	if(max <= h) {
        		ans++;
        		max = h;
        	}
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22612
import math
N, K = map(int, (input().split()))

mod = 10**9 + 7

ans_array = []
divide_max = N
divide_count = []

for i in range(2, math.floor(math.sqrt(N)) + 2):
    divide = math.floor(N / i)
    ans_array.append(divide_max - divide)
    divide_count.append(divide_max - divide)
    divide_max = divide

for i in range(divide):
    ans_array.append(1)
ans_array = ans_array[::-1]
# print(ans_count)
ans_length = len(ans_array)
ans_acc = [0] * ans_length

for k in range(2, K + 1):
    ans_acc[0] = ans_array[0]
    for i in range(1, ans_length):
        ans_acc[i] = (ans_acc[i - 1] + ans_array[i]) % mod
    # print(ans_array)
    # print(ans_acc)
    for i in range(divide):
        ans_array[i] = ans_acc[ans_length - i - 1]
    for i in range(divide, ans_length):
        ans_array[i] = ans_acc[ans_length - i - 1] * divide_count[
            ans_length - 1 - i] % mod

ans_acc[0] = ans_array[0]
for i in range(1, ans_length):
    ans_acc[i] = (ans_acc[i - 1] + ans_array[i]) % mod

print(ans_acc[-1])

Measured memory_bytes: 147880