akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll a,b,c; cin >> a >> b >> c;
  if ((c - a - b) > 0 && 4 * a * b < (c - a - b)*(c - a - b)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A, B, C;
    cin >> A >> B >> C;
    int ans;
    ans = min(B/A, C);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <time.h> 
#include <vector>


int main() {
    long long N , K;
    std::vector<long long> A;
    scanf("%lld %lld", &N, &K);
    std::vector<long long> S(N, 0);
    for (int i = 0; i < N; i++) {
        int a;
        scanf("%d", &a);
        A.push_back(a);
        if (i > 0)
            S[i] = S[i - 1] + a;
        else
            S[i] = a;
    }
    std::vector<long long> parts;
    for (int l = 0; l < N; l++) {
        for (int r = l; r < N; r++) {
            if ((l - 1) >= 0)
                parts.push_back(S[r] - S[l - 1]);
            else
                parts.push_back(S[r]);
        }
    }
    long long res = 0;
    std::vector<bool> is_use(parts.size(), true);
    for (int i = 0; i < 45; i++) {
        long long mask = (1LL << (44 - i));
        int count = 0;
        std::vector<bool> is_use_save(is_use);
        for (int j = 0; j < parts.size(); j++) {
            if (((parts[j] & mask) != 0) && (is_use[j] == true)) {
                is_use[j] = true;
                count += 1;
            }
            else {
                is_use[j] = false;
            }
        }
        if (count >= K)
            res += mask;
        else
            for (int k = 0; k < is_use_save.size(); k++) {
                is_use[k] = is_use_save[k];
            }
    }
    printf("%lld\n", res);
}

Measured memory_bytes: 6524
# -*- coding: utf-8 -*-

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

class Dinic:
    """ 最大流(Dinic) """

    INF = 10 ** 18

    def __init__(self, n):
        self.n = n
        self.links = [[] for _ in range(n)]
        self.depth = None
        self.progress = None
 
    def add_link(self, _from, to, cap):
        self.links[_from].append([cap, to, len(self.links[to])])
        self.links[to].append([0, _from, len(self.links[_from]) - 1])
 
    def bfs(self, s):
        from collections import deque

        depth = [-1] * self.n
        depth[s] = 0
        q = deque([s])
        while q:
            v = q.popleft()
            for cap, to, _ in self.links[v]:
                if cap > 0 and depth[to] < 0:
                    depth[to] = depth[v] + 1
                    q.append(to)
        self.depth = depth
 
    def dfs(self, v, t, flow):
        if v == t:
            return flow
        links_v = self.links[v]
        for i in range(self.progress[v], len(links_v)):
            self.progress[v] = i
            cap, to, rev = link = links_v[i]
            if cap == 0 or self.depth[v] >= self.depth[to]:
                continue
            d = self.dfs(to, t, min(flow, cap))
            if d == 0:
                continue
            link[0] -= d
            self.links[to][rev][0] += d
            return d
        return 0
 
    def max_flow(self, s, t):
        INF = Dinic.INF
        flow = 0
        while True:
            self.bfs(s)
            if self.depth[t] < 0:
                return flow
            self.progress = [0] * self.n
            current_flow = self.dfs(s, t, INF)
            while current_flow > 0:
                flow += current_flow
                current_flow = self.dfs(s, t, INF)

N = INT()
A = [input() for i in range(N)]
M = 26
C = Counter()
outcnt = [0] * M
incnt = [0] * M
for s in A:
    a, b = ord(s[0])-97, ord(s[-1])-97
    # 辺(a, b)の容量、aから出る辺の数、bに入る辺の数
    C[(a, b)] += 1
    outcnt[a] += 1
    incnt[b] += 1

dinic = Dinic(M*2)
for a in range(M):
    # 各文字でin -> out間はINFで繋いでおく
    dinic.add_link(a, M+a, INF)
    for b in range(M):
        # 文字aのout -> 文字bのin
        dinic.add_link(M+a, b, C[(a, b)])

ans = []
for a in range(M):
    # 文字aのoutからinに向かって流す
    res = dinic.max_flow(M+a, a)
    # aで終わる単語が1つ以上あって、aに戻ってこれる流量がaを出る辺の数以上にあればOK
    if incnt[a] >= 1 and res >= outcnt[a]:
        ans.append(chr(a+97))
[print(a) for a in ans]



Measured memory_bytes: 7684
using System;
using System.Linq;

namespace _029_EnglishSentence
{
	class Program
	{
		static void Main ( string[] args )
		{
			string[] inputStr = Console.ReadLine ().Split (' ');

			Array.Sort (inputStr);

			int[] countArray = new int[inputStr.Length];
			countArray[0] = 1;

			int index = 0;

			string maxLengthStr = inputStr[0];

			for (int lp = 1; lp < inputStr.Length; lp++)
			{
				//count
				if (inputStr[lp] == inputStr[lp - 1])
				{
					countArray[lp] = countArray[lp - 1] + 1;
				}
				else
				{
					countArray[lp] = 1;

					if (countArray[index] < countArray[lp - 1])
					{
						index = lp - 1;
					}
				}

				//length
				if (maxLengthStr.Length < inputStr[lp].Length)
				{
					maxLengthStr = inputStr[lp];
				}
			}

			int lastIndex = countArray.Length - 1;
			if (countArray[index] < countArray[lastIndex])
			{
				index = lastIndex;
			}

			string maxCountStr = inputStr[index];

			Console.WriteLine (maxCountStr + " " + maxLengthStr);
		}
	}
}

Measured memory_bytes: 9828
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

ll n;

ll ch(ll a){
  return (a+n)%n;
}

int main (){
  cin>>n;
  vector<ll>v(n,0);
  ll sum=0;
  for(ll i=0;i<n;i++){
    cin>>v[i];
    sum+=v[i];
  }
  ll f=0;
  ll i=0;
  ll j=1;
  ll l=2;
  ll ans=0;
  ll asum,bsum,csum;
  asum=v[0];
  bsum=v[1];
  csum=sum-v[0]-v[1];
  ans=min({asum,bsum,csum});
  if(n==3){
    cout<<ans<<endl;
    return 0;
  }
  while(!(f!=0&&i==0)){
    ll m=min({asum,bsum,csum});
    ll mm=max({asum,bsum,csum});
    if(csum==m&&ch(j-i)!=1){
      asum-=v[i];
      csum+=v[i];
      i++;
      i=ch(i);
    }
    else if(asum==m&&ch(l-j)!=1){
      bsum-=v[j];
      asum+=v[j];
      j++;
      j=ch(j);
    }
    else if(bsum==m&&ch(i-l)!=1){
      csum-=v[l];
      bsum+=v[l];
      l++;
      l=ch(l);
    }
    else if(asum==mm&&ch(j-i)!=1){
      asum-=v[i];
      csum+=v[i];
      i++;
      i=ch(i);
    }
    else if(bsum==mm&&ch(l-j)!=1){
      bsum-=v[j];
      asum+=v[j];
      j++;
      j=ch(j);
    }
    else if(csum==mm&&ch(i-l)!=1){
      csum-=v[l];
      bsum+=v[l];
      l++;
      l=ch(l);
    }
    else{
      ans=max(ans,min({asum,bsum,csum}));
      break;
    }
    ans=max(ans,min({asum,bsum,csum}));
    if(i>1)f=1;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3636
n,m = map(int, input().split())
a = list(map(int, input().split()))
flag = False
allVote = sum(a)
a.sort(reverse=True)
counter = 0

for i in range(n):
  if allVote/4 <= a[i]*m:
    counter +=1 
  else:
    break


if counter >= m:
  flag = True

if flag is False:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MT make_tuple
#define PB push_back
typedef long long ll;

int a, b;

int main () {
        scanf("%d %d", &a, &b);
        if (a <= 0 && 0 <= b) return puts("Zero"), 0;
        if (a > 0) return puts("Positive"), 0;
        if ((b+1-a)&1) return puts("Negative"), 0;
        puts("Positive");
        return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <algorithm>

using namespace std ;

int main(void){
    int N,M,Q;
    
    cin >> N >> M >> Q;
    // pair<int,int> lr[M];
    // pair<int,int> pq[Q];
    int L[M], R[M], A[1000][1000], C[1000][1000];

	for (int i=1; i<= M; i++) {
		cin >> L[i] >> R[i]; A[L[i]][R[i]]++;
	}
	for (int i=1; i<= N; i++) {
		for (int j=1; j<=N; j++) C[i][j] = C[i][j - 1] + A[i][j];
	}
	for (int i=1; i<=Q; i++) {
		int p, q;
        cin >> p >> q;
		int sum = 0;
		for (int j = p; j <= q; j++) sum += C[j][q] - C[j][p - 1];
		cout << sum << endl;
    }

    // for(int i=0; i<N; i++){
    //     cin >> lr[i].first >> pq[i].second;
    // }
    // sort(lr, lr+N,greater<pair<int,int>>());

    // for(int i=0; i<N; i++){
    //     // cout << ab[i].first << ab[i].second << endl;
        
    // }
    


    // cout << ans << endl;

    return 0;
}



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

int main() {
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  int cnt=0;
  for(int i=0;i<=a;i++) {
    for(int j=0;j<=b;j++) {
      for(int k=0;k<=c;k++) {
        int total = 500*i+100*j+50*k;
        if(total==x) cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf = 1e9;

const int NODE_SIZE = 55;

int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { -1, 0, 1, 0 };

int H,W;
string field[NODE_SIZE];
int ans;
//幅優先探索 (グラフ: vector)
int bfs(){
    int ret=-1;
    queue<pair<int, pair<int,int>>> q; //<コスト, ノード>
    bool visited[NODE_SIZE][NODE_SIZE];
    for(int i=0; i<H; i++) for(int j=0; j<W; j++) visited[i][j]=false;    //初期位置を設定
    q.push({1, {0, 0}});

    while(!q.empty()){
        int curStep = q.front().first;
        int curY = q.front().second.first;
        int curX = q.front().second.second;
        q.pop();
        if(curY==H-1&&curX==W-1) {
            ret = curStep;
            break;
        }
        if(visited[curY][curX]) continue;
        visited[curY][curX] = true;

        for(int i=0; i<4; i++){
            int nextY = curY + dy[i];
            int nextX = curX + dx[i];
            if(!CK(nextY,0,H)||!CK(nextX,0,W)||field[nextY][nextX]=='#') continue;
            if(!visited[nextY][nextX]){     //未到達のノードだけpush.
                q.push({curStep + 1, {nextY,nextX}});
            }
        }
    }
    return ret;
}

int main() {
    cin>>H>>W;
    REP(i,0,H){
        cin>>field[i];
        REP(j,0,W){
            if(field[i][j]=='.') ans++;
        }
    }
    int path=bfs();
    if(path==-1) p(-1);
    else p(ans-path);
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    long long p=0,g=0;
    long long count=0;
    for(long long i=0;i<s.size();i++){
        if(p==g&&s[i]=='g') g++;
        else if(p==g&&s[i]=='p'){
            g++;
            count--;
        }
        else if(p<g&&s[i]=='g'){
            p++;
            count++;
        }
        else if(p<g&&s[i]=='p'){
            p++;
        }
    }
    long long ans=max(count,0LL);
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007 
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ll dp[104][1 << 6];

bool is_val(int state, int nxt){
	vector<int> v(4);
	v[0] = state & 0x3;
	v[1] = (state >> 2) & 0x3;
	v[2] = (state >> 4) & 0x3;
	v[3] = nxt;
	if((v[0] == 0 && v[1] == 2 && v[2] == 1) || (v[1] == 0 && v[2] == 2 && v[3] == 1)){
		return false;
	}
	cu(i,0,(nxt != -1?3:2)){
		swap(v[i],v[i+1]);
		if((v[0] == 0 && v[1] == 2 && v[2] == 1) || (v[1] == 0 && v[2] == 2 && v[3] == 1)){
			return false;
		}
		swap(v[i],v[i+1]);
	}
	return true;
}

int main(){
	fast_io();
	int n = 0;
	cin >> n;
	cu(i,0,1 << 6){
		dp[3][i] = is_val(i,-1);	
	}
	fu(i,4,n){
		cu(j,0,4){
			cu(k,0,1 << 6){
				if(is_val(k,j)){
					dp[i][(k >> 2) | (j << 4)] += dp[i-1][k];
					dp[i][(k >> 2) | (j << 4)] %= MOD;
				}
			}
		}
	}
	ll ans = 0;
	cu(i,0,1 << 6){
		ans = (ans + dp[n][i]) % MOD;
		assert(ans > 0);
	}
	cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    rep(i, n)cin >> a[i];
    rep(i, m)cin >> b[i];
    rep(i, n-1)a[i+1] += a[i];
    rep(i, m-1)b[i+1] += b[i];
    int ans = 0;
    int l = 0;
    int r = 0;
    while(a[l] <= k){
        l++;
        if(l == n)break;
    }
    l--;
    while(b[r] + a[l] <= k){
        r++;
        if(r == m)break;
    }
    r--;
    ans = l + r + 2;
    while(l >= 0){
        l--;
        if(l >= 0){
            while(a[l]+b[r] <= k){
                r++;
                if(r == m)break;
            }
        }else{
            while(b[r] <= k){
                r++;
                if(r == m)break;
            }
        }
        r--;
        ans = max(ans, l+r+2);
    }
   
    cout << ans << endl;
}

Measured memory_bytes: 6432
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
using pii = pair<int, int>;

#define rep(i,k,n) for(int i=(k); i != int(n); ++i)
#define sz(x) x.size()
#define all(x) x.begin(), x.end()

#define dbg(x) cout << #x << '=' << x << '\n'
#define dbg2(x, y) cout << #x << '=' << x << ' ' << #y << '=' << y << '\n' 

#define input() (*istream_iterator<int>(cin))
#define strin() (*istream_iterator<string>(cin))
#define output(x) cout << x << '\n' 

const int mxn = 1e5+10;
vector<int> adj[mxn], h;
int main(){
    ios::sync_with_stdio(false);
    int n = input(), m = input();
    int cnt = 0;
    for(int i = 0; i != n; ++i) h.push_back(input());
    for(int i = 0; i != m; ++i){
        int u = input(), v = input();
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for(int i = 0; i != n; ++i){
        bool is_good = true;
        for(int cur: adj[i+1]){
            if(h[cur-1] >= h[i]){
                is_good = false;
                break;
            }
        }
        if(is_good) cnt++;
    }
    cout << cnt;
}

Measured memory_bytes: 8788
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int p[510000];
int q[510000];
long long dp[510000][2];
vector<int>v[1<<20];
int N;
long long calc(int a,int b){
	for(int i=0;i<v[a].size()+1;i++)for(int j=0;j<2;j++)dp[i][j]=0;
	if(v[a].size()==0){
		return 0;
	}
	dp[0][0]=dp[0][1]=1;

	for(int i=1;i<v[a].size();i++){
		dp[i][0]=(dp[i-1][0]+dp[i-1][1]*(upper_bound(v[0].begin(),v[0].end(),v[a][i])-lower_bound(v[0].begin(),v[0].end(),v[a][i-1])))%mod;
		dp[i][1]=(dp[i-1][1]+dp[i-1][0]+dp[i-1][1]*(upper_bound(v[0].begin(),v[0].end(),v[a][i])-lower_bound(v[0].begin(),v[0].end(),v[a][i-1])))%mod;
	//	printf("%d %d: %lld %lld\n",a,i,dp[i][0],dp[i][1]);
	}
	if(b==0)return (dp[v[a].size()-1][1])%mod;
	return dp[v[a].size()-1][0];
}
int main(){
	int a;scanf("%d",&a);
	N=a;
	for(int i=0;i<a;i++)scanf("%d",p+i);
	for(int i=0;i<a;i++){
		q[i+1]=q[i]^p[i];
	//	printf("%d ",q[i+1]);
	}//printf("\n");
	for(int i=0;i<=a;i++){
		v[q[i]].push_back(i);
	}
	long long ret=0;
	if(q[a]==0){
		for(int i=1;i<(1<<20);i++){
			long long tmp=calc(i,0);
			ret=(ret+tmp+mod)%mod;
		}
		long long tmp=1;
		for(int i=2;i<v[0].size();i++){
			tmp=(tmp+tmp)%mod;
		}
		ret=(ret+tmp)%mod;
	}else{
	//	N--;
		v[a].pop_back();
		ret=calc(q[a],1);
	}
	printf("%lld\n",ret);
}


Measured memory_bytes: 42228
#include<stdio.h>
#include<math.h>

int main(){
	long int n,i,j,t;
	char data[10];
	scanf("%ld",&n);
	
	for(;n>0;n--){
		scanf(" %s ",data);
		
		for(i=0;i<8;i++){
			for(j=i;j<8;j++){
				if(data[i]<data[j]){
					t=data[i];
					data[i]=data[j];
					data[j]=t;
				}
			}
		}
		t=0;
		
		for(i=0;i<8;i++){
			t+=((int)data[i]-48)*(int)pow(10,7-i);
			t-=((int)data[i]-48)*(int)pow(10,i);
		}
		
		printf("%ld\n",t);
	}
	return 0;
}

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

typedef long long ll;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF (1<<30)

class DisjointSet {
public:
	vector<ll> rank, p;

	DisjointSet() {}
	DisjointSet(ll size) {
		rank.resize(size, 0);
		p.resize(size, 0);
		for (ll i = 0; i < size; i++) makeSet(i);
	}

	void makeSet(ll x) {
		p[x] = x;
		rank[x] = 0;
	}

	bool same(ll x, ll y) {
		return findSet(x) == findSet(y);
	}

	void unite(ll x, ll y) {
		link(findSet(x), findSet(y));
	}

	void link(ll x, ll y) {
		if (rank[x] > rank[y]) {
			p[y] = x;
		}
		else {
			p[x] = y;
			if (rank[x] == rank[y]) {
				rank[y]++;
			}
		}
	}

	ll findSet(ll x) {
		if (x != p[x]) {
			p[x] = findSet(p[x]);
		}
		return p[x];
	}
};

int main() {
	ll n, a, b, q;
	ll t;

	cin >> n >> q;
	vector<ll> A(q), B(q);
	for (ll i = 0; i < q; i++) {
		cin >> A[i] >> B[i];
		A[i]--; B[i]--;
	}
	DisjointSet ds = DisjointSet(n);
	vector<ll> c(n,1);

	ll ans=0, x;
	for(ll i=0; i<n; i++) ans+=i;
	x = ans;

	vector<ll> res;
	for (ll i = q-1; i >= 0; i--) {
		if (ds.same(A[i], B[i])) {

		}
		else {
			ll pcA, pcB;
			pcA = ds.findSet(A[i]); pcB = ds.findSet(B[i]);
			//cout <<" "<< A[i] <<" "<< B[i] << endl;
			//cout << pcA <<" "<< pcB << endl;

			ll u = c[pcA] + c[pcB];
			ans -= c[pcA]*c[pcB];
			ds.unite(A[i],B[i]);
			ll pu = ds.findSet(A[i]);
			c[pu] = u;

		}

		//cout << ans << endl;
		res.push_back(ans);
	}

	reverse(res.begin(), res.end());
	for(ll i=1; i<res.size(); i++) cout << res[i] << endl;
	cout << x << endl;

	return 0;
}


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

int main(){
        string A,B;
        cin >> A >> B;
        if(A.size()>B.size()) {
                cout << "GREATER" << endl;
        }else if(A.size()<B.size()) {
                cout << "LESS" << endl;
        }else{
                for(int i=0; i<A.size(); i++) {
                        if(A[i]>B[i]) {
                                cout << "GREATER" << endl;
                                break;
                        }else if(A[i]<B[i]) {
                                cout << "LESS" << endl;
                                break;
                        }else if (i == A.size()-1) {
                                cout << "EQUAL" << endl;
                        }
                }
        }
        return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n, x;
	while (scanf("%d%d", &n, &x) == 2 && (n|x) != 0) {
		int i, j;
		int count = 0;
		for (i = 1; i <= n; i++) {
			for (j = i + 1; j <= n; j++) {
				int k = x - i - j;
				if (j < k && k <= n) count++;
			}
		}
		printf("%d\n", count);
	}
	return 0;
}



Measured memory_bytes: 2056
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())
#どっかで最悪計算量の入力データを用意する関数を作ろう？
"""
O(N^2)
"""
#solution:
#潜 影 蛇 手 ! !
*c,N=pin()

ans=0


I=(N//c[0])+1
J=N//c[1]+1
for i in range(I):
    for j in range(J):
        remain=(N-i*c[0]-j*c[1])
      
        if remain>=0 and remain%c[2]==0:
            
            ans+=1
            
print(ans)
#print(["NO","YES"][1-cond])
#print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])



Measured memory_bytes: 40812
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    bool t=0;
    for(int i=1;i<=9;i++)
        for(int j=i;j<10;j++)
            if(i*j==n)
            {
                t=1;
                break;
            }

    if(t)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    

    return 0;   
}


 
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
#define int long long
using namespace std;
bool ispalindrome(string& s)
{
    int i=0;
    int j=s.size()-1;
    while(i<=j)
        if(s[i++]!=s[j--])
        return false;
    return true;
}
int modPow(int a,int b,int mod)
{
    while(b>1)
    {
        if(b%2==0)
        {
            a=a*a%mod;
            b/=2;
        }
        else
            return a*modPow(a,b-1,mod)%mod;
    }
    return a;

}
bool prime[2001];
void sieve()
{
    prime[1]=false;
    for(int i=2;i*i<2001;i++)
    {
        if(prime[i])
        {
            for(int j=i*i;j<2001;j+=i)
                prime[j]=false;
        }
    }
}
signed main() {
	//code

	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++)
       {
          ans+=(n/i);
          if(n%i==0)
            ans--;
       }

    cout<<ans<<endl;

}


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

int main() {
	size_t n;
	std::cin >> n;

	std::vector<std::pair<size_t, size_t>> v;
	v.reserve(n);
	for (size_t i = 0; i < n; ++i) {
		size_t a, b;
		std::cin >> a >> b;
		v.emplace_back(a, b);
	}
	size_t count = 0;
	for (size_t i = 1; i <= n; ++i) {
		std::pair<size_t, size_t>& p = v[n - i];
		size_t remain = ((p.first + count) % p.second);
		if (remain != 0) {
			count += p.second - remain;
		}
	}
	std::cout << count << std::endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int Maxn=100010;
const int inf=2147483647;
int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x*f;
}
int mark[Maxn];
vector<int>h[Maxn];
int main()
{
	int t=0;
	for(int i=1;i<=3000;i++)
	{
		t+=i;
		if(t>100000)break;
		mark[t]=i;
	}
	int n=read();
	if(!mark[n])return puts("No"),0;
	puts("Yes");
	int u=mark[n]+1,cnt=0;
	for(int i=1;i<=u;i++)
		for(int j=i+1;j<=u;j++)++cnt,h[i].push_back(cnt),h[j].push_back(cnt);
	printf("%d\n",u);
	for(int i=1;i<=u;i++)
	{
		printf("%d ",h[i].size());
		for(int j=0;j<h[i].size();j++)printf("%d ",h[i][j]);
		puts("");
	}
}

Measured memory_bytes: 4992
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <cstring>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    int x1,x2,y1,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << x2-(y2-y1) << " " << y2+(x2-x1) << " " << x2-(y2-y1)-(x2-x1) << " " << y2+(x2-x1)-(y2-y1);  
}

Measured memory_bytes: 764
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define rev(v) 	v.rbegin(), v.rend()
#define all(v) v.begin(), v.end()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;

template<typename T>
void say(T s) {
	cout << s << endl;
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << endl;
}

int main() {
	int X, A, B;
	cin >> X >> A >> B;
	say((X - A) % B);
}

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

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

    vector<bool> rate(8,false);
    int other=0;
    rep(i,n) {
        int ibuff;
        cin >> ibuff;
        if (ibuff<=399)         rate.at(0)=true;
        else if (ibuff<=799)    rate.at(1)=true;
        else if (ibuff<=1199)   rate.at(2)=true;
        else if (ibuff<=1599)   rate.at(3)=true;
        else if (ibuff<=1999)   rate.at(4)=true;
        else if (ibuff<=2399)   rate.at(5)=true;
        else if (ibuff<=2799)   rate.at(6)=true;
        else if (ibuff<=3199)   rate.at(7)=true;
        else                    other++;
    }

    int trueCnt=0;
    int minValue=0, maxValue=0;
    //trueの数を数える
    trueCnt = count(rate.begin(), rate.end(), true);

    //最小値は現在使用している色の数(最小1)
    minValue = max(1, trueCnt);

    //最大値は自由色を最大限ちりばめる
    maxValue = trueCnt+other;

    cout << minValue << " " << maxValue << endl;

    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int a=0;
    for(int i=0;i<=3;i++)
    {
        if(s[i]=='+')
            a++;
        else
            a--;
    }
    cout<<a;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (b > c * a)
	{
		cout << c << endl;
	}
	else
	{
		cout << (b / a) << endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin>>s;
	if(s=="hi"||s=="hihi"||s=="hihihi"||s=="hihihihi"||s=="hihihihihi")
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

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

int main() {
  int N, M; cin >> N >> M;
  priority_queue<int> que;
  for(int i = 0; i < N; i++) {
    int A; cin >> A;
    que.push(A);
  }
  int cnt = 0;
  while(cnt < M) {
    int q = que.top(); que.pop();
    cnt++;
    que.push(q/2);
  }
  long long ans = 0LL;
  while(!que.empty()) {
    ans += que.top(); que.pop();
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	set<string> s;
	for(int i=1;i<=n;i++)
	{
		string st;
		cin>>st;
		s.insert(st);
	}
	cout<<s.size();
}

Measured memory_bytes: 19084
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in), 1);
		for(String line=br.readLine(); line!=null; line=br.readLine()) {
			if(line.length()==0) break;
			int n=Integer.parseInt(line);
			int count=0;
			boolean[] array=new boolean[n];
			array[0]=false;	// 1は素数でない
			for(int i=1; i<array.length; i++)
				array[i]=true;
			for(int i=1; i<array.length; i++) { 
				if(array[i]) {
					count++;
					for(int j=1; j*(i+1)<=n; j++) {
						array[j*(i+1)-1]=false;
						//System.out.println(((i+1)*j-1)+": false");
					}
				}
			}
			System.out.println(count);
		}
	}

}

Measured memory_bytes: 33604
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
#define inf 1e9+1
#define Inf 223372036854775807
#define maxn 1010000
#define eps 1e-8
const ll mod=998244353;

pair<int, int> pr[maxn];
int n, ans;

int main()
{
    cin>>n;
    for (int i=1, x, l; i<=n; i++)
    {
        cin>>x>>l;
        pr[i].first=x-l, pr[i].second=x+l;
    }
    sort(pr+1, pr+1+n);
    cout<<endl;
    int temp=-inf;
    for (int i=1; i<=n; i++)
    {
        //cout<<temp<<" "<<pr[i].first<<" "<<pr[i].second<<endl;
        if (pr[i].first<temp)
        {
            ans++;
            temp=min(temp, pr[i].second);
        }
        else temp=pr[i].second;
    }
    cout<<n-ans;
    return 0;
}


Measured memory_bytes: 1024
N = int(input())
*X, = map(int, input().split())
for i in range(N):
    X[i] -= 1
U = [0]*2019
for i, x in enumerate(X):
    U[x] = 1
M = int(input())
*A, = map(int, input().split())
for a in A:
    x = X[a-1]
    if x < 2018 and not U[x+1]:
        U[x+1] = 1; U[x] = 0
        X[a-1] += 1
for x in X:
    print(x+1)


Measured memory_bytes: 5620
<?php
	fscanf(STDIN, "%d %d %d", $N, $Z, $W);

	$inp = fgets(STDIN);

	$a = split(' ', $inp);

	$count = count($a);

	// debug
// 	print 'count:'.$count.'\n';

	// a(N)まで取るケース
	$ans1 = abs($a[$count - 1] - $W);

	if ($count === 1){
		echo $ans1."\n";
		return;
	}

	// a(N - 1)まで取るケース
	$ans2 = abs($a[$count - 2] - $a[$count - 1]);

	if ($ans1 > $ans2){
		echo $ans1."\n";
	}else{
		echo $ans2."\n";
	}

?>

Measured memory_bytes: 3956
N = int(input()) - 1
result = ''
for i in range(1, 10 ** 15):
    if N >= 26 ** i:
        N -= 26 ** i
        continue
    for j in range(i):
        result += chr(ord('a') + N % 26)
        N //= 26
    print(result[::-1])
    break

Measured memory_bytes: 9188
#include<iostream>
#include<vector>
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
    int n,i;
    map<int,int> ns;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        int a;
        scanf("%d",&a);
        ns[a] ++;
    }
    map<int,int>::iterator it;
    int ans = 0;
    for(it=ns.begin();it!=ns.end();it++)
    {
        if((*it).first <= (*it).second)
            ans += (*it).second-(*it).first;
        else
            ans += (*it).second;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 4736
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<climits>
using namespace std;
const int MAX_N=100000;

int n;
vector<int> dat(4*MAX_N,0);

void init(int N){
	n=1;
	while(n<N){
		n*=2;
	}
}

void add(int i, int y){
	int k;
	k=n-1+i;
	dat[k] += y;
	while(k>0){
		k=(k-1)/2;
		dat[k]+=y;
	}
}

int find(int x, int y, int k,int l,int r){
	if(r <= x || l >= y){
		return 0;
	}
	if(r <= y && l >= x){
		return dat[k];
	}else{
		int vl = find(x,y,2*k+1,l,(l+r)/2);
		int vr = find(x,y,2*k+2,(l+r)/2,r);
		return vl+vr;
	}
}

int main(){
	int N,q,command,x,y;
	
	cin >> N >> q;
	init(N);
	
	for (int i=0;i<q;i++){
		cin >> command >> x >> y;
		if(command){
			cout << find(x-1,y,0,0,n) << endl;
		}else{
			add(x-1,y);
		}
	}
	return 0;
}

Measured memory_bytes: 2592
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// go run ./ABC168/B\ -\ ...\ \(Triple\ Dots\)/main.go < ./ABC168/B\ -\ ...\ \(Triple\ Dots\)/in

func main() {
	sc := bufio.NewScanner(os.Stdin)
	var maxStr int
	sc.Scan()
	maxStr, _ = strconv.Atoi(sc.Text())
	sc.Scan()
	inputs := sc.Text()
	if len(inputs) > maxStr {
		fmt.Println(inputs[:maxStr] + "...")
	} else {
		fmt.Println(inputs)
	}
}


Measured memory_bytes: 1756
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) {puts("error");exit(666);}
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;GG(e<0)while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e5+10;

    int a[N],b[N],c[N];
    void main()
	{
		int n=qread(),K=qread();
		fo(i,1,n) c[n-i+1]=n+n+n-i-K;
		if(n==1) b[1]=1;
		else
		{
			int x=n-1,y=c[n-1]-x;
			for(int i=n-1;i>=1;i-=2) {a[i]=x,b[i]=y,x--,y--;if(y==n-1)y=n+n-1;}
			for(int i=n;i>=1;i-=2) {a[i]=x,b[i]=y,x--,y--;if(y==n-1)y=n+n-1;}
		}
		fo(i,1,n) if(a[i]+b[i]>c[i] or b[i]<n or b[i]>=n+n) {puts("-1");return;}
		//puts("ok");
		fo(i,1,n) printf("%d %d %d\n",a[i]+K,b[i]+K,c[i]+K+K);
	}
};//(ans+MOD)%MOD
signed main()
{
	//freopen("z.txt","r",stdin);
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 3456
N=int(input())
A=list(map(int,input().split()))
tmp=A[0]
ans=1000
kabu=0
for i in range(1,N):
    if tmp < A[i]:
        if kabu==0:
            kabu=ans//tmp
            ans=ans%tmp
            tmp=A[i]
    elif tmp > A[i]:
        ans+=kabu*tmp
        kabu=0
        tmp=A[i]
    tmp=A[i]
if kabu > 0:
    ans+=kabu*A[-1]
print(ans)

Measured memory_bytes: 9160
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,x,y;

int main(){
  ll ans=0;
  cin >> n ;
  vi a(n);
  REP(i,n) cin>>a[i];
  sort(a.begin(), a.end());

  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      //最初から最後まで
      int sti=j+1;
      int edi=n-1;
      ll l=a[i]+a[j];
      auto Iter2 = lower_bound(a.begin(),a.end(), l);//1,2,3・・のときl=3なら2が返る
      int k=(Iter2-a.begin());
      ans+=(k-j-1);
    }
  }





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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main (String[] args){
		Scanner cin = new Scanner(System.in);
		int N = cin.nextInt();
		String[] strings = new String[N];
		for(int i=0;i<N;i++){
			strings[i] = cin.next();
		}
		int[][] map = new int[N][26];
		for(int i=0;i<N;i++){
			for (char c:strings[i].toCharArray()){
				map[i][c-'a']++;
			}
		}
		int[] minMap = new int[26];
		for(int j=0;j<26;j++){
			minMap[j] = Integer.MAX_VALUE;
			for(int i=0;i<N;i++){
				if (map[i][j] == 0) {
					minMap[j] = 0;
					break;
				} else {
					minMap[j] = Math.min(minMap[j], map[i][j]);
				}
			}
		}
		for (int i=0;i<26;i++){
			for(int j=0;j<minMap[i];j++){
				System.out.print((char)('a'+i));
			}
		}
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define pb push_back
#define xx first
#define yy second
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define Max(x) max_element(all(x))
#define Min(x) min_element(all(x))
#define rep(i,n) for(int i=0;i<n;i++)
#define repp(i,k,n) for(int i=k;i<n;i++)
#define reppp(i,k,n,m) for(int i=k;i<n;i+=m)
#define repv(i,n) for(int i=n-1;i=0;i--)
#define vi vector<int> 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> iv;
typedef pair<int,int> iip;
typedef map<int,int> mii;

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<(((a*100+b*10+c)%4==0)?"YES":"NO");
	
	return 0;
	}

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

int main() {
    int n;
    int counts[4][3][10];

    cin >> n;
    for(int i=0; i<4; i++) {
	for(int j=0; j<3; j++) {
	    for(int k=0; k<10; k++) {
		counts[i][j][k] = 0;
	    }
	}
    }

    for(int i=0; i<n; i++) {
        int b, f, r, v;
	cin >> b >> f >> r >> v;
	counts[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 << " " << counts[i][j][k];
	    }
	    cout << endl;
	}
	if(i != 3) {
	    cout << "####################" << endl;
	}
    }
}

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

const int maxn = 1e5+5;
int n;
int ans[maxn]; //用来描述羊（是0）和狼（是1）;
char S[maxn];

bool check() //当条件不成立的时候才返回false;
{
    if (!ans[n])
    {
        if (S[n]=='o'&&ans[n-1]!=ans[1]) return 0;
        if (S[n]=='x'&&ans[n-1]==ans[1]) return 0;
    }
    else
    {
        if (S[n]=='x'&&ans[n-1]!=ans[1]) return 0;
        if (S[n]=='o'&&ans[n-1]==ans[1]) return 0;
    }
    if (!ans[1])
    {
        if (S[1]=='o'&&ans[n]!=ans[2]) return 0;
        if (S[1]=='x'&&ans[n]==ans[2]) return 0;
    }
    else
    {
        if (S[1]=='x'&&ans[n]!=ans[2]) return 0;
        if (S[1]=='o'&&ans[n]==ans[2]) return 0;
    }
    return 1;
}

int main()
{
    scanf("%d%s",&n,S+1);
    for(int i=0;i<4;i++) //枚举四种情况,0代表羊,1代表狼,ans[1] 与 ans[2]的组合分别是：0 0,1 0,0 1,1 1.
    {
        ans[1] = i&1;
        ans[2] = (i>>1)&1;
        for(int j=3;j<=n;j++)
        {
            if(!ans[j-1])
            {
                if(S[j-1]=='o')
                    ans[j] = ans[j-2];
                else
                    ans[j] = ans[j-2]^1;
            }
            else
            {
                if(S[j-1]=='o')
                    ans[j] = ans[j-2]^1;
                else
                    ans[j] = ans[j-2];
            }
        }
        if(check())
        {
            for(int k=1;k<=n;k++)
                if(!ans[k])
                    printf("S");
                else
                    printf("W");
            return 0;
        }
    }
    printf("-1\n");
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int limit = 50;
bool visit[limit];
bool graph[limit][limit];

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long 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;
}
void dfs(int v, int n) {
	//対象の頂点について訪問済みとする
	visit[v] = true;
	//訪問した頂点から繋がる頂点は全て探索する
	for (int v2 = 0; v2 < n; ++v2) {
		//経路が存在しない場合は無視する
		if (graph[v][v2] == false) continue;
		//訪問済みの頂点は無視する
		if (visit[v2] == true) continue;
		dfs(v2, n);
	}
}

void solve() {
	int n, m;
	cin >> n >> m;
	vector<int> a(limit), b(limit);
	for (int i = 0; i < m; ++i) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		graph[a[i]][b[i]] = true;
		graph[b[i]][a[i]] = true;
	}
	int ans = 0;
	for (int i = 0; i < m; ++i) {
		//各辺を除外して橋となる辺であるか調査する
		graph[a[i]][b[i]] = false;
		graph[b[i]][a[i]] = false;
		for (int j = 0; j < n; ++j) visit[j] = false;
		//除外した状態でdfsで探索
		dfs(0, n);
		bool bridge = false;
		//全ての頂点を訪問できなかった場合、除外した辺は橋である
		//辺を除外することで未連結となっているか調査している
		for (int j = 0; j < n; ++j) {
			if (visit[j] == false) {
				bridge = true;
			}
		}
		if (bridge) ans++;
		graph[a[i]][b[i]] = true;
		graph[b[i]][a[i]] = true;
	}
	cout << ans << endl;
    return;
}

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



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

#define show(x) cerr << #x << " = " << x << endl ;
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define fastio ios_base::sync_with_stdio(0)
#define endl '\n'



int main()
{
    #ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif
    fastio;cin.tie(0);cout.tie(0);
    int n ; cin >> n ;
    for(int i = 1 ; i <= 9 ; ++i)
        for(int j = 1 ; j <= 9 ; ++j)
            if(n == i*j)
            {
                cout << "Yes";
                exit(0);
            }
            cout << "No";

    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
H = [int(input()) for _ in range(N)]

H.sort()

for i in range(0, N - (K-1)):
    min_K = H[i]
    max_K = H[i + K - 1]

    if i == 0:
        min_diff = max_K - min_K
    else:
        min_diff = min(min_diff, max_K - min_K)

print(min_diff)

Measured memory_bytes: 50520
#include<iostream>
using namespace std;
int main()
{
	int i,n,a=0,s=0;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		for(int j=1;j<=i;j++)
		{
			if(i%j==0&&i&1) a++;
		}
		if(a==8) s++;
		a=0;
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    ll x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x);
    vector<ll> b(y);
    vector<ll> c(z);
    rep(i, x) cin >> a[i];
    rep(i, y) cin >> b[i];
    rep(i, z) cin >> c[i];
    sort(whole(a)); reverse(whole(a));
    sort(whole(b)); reverse(whole(b));
    sort(whole(c)); reverse(whole(c));
    vector<ll> ab;
    rep(i, x) rep(j, y) {
        ab.push_back(a[i]+b[j]);
    }
    sort(whole(ab));
    reverse(whole(ab));
    ll nab = ab.size();

    priority_queue<ll> q;
    rep(i, z) {
        ll temp = min(k, nab);
        rep(j, temp) {
            q.push(c[i] + ab[j]);
        }
    }

    rep(i, k) {
        cout << q.top() << endl;
        q.pop();
    }
    return 0;
}


Measured memory_bytes: 43368
main()
{
    int A, B, K, ans=0, k=0, i=0;
    scanf("%d%d%d", &A, &B, &K);
    i = (A>B?A:B)+1;
    do{
        i--;
        if(A%i==0 && B%i==0) k++;
    }while(k<K);
    printf("%d",i);
}


Measured memory_bytes: 128
n=int(input())
c0=0
c1=0
c2=0
c3=0
for i in range(n):
  s=str(input())
  if s=="AC":
    c0+=1
  elif s=="WA":
    c1+=1
  elif s=="TLE":
    c2+=1
  else:
    c3+=1
print("AC x"+" "+str(c0))
print("WA x"+" "+str(c1))
print("TLE x"+" "+str(c2))
print("RE x"+" "+str(c3))

Measured memory_bytes: 9168
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Stack stack = new Stack();
        for (String s : scanner.nextLine().split(" ")) {
            if ("+".equals(s)) {
                stack.push(stack.pop() + stack.pop());
            } else if ("-".equals(s)) {
                int i1 = stack.pop();
                int i2 = stack.pop();
                stack.push(i2 - i1);
            } else if ("*".equals(s)) {
                stack.push(stack.pop() * stack.pop());
            } else {
                stack.push(Integer.parseInt(s));
            }
        }
        System.out.println(stack.pop());
    }

    private static class Stack {
        private static class Node {
            int i;
            Node next;

            public Node(int i, Node next) {
                this.i = i;
                this.next = next;
            }
        }

        Node top;

        public void push(int i) {
            top = new Node(i, top);
        }

        public int pop() {
            int i = top.i;
            top = top.next;
            return i;
        }
    }
}

Measured memory_bytes: 26224