akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#warning do not forget to change size of N and M 
#define popcnt(a) __builtin_popcount(a)
#define gcd(a,b) __gcd(a,b)
#define IO() assert(freopen("in.in", "rt", stdin)), assert(freopen("out.out", "wt", stdout))
#define FastIO() ios::sync_with_stdio(false),cin.tie(0);
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl


typedef long long ll;

const ll MOD = 1e9 + 7;
const int N = 1e3 + 9, M = 1e7 + 9, OO = 0x3f3f3f3f;
const double EPS = 1e-10,PI=acos(-1.0);

//Number Theory
inline bool dCMP(const long double &a, const long double &b) { return fabsl(a - b) < EPS;}

//Geometry 
inline double MintoDeg(double min){return min/60;}
inline double to_Radian(double deg){return deg*PI/180.0;}
inline double to_Degree(double radian){if(radian<0) radian+=2*PI; return radian*180/PI ;}
inline double fixAngle(double A){return A>1 ? 1 : (A<-1 ? -1 : A);}
int n,m,adjMax[N][N],vis[N],dist[N],freq[M],edge[N][N],pre[N];
void init()
{
  memset(vis,0,sizeof vis);
  memset(dist,OO,sizeof dist);
  memset(pre,-1,sizeof pre);
}
void parents(int dest)
{
  if(pre[dest]==-1) return;
  freq[edge[dest][pre[dest]]]++;
  parents(pre[dest]);
}
int dijkstra(int src,int dest)
{
  init();
  dist[src] = 0;
	while(true) {
		int val = OO, idx = -1;
		for(int i=1;i<=n;++i) if(!vis[i] && dist[i] < val) val = dist[i],idx = i;
  
		if(idx == -1 || idx == dest) break;
 
		vis[idx] = 1;
		for(int i=1;i<=n;++i) if (adjMax[idx][i] && idx!=i && dist[i] > (val=dist[idx] + adjMax[idx][i])) dist[i] = val,pre[i]=idx;
	}
  parents(dest);
	return dist[dest];
}
int main()
{
  scanf("%d%d",&n,&m);
  for(int i=1;i<=m;++i)
  {
    int u,v,c;
    scanf("%d%d%d",&u,&v,&c);
    adjMax[u][v]=c;
    adjMax[v][u]=c;
    edge[u][v]=i;
    edge[v][u]=i;
  }

  for(int i=1;i<=n;++i)
  {
    for(int j=i+1;j<=n;++j)
    {
      if(i==j) continue;
      dijkstra(i,j);
    }

  }
  ll ans=0;
  for(int i=1;i<=m;++i) if(!freq[i]) ans++;
  

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


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    int ans=100000;
    for (int i=0;i<s.size()-2;i++) {
        string tmp=s.substr(i,3);
        int num=stoi(tmp);
        if (abs(753-num)<ans) {
            ans=abs(753-num);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
//Magical Tiles
#include <iostream>

using namespace std;

int main(){
	int H, W;
	char Tile[101][101];//縦横 HW
	bool TileIsMoved[101][101];
	bool IsLoop,IsEnd;
	char Loader[101];//横行読み
	int px, py;//人位置
	while (1){
		cin >> H >> W;
		if (H == 0 && W == 0)break;
		//初期化
		px = 0; py = 0;
		IsLoop = false;
		IsEnd = false;
		//タイル代入/moved初期化
		for (int i = 0; i < H; ++i){
			cin >> Loader;
			for (int j = 0; j < W; ++j){
				Tile[i][j] = Loader[j];
				TileIsMoved[i][j] = false;
			}
		}
		TileIsMoved[0][0] = true;
		//移動
		while (1){
			switch (Tile[py][px]){
			case '>':
				++px;
				break;
			case '^':
				--py;
				break;
			case 'v':
				++py;
				break;
			case '<':
				--px;
				break;
			case '.':
				IsEnd = true;
				break;
			}
			if (IsEnd)break;
			if (TileIsMoved[py][px]){
				IsLoop = true;
				break;
			}
			TileIsMoved[py][px] = true;
		}
		//出力
		if (IsLoop){
			cout << "LOOP" << endl;
		} else{
			cout << px << " " << py << endl;
		}
	}

	return 0;
}

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

// iterator
#define REP(i,init, n)          for(lli i=init;i<n;i++)
#define REPE(i,init, n)         for(lli i=init;i<=n;i++)
#define REPIT(it,container)     for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container)   for(auto it = container.rbegin(); it != container.rend(); it++)

#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

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

// dp[i][ag][bg]: i 個目までを使えるときに、ag, bg を実現する最小コスト 
lli dp[41][401][401];
lli inf = 100000;

int main() {
    lli n, ma, mb;
    cin3(n, ma, mb);
    lli a[n];
    lli b[n];
    lli c[n];
    ncin3(n, a, b, c);

    REPE(i, 0, 40) {
        REP(ag, 0, 401) {
            REP(bg, 0, 401) {
                dp[i][ag][bg] = inf;
            }
        }
    }
    dp[0][0][0] = 0;

    REPE(i, 1, n) {
        REP(ag, 0, 401) {
            REP(bg, 0, 401) {
                if (ag - a[i-1] < 0 || bg - b[i-1] < 0) {
                    dp[i][ag][bg] = dp[i-1][ag][bg];
                }
                else {
                    dp[i][ag][bg] = min(dp[i-1][ag][bg], dp[i-1][ag-a[i-1]][bg-b[i-1]] + c[i-1]);
                }
            }
        }
    }

    // dump
    // REPE(i, 1, n) {
    //     REP(ag, 1, 401) {
    //         REP(bg, 1, 401) {
    //             if (dp[i][ag][bg] == inf)
    //                 continue;
    //             cout << "dp[" << i << "][" << ag << "][" << bg << "]: " << dp[i][ag][bg] << endl;
    //         }
    //     }
    // }
    lli ans = inf;
    REP(ag, 1, 401) {
        REP(bg, 1, 401) {
            if (bg*ma == ag*mb) {
                ans = min(ans, dp[n][ag][bg]);
            }

        }
    }
    if (ans == inf)
        cout << -1 << endl;
    else
        cout << ans << endl;
}


Measured memory_bytes: 51712
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        String S = scan.next();
        char[] d = S.toCharArray();
        TreeSet<Integer>[] segs = new TreeSet[26];
        for (int i = 0; i < 26; i++) {
            segs[i] = new TreeSet<>();
            segs[i].add(510000);
        }
        for (int i = 0; i < N; i++) {
            segs[(int) d[i]-'a'].add(i);
        }
        int Q = scan.nextInt();
        for (int i = 0; i < Q; i++) {
            int type = scan.nextInt();
            if (type == 1) {
                int index = scan.nextInt()-1;
                char old_c = d[index];
                char new_c = scan.next().toCharArray()[0];
                if (old_c == new_c) {
                    continue;
                }
                segs[(int)old_c-'a'].remove(index);
                segs[(int)new_c-'a'].add(index);
                d[index] = new_c;
                continue;
            }
            int l = scan.nextInt()-1;
            int r = scan.nextInt()-1;
            int ans = 0;
            for (int j = 0; j < 26; j++) {
                if (segs[j].ceiling(l) <= r) {
                    ans += 1;
                }
            }
            System.out.println(ans);
        }
    }
}


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

s = list(input())
t = list(input())

l='abcdefghijklmnopqrstuvwxyz'

for item in l:
    can = [i for i, x in enumerate(t) if x == item]
#    print(can)
    if len(can) > 1:
        d = [s[i] for i in can]
        if len(set(d)) != 1:
            print('No')
            exit()
for item in l:
    can = [i for i, x in enumerate(s) if x == item]
#    print(can)
    if len(can) > 1:
        d = [t[i] for i in can]
        if len(set(d)) != 1:
            print('No')
            exit()
print('Yes')


Measured memory_bytes: 15364
#include<bits/stdc++.h>
using namespace std;
inline void read(int &x){
    char c=getchar();
    int p=1;
    x=0;
    while(!isdigit(c)){
        if(c=='-')p=-1;
        c=getchar();
    }
    while(isdigit(c)){
        x=(x<<1)+(x<<3)+(c^'0');
        c=getchar();
    }
    x*=p;
}
#define N 500010
using namespace std;
int dis[N<<1],fa[N<<1],siz[N<<1],ch[N<<1][26],sz=1,root=1,last=root,len,t,k;
char s[N];
void insert(int x)
{
    int pre=last,now=++sz;last=now;
    dis[now]=dis[pre]+1;siz[now]=1;
    for (;pre && !ch[pre][x];pre=fa[pre]) ch[pre][x]=now;
    if (!pre) fa[now]=root;
    else
    {
        int q=ch[pre][x];
        if (dis[q]==dis[pre]+1)
            fa[now]=q;
        else
        {
            int nows=++sz;dis[nows]=dis[pre]+1;
            fa[nows]=fa[q],fa[now]=fa[q]=nows;
            memcpy(ch[nows],ch[q],sizeof ch[q]);
            for (;pre && ch[pre][x]==q;pre=fa[pre]) ch[pre][x]=nows;
        }
    }
}
int ton[N<<1],ti[N<<1],sum[N<<1];
void work()
{
    for(register int i=1;i<=sz;i++) ton[dis[i]]++;
    for(register int i=1;i<=len;i++) ton[i]+=ton[i-1];
    for(register int i=1;i<=sz;i++) ti[ton[dis[i]]--]=i;
    for(register int i=sz;i;i--)
        if (t) siz[fa[ti[i]]]+=siz[ti[i]];
        else siz[ti[i]]=1;
    siz[root]=0;
    for(register int i=sz;i;i--){
        sum[ti[i]]=siz[ti[i]];
        for (int j=0;j<26;j++)
            if (ch[ti[i]][j])
                sum[ti[i]]+=sum[ch[ti[i]][j]];
    }
}
int main(){
    scanf("%s",s+1);
    read(k);
    t=0;len=strlen(s+1);
    for (int i=1;i<=len;i++) insert(s[i]-'a');
    work();
    if (k>sum[root])    return puts("-1"),0;
    int now=root;
    while((k-=siz[now])>0)
    {
        int p=0;
        while(k>sum[ch[now][p]]) k-=sum[ch[now][p++]];
        now=ch[now][p];
        putchar('a'+p);
    }
}


Measured memory_bytes: 14592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
typedef long long ll;
const int mod = 1e9 + 7;
int main() {

    int n;
    cin >> n;
    vector<int> v(n+1);
    rep(i, n) cin >>  v[i+1];

    int ans = 0;
    for(int i=1; i<=n; i++){
        if(i == v[i]){
            swap(v[i], v[i+1]);
            ans++;
        }
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))

A.sort()
from collections import deque
d = deque(A)
ans = []
r = d.pop()
for i in range(N-1):
  l = d.popleft()
  if i < N-2:
    nex = d.pop()
  else:
    nex = -1
  if nex>=0:
    ans.append((min(l,r),max(l,r)))
    d.appendleft((-1)*abs(l-r))
  else:
    ans.append((max(l,r),min(l,r)))
    d.appendleft(abs(l-r))
  r = nex
print(d.pop())
for a in ans:
  print(*a,sep=' ')

Measured memory_bytes: 20328
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <stack>
#include <queue>
#include <deque>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

// template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//  order_of_key (k) : Number of items strictly smaller than k .
//  find_by_order(k) : K-th element in a set (counting from zero).
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
//#define int ll

const int N = 2e5 + 5;
const int oo = 1e9 + 5;

const double PI = acos(-1.0);

double a, b, h, m;

void solve() {
    cin >> a >> b >> h >> m;
    double c = fabs((60 * h - 11 * m) / 2);
    double cos_c = cos(c * PI / 180.0);
    cout << fixed << setprecision(10) << sqrt((a*a) + (b*b) - (2*a*b*cos_c));
}

 main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tt = 1;
	while (tt --) {
		solve();
	}
	return 0;
}
/*
	“I’m not gonna run away, I never go back on my word! That’s my nindo: my ninja way.” Naruto
*/


Measured memory_bytes: 4248
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)

int main(){
  int N;
  int A;
  cin >> N;
  vector<int> G,H;
  REP(i,(1<<N)){
    cin >> A;
    G.push_back(A);
  }

  while(G.size()!=1){
    int M=G.size();
    REP(i,M/2){
      if(G[2*i]>G[2*i+1]){
        H.push_back(G[2*i]-G[2*i+1]);
      }else if(G[2*i]<G[2*i+1]){
        H.push_back(G[2*i+1]-G[2*i]);
      }else{
        H.push_back(G[2*i]);
      }
    }
    G=H;
    H.clear();
  }
  cout << G[0] << endl;
  return 0;
}


Measured memory_bytes: 2292
#include <iostream>
using namespace std;
int a, b, c, x, y, r;
int main() {
  cin >> a >> b >> c >> x >> y;
  r = min(a*x+b*y, c*2*max(x,y));
  r = min(r, min(x,y)*2*c+abs(x-y)*(x>y?a:b));
  cout << r;
  return 0;
}

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

int main(){
    int N,D,x=0;
    cin>>N>>D;
    int X[N][D];
    for(int i=0;i<N;i++){
        for(int j=0;j<D;j++)
            cin>>X[i][j];
    }

    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            double Y=0;
            for(int d=0;d<D;d++){
                Y+=pow(X[i][d]-X[j][d],2);
            }
            Y=(double)sqrt(Y);
            int y=Y/1;
            if((double)Y-y==0)x++;
        }
    }
cout<<x<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    string s; cin>>s;
    deque<char> dq;
    int n = s.length();
    rep(i,n) dq.push_back(s[i]);
    int q; cin>>q;
    bool rev = false;
    while (q--) {
        int t; cin>>t; --t;
        if (t) {
            int f; char c; cin>>f>>c;
            if (rev) {
                if (f==1) dq.push_back(c);
                else dq.push_front(c);
            }
            else {
                if (f==1) dq.push_front(c);
                else dq.push_back(c);
            }
        }
        else {
            rev ^= 1;
        }
    }

    if (!rev) {
        while (!dq.empty()) {
            char ret = dq.front(); dq.pop_front();
            cout << ret;
        }
        cout << '\n';
    }
    else {
        while (!dq.empty()) {
            char ret = dq.back(); dq.pop_back();
            cout << ret;
        }
        cout << '\n';
    }
    return 0;
}

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

int main() {
  int N, M, X; cin >> N >> M >> X;
  vector<int> v(M);
  for(int i = 0; i < M ; i++){
    cin >> v[i];
  }
  int count; count = 0;
  int ans; ans = 0;

  for(int j = 0; j < M ; j++){
    if(v[j] < X){
      count++;
    }
    else {
      ans++;
    }
  }
cout << min(count,ans) << endl;
  }

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n;
	int a[100000];
	int sum[1000000] = {};
	int max = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (max < a[i]) {
			max = a[i];
		}
	}
	for (int i = 0; i < n; i++) {
        if(a[i]==0){
            sum[a[i]]++;
            sum[a[i] + 1]++;
        }else{
            sum[a[i]]++;
            sum[a[i] - 1]++;
		    sum[a[i] + 1]++;
        }
		
	}
	

	int ans = 0;
	for (int i = 0; i <= max; i++) {
        //printf("sum=%d\n",sum[i]);
		if (ans < sum[i]) {
			ans = sum[i];
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

int main(){
    int n, a[100];
    cin >> n;
    
    for(int i = 0; i < n; i++) cin>> a[i];
    
    for (int i = (n-1); i >= 0; i--){
        if(i != (n-1)) cout << " ";
        cout << a[i];
        
    }
    cout << endl;
    return 0;
    
}


Measured memory_bytes: 3092
import numpy as np
H, W = map(int, input().split())
mat = np.array([list(input()) for _ in range(H)])
bools = np.where(mat == '.', True, False)
mat = mat[:, ~bools.all(axis=0)]
bools = np.where(mat == '.', True, False)
mat = mat[~bools.all(axis=1)]

print('\n'.join([''.join(row) for row in mat]))


Measured memory_bytes: 12528
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;


public class Main {
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception addd) {
					addd.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception addd) {
				addd.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	
	public static FastReader sc = new FastReader();
 
	static long mod = (int) (1e9+7),MAX=(long)(1e18);
	static List<Integer>[] edges;
	public static int[][] parent;
	public static int col = 20;
	public static void main(String[] args) throws IOException{
		
		Scanner sc = new Scanner(System.in);
	    BigDecimal a = sc.nextBigDecimal();
	    BigDecimal b = sc.nextBigDecimal();
	    BigInteger c = a.multiply(b).toBigInteger();
	    out.print(c);
		out.close();
	}
}

Measured memory_bytes: 37772
#include <iostream>
using namespace std;
int main()
{
	int a, b;
  	cin >> a >> b;
  	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0){
    	cout << "Possible";
    } else {
    	cout << "Impossible";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
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 MAX_NUM = 999999999;
void solve() {
	int x1,x2,x3,x4,x5; cin >> x1 >> x2 >> x3 >> x4>> x5;
	if (x1 == 0) cout << 1 << endl;
	else if (x2 == 0) cout << 2 << endl;
	else if (x3 == 0) cout << 3 << endl;
	else if (x4 == 0) cout << 4 << endl;
	else cout << 5 << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    long a[n];
    for(int k=0;k<n;k++)cin >> a[k];
    int h=0;
    int i=0;
    while(h==0){
        for(int j=0;j<n;j++){
            if(a[j]%2!=0||a[n]==0){
                h++;
            }
            else{
                a[j]=a[j]/2;
            }
        }
        if(h==0)i++;
    }
    cout << i << endl;
    return 0;
}

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



int main() {
   ios_base::sync_with_stdio(false);

   long long int q,a,b,c,d,e,f,g,i,j,k,n,m;
   cin>>n>>k>>q;
   a=k-q;
   long long int ar[n+1];
   //memset(a,ar,sizeof(ar));
   for(i=1;i<=n;i++)
    ar[i]=a;
   for(i=0;i<q;i++)
   {
       cin>>a;
       ar[a]++;
   }
   for(i=1;i<=n;i++)
   {
       if(ar[i]<=0)
        cout<<"No\n";
       else
        cout<<"Yes\n";
   }

  return 0;
}


Measured memory_bytes: 1408
D = {}
N, K = map(int, input().split())
for i in range(N):
  A, B = map(int, input().split())
  if A in D:
    D[A] += B
  else:
    D[A] = B
C = sorted(D)
i, S = 0, 0
while S < K:
  S += D[C[i]]
  i += 1
print(C[i-1])

Measured memory_bytes: 10596
N,K,Q=gets.split.map(&:to_i)
A=Q.times.map{gets.to_i}

pati = Array.new(N, K-Q)
A.each do |n|
  pati[n-1] += 1
end

N.times do |i|
  if pati[i] > 0
    puts "Yes"
  else
    puts "No"
  end
end

Measured memory_bytes: 4148
//#include <unordered_set>
//#include <unordered_map> 
#include <functional>
#include <stdexcept>
#include <streambuf>
#include <exception>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <typeinfo>
#include <utility>
#include <complex>
#include <numeric>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <cstring>
#include <locale>
#include <memory>
#include <iosfwd>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <ios>
#include <new>
#include <set>
    
using namespace std;
     
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define al 0x3F3F3F3F
#define sz(x) x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
#define resize(v) v.resize(unique(all(v)) - v.begin());
#define int long long

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <int, ll> pil;
typedef pair < ll, int > pli;
typedef pair <double, double> pdd;
typedef pair <int, double> pid;
typedef pair <double, int> pdi;
typedef pair <ll, double> pld;
typedef pair <double, ll> pdl;
    
const int mod = (int)1e9 + 7;
const int MAX_N = (int)2e5 + 123;
const int N = 1e6 + 3;
const int INF = al;           
const ll INFL = 3e18 + 1;
const double pi = acos(-1.0);
const double eps = 1e-9;
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, ans, a[201];

inline int gcd(int a, int b) {
	if (!b) return a; 
    return gcd(b, a % b);                  
}                                    
                                                                                                      
inline void boost() {
    ios_base :: sync_with_stdio(NULL);
    cin.tie(NULL), cout.tie(NULL);
}
    
inline void Solve() {    
    boost();
    cin >> n;
    for (int i = 1; i <= n + n; i ++) cin >> a[i];
    sort(a + 1, a + n + n + 1);
    for (int i = 1; i <= n + n; i += 2) {
    	ans += a[i];
    }
    cout << ans;
    
}

main () {
//	freopen("differ.in", "r", stdin);
//	freopen("differ.out", "w", stdout);                   	
    int tt = 1;
    while (tt--) {
        Solve();
		}
}         

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

namespace Sample
{
  class Sample
  {
    static void Main()
    {
      string a = Console.ReadLine();
      string[] b= Console.ReadLine().Split(' ');
      string[] c= Console.ReadLine().Split(' ');

      int A = int.Parse(b[0]);
      int B = int.Parse(b[1]);
      int aa= c.Where(x => int.Parse(x) <= A).Count(); //A以下
      int uu = c.Where(x => int.Parse(x) >= B+1).Count();//B+1以上
      int ii = int.Parse(a) - aa -uu;

      int[] aiueo = { aa, ii, uu };

      int ans= aiueo.Min();

      Console.WriteLine(ans);

    }
  }
}

Measured memory_bytes: 13396
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		long mod = 1000000007;
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int m = int.Parse(input[1]);
		long[,,] dp = new long[m+1,n+1,2];//a個見てb個残っている時0となったことがある
    dp[0,0,1] = 1;
    for(int i = 1; i <= n; i++) dp[0,i,0] = 1;
    long answer = 0;

    for(int i = 1; i <= m; i++)
    {
      for(int j = 0; j <= n; j++)
      {
        //左へ
        if(j > 0 && j < n)
        {
          dp[i,j,0] += dp[i-1,j+1,0];
          dp[i,j,1] += dp[i-1,j+1,1];
        }
        else if(j == 0) dp[i,j,1] += dp[i-1,j+1,0] + dp[i-1,j+1,1];

        //左へターン
        if(j > 1)
        {
          dp[i,j,0] += dp[i-1,j,0];
          dp[i,j,1] += dp[i-1,j,1];
        }
        else if(j == 1) dp[i,j,1] += dp[i-1,j,0] + dp[i-1,j,1];

        //右へ
        if(j > 0)
        {
          dp[i,j,0] += dp[i-1,j-1,0];
          dp[i,j,1] += dp[i-1,j-1,1];
        }

        //右へターン
        if(j < n)
        {
          dp[i,j,0] += dp[i-1,j,0];
          dp[i,j,1] += dp[i-1,j,1];
        }
        
        dp[i,j,0] %= mod;
        dp[i,j,1] %= mod;
        //Console.WriteLine(i+" "+j+" "+dp[i,j,0]+" "+dp[i,j,1]);
      }
    }

    for(int i = 0; i <= n; i++)
    {
      answer += dp[m,i,1];
      answer %= mod;
    }
    
		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 151648
#include<iostream>
#include<string>
#define ll long long
using namespace std;
ll cnt[30];
int main(){
	string s;
	cin>>s;
	ll l=s.size();
	ll ans=l*(l-1);
	for(int i=0;i<l;i++) cnt[s[i]-'a']++;
	for(int i=0;i<26;i++) ans-=cnt[i]*(cnt[i]-1);
	cout<<ans/2+1<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define endl '\n'
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define fr1(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define input(a,n) fr(i,0,n)cin>>a[i]
#define output(a,n) fr(i,0,n)cout<<a[i]<<" "
#define dbg cout<<"hurr"<<endl;
#define dbg2 cout<<"hurr2"<<endl;
#define md 1000000007
#define sp << " " <<
#define pi 3.14159265358979323846
#define fixd(x) cout << fixed << setprecision(x);

vi v[100001];
bool vis[100001]={0};

void dfs(ll ind, ll count, ll dp[])
{
    vis[ind]=1;
    fr(i,0,v[ind].size())
    {
        if(!vis[v[ind][i]])
            dfs(v[ind][i],count,dp);
        dp[ind]=max(dp[ind],1+dp[v[ind][i]]);
    }
}

int main()
{
    fast;
    ll n,m;
    cin >> n >> m;
    fr(i,0,m)
    {
        ll x,y;
        cin >> x >> y;
        v[x].pb(y);
    }
    ll dp[n+1]={0},ans=0;
    fr(i,1,n+1)
        if(!vis[i])
            dfs(i,0,dp);
    fr(i,0,n+1)
        ans=max(ans,dp[i]);
    cout << ans;
}

Measured memory_bytes: 9344
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
 
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<pair<ll, ll> > vpi;
typedef vector<ll> vi;
typedef vector<bool> vb;
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define in insert
#define ull unsigned long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll inf = 1e18;
const ll mod = 1e9 + 7;

// int lcm(int a,int b){
//   return (a*b)/ __gcd(a,b);
// }

int main(){
  speed;
  ull t;
  cin >> t;
  ull dp[100100][10];
  ull a,b,c;
  cin >> dp[0][0] >> dp[0][1] >> dp[0][2];

  for(int i = 1; i < t; i++){
    cin >> a >> b >> c;
    dp[i][0] = max(dp[i-1][1]+a,dp[i-1][2]+a);
    dp[i][1] = max(dp[i-1][2]+b,dp[i-1][0]+b);
    dp[i][2] = max(dp[i-1][1]+c,dp[i-1][0]+c);
  }
  cout << max(dp[t-1][0],max(dp[t-1][1],dp[t-1][2]));
  return 0;
}

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


int main() {
  int n;
  cin >> n;
  map<ll,int> mp;
  ll ans = 0, sum = 0;
  mp[0]++;
  rep(i,n) {
    int x;
    cin >> x;
    sum += x;
    if(mp[sum]>0) ans += mp[sum];
    mp[sum]++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 15856
//author: Harsh :)
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 922337203685477;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define maxN 100007
using namespace std;
int main() {
  fastio;
  ll n = 0;
  cin >> n;
  vector<ll>v(n + 1, 0), par(n + 1, 0);
  vector<ll>good;
  for (ll i = 1; i <= n; ++i) cin >> v[i];
  for (ll i = n; i >= 1; --i) {
    ll x = 0;
    for (ll j = 2 * i; j <= n; j += i) {
      x ^= par[j];
    }
    par[i] = x ^ v[i];
    if (par[i] & 1)
      good.pb(i);
  }
  cout << good.size() << "\n";
  for (auto i : good) cout << i << " ";
}


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

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  ll n, c;
  cin >> n >> c;
  vector<ll> x(n + 2), v(n + 2), l(n + 1), r(n + 1);
  for(int i = 1; i <= n; i++) cin >> x[i] >> v[i];
  x[n + 1] = c;
  for(int i = 1; i <= n; i++) {
    int ii = n + 1 - i;
    r[i] = v[i] - (x[i] - x[i - 1]);
    l[i] = v[ii] - (x[ii + 1] - x[ii]);
    r[i] += r[i - 1];
    l[i] += l[i - 1];
  }
  ll ans = 0;
  vector<ll> lma(n + 1), rma(n + 1);
  for(int i = 1; i <= n; i++) {
    lma[i] = max(lma[i - 1], l[i]);
    rma[i] = max(rma[i - 1], r[i]);
  }
  for(int i = 1; i <= n; i++) {
    ans = max(ans, l[i]);
    ans = max(ans, l[i] - (c - x[n + 1 - i]) + rma[n - i]);
    ans = max(ans, r[i]);
    ans = max(ans, r[i] - x[i] + lma[n - i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <list>

using namespace std;

int main()
{
    int n, cnt = 0;

    cin >> n;

    for (int i = 1; i <= n; i++) {
        if (i % 2) {
            cnt++;
        }
    }

    printf("%.10lf\n", (double)cnt / n);

}


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

typedef long long ll;
typedef long double ld;

ll cost[55][55];
ll tajm[55][55];
ll kosta[55];
int vreme[55];

ll n, m, s;

ll dist[55][2505];

const ll INF = 1000000000000000000LL;

vector <ll> graf[55];

void dijkstra(){
    if(s > 50*n) s = 50*n;
    for(ll i=1; i<=n; i++){
        for(ll j=0; j<=50*n; j++){
            dist[i][j] = INF;
        }
    }
    dist[1][s] = 0;
    set <pair <ll, pair <ll, ll>>> q;
    q.insert({0, {1, s}});
    while(!q.empty()){
        auto x = *q.begin();
        q.erase(q.begin());
        ll v = x.second.first;
        ll j = x.second.second;
        ll jos = min(50*n, j+kosta[v]);
        if(dist[v][jos] > dist[v][j] + vreme[v]){
            q.erase({dist[v][jos], {v, jos}});
            dist[v][jos] = dist[v][j] + vreme[v];
            q.insert({dist[v][jos], {v, jos}});
        }
        for(auto c : graf[v]){
            ll jos = j-cost[v][c];
            if(jos < 0) continue;
            if(dist[c][jos] > dist[v][j] + tajm[v][c]){
                q.erase({dist[c][jos], {c, jos}});
                dist[c][jos] = dist[v][j] + tajm[v][c];
                q.insert({dist[c][jos], {c, jos}});
            }
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    cin >> n >> m >> s;
    for(ll i=1; i<=m; i++){
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        graf[a].push_back(b);
        graf[b].push_back(a);
        cost[a][b] = c;
        tajm[a][b] = d;
        tajm[b][a] = d;
        cost[b][a] = c;
    }
    for(ll i=1; i<=n; i++){
        cin >> kosta[i] >> vreme[i];
    }
    dijkstra();
    for(int i=2; i<=n; i++){
        ll res = dist[i][0];
        for(int j=0; j<=50*n; j++) res = min(res, dist[i][j]);
        cout << res << "\n";
    }
    return 0;
}


Measured memory_bytes: 7960
#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[i];
    
    int ans=0;
    for (int i=1; i<n-1; i++){
        if ((A[i-1]<A[i]) && (A[i]<A[i+1])) ans++;
        else if ((A[i-1]>A[i]) && (A[i]>A[i+1])) ans++;
    }
    cout << ans;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 100005;
int p[N];

int find(int v){
	return (p[v] < 0)?v:(p[v] = find(p[v]));
}

bool combine(int u, int v){
	u = find(u);
	v = find(v);
	if(u == v)return false;
	if(p[u] > p[v])swap(u, v);
	p[u] += p[v];
	p[v] = u;
	return true;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n; cin>>n;
	vector<pair<int, int> > x(n), y(n);
	for(int i = 0; i < n; i++){
		cin>>x[i].first>>y[i].first;
		x[i].second = y[i].second = i;
	}
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	vector<pair<int, pair<int, int> > > edge;
	for(int i = 1; i < n; i++){
		int u = x[i].second;
		int v = x[i - 1].second;
		int w = x[i].first - x[i - 1].first;
		edge.push_back({w, {u, v}});
	}
	for(int i = 1; i < n; i++){
		int u = y[i].second;
		int v = y[i - 1].second;
		int w = y[i].first - y[i - 1].first;
		edge.push_back({w, {u, v}});
	}
	sort(edge.begin(), edge.end());
	memset(p, -1, sizeof(p));
	ll ans = 0;
	for(auto ppp : edge){
		int u = ppp.second.first;
		int v = ppp.second.second;
		int w = ppp.first;
		if(combine(u, v))ans += w;
	}
	cout<<ans<<'\n';

	return 0;
}

Measured memory_bytes: 6388
// AOJ 1057: Rolling Dice
// 2017.10.21 bal4u@uu

#include <stdio.h>
#include <string.h>

#define QSIZE 2000000

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

typedef struct { char r, c, d[3]; int t; } QUE;
QUE que[QSIZE+2];
int qsize;

void min_heapify(int i)
{
	int l, r, min;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		QUE t = que[i]; que[i] = que[min]; que[min] = t;
		min_heapify(min);
	}
}

void deq(void)
{
//	if (qsize == 0) return 0;
//	*a = que[0].a, *b = que[0].b, *c = que[0].c;
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(void)
{
	int i, min;

	i = qsize++;
//	que[i].t = t, que[i].a = a, que[i].b = b, que[i].c = c;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		QUE tt = que[i]; que[i] = que[min]; que[min] = tt;
		i = min;
	}
}

char map[11][11];
int mk[11][11][6][6];
int mv[4][2] =  {{-1,0},{0,1},{1,0},{0,-1}};
int rot[4][3] = {{2,6,3},{4,2,1},{5,1,3},{3,2,6}};

int main()
{
	int h, w, sr, sc, gr, gc, i, r, c, t, r2, c2, t2, ans;
	char dice[7], dice2[7];

	while (scanf("%d%d", &h, &w) && h > 0) {
		memset(mk, -1, sizeof(mk));
		for (r = 0; r < h; r++) for (c = 0; c < w; c++) scanf("%d", &i), map[r][c]= i;
		scanf("%d%d%d%d", &sr, &sc, &gr, &gc);
		qsize = 0;
		que[0].r = sr, que[0].c = sc, que[0].t = 0, que[0].d[0] = 1, que[0].d[1] = 2, que[0].d[2] = 3;
		ans = 0x7fffffff; enq();
		while (qsize > 0) {
			r = que[0].r, c = que[0].c, t = que[0].t;
			memcpy(dice+1, que[0].d, 3); for (i = 4; i <= 6; i++) dice[i] = 7 - dice[7-i]; deq();
			if (r == gr && c == gc) { ans = t; break; }
			for (i = 0; i < 4; i++) {
				r2 = r + mv[i][0], c2 = c + mv[i][1];
				if (r2 < 0 || r2 >= h || c2 < 0 || c2 >= w) continue;
				dice2[1] = dice[rot[i][0]],	dice2[2] = dice[rot[i][1]], dice2[3] = dice[rot[i][2]];
				t2 = t + (7 - dice2[1])*map[r2][c2];
				if (mk[r2][c2][dice2[1]][dice2[2]] < 0 || mk[r2][c2][dice2[1]][dice2[2]] > t2) {
					mk[r2][c2][dice2[1]][dice2[2]] = t2;
					que[qsize].r = r2, que[qsize].c = c2, que[qsize].t = t2;
					memcpy(que[qsize].d, dice2+1, 3); enq();
				}
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1816
import math
a, b = map(int, input().split())

t = 0
if 1 <= b <= 9:
    t = 10 * a + b
elif 10 <= b <= 99:
    t = 100 * a + b
else:
    t = 1000 * a + b

if math.sqrt(t) - int(math.sqrt(t)) == 0:
    print("Yes")
else:
    print("No")

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

#define MAX_NUM (1000000007)
#define PI 3.14159265358979323846

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T> &A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T> &A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

template <typename T>
static inline T ArraySum(vector<T> &A) {
  T res = 0;
  for (auto itr = A.begin(); itr < A.end(); ++itr) res += *itr;
  return res;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first > b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

i64 modinv(i64 a, i64 m) {
  i64 b = m, u = 1, v = 0;
  while (b) {
    i64 t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

i64 My_Comb(u64 n, u64 k, i64 m) {
  if (n < k) return 0;
  if (k == 0 || n == k) return 1;
  u64 res = 1;
  k = (n / 2 < k) ? n - k : k;
  for (u64 i = 1; i <= k; ++i)
    res = (((res * (n + 1 - i)) % m) * modinv(i, m)) % m;
  return res;
}

i64 My_Pow(u64 a, u64 n, i64 m) {
  u64 tmp = n, calc = 1;
  while (tmp > 0) {
    if (tmp % 2) {
      tmp--;
      calc *= a;
      calc %= m;
    } else {
      a *= a;
      a %= m;
      tmp /= 2;
    }
  }
  return calc;
}

class UnionFind {
 public:
  vector<u64> Par;
  vector<u64> sz;

  UnionFind(u64 n);
  u64 root(u64 x);
  bool same(u64 x, u64 y);
  void unite(u64 x, u64 y);
  u64 size(u64 x);
};

UnionFind::UnionFind(u64 n) {
  Par.resize(n);
  sz.assign(n, 1);
  for (u64 i = 0; i < n; ++i) Par[i] = i;
}

u64 UnionFind::root(u64 x) {
  if (Par[x] == x) {
    return x;
  } else {
    return Par[x] = root(Par[x]);
  }
}

bool UnionFind::same(u64 x, u64 y) { return root(x) == root(y); }

u64 UnionFind::size(u64 x) { return sz[root(x)]; }

void UnionFind::unite(u64 x, u64 y) {
  x = root(x);
  y = root(y);
  if (x == y) return;
  if (sz[x] < sz[y]) swap(x, y);
  sz[x] += sz[y];
  Par[y] = x;
}

bool isPrime(u32 n) {
  if (n == 2) return true;
  if (n % 2) return false;
  for (u32 i = 3; i * i <= n; i += 2) {
    if (n % i == 0) return false;
  }
  return true;
}

int main() {
  cout << setprecision(18);

  u32 N;
  cin >> N;
  u32 cnt = 0;
  bool flag = false;
  for (u32 i = 0; i < N; ++i) {
    u32 d1, d2;
    cin >> d1 >> d2;
    if (d1 != d2) {
      cnt = 0;
    } else {
      cnt++;
    }
    if (cnt == 3) {
      flag = true;
    }
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int N;
	cin >> N;
	vector<pair<int, int>> vec;
	rep(i,0,N){
		int a;
		cin >> a;
		vec.push_back(make_pair(a, i+1));
	}
	sort_asc(vec);
	for(auto v:vec){
		cout << v.second << " ";
	}
	cout << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 1780
#include <iostream>

using namespace std;

long long a[26], sol;
string s;

long long pov2(long long x){
  if (x == 0)
    return 0;
  return ( (long long)x * (long long)(x+1)) / 2;
}

int main(){
  cin >> s;

  for (int i = 0; i < s.length(); i++){
    a[s[i] - 'a']++;
  }
  sol = ((long long)s.length() * (long long)(s.length() + 1)) / 2;

  for (int i = 0; i < 26; i++){
    sol -= pov2(a[i]);
  }

  cout << sol + 1 << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
using namespace std;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    if(x/d<k)
    {
        k-=(x/d);
        x=x-(x/d)*d;
        // ull ans=1;
        // cout<<k;
        if(k%2==0) cout<<x; 
        else cout<<abs(x-d);
        // cout<<ans;
    }
    else cout<<x-k*d;    
    return 0;
}

Measured memory_bytes: 3648
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
	int n, mn = 1 << 30, p, ans = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> p;
		if (p <= mn) {
			++ans;
		}
		mn = min(mn, p);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <numeric>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// to container
template <class C>
C input(C &c)
{
    for_each(c.begin(), c.end(), [](auto &i) { cin >> i; });
    return c;
}

// to number, string
template <class T>
T input()
{
    T data;
    cin >> data;
    return data;
}

int main()
{
    int N = input<int>();
    vector<vector<int>> a;
    vector<int> tmp1(N, 0), tmp2(N, 0);
    a.push_back(input(tmp1));
    a.push_back(input(tmp2));

    ll m = -1;
    for (int i = 0; i < N; i++)
    {
        ll sum = 0;
        sum += accumulate(a[0].begin(), a[0].begin() + i + 1, 0);
        sum += accumulate(a[1].begin() + i, a[1].end(), 0);
        m = max(m, sum);
    }
    cout << m << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,z,w;
  cin >> n >> z >> w;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  if(n==1){
    cout << abs(a[0]-w) << endl;
  }
  else{
    cout << max(abs(a[n-2]-a[n-1]),abs(a[n-1]-w)) << endl;
  }
}

Measured memory_bytes: 256
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 100001;
static const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

string str;
vector<string> ans;
string res;
bool trans[30];

void dfs(int k){
	if(k == str.size()){
		ans.push_back(res);
		return;
	}

	if(str[k] == 'a' || trans[str[k] - 'a' - 1]){
		char b = (char)(str[k]);
		res.push_back(b);
		dfs(k+1);
		res.erase(res.end()-1);
	}
	if(str[k] != 'z' && !trans[str[k] - 'a']){
		char a = (char)(str[k] + 1);
		res.push_back(a);
		trans[str[k] - 'a'] = true;
		dfs(k+1);
		trans[str[k] - 'a'] = false;
		res.erase(res.end()-1);
	}
}

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	while(1){
		cin >> str;
		if(str.size() == 1 && str[0] == '#') break;
		memr(trans, 0);

		ans.clear();
		res.clear();
		dfs(0);
		sort(ALL(ans), [](auto const& lhs, auto const& rhs) {
			int k = 0;
			int l = -1;
			int r = -1;
			while(1){
				if(k < lhs.size()) l = lhs[k];
				else l = -1;
				if(k < rhs.size()) r = rhs[k];
				else r = -1;
				if(l != r) {
					// print(lhs.size(), rhs.size(), lhs, rhs);
					break;
				}
				k++;
			}
			return l < r;
		});
		cout << ans.size() << endl;
		if(ans.size() < 10){
			rep(i, ans.size()){
				cout << ans[i] <<endl;
			}
		}
		else{
			rep(i, 5){
				cout << ans[i] << endl;
			}
			reverse(ALL(ans));
			rrep(i, 5){
				cout << ans[i] << endl;
			}
		}
	}

	return 0;
}



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

int main() {
  
  int num=0;
  
  cin >> num;
  
  if(num<10) {
    
    if(num==2 || num==4 || num==5 || num==7 || num==9) {
      
      cout << "hon" << endl;
      
    } else if(num==0 || num==1 || num==6 || num==8) {
      
      cout << "pon" << endl;
      
    } else if(num==3) {
      
      cout << "bon" << endl;
      
    }
    
  } else if(10<=num) {
    
    if(num%10==2 || num%10==4 || num%10==5 || num%10==7 || num%10==9) {
      
      cout << "hon" << endl;
      
    } else if(num%10==0 || num%10==1 || num%10==6 || num%10==8) {
      
      cout << "pon" << endl;
      
    } else if(num%10==3) {
      
      cout << "bon" << endl;
      
    }
    
  } 
  
  return 0;
  
}

Measured memory_bytes: 3588