akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}



int main(){
    unsigned long long N;
    cin >> N;
    // scanf("%lld",&N);
    // 1000000000000001
    // N=754;
    unsigned long long q=N;
    unsigned long long r=N%26;
    string s;

    do {
        q--;
        char c;
        c='a'+q%26;
        // if(r==0){
        //     c='z';
        // }else{
        //     c='a'+r-1;
        // }
        s+=c;
        q/=26;
        // if(r==0){
        //     q--;
        // }
        // r=q%26;
    } while (q>0);

    reverse(all(s));
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3604
n=100001
a=[True]*n
b=[0]*n
a[0]=False
a[1]=False
for i in range(2,n):
    if a[i]:
        for j in range(i*2,n,i):
            a[j]=False

cnt=0
for i in range(3,n):
    if a[i] and a[(i+1)//2]:
        cnt+=1
    b[i]=cnt
q=int(input())
for i in range(q):
    l,r=map(int,input().split())
    print(b[r]-b[l-1])

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

int main(){
	#ifdef LOCAL_DEFINE
		freopen("../a.in","r",stdin);
		freopen("../a.out", "w",stdout);
	#endif
	
	int H,W,h,w;
	cin >> H >> W >> h >> w;

	cout << (H-h)*(W-w) << endl;

	return 0;
}

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

const int INF = 1e+8;

signed main(){
	int n,e,t,w[310],g[1010],c[1010],s[1010][12];
	cin >> n >> e >> t; t--;
	int d[310];
	for(int i = 0;i < n;i++){
		cin >> w[i];
		d[i] = (w[i] ? 1 : INF);
	}
	for(int i = 0;i < e;i++){
		cin >> g[i] >> c[i]; g[i]--;
		for(int j = 0;j < c[i];j++){
			cin >> s[i][j]; s[i][j]--;
		}
	}
	for(int i = 0;i < n;i++){
		for(int j = 0;j < e;j++){
			int ma = 0;
			vector<int> vec;
			for(int k = 0;k < c[j];k++) vec.push_back(d[s[j][k]]);
			sort(vec.begin(),vec.end(),greater<int>());
			for(int k = 0;k < c[j];k++) ma = max(ma,vec[k] + k);
			d[g[j]] = min(d[g[j]],ma);
		}
	}
	if(d[t] != INF) cout << d[t] << endl;
	else cout << -1 << endl;
}


Measured memory_bytes: 3216
main = interact $ unlines . map (show . sumOfCI . read) . init . lines

sumOfCI n
 | n < 3 = 0
 | otherwise = length $ filter isSeq [1..half]
 where
  half = div (n+1) 2
  isSeq x = sum (takeWhile (\n' -> sum [x..n'] <= n) [x..half]) == n

Measured memory_bytes: 4176
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for a in range(A+1):
  change = X
  if change - a*500 < 0:
    break
  else:
    change -= a*500
    for b in range(B+1):
      change_b = change
      if change_b - b*100 < 0:
        break
      else:
        change_b -= b*100
        for c in range(C+1):
          if change_b == c*50:
            ans += 1
            break
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

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

    int n,r,l;
    cin>>n>>r>>l;
    using T = tuple<int,int,int>;
    T dtx[r];
    int sec[n]={},val[n]={};
    priority_queue<P> pq;
    int pret=0,preidx=0;
    for(int i=0;i<r;i++){
        int d,t,x;
        cin>>d>>t>>x;
        d--;
        val[d]+=x;
        pq.push(P(val[d],-d));
        while(1){
            P p=pq.top();
            if(p.first==val[-p.second]){
                sec[preidx]+=t-pret;
                preidx=-p.second;
                pret=t;
                break;
            }
            pq.pop();
        }
    }
    sec[preidx]+=l-pret;
    int ans=0,maxt=-1;
    for(int i=0;i<n;i++){
        if(maxt<sec[i]){
            maxt=sec[i];
            ans=i+1;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 19616
#include <stdio.h>
int main()
{
    int i,num=0,a=0,b=0;
    char ch[200001];
    scanf("%s",ch);
    for(i=0;ch[i]!='\0';i++)
    {
        if(ch[i]=='S')
        {
            if(i!=0&&ch[i-1]=='T')
            {
                if(b>a)
                {
                    num=num+b-a;
                    a=0;
                }
                else
                {
                    a=a-b;
                }
                b=0;
            }
            a++;
        }
        else
        {
            b++;
        }
    }
    if(b>a)
    {
        num=num+b-a;
        a=0;
    }
    else
    {
        a=a-b;
    }
    printf("%d",num+a);
    return 0;
}


Measured memory_bytes: 384
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    c = []
    for _ in range(3):
        c.append(input_int_list())

    if (c[0][0] - c[1][0]) == (c[0][1] - c[1][1]) and (c[0][1] - c[1][1]) == (c[0][2] - c[1][2]) and (c[0][0] - c[2][0]) == (c[0][1] - c[2][1]) and (c[0][1] - c[2][1]) == (c[0][2] - c[2][2]) and (c[2][0] - c[1][0]) == (c[2][1] - c[1][1]) and (c[2][1] - c[1][1]) == (c[2][2] - c[1][2]):
        print("Yes")
    else:
        print("No")

    return


if __name__ == "__main__":
    main()


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

/* not complete */

int uf_table[100];

void uf_init(void) {
	int i;
	for(i=0;i<100;i++)uf_table[i]=0;
}

void uf_merge(int a,int b) {
	int next;
	while(uf_table[a]>0) {
		next=uf_table[a]-1;
		if(uf_table[next]>0)uf_table[a]=uf_table[next];
		a=next;
	}
	while(uf_table[b]>0) {
		next=uf_table[b]-1;
		if(uf_table[next]>0)uf_table[b]=uf_table[next];
		b=next;
	}
	if(a!=b)uf_table[a]=b+1;
}

int uf_issame(int a,int b) {
	int next;
	while(uf_table[a]>0) {
		next=uf_table[a]-1;
		if(uf_table[next]>0)uf_table[a]=uf_table[next];
		a=next;
	}
	while(uf_table[b]>0) {
		next=uf_table[b]-1;
		if(uf_table[next]>0)uf_table[b]=uf_table[next];
		b=next;
	}
	return a==b;
}

typedef struct {
	int a,b;
	int length;
} pipe_t;

pipe_t pipe[50*50*2];

int qsort_comp(const void* x,const void* y) {
	const pipe_t* a=(const pipe_t*)x;
	const pipe_t* b=(const pipe_t*)y;
	if((a->length)>(b->length))return 1;
	if((a->length)<(b->length))return -1;
	if((a->a)>(b->a))return 1;
	if((a->a)<(b->a))return -1;
	if((a->b)>(b->b))return 1;
	if((a->b)<(b->b))return -1;
	return 0;
}

int main(void) {
	int hs_num,ds_num;
	int now;
	int i,j;
	int pos;
	int result;
	while(1) {
		scanf("%d%d",&hs_num,&ds_num);
		if(hs_num==0 && ds_num==0)break;
		pos=0;
		for(i=0;i<hs_num;i++) {
			for(j=0;j<ds_num;j++) {
				scanf("%d",&now);
				if(now>0) {
					pipe[pos].a=i;
					pipe[pos].b=hs_num+j;
					pipe[pos].length=now;
					pos++;
				}
			}
		}
		for(i=0;i<ds_num;i++) {
			for(j=i+1;j<ds_num;j++) {
				scanf("%d",&now);
				if(now>0) {
					pipe[pos].a=hs_num+i;
					pipe[pos].b=hs_num+j;
					pipe[pos].length=now;
					pos++;
				}
			}
		}
		qsort(pipe,pos,sizeof(pipe_t),qsort_comp);
		uf_init();
		for(i=1;i<hs_num;i++)uf_merge(i-1,i);
		result=0;
		for(i=0,now=0;i<pos && now<ds_num;i++) {
			if(!uf_issame(pipe[i].a,pipe[i].b)) {
				uf_merge(pipe[i].a,pipe[i].b);
				result+=pipe[i].length;
				now++;
			}
		}
		printf("%d\n",result);
	}
	return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;


    void calc()
    {
        cin = new Scanner();
        int[] n=new int[5];
        int ans=0;
        for(int i=0;i<5;i++)
        {
          n[i]=int.Parse(Console.ReadLine());
        }
        int k=cin.nextInt();
        for(int i=0;i<5;i++)
        {
          for(int j=0;j<5;j++)
          {
            if(n[i]-n[j]>k){ans++;goto label1;}
      
          }
        }
      label1:
      if(ans!=0)Console.WriteLine(":(");
      else Console.WriteLine("Yay!");
    }


}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 11092
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

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

  int N;
  cin >> N;

  int total = 0;
  REP(i, N) {
    int l, r;
    cin >> l >> r;
    total += (r - l + 1);
  }

  cout << total << endl;
  return 0;
}


Measured memory_bytes: 256
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 k = sc.nextInt();
        
        for(int i=0; i<k; i++){
            if(i%2==0){
                if(a%2==1) a = a-1;
                a = a/2;
                b = b + a;
            }else{
                if(b%2==1) b = b-1;
                b = b/2;
                a = a + b;
            }
         
        }
        System.out.println(a+" "+b);
    }
}

Measured memory_bytes: 22868
//https://atcoder.jp/contests/abc122/tasks/abc122_b
//B - ATCoder
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}
int main() {
    string S; cin>>S;
    ll count=0;
    ll ans=0;
    FOR(i,0,S.size()){
        //ACGT
        char acgt[]={'A','C','G','T'};
        bool flag=false;
        for(const auto& c:acgt){
            if(S.at(i)==c) {
                flag=true;
                break;
            }
        }
        if(flag){
            ++count; 
            ans=max(count,ans);
        }else{
            count=0;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
k = int(input())
for i in range(k):
  if i == 0:
    x = 7
    y = x % k
    if y == 0:
      print(i+1)
      exit()
  else:
    y = ((10 % k) * y + (7 % k)) % k
    if y == 0:
      print(i+1)
      exit()
print(-1)

Measured memory_bytes: 9136
from collections import Counter

N=int(input())

if N==1:
  print(0)
  exit()
  
def factorize(n):
    out=[]
    i = 2
    while 1:
        if n%i==0:
            out.append(i)
            n //= i
        else:
            i += 1
        if n == 1:break
        if i > int(n**.5+3):
            out.append(n)
            break
    
    return out
  
c = Counter(factorize(N))

def n_unique(n):
  out = 0
  while 1:
    if out*(out+1)//2 > n:
      return out-1
    out += 1

ans = 0
for k in c.keys():
  ans += n_unique(c[k])
  
print(ans)

Measured memory_bytes: 9580
import itertools

K = int(input().strip())

def gcd(a, b):
  if a < b: a,b = b,a
  if a % b == 0: return b
  else: return gcd(b, a%b)

ans = 0
for a in range(1, K+1):
  for b in range(1, a+1):
    ab = gcd(a,b)
    for c in range(1, K+1):
      abc = gcd(ab, c)
      if a == b:
        ans += abc
      else:
        ans += 2*abc
print(ans)


Measured memory_bytes: 9200
c1 = list(map(int, input().rstrip().split()))
c2 = list(map(int, input().rstrip().split()))
c3 = list(map(int, input().rstrip().split()))
answer = 'No'
#a1を定めればa2,a3,b1,b2,b3は芋づる式に求まる
for i in range(101):
    a1 = i
    b1 = c1[0] - a1
    b2 = c1[1] - a1
    b3 = c1[2] - a1
    a2 = c2[0] - b1
    a3 = c3[0] - b1
    c2_2 = a2 + b2
    c2_3 = a2 + b3
    c3_2 = a3 + b2
    c3_3 = a3 + b3
    if c2_2 == c2[1] and c2_3 == c2[2] and c3_2 == c3[1] and c3_3 == c3[2]:
        answer = 'Yes'
        break
print(answer)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = 998244353; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

using P = pair<ll, ll>;
ll mpow(ll x, ll n) { ll y = 1; for (; n > 0; n /= 2) { y = n % 2 ? y * x % MOD : y; x = x * x % MOD; } return y; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
P add(P l, P r) {
    return P((l.first * r.second + r.first * l.second) % MOD, l.second * r.second % MOD);
}
P mul(P l, P r) {
    return P(l.first * r.first % MOD, l.second * r.second % MOD);
}
P reduce(P x) {
    ll d = gcd(x.first, x.second);
    return P(x.first / d, x.second / d);
}

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

    P a(A, 100);
    a = reduce(a);

    vector<P> E(K + N);
    rep(i, K, K + N - 1) E[i] = P(1, 1);

    P sum(0, 1);
    for (int i = K - 1; i >= 0; --i) {
        P ok(max(0, N - (K - i - 1)), N);
        ok = reduce(ok);

        E[i] = add(ok, P(a.first * sum.first % MOD, a.second * sum.second % MOD));
        
        sum = add(sum, P(E[i].first, E[i].second * N % MOD));

        int j = i + N;
        if (j < K) {
            P sub(MOD - E[j].first, E[j].second * N % MOD);

            sum = add(sum, sub);
        }
    }

    write(E[0].first * mpow(E[0].second, MOD - 2) % MOD);
}


Measured memory_bytes: 5916
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<cstring>
using namespace std;
#define INF 10000000
int mini(int a,int b){
	if(a<b){
		return a;
	}else{
		return b;
	}
}
int maxim(int a,int b){
	if(a>b){
		return a;
	}else{
		return b;
	}
}


int main(){
	while(1){
		int i,j,n,s,t,max=0,min=500;
		cin>>n;
                if(n==0)break;
		for(i=0;i<n;i++){
			t=0;
			for(j=0;j<5;j++){
				cin>>s;
				t+=s;
			}
			max=maxim(max,t);
			min=mini(min,t);
		}
		cout<<max<<' '<<min<<endl;
	}
    return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a.at(i);
	}
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	int Alice = 0, Bob = 0;
	if(N % 2 == 0) {
		for(int i = 0; i < N; i += 2) {
			Alice += a.at(i);
			Bob   += a.at(i+1);
		}
		cout << Alice - Bob << endl;
	}
	else {
		for(int i = 0; i < N-1; i += 2) {
			Alice += a.at(i);
			Bob   += a.at(i+1);
		}
		Alice += a.at(N-1);
		cout << Alice - Bob << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
            #include<vector>
            #include <algorithm>
            #include <map>
            using namespace std;
            #define debug(x) //printf((char*)x);printf("\n");
            int main(){
              int n;
             
              cin >> n;
              long long *v = new long long[n+1];
              v[0]=0;
              for(int i=1;i<n+1;i++){
                cin >> v[i];
                v[i] += v[i-1];
                debug("read val");
              }
             
              long long cnt = 0;
              map<long long,int> comb;
              for(int i=0;i<n+1;i++){
                cnt += comb[v[i]];
                comb[v[i]] += 1;
              }
              
         
              cout << cnt; 
              delete(v);
              return 0;
            }

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

////How Many Divisors? ??\????????????????????£?????????
//int main()
//{
//    int a,b,c;
//    cin >> a >> b >> c;
//    cout << a+b+c << endl;
//    return 0;
//}


//Rectangle ??\????????????????????£?????????
int main(){
    int a,b;
    cin >> a >> b;
    cout << a*b << " " << 2*(a+b) << endl;
    return 0;
}

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

int main(){
    int N;
    int al = 0, bo = 0; 
    cin >> N;
    bool flag = true;
    vector<int> a(N);
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for(int i = N-1; i >= 0; i--){
        if(flag)al += a[i], flag = false;
        else al -= a[i], flag = true;
    }
    cout << al << endl;
    
}

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

const int maxN = 1e5 + 10;

struct Node
{
	int to, next;
}edge[maxN * 2 + 1];

int n;
int tot, head[maxN + 1];
int f[maxN + 1][2];

inline int read()
{
	int num = 0, f = 1;
	char ch = getchar();
	while( !isdigit( ch ) ) { if(ch == '-') f = -1; ch = getchar(); }
	while( isdigit( ch ) ) num = (num << 3) + (num << 1) + (ch ^ 48), ch = getchar();
	return num * f;
}

inline void add(int x, int y)
{
	tot ++;
	edge[tot].to = y;
	edge[tot].next = head[x];
	head[x] = tot;
}

inline void dfs(int u, int pa)
{
	f[u][1] = 1;
	for(int i = head[u]; i; i = edge[i].next)
	{
		int v = edge[i].to;
		if(v == pa) continue;
		dfs(v, u);
		f[u][0] += max(f[v][0], f[v][1]);
		f[u][1] += f[v][0];
	}
}

int main()
{
	n = read();
	for(int i = 1; i < n; i++)
	{
		int x = read(), y = read();
		add(x, y); add(y, x);
	}

	dfs(1, 0);

	int ans = max(f[1][0], f[1][1]);
	if(2 * ans == n) puts("Second");
	else puts("First");
	return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	if (a + b < 10) {
		dunk(a + b);
	}
	else {
		dunk("error");
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)
class Point{
  public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}
  Point operator + (Point p){return Point(x+p.x,y+p.y);}
  Point operator - (Point p){return Point(x-p.x,y-p.y);}
  Point operator * (double a){return Point(a*x,a*y);}
  Point operator / (double a){return Point(x/a,y/a);}

  bool operator < (const Point &p) const{
    return x!=p.x?x<p.x:y<p.y;
  }
  bool operator == (const Point &p) const{
    return fabs(x-p.x)<EPS&&fabs(y-p.y)<EPS;
  }
};

typedef Point vect;
struct seg{Point p1,p2;};
//????????´???
double norm(Point p){return p.x*p.x+p.y*p.y;}
//??¶??????
double abs(Point p){return sqrt(norm(p));}
//??????
double dot(Point a,Point b){
  return a.x*b.x+a.y*b.y;
}
//??????
double cross(Point a,Point b){
  return a.x*b.y-a.y*b.x;
}
//??´?????????
bool C90(seg s1,seg s2){
  return equals(dot(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}
bool C0(seg s1,seg s2){
  return equals(cross(s1.p2-s1.p1,s2.p2-s2.p1),0.0);
}
//?°???±
Point projec(seg s,Point p){
  Point base = s.p2-s.p1;
  double r=dot(p-s.p1,base) / norm(base);
  return s.p1+base*r;
}
main(){
  int n;
  seg a;
  cin>>a.p1.x>>a.p1.y>>a.p2.x>>a.p2.y;
  cin>>n;
  while(n--){
    Point b,c;
    cin>>b.x>>b.y;
    c=projec(a,b);
    printf("%.11f %.11f\n",c.x,c.y);
  }
}

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

int main(){
    vector<pair<int,int>> dish(5);
    rep(i, 5){
        int tmp, mod;
        cin >> tmp;
        mod = tmp%10;
        if(mod != 0) dish[i].first = mod;
        else dish[i].first = 10;
        dish[i].second = tmp;
    }

    sort(dish.begin(), dish.end());

    int sum = 0;
    rep(i, 5){
        sum += 10 -dish[i].first;
        sum += dish[i].second;
    }
    sum -= 10 - dish[0].first;
    
    cout << sum << endl;

    return 0;
}

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

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define F first
#define S second

const int maxn = 1e6 + 12;
int a[maxn], n, C = 0, ans;
string s;

int main() {
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		a[i] = s[i] - '0' - 1;
		if(!C && a[i] == 1) C = 1;
	}
	for (int i = 0; i < n; i++) if(C) a[i] %= 2;
	for (int i = 0; i < n; i++) if(((n - 1) & i) == i) ans ^= a[i];
	cout << ans;
	return 0;
}	


Measured memory_bytes: 5252
#include <stdio.h>

int prime[2000000];

int main(void)
{
    int n;
    int i, j;
    int cnt;
    int prime_max = 3;

    prime[2] = 1;
    prime[3] = prime[4] = 2;
    while (~scanf("%d", &n)){
        if (n < 2){
            puts("0");
        }
        else if (prime[n] != 0){
            printf("%d\n", prime[n]);
        }
        else {
            for (i = prime_max + 2; i <= n; i += 2){
                prime[i] = prime[i - 1];
                prime[i + 1] = prime[i - 1];
                for (j = 3; j * j <= i; j += 2){
                    if (i % j == 0){
                        break;
                    }
                }
                if (j * j > i){
                    prime[i]++;
                    prime[i + 1]++;
                }
            }
            printf("%d\n", prime[n]);
            prime_max = n - (n + 1) % 2;
        }
    }

    return (0);
}

Measured memory_bytes: 4700
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,s,e) for(int i=s;i<=e;i++)
int gcd(int a,int b);
int main(){
    int K;cin>>K;
    lli res=0;
    rep(p,1,K){
        rep(q,1,K){
            rep(r,1,K)res+=gcd(p,gcd(q,r));
        }
    }
    cout<<res<<endl;
}

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

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

const int MAX=510000;
const int mod=998244353;
ll fac[MAX],finv[MAX],inv[MAX];

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

ll modinv(ll a){
  return modpow(a,mod-2);
}

void init(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  rep(i,MAX){
    if(i>1){
      fac[i]=fac[i-1]*i%mod;
      inv[i]=mod-inv[mod%i]*(mod/i)%mod;
      finv[i]=finv[i-1]*inv[i]%mod;
    }
  }
}

ll com(int n,int k){
  if(n<k) return 0;
  if(n<0||k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

int main(){
  ll N,M,K;
  cin>>N>>M>>K;
  init();
  ll ans=0;
  rep(i,K+1){
    ll tmp=M*modpow(M-1,N-i-1)%mod;
    (tmp*=com(N-1,i))%=mod;
    (ans+=tmp)%=mod;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 15580
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define ll long long
#define inf 0x3f3f3f3f
#define mod 998244353
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20];
	int len=0;
	if(x<0)putchar('-'),x=-x;
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
ll n,a,b;
int main()
{
	n=read(); a=read(); b=read();
	if(a>b)std::swap(a,b);
	if((a+b)&1)writeln(std::min(b-(1-a),(2*n-b+1)-a)>>1);
	else writeln((b-a)>>1);
	return 0;
}

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

string ans = "";
void binding(int a, char b) {
  rep(i,a) ans += b;
}
int main() {
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  int x = tx-sx, y = ty-sy;
  binding(y,'U');
  binding(x,'R');
  binding(y,'D'); 
  binding(x,'L');
  ans += 'L';
  binding(y+1,'U');
  binding(x+1,'R');
  ans += 'D'; ans += 'R';
  binding(y+1,'D');
  binding(x+1,'L');
  ans += 'U';

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3660
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

p = I()
a = LI()

# iで1,i以外で0をとる多項式は 1-(x-i)**(p-1)
# これらを足し合わせればよい

C = [1]
for i in range(1,p):
    C.append((C[-1]*(p-i)*pow(i,p-2,p)) % p)
# C[i] = (p-1)_C_i

ANS = [a[0]]
for i in range(1,p):
    s = -C[i] % p
    t = sum(a[j]*pow(-j,p-1-i,p) for j in range(p)) % p
    ANS.append((s*t) % p)

print(*ANS)

Measured memory_bytes: 69884
#include<stdio.h>
#include<string.h>
char c[103][103];
char copy[103];
int n,l;
int main(){
	scanf("%d %d",&n,&l);
	
	for(int i=1;i<=n;i++){//正在放第i张牌
		scanf("%s",c[i]);
		for(int j=1;j<i;j++){//打算放在j位置
			if(strcmp(c[j],c[i])>0){
				strcpy(copy,c[i]);
				for(int k=i;k>j;k--){
				strcpy(c[k],c[k-1]);
				}
				strcpy(c[j],copy);
				break;
			}
		}
	}

	for(int k=1;k<=n;k++){
		printf("%s",c[k]);
	}
}


Measured memory_bytes: 128
import java.util.*;

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

		int N = sc.nextInt();
		int M = sc.nextInt();
		
		int[] city = new int[N];
		
		for(int i = 0;i < N;i++) city[i] = 0;
		for(int i = 0;i < 2*M;i++) city[sc.nextInt() - 1]++;
				
		for(int i = 0;i < N;i++) System.out.println(city[i]);
	}
}




Measured memory_bytes: 21972
/* winners never quit and quitters never win.
      #swap                                 */
      
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(v) v.begin(),v.end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ll h,n;
    cin>>h>>n;
    ll dp[h+1];
    rep(a,0,h+1)
        dp[a]=inf;
    dp[0]=0;
    rep(a,0,n)
    {
        ll b,c;
        cin>>b>>c;
        for(ll d=0;d<=h;d++)
        {
            if(d<b)
                dp[d]=min(dp[d],c);
            else
                dp[d]=min(dp[d-b]+c,dp[d]);
        }
    }
    cout<<dp[h]<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
	int x, y, p = 0;
	cin >> x >> y;
	if(x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12){
		if(y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12){
			p = 1;
		}
	} else if(x == 4 || x == 6 || x == 9|| x == 11){
		if(y == 4 || y == 6 || y == 9|| y == 11){
			p = 1;
	    }
	} else if(x == 2 && y == 2){
		p = 1;
    }
	if(p == 1){
		cout << "Yes";
    } else {
		cout << "No";
    }
}

Measured memory_bytes: 256
# coding: utf-8
s = input().split()

n = int(s[0])
k = int(s[1])

treat = []

for i in range(n):
    treat.append(False)

for i in range(k):    
    d = int(input())
    a = input().split()
    
    for j in range(d):
        treat[int(a[j]) - 1] = True
    
res = 0

for i in range(n):
    if not treat[i]:
        res += 1

print(res)


Measured memory_bytes: 9176
#include <bits/stdc++.h>
 
using namespace std;
 
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.12lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
const int mod = 1000 * 1000 * 1000 + 7;
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;
 
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265359;
 
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};


int main(){
   ll n,a,b;
   cin>>n>>a>>b;
   ll tmp =n/(a+b);
   ll rem = n-tmp*(a+b);
   ll ans = (tmp*a)+min(rem,a);
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if(a+b==15){
        cout << "+" << endl;
    }else if(a*b==15){
        cout << "*" << endl;
    }else{
        cout << "x" << endl;
    }
}

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

X = parseInt(readline())

gohyaku = X ÷ 500
go = (X - (500*gohyaku)) ÷ 5

println(1000 * gohyaku + 5 * go)

Measured memory_bytes: 168832
def foo
  n, m = gets.split.map(&:to_i)
  cs = []
  m.times do
    cs << gets.split.map(&:to_i)
  end
  a = "1" + "0"*(n-1)
  a = "0" if n == 1
  b = "9"*n

  (a..b).each do |str|
    return str if cs.all?{|s,c| str[s-1] == c.to_s}
  end

  return -1
end

puts foo()


Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static int[] dep;
        static List<int>[] e;
        static int[] md, fa;
        static int n, s, t;
        //int dep[100009],  *e[100009], md[100009], fa[100009], n, s, t, elen[100009];

        static void dfs(int u, int f)
        {
            dep[u] = md[u] = dep[f] + 1;
            fa[u] = f;
            for (int i = 0; i < e[u].Count; i++)
            {
                if (e[u][i] != f)
                {
                    dfs(e[u][i], u);
                    md[u] = Math.Max(md[u], md[e[u][i]]);
                }
            }
        }

        static void Main()
        {
            var ipt = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            n = ipt[0]; s = ipt[1]; t = ipt[2];

            e = new List<int>[n+1];
            dep = new int[n +1];
            md = new int[n + 1];
            fa = new int[n + 1];

            for (int i = 0; i < n + 1; i++)
            {
                e[i] = new List<int>();
            }
            for (int i = 1; i < n; i++)
            {
                ipt = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                e[ipt[0]].Add(ipt[1]);
                e[ipt[1]].Add(ipt[0]);
            }
            dfs(t, 0);

            int ans = 0, x = s;
            while (dep[s] - dep[x] < dep[x] - dep[t])
            {
                ans = Math.Max(ans, md[x] - 1);
                x = fa[x];
            }

            Console.WriteLine(ans - 1);
        }
    }
}


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

using namespace std;

int n, m;

vector<vector<pair<int, int>>> g;

vector<int> p;
vector<int> f;

bool dfs(int r) {
    
    f[r] = 1;

    for (auto e : g[r]) {
        int to = e.first;
        int d = e.second;

        if (!f[to]) {
            p[to] = p[r] + d;

            if (!dfs(to)) {
                return false;
            }
        } else if (p[to] != p[r] + d) {
            return false;
        }
    }

    return true;
}


int main() {
    cin >> n >> m;

    g.resize(n);
    p.resize(n);
    f.resize(n);

    for (int i = 0; i < m; i++) {
        int l, r, d;
        cin >> l >> r >> d;
        l--;
        r--;

        g[l].emplace_back(r, d);
        g[r].emplace_back(l, -d);
    }

    for (int i = 0; i < n; i++) {
        if (!f[i]) {
            if(!dfs(i)) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 12416
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
  long double n,k;
  long double ans=0;
  cin >> n >> k;
  for(int i=1; i<=n; i++){
    int num = i;
    int l = 0;
    while(num < k){
      num *= 2;
      l++;
    }
    ans += (1.0/n * pow((long double)1/2, l));
  }
  printf("%.14Lf\n", ans);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int N;
  cin >> N;
  
  int a = N/1000;
  int b = N/100 - a*10;
  int c = N/10 - a*100 - b*10;
  int d = N - a*1000 - b*100 -c*10;
  
  if( (a == b && b == c ) || ( b == c && c == d ) ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
#define int long long
//template
std::vector<int> imos(234567,0);
//main
signed main(){
  int N,M;cin>>N>>M;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i],v[i]--;
  int sum=0;
  for(int i=1;i<N;i++){
    int low=v[i-1],high=v[i];
    if(low>high)high+=M;sum+=high-low;
    imos[low+2]++;imos[high+1]--;
  }
  for(int i=0;i<234566;i++)imos[i+1]+=imos[i];
  for(int i=1;i<N;i++){
    int low=v[i-1],high=v[i];
    if(low>high)high+=M;
    imos[high+1]-=high-low-1;
  }
  for(int i=0;i<234566;i++)imos[i+1]+=imos[i];
  int mx=0;
  std::vector<int> happy(M,0);
  for(int i=0;i<234566;i++)happy[i%M]+=imos[i];
  for(int i=0;i<M;i++)mx=max(mx,happy[i]);
  cout<<sum-mx<<endl;
}


Measured memory_bytes: 3712
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF INT32_MAX / 2
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

template <class T>
struct UnionFind {
    vector<T> parent;
    vector<T> rank;
    vector<T> size_of;

    UnionFind(T n) : parent(n), rank(n), size_of(n) {
        for (T i = 0; i < n; i++) {
            parent[i] = i;
            rank[i] = 0;
            size_of[i] = 1;
        }
    }

    T root(T x) {
        return parent[x] == x ? x : parent[x] = root(parent[x]);
    }

    bool same(T x, T y) {
        return root(x) == root(y);
    }

    T size(T x) {
        return size_of[root(x)];
    }

    void unite(T x, T y) {
        x = root(x);
        y = root(y);
        if (x == y)
            return;
        if (rank[x] < rank[y]) {
            size_of[y] += size_of[x];
            parent[x] = y;
        }
        else {
            size_of[x] += size_of[y];
            parent[y] = x;
            if (rank[x] == rank[y])
                rank[x]++;
        }
        return;
    }
};

signed main() {
    int n, m;
    cin >> n >> m;
    UnionFind<int> uf(n);
    int a, b;
    while (m--) {
        cin >> a >> b;
        a--;
        b--;
        uf.unite(a, b);
    }
    set<int> s;
    int ans = 0;
    rep(i, n) {
        if (s.find(uf.root(i)) == s.end()) {
            chmax(ans, uf.size(i));
            s.insert(uf.root(i));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 14696
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string.h>
#include<string>
#include<functional>
#include<iomanip>
using namespace std;

#define INF 1<<21
#define DIV 1000000007

int main() {
  int m, nmin, nmax;
  while (cin >> m >> nmin >> nmax, (m || nmin || nmax)) {
	int p[10005];
	int gap = 0, gap1=0, gap2=0;
	int ans = 0;
	for (int i = 1; i <= m; i++) {
	  cin >> p[i];
	}
	for (int i = nmin; i <= nmax; i++) {
	  if (gap <= p[i] - p[i+1]) {
		gap = p[i] - p[i + 1];
		ans = i;
	  }
	}
	cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3076
#define s(X,Y,Z)(t=X,X=Y,Y=t,p=Z?&X:&Y,*p^=7,a)
a,b,c,t,m,r,*p;main(n){for(;r=a=scanf("%d",&n),n;printf("%d\n",r))for(b=2,c=3;n--;scanf(" %c%*s",&t),m=t-76,r+=m%6==0?s(c,b,m):1<m&m<8?s(b,a,m^7):s(c,a,m>0));}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;

// 入力
int N;
long long W, weight[110], value[110]; // 品物の個数は 100 個なので少し余裕持たせてサイズ 110 に

// DPテーブル
long long dp[110][100100] = {0};

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];

    // DPループ
    for (int i = 0; i < N; ++i) {
        for (int sum_w = 0; sum_w <= W; ++sum_w) {

            // i 番目の品物を選ぶ場合
            if (sum_w - weight[i] >= 0) {
                chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
            }

            // i 番目の品物を選ばない場合
            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }

    // 最適値の出力
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 81648
// In god we trust

#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>

#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define INF 1000000000
#define LINF 1000000000000000
#define int long long
using namespace std;
using namespace std::chrono;

int a[200010], cnt[200010];

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


  int n;
  cin >> n;
  
  for (int i = 0; i < n; i++){
    cin >> a[i];
    cnt[a[i]] ++;
  }

  int ans = 0;
  for (int i = 0; i < n + 1; i++)
    ans += cnt[i] * (cnt[i] - 1) / 2;
  

  for (int i = 0; i < n; i++){
    int new_ = ans - (cnt[a[i]] - 1);
    cout << new_ << endl;
  }
    
  
}  






Measured memory_bytes: 4864
#include<bits/stdc++.h>
using Int = long long;
using namespace std;
int main(){
    Int N; cin >> N;
    vector<Int>v(N);
    for(auto& e : v)
        cin >> e;
    vector<Int>base = v;
    map<Int,Int>toIdx, dis;
    sort(base.begin(),base.end());
    for(Int id = 0; id  < N; ++id)
        toIdx[base[id]] = id;
    for(Int i = 0; i < N; ++i)
        dis[v[i]] = abs(i - toIdx[v[i]]);
    cout << accumulate(dis.begin(), dis.end(), 0LL,[](Int res, const pair<Int,Int> p){
        return res += ( p.second % 2);
    }) / 2<<endl;
}


Measured memory_bytes: 16384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d,flag=0;
	cin>>a>>b>>c>>d;
	while(1)
	{
		c-=b;
		a-=d;
		if(c<=0)
		{
			flag=1;
			break;
		}
		if(a<=0)
		{
			flag=2;
			break;
		}
	}
	if(flag==1)
	cout<<"Yes"<<endl;
	else 
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3632
/// However long the night,
///     The dawn will break
/// ICPC next year

#include<bits/stdc++.h>
using namespace std ;
const int N = 2e5+5 ;

string s ;
deque<int> dq[26] ;
long long seg[1<<20] ,lazy[1<<20] ;
void propgate(int ni,int ns,int ne){
    seg[ni] += lazy[ni] ;
    if(ns!=ne){
        lazy[ni*2+1] += lazy[ni] ;
        lazy[ni*2+2] += lazy[ni] ;
    }
    lazy[ni] = 0 ;
}
void update(int qs,int qe,int v,int ni=0,int ns=0,int ne=s.size()-1){
    if(lazy[ni]) propgate(ni,ns,ne) ;
    if(ne<qs || ns>qe || ns>ne) return ;
    if(ns>=qs && ne<=qe){
        seg[ni] += v ;
        if(ns!=ne){
            lazy[ni*2+1] += v ;
            lazy[ni*2+2] += v ;
        }
        return ;
    }
    int l = ni*2+1 ,r = l+1 ,mid = (ns+ne)/2 ;
    update(qs,qe,v,l,ns,mid);
    update(qs,qe,v,r,mid+1,ne);
    seg[ni] = seg[l] + seg[r] ;
}
int query(int qs,int qe,int ni=0,int ns=0,int ne=s.size()-1){
    if(lazy[ni]) propgate(ni,ns,ne) ;
    if(ne<qs || ns>qe || ns>ne) return 0;
    if(ns>=qs && ne<=qe) return seg[ni] ;
    int l = ni*2+1 ,r = l+1 ,mid = (ns+ne)/2 ;
    return query(qs,qe,l,ns,mid) + query(qs,qe,r,mid+1,ne) ;
}
int main(){
    cin >> s ;
    for(int i=0;i<s.size();++i) dq[s[i]-'a'].push_back(i);
    int i=0 ,j=s.size()-1 ;
    long long ans = 0 ;
    while(i<j){
        int mn = 1e9 ,chr ;
        bool flag = 0 ;
        for(int ch=0;ch<26;++ch){
            if(dq[ch].size()<2) continue ;
            flag = 1 ;
            int a = dq[ch].front() + query(dq[ch].front(),dq[ch].front()) ;
            int b = dq[ch].back() + query(dq[ch].back(),dq[ch].back()) ;
            int x = a - i + j - b ;
            if(x < mn) mn = x ,chr = ch ;
        }
        if(!flag) return cout << -1,0 ;
        ans += mn ;
        update(0,dq[chr].front()-1,1) ;
        update(dq[chr].back()+1,s.size()-1,-1) ;
        ++i,--j ;
        dq[chr].pop_back() ;
        dq[chr].pop_front();
    }
    cout << ans ;
    return 0;
}


Measured memory_bytes: 13700
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main(){
    int n,m;
    cin >> n >> m;

    if(n == m){
        dunk("Yes");
    }
    else{
        dunk("No");
    }
}
    





Measured memory_bytes: 256
#!/usr/bin/env python3
def f(xs, ys):
    acc = 0
    for x, y in zip(xs, ys):
        acc += min(x, y)
    return acc
n = int(input())
l = sorted(map(int,input().split()))
ans = max(f(l[0::2], l[1::2]), f(l[1::2], l[2::2]))
print(ans)

Measured memory_bytes: 3060
n,m = map(int,input().split())
lst = list(map(int,input().split()))
syukudai = 0
while lst:
    syukudai += lst.pop()

nokori = n - syukudai
if nokori < 0:
    print("-1")
else:
    print(nokori)
# print(n,m,lst)



Measured memory_bytes: 9992
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
//#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
int h, w;
string s;
signed main() {
	cin >> h >> w;
	for1(i, h) {
		cin >> s; cout << s << '\n' << s << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DIM 100007
#define INF 1000000007
using namespace std;

long long n,h[DIM],d[DIM];

int main()
{
    cin>>n;
    for(int i = 1; i <= n; ++i)
        cin>>h[i];

    d[n-1] = abs(h[n]-h[n-1]);
    for(int i = n-2; i >= 1; --i)
        d[i] = min(abs(h[i]-h[i+1])+d[i+1],abs(h[i]-h[i+2])+d[i+2]);

    cout<<d[1];
    return 0;
}


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

void prians(bool answer) {
  if(answer)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

int a[4] = {0};
int b[4] = {0};
int cnt[5] = {0};
int ch[100] = {0};

int main() {
  for(int i = 0; i < 3; ++i) cin >> a[i] >> b[i];
  for(int i = 0; i < 3; ++i) {
    ++cnt[a[i]];
    ++cnt[b[i]];
  }
  for(int i = 1; i <= 4; ++i) ++ch[cnt[i]];
  prians(ch[1] == 2 && ch[2] == 2);
  return 0;
}

Measured memory_bytes: 256