akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <sstream>
#include <stdio.h>

using namespace std;

int ctoi(char c) {
	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

int main(void){
  char n[200000];
  long int num, sum=0, size;
  scanf("%s", n);
  size = sizeof(n)/sizeof(n[0]);
  for(long int i=0; i<size;i++){
    if(n[i]=='\0'){
      break;
    }
    num = ctoi(n[i]);
    sum += num;
  }
  if(sum%9==0){
    cout << "Yes";
  }else{
    cout << "No";
  }
  return 0;
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

ll N, Q;

pair<ll, ll> QUERY[200005];

int main(){
	cin >> N >> Q;

	rep(i, Q) {
		cin >> QUERY[i].first >> QUERY[i].second;
		QUERY[i].second--;
	}
	ll ans =  (N-2) * (N-2);

	set<ll> yokoset;
	set<ll> tateset;
	map<ll, ll> yokomemo;
	map<ll, ll> tatememo;

	yokoset.insert(N);
	tateset.insert(N);
	yokomemo[N] = N - 2;
	tatememo[N] = N - 2;

	rep(i, Q) {
		ll pos = QUERY[i].second;

		if(QUERY[i].first == 1) {
			//下に行く
			ll haba = tatememo[*tateset.lower_bound(pos)];

			//cout << "get " << haba << endl;
			ans -= haba;

			ll curyoko = yokomemo[*yokoset.lower_bound(haba)];
			if(curyoko < pos - 1) continue;
			yokoset.insert(haba);
			yokomemo[haba] = pos - 1;
		} else {
			//右に行く
			ll haba = yokomemo[*yokoset.lower_bound(pos)];

			//cout << "get " << haba << endl;
			ans -= haba;

			ll curtate = tatememo[*tateset.lower_bound(haba)];
			if(curtate < pos - 1) continue;
			tateset.insert(haba);
			tatememo[haba] = pos - 1;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 17648
#include <string>
#include <algorithm>
#include <vector> 
#include <math.h>
#include <iostream>
using namespace std;


int main()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	string t = "No War";

	vector<int> x1(n + 1);
	vector<int> y1(m + 1);

	x1[0] = x;
	y1[0] = y;
	for (int i = 0; i < n; i++) {
		cin >> x1[i + 1];
	}
	for (int j = 0; j < m; j++) {
		cin >> y1[j + 1];
	}
	sort(x1.begin(), x1.end());
	sort(y1.begin(), y1.end());
	if (x1[n] >= y1[0]) {
		t = "War";
	}
	cout << t << endl;
	return 0;

}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
typedef vector<vector<int>> Graph;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

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

    ll ans = 0;
    ll N, K;
    cin >> N >> K;
    if (K == 0) {
        cout << N * N << endl;
        return 0;
    }

    for (int i=1; i<=N; i++) {
        ll num = i - K;
        if (num <= 0) continue;
        ans += (N / i) * num;

#ifdef DEBUG
        cerr << i << ": " << ans << endl;
#endif

        ll r = N % i;
        if (r == 0) continue;
        ans += max(0LL, r - K + 1);

#ifdef DEBUG
        cerr << i << ": " << ans << endl;
#endif
    }
    cout << ans << endl;
}

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

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

  int cnt_1=0,cnt_2=0,cnt_4=0;
  for (int i=0; i<n; i++) {
    if (a[i]%2!=0)
      cnt_1++;
    else if (a[i]%4!=0)
      cnt_2++;
  }
  cnt_4=n-cnt_1-cnt_2;

  if (cnt_2) {
    if (cnt_1<=cnt_4)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
  else {
    if (cnt_1<=cnt_4+1)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 640
n = int(input())

s = set()

for i in range(n):
    
    cmd = input().split()
    #print(cmd)
    
    if cmd[0] == 'insert':
        #print(cmd[1])
        s.add(cmd[1])
        #print(s)
    
    if cmd[0] == 'find':
        if cmd[1] in s:
            print('yes')
        else:print('no')


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

const int N=100010;
struct edge{
	int y,next,c;
}s[N<<3];
struct op{
	int x,y;
}we[N];
int first[N<<1],len=0,n,m,bg,nd,c[N<<1],d[N<<1],las[N];
int lis[N<<1],st,ed;
vector<int> P[N];

void ins(int x,int y){
	s[len++]=(edge){y,first[x],1};first[x]=len-1;
	s[len++]=(edge){x,first[y],0};first[y]=len-1;
}

bool bfs(){
	lis[st=1]=bg;ed=2;
	memset(d,0,sizeof(d));d[0]=1;
	while(st!=ed){
		int x=lis[st];st++;
		for(int i=first[x];i!=-1;i=s[i].next) if(!d[s[i].y] && s[i].c) 
			d[s[i].y]=d[x]+1,lis[ed++]=s[i].y;
	}
	return d[nd];
}

int dfs(int x,int t){
	if(x==nd) return t;
	int tot=0,my;
	for(int i=first[x];i!=-1;i=s[i].next) if(d[s[i].y]==d[x]+1 && s[i].c){
		my=dfs(s[i].y,min(t-tot,s[i].c));tot+=my;
		if(my && x>=1 && x<=n-1 && s[i].y) c[x]=s[i].y-n+2;
		s[i].c-=my;s[i^1].c+=my;
		if(t==tot) break;
	}
	if(!tot) d[x]=0;
	return tot;
}

int Dinic(){
	int dx,ans=0;
	while(bfs()){
		dx=dfs(bg,1e9);
		while(dx) ans+=dx,dx=dfs(bg,1e9);
	}
	return ans;
}

int main(){
	scanf("%d",&n);bg=0,nd=2*n-1;
	int x;
	memset(first,-1,sizeof(first));
	for(int i=1;i<n;i++){
		ins(bg,i);
		ins(i+n-1,nd);
		scanf("%d",&m);
		while(m--){
			scanf("%d",&x);
			P[x].push_back(i);
			if(x-1) ins(i,n-1+x-1);
		}
	}
	if(Dinic()==n-1){
		st=ed=1;
		for(int i=0;i<P[1].size();i++) lis[ed++]=P[1][i],las[P[1][i]]=1;
		while(st!=ed){
			int x=lis[st];st++;
			we[x]=(op){las[x],c[x]};
			for(int i=0;i<P[c[x]].size();i++) if(!las[P[c[x]][i]]) lis[ed++]=P[c[x]][i],las[P[c[x]][i]]=c[x];
		}
		if(ed==n) for(int i=1;i<n;i++) printf("%d %d\n",we[i].x,we[i].y);
		else printf("-1\n");
	}
	else printf("-1\n");
}

Measured memory_bytes: 21888
import java.util.Scanner;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int[] b = new int[a];
    int[] c = new int[a];
    int[] d = new int[a-1];
    int ans = 0;
    for(int i = 0;i < b.length;i++){
      b[i] = sc.nextInt();
      b[i]--;
    }
    for(int j = 0;j < c.length;j++){
      c[j] = sc.nextInt();
    }
    for(int x = 0;x < d.length;x++){
      d[x] = sc.nextInt();
    }
    for(int y = 0;y < c.length;y++){
      ans += c[b[y]];
      if(y < b.length-1 && b[y] == b[y+1]-1){
        ans += d[b[y]];
      }
    }  
    System.out.println(ans);
  }
}

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

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int> > xs(n);
    vector<int> ys(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        xs[a].push_back(b);
        ys[b]++;
    }
    vector<int> que;
    for (int i = 0; i < n; i++) {
        if (ys[i] == 0) {
            que.push_back(i);
        }
    }
    vector<int> zs(n);
    for (int i = 0; i < n; i++) {
        int p = que[i];
        zs[p] = i;
        cout << p << endl;
        // cout << i << ":" << p << ", ";
        for (int j = 0; j < (int)xs[p].size(); j++) {
            int e = xs[p][j];
            ys[e]--;
            if (ys[e] == 0) {
                que.push_back(e);
            }
        }
    }
    // for (int i = 0; i <= m; i++) {
        // int x, y;
        // cin >> x >> y;
        // if (zs[x] > zs[y]) {
            // puts("1");
        // } else {
            // puts("-1");
        // }
    // }
    
    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1e9;
const int MOD = 1e9+7;
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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

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

    int n; cin >> n;
    string S; cin >> S;
    vector<int> a(n, 0);
    rep(i, n) {
        if (S[i]=='(') a[i]=1;
        else a[i]=-1;
    }
    vector<int> s(n+1, 0);
    rep(i, n) s[i+1] = s[i]+a[i];
    debug(s);
    int base = 0;
    string t;
    rep(i, n+1) {
        if (s[i]+base<0) {
            int m = abs(s[i]+base);
            debug(i, m, base);
            rep(j, m) {
                t+='(';
                base++;
            }
        }
    }
    string u;
    debug(s.back(), base);
    if (s.back()+base>0) {
        rep(i, s.back()+base) u+=')';
    }
    string ans = t + S + u;
    cout << ans << endl;
}

Measured memory_bytes: 3668
'use strict'
function Main(input) {
  input = input.split("\n")
  let N = parseInt(input[0])
  let res = ''
  if (N === 0) {
    console.log(0)
    return
  }
  while (N !== 0) {
    res = String(Math.abs(N % -2)) + res
    if (N % -2 < 0) N += N < 0 ? -1 : 1
    N = parseInt(N / -2)
  }
  console.log(res)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 11724
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0)
#define fori(x,a,b) for (int x=a;x<=b;++x)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define mp make_pair
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define getbit(x,i) ((x>>(i-1))&1)
#define batbit(x,i) (x|(1ll<<(i-1)))
#define tatbit(x,i) (x&~(1<<(i-1)))
#define gg exit(0);
const int maxn = 1e5 + 10;
int f[maxn],k;
int main()
{
    cin>>k;

    priority_queue<ii,vector<ii> ,greater<ii> > h;
    memset(f,127,sizeof(f));
    fori(i,1,9)
    {
        f[i%k] = min(f[i%k],i);
        h.push({f[i%k],i});
    }

    while(!h.empty())
    {
        ii u = h.top();
        h.pop();

        if (u.fi!=f[u.se]) continue;
        fori(i,0,9)
        {
            int tmp = (u.se*10+i)%k;
            if (f[tmp] > f[u.se] + i)
            {
                f[tmp] = f[u.se] + i;
                h.push({f[tmp],tmp});
            }
        }
    }
    cout<<f[0];
}


Measured memory_bytes: 5732
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<set>
#include<vector>

using namespace std;
int N=2e5+10,inf=1e9;

int main(){
	long long N,zero=0,plus=0,minus=0,ans=0,mini=1e9,tmp;
    cin >> N;
    vector<long> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
        if(A[i]==0){
            zero++;
        }else if(A[i]>0){
            plus++;
        }else{
            minus++;
        }
        tmp = abs(A[i]);
        mini = min(mini,tmp);
    }
    //cout << minus << endl;
    for(int i=0;i<N;i++){
        if(A[i]<0){
            ans -= A[i];
        }else{
            ans += A[i];
        }
    }

    if(zero>0){
        cout << ans << endl;
    }else{
        if(minus%2==1){
            //cout << "OK" << endl;
            ans -= mini*2;
        }
         cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <queue>
#include <cmath>
#include <random>
#include <fstream>
#include <string>
#include <tuple>
#include <deque>
#include <set>
#include <map>
#include <stack>

#define REP(i, N) for(int i = 0; i< N; i++)
using namespace std;
#define ll long long
const int INF = 1 << 29;
const ll llINF = 10000000000000000;

const int MOD = 1000000007;

#define MAX_N 100100
typedef pair<int, int> P;
typedef pair<ll, ll> llP;

class UnionFindTree{
private:
    int par[MAX_N];
    int urank[MAX_N];
    int size[MAX_N];
public:
    int init(int n);
    int find(int x);
    int unite(int x, int y);
    int same(int x, int y);
    int parnum(int x){return par[x];}
    int ranknum(int x){return urank[x];}
    int sizenum(int x){return size[find(x)];}
};

int UnionFindTree::init(int n){
    REP(i, n){
        par[i] = i;
        urank[i] = 0;
        size[i] = 1;
    }
    return 0;
}

int UnionFindTree::find(int x){
    if(par[x] == x)return x;
    else return par[x] = find(par[x]);
}

int UnionFindTree::unite(int x, int y){
    x = find(x);
    y = find(y);
    
    if(x == y)return 0;
    if(urank[x] < urank[y]){
        par[x] = y;
        size[y] += size[x];
    }else{
        par[y] = x;
        size[x] += size[y];
        if(urank[x] == urank[y])urank[x] ++;
    }
    return 0;
}

int UnionFindTree::same(int x, int y){
    return find(x) == find(y);
}



ll d[1010][1010] = {INF};
int V;

int scoreatack(){
    int E;
    cin >> V >> E;
    REP(i, V){
        REP(j, V){
            d[i][j] = -llINF / 100;
        }
    }
    REP(i, V){
        d[i][i] = 0;
    }
    REP(i, E){
        int s, t, de;
        cin >> s >> t >> de;
        s--;
        t--;
        d[s][t] = de;
    }
    
    REP(k, V){
        REP(i, V){
            REP(j, V){
                if(d[i][j] < d[i][k] + d[k][j])d[i][j] = d[i][k] + d[k][j];
            }
        }
    }
    bool isinf = false;
    REP(i, V){
        if(d[i][i] > 0 && d[0][i] > -llINF / 200 && d[i][V - 1] > -llINF / 200)isinf = true;
    }
    
    if(isinf)printf("inf\n");
    else printf("%lld\n", d[0][V - 1]);
    return 0;
}

int warshall_floyd(){
    int E, r;
    cin >> V >> E >> r;
    REP(i, V){
        REP(j, V){
            d[i][j] = INF;
        }
    }
    REP(i, V){
        d[i][i] = 0;
    }
    REP(i, E){
        int s, t, de;
        cin >> s >> t >> de;
        d[s][t] = de;
    }
    REP(k, V){
        REP(i, V){
            REP(j, V){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    bool nc = false;
    REP(i, V){
        if(d[i][i] < 0 && d[r][i] < INF / 2)nc = true;
    }
    if(nc)printf("NEGATIVE CYCLE\n");
    else{
        REP(i, V){
            if(d[r][i] > INF / 2)printf("INF\n");
            else printf("%d\n", d[r][i]);
        }
    }
    
    return 0;
}
int main(){
    scoreatack();
}


Measured memory_bytes: 8192
#include <cstdio>
#include <vector>
#include <climits>

using namespace std;

int main() {

    int n;
    scanf("%d", &n);

    vector<vector<int> > F(n, vector<int>(10));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 10; j++) {
            scanf("%d", &F[i][j]);
        }
    }

    vector<vector<int> > P(n, vector<int>(11));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 11; j++) {
            scanf("%d", &P[i][j]);
        }
    }

    long long max_profit = INT_MIN;
    for (int i = 1; i < (1 << 10); i++) {
        long long profit = 0LL;
        for (int j = 0; j < n; j++) {
            int overlap = 0;
            for (int k = 0; k < 10; k++) {
                if (((i >> k) & F[j][k]) == 1) {
                    overlap++;
                }
            }
            profit += (long long)P[j][overlap];
        }
        max_profit = max(profit, max_profit);
    }

    printf("%lld\n", max_profit);

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstring>
#include<cstdlib>

using namespace std;
long long int INF=1000000000;
int st[152],stx[152][11],sts[152][11];
long long int dp[152][11][78];

int main(void){
	int n,m;
	while(1){
		scanf("%d%d",&n,&m);
		if(n==0 && m==0)break;
		memset(st,0,sizeof(st));
		memset(stx,0,sizeof(stx));
		memset(sts,0,sizeof(sts));
		memset(dp,0,sizeof(dp));
		for(int i=0;i<152;i++){
			for(int j=0;j<11;j++){
				for(int k=0;k<76;k++){
					dp[i][j][k]=INF;
				}
			}
		}
		st[0]=1;
		for(int i=0;i<n;i++){
			scanf("%d",&st[i]);
			for(int j=0;j<st[i];j++){
				scanf("%d%d",&stx[i][j],&sts[i][j]);
			}
		}
		for(int i=0;i<st[0];i++){
			dp[0][i][0]=0;
		}
		if(m>=1)for(int i=0;i<st[1];i++){
			dp[1][i][1]=0;
		}
		for(int i=1;i<n;i++){
			for(int j=0;j<=m;j++){
				for(int k=0;k<st[i];k++){
					for(int l=0;l<st[i-1];l++){
						dp[i][k][j]=min(dp[i][k][j],dp[i-1][l][j]+(sts[i][k]+sts[i-1][l])*abs(stx[i][k]-stx[i-1][l]));
					}
					if(j!=m && i>=2)for(int l=0;l<st[i-2];l++){
						dp[i][k][j+1]=min(dp[i][k][j+1],dp[i-2][l][j]+(sts[i][k]+sts[i-2][l])*abs(stx[i][k]-stx[i-2][l]));
					}
				}
			}
		}
		long long int ans=INF;
		for(int j=0;j<=m;j++){
			for(int k=0;k<st[n-1];k++){
				ans=min(ans,dp[n-1][k][j]);
			}
			if(j!=m)for(int k=0;k<st[n-2];k++){
				ans=min(ans,dp[n-2][k][j]);
			}
		}
		printf("%d\n",ans);
	}
    return 0;
}

Measured memory_bytes: 1916
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

        final int N = sc.nextInt();
        final int M = sc.nextInt();

        boolean[] ok = new boolean[N+1];
        for (int i = 0; i <= N; i++) {
            ok[i] = true;
        }

        for (int i = 0; i < M; i++) {
            ok[sc.nextInt()] = false;
        }

        final int[] dp = new int[N+1];
        for (int i = 0; i <= N; i++) dp[i] = 0;

        dp[0] = 1;
        for (int i = 0; i < N; i++) {
            for (int j = i+1; j <= Math.min(N, i+2); j++) {
                if (ok[j]) {
                    dp[j] += dp[i];
                    dp[j] %= 1000000007;
                }
            }
        }

        System.out.println(dp[dp.length-1]);
    }
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n,x;
  cin >> n >> x;
  ll a[100];
  REP(i,n) cin >> a[i];
  sort(a,a+n);
  ll count = 0;
  REP(i,n){
    x -= a[i];
    if(x<0) break;
    count ++;
  }
  if(x>0) count --;
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <climits>
#include <set>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ve vector
#define umap unordered_map
#define iter iterator
int n, m, a[10000], b[10000], col[10000], c, res;
vector<int>x[100];

void dfs(int pos) {
	if (col[pos] >= 1) return;
	col[pos] = c;
	for (int j = 0; j < x[pos].size(); j++)dfs(x[pos][j]);
}

void solve() {
	cin >> n >> m;
	for (int i=0; i<m; i++) cin >> a[i] >> b[i];
	for (int i=0; i<m; i++) {
		for (int j=0; j<=n; j++) { x[j].clear(); col[j] = 0; }
		for (int j=0; j<m; j++) {
            if (i != j) {
                x[a[j]].push_back(b[j]);
                x[b[j]].push_back(a[j]);
            }
        }
		c = 0;
		for (int j=1; j<=n; j++) {
            if (col[j] >= 1) continue;
            c++;
            dfs(j);
        }
		if (c >= 2) res++;
	}
	cout << res << endl;
}

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

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main(){
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll a,b;
	cin >>a >>b;
	if(a>b) swap(a, b);
	int ans = (b+a) /2;
	//dbg(ans);
	if( abs(b-ans) == abs(a-ans) ){ cout << ans <<"\n";}
	else puts("IMPOSSIBLE");
}

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

int main() {
  char b;
  cin >> b;
  if (b=='A')
    cout << 'T' ;
  else if (b=='T')
    cout << 'A';
  else if (b=='G')
    cout << 'C';
  else 
    cout << 'G';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=400005;
int a[N],b[N];
int s1[N],s2[N];
bool ans[N],ok[N];
int Next[N],n;
void getNext(){
	memset (Next,0,sizeof(Next));
	for (int i=2,k=0;i<=n;i++){
		while (k&&s2[k+1]!=s2[i]) k=Next[k];
		if (s2[k+1]==s2[i]) k++;
		Next[i]=k;
	}
}
void KMP(){
	for (int i=1,k=0;i<=n*2-1;i++){
		while (k&&s2[k+1]!=s1[i]) k=Next[k];
		if (s2[k+1]==s1[i]) k++;
		if (k==n) ok[i-n+1]=true;
	}
}
int main (){
	scanf ("%d",&n);
	for (int i=1;i<=n;i++) scanf ("%d",&a[i]);
	for (int i=1;i<=n;i++) scanf ("%d",&b[i]);
	for (int i=1;i<=n;i++) a[i+n]=a[i];
	for (int i=1;i<=n;i++) ans[i]=true;
	memset (s1,-1,sizeof(s1));
	memset (s2,-1,sizeof(s2));
	for (int w=0;w<3;w++){
		memset (ok,false,sizeof(ok));
		for (int i=1;i<=n*2;i++) s1[i]=(a[i]>>w)&1;
		for (int i=1;i<=n;i++) s2[i]=(b[i]>>w)&1;
		getNext();KMP();
		for (int i=1;i<=n*2;i++) s1[i]=(a[i]>>w)&1;
		for (int i=1;i<=n;i++) s2[i]=((b[i]>>w)&1)^1;
		getNext();KMP();
		for (int i=1;i<=n;i++) ans[i]&=ok[i];
	}
	for (int i=1;i<=n;i++)
		if (ans[i]) printf ("%d %d\n",i-1,a[i]^b[1]);
	return 0;
}


Measured memory_bytes: 12032
k=int(input())
l=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[k-1])

Measured memory_bytes: 3316
from collections import Counter

R = lambda: map(int, input().split())
n, k = R()
a = list(R())
w = [0] * n

def merge(b, e):
    m = b + (e - b) // 2
    i, j = b, m
    r = k = 0
    while i < m and j < e:
        if a[i] <= a[j]:
            w[k] = a[i]
            i += 1
        else:
            r += m - i
            w[k] = a[j]
            j += 1
        k += 1
    a[e - m + i: e] = a[i: m]
    a[b: b + k] = w[:k]
    return r        
    
def mergesort(b, e):
    if e - b < 2:
        return 0
    m = b + (e - b) // 2
    return mergesort(b, m) + mergesort(m, e) + merge(b, e)


r = k * mergesort(0, n)
c = n*(n-1)//2 - sum(x*(x-1)//2 for x in Counter(a).values())
print((r + c * k * (k - 1) // 2) % (10**9 + 7))


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

long long n, a, b;

int main() {
   ios::sync_with_stdio(false); cin.tie(0);
   cin >> n >> a >> b;
   if (a > b) {
      cout << 0;
   } else if (a == b) {
      cout << 1;
   } else { // a<b
      if (n==1) cout << 0;
      else {
         cout << a+b*(n-1)-(a*(n-1)+b)+1;
      }
   }
   return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    var n = readLine()!!.toString()
    println(
        if (n.count { it == n[0] } == 4) "No"
        else if (n[0] == n[1] && n[2] == n[3]) "Yes"
        else if (n[0] == n[2] && n[1] == n[3]) "Yes"
        else if (n[0] == n[3] && n[1] == n[2]) "Yes"
        else "No"
    )
}

Measured memory_bytes: 33692
#include<bits/stdc++.h>
using namespace std;
bool isPrime(int n) {
  if (n < 2) return false;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
int main(){
    int n;
    cin>>n;
    if(isPrime(n)==true){
        cout<<n<<endl;
        return 0;
    }
    else {
        for(int i=n+1;;i++){
            if(isPrime(i)==true){
                cout<<i<<endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]
check = 0

for i in range(N - M + 1):
    for j in range(N - M + 1):
        bb = []
        for k in range(M):
            bb.append(A[i + k][j:j+M])
        if bb == B:
            check = 1

if check == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE RecordWildCards       #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    n <- readLn :: IO Int
    cs <- U.unfoldrN n B.uncons <$> B.getLine
    q <- readLn :: IO Int
    ks <- map read.words <$> getLine
    mapM_ (print.solve cs) ks

solve :: U.Vector Char -> Int -> Int
solve cs k = fst $ U.foldl' step (U.foldl' step0 (0, emptyQ) pre) post
  where
    (pre, post) = U.splitAt k cs
    step0 (!res, !q) c
        | c == 'C' = (res + score q', q')
        | otherwise = (res, q')
      where
        q' = push c q

    step (!res, !q) c
        | c == 'C' = (res + score q', q')
        | otherwise = (res, q')
      where
        q' = push c $ pop (U.unsafeIndex cs) q

data Q = Q !Int !Int !Int !Int

emptyQ :: Q
emptyQ = Q 0 0 0 0

push :: Char -> Q -> Q
push 'D' (Q d m dm f) = Q (d + 1) m dm f
push 'M' (Q d m dm f) = Q d (m + 1) (dm + d) f
push c q              = q

pop :: (Int -> Char) -> Q -> Q
pop v (Q d m dm f) = case v f of
    'D' -> Q (d - 1) m (dm - m) (f + 1)
    'M' -> Q d (m - 1) dm (f + 1)
    _   -> Q d m dm (f + 1)

score :: Q -> Int
score (Q _ _ dm _) = dm


Measured memory_bytes: 8956
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;


int main()
{
	int n, a, b;

	scanf("%d%d%d", &n, &a, &b);

	if(n == 1) {
		printf("%d\n", a == b ? 1 : 0);
		return 0;
	}

	if(a > b) {
		printf("0\n");
		return 0;
	}

	i64 mi = ((i64)a * (n - 1) + b);
	i64 ma = ((i64)b * (n - 1) + a);
	i64 c = ma - mi + 1;

	printf("%lld\n", c);

	return 0;
}

/* waffle */


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

const int MaxN = 100005, INF = 2000000000;

int n, K;
int h[MaxN], f[MaxN];

int main() {
	scanf("%d%d", &n, &K);
	for (int i = 1; i <= n; ++ i) scanf("%d", &h[i]);
	f[1] = 0;
	for (int i = 2; i <= n; ++ i) {
		f[i] = INF;
		for (int j = 1; j <= K && i - j >= 1; ++ j) {
			f[i] = min(f[i], f[i - j] + abs(h[i] - h[i - j]));
		}
	}
	printf("%d\n", f[n]); 
	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>istream&operator>>(istream&is,vector<T>&vec){rep(i,vec.size())is>>vec[i];return is;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

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

const int inf = 1e9;
const ll linf = 3e18;

int mi[200001];
int R[200001];

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

    int N; cin >> N;

    mi[0] = inf;

    rep1(i, N) {
        cin >> R[i];
        mi[i] = min(mi[i - 1], R[i]);
    }

    int ma = -inf;

    for (int i = 2; i <= N; ++i) {
        ma = max(ma, R[i] - mi[i - 1]);
    }

    cout << ma << endl;
}

Measured memory_bytes: 2756
#include <iostream>
#include <bitset>

using namespace std;

int main() {
  bitset<1000000> primes;
  int i, j, n, ans;
  while (cin >> n) {
    primes.reset();
    for (i = 2; i <= n; i++)
      if (primes[i] == false)
	for (j = i + i; j <= n; j += i)
	  primes[j] = true;
    cout << (n == 0 ? 0 : n - primes.count() - 1) << endl;
 }
  return 0;
}

Measured memory_bytes: 988
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <list>

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using TP = tuple<ll, ll, ll>;
ll MOD = 1e9+7;
const int INF = 1e6;
const ll LINF = (ll)1e18;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, M;
    cin >> N >> M;
    int A[1000], B[1000], C[1000], mp[100][100];
    
    REP(i, N){
        REP(j, N){
            if(i==j){
                mp[i][j] = 0;
            }else{
                mp[i][j] = INF;
            }
        }
    }
    REP(i, M){
        cin >> A[i] >> B[i] >> C[i];
        A[i]--;B[i]--;
        mp[A[i]][B[i]] = C[i];
        mp[B[i]][A[i]] = C[i];
    }

    //warshall-floyd
    REP(k, N){
        REP(i, N){
            REP(j, N){
                mp[i][j] = min(mp[i][j], mp[i][k] + mp[k][j]);
            }
        }
    }

    int ans = M;
    REP(i, M){
        bool shortest = false;
        REP(j, N){
            if(mp[j][A[i]] + C[i] == mp[j][B[i]]){
                shortest=true;
            }
        }
        if(shortest==true){
            ans--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<complex>
#include<bitset>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N;
int C[200200];
int dp[200200];
int sum[200200];
const int mod = 1000000007;

signed main() {
    cin >> N;
    C[0] = 200001;
    rep(i, N) {
        cin >> C[i + 1];
    }
    dp[0] = 1;
    for (int i = 1; i <= N; ++i) {
        if (C[i] != C[i - 1]) {
            (sum[C[i]] += dp[i - 1]) %= mod;
        }
        dp[i] = sum[C[i]];
    }
    (dp[N] += mod) %= mod;
    cout << dp[N] << endl;
    return 0;
}


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

#define MOD 1000000007

vector<int> l;
vector<int> r;
long long memo[60][2][2][2];

long long f( int pos, int flagX, int flagY, int flagZ )
{
	if( pos == -1 ) return 1;
	if( memo[pos][flagX][flagY][flagZ] >= 0 ) return memo[pos][flagX][flagY][flagZ];
	long long ret = 0;
	if( flagX || l[pos] == 0 ) {
		int flag = flagY;
		if( r[pos] ) flag = 1;
		ret += f( pos - 1, flagX, flag, flagZ );
	}
	if( ( flagX || l[pos] == 0 ) &&
		( flagY || r[pos] ) && flagZ ) {
		ret += f( pos - 1, flagX, flagY, flagZ );
	}
	if( flagY || r[pos] ) {
		int flag = flagX;
		if( l[pos] == 0 ) flag = 1;
		ret += f( pos - 1, flag, flagY, 1 );
	}
	ret %= MOD;
	memo[pos][flagX][flagY][flagZ] = ret;
	return ret;
}

int main()
{
	long long L, R;
	cin >> L >> R;

	while( L ) {
		int b = L % 2;
		l.push_back( b );
		L /= 2;
	}
	int n = 60 - l.size();
	for( int i = 0; i < n; i++ ) l.push_back( 0 );
	while( R ) {
		int b = R % 2;
		r.push_back( b );
		R /= 2;
	}
	n = 60 - r.size();
	for( int i = 0; i < n; i++ ) r.push_back( 0 );
	memset( memo, -1, sizeof( memo ) );
	long long ans = f( 59, 0, 0, 0 );

	cout << ans << endl;
}


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

int N;
int A;
int counter=0;

int main()
{
    cin>>N;

    for (int i=0; i<N; i++)
    {
        cin>>A;

        if (A%2==1)
        {
            counter++;
        }
    }

    if (counter%2==0)
    {
        cout<<"YES"<<endl;
    }

    else
    {
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 3556
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
class SCC {
public:
	int V, cnt;
	vector<vector<int> > G, rG, graph;
	vector<int> vs, cmp;
	vector<bool> used;
	SCC(int node_size) : V(node_size), G(V), rG(V), cmp(V), used(V, false) {}
	void add_edge(int from, int to) {
		G[from].push_back(to);
		rG[to].push_back(from);
	}
	void dfs(int u) {
		used[u] = true;
		for (int v : G[u]) {
			if (!used[v]) {
				dfs(v);
			}
		}
		vs.push_back(u);
	}
	void dfs(int u, const int k) {
		used[u] = true;
		cmp[u] = k;
		for (int v : rG[u]) {
			if (!used[v]) {
				dfs(v, k);
			}
		}
	}
	int solve() { //強連結成分の数を返す
		for (int i = 0; i < V; i++) {
			if (!used[i]) {
				dfs(i);
			}
		}
		fill(used.begin(), used.end(), false);
		cnt = 0;
		for (int i = V - 1; i >= 0; i--) {
			if (!used[vs[i]]) {
				dfs(vs[i], cnt++);
			}
		}
		return cnt;
	}
	void make_graph() {
		graph.resize(cnt);
		for (int i = 0; i < V; i++) {
			for (int v : G[i]) {
				if (cmp[i] != cmp[v]) {
					graph[cmp[i]].push_back(cmp[v]);
				}
			}
		}
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	SCC scc(N);
	int a, b;
	for (int i = 0; i < M; i++) {
		cin >> a >> b; a--; b--;
		scc.add_edge(a, b);
	}
	scc.solve();
	for (int i = 0; i < N; i++) {
		bool f = true;
		for (int j = 0; j < N; j++) {
			if (scc.cmp[i] == scc.cmp[j]) {
				if (f)f = false;
				else cout << " ";
				cout << j + 1;
			}
		}
		cout << endl;
	}
}


Measured memory_bytes: 5428
M=gets[/ .*/].to_i;X=$<.map{|s|s.split.map &:to_i};*s=1,-1;p s.product(s,s).map{|a,b,c|eval X.map{|x,y,z|x*a+y*b+z*c}.max(M)*?+}.max||0

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

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    long long n,k;cin>>n>>k;
    long long ans=k;n--;
    while (n--){
        ans*=(k-1);
    }cout<<ans<<endl;
    return 0;

}

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

#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

const int MOD = 1e9+7;

int main() {
  int n;
  cin >> n;
  vector<cpp_int> arr(n);
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  cpp_int res = 0;
  cpp_int power_of_two = 1;
  for (int i = 0; i < 60; ++i) {
    cpp_int one = 0;
    for (cpp_int &element : arr) {
      if (element % 2 == 1) {
        one++;
      }
      element /= 2;
    }
    cpp_int zero = n - one;
    res = (res + power_of_two * one * (n - one)) % MOD;
    power_of_two = (power_of_two * 2) % MOD;
  }
  cout << res << endl;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int64_t sum=0;
string s;
void dfs(int64_t a,int64_t b,int64_t c)
{
    int64_t next=c*10+(s[a]-'0');
    if(a==s.size()){sum+=b*(c==0);return;}
    dfs(a+1,b,next);dfs(a+1,b+next,0);
}

void solve()
{
    cin>>s;
    dfs(0,0,0);
    cout<<sum<<endl;
}

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

Measured memory_bytes: 256
// cities to vapori-
// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define sz(x) int(x.size())
#define fill(x,v) memset(x,v,sizeof(x))
#define REP(i,a,b) for(int i = int(a); i < int(b); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int N = 1e5+20, MOD = 1e9+7;

int gg[N];

int main(){

	fastio;
	int n,m;
	cin >> n >> m;
	fill(gg,0);
	REP(i,0,m){
		int x;
		cin >> x;
		gg[x] = 1;
	}

	vector<int> dp(n+1,1);
	for(int i = 1; i <= n; ++i){
		if(gg[i]){
			dp[i] = 0;
			continue;
		}
		dp[i] = dp[i-1];
		if(i-2 >= 0) dp[i] = (dp[i] + dp[i-2]) % MOD;
	}

	cout << dp[n] << endl;

	return 0;
}


Measured memory_bytes: 4100
N,M,X = map(int,input().split())
data = []
ans = 0
for i in range(N):
    d = list(map(int,input().split()))
    data.append(d)
    ans += d[0]

x = 2**N + 1
ans_candidate = []
valid = False
ans += 1
ans_old = ans
for i in range(x):
    if i != 0:
        for l in range(len(sum)):
            if sum[l] >= X and l == len(sum) -1:
                valid = True
            if sum[l] >= X:
                continue
            else:
                valid = False
                break
        if valid and price < ans:
            ans = price
    sum = [0] * M
    price = 0
    for j in range(N):
        if i >> j & 1 == 1:
            price += data[j][0]
            for k in range(M):
                sum[k] += data[j][k+1]

if ans_old == ans:
    print(-1)
else:
    print(ans)


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

using namespace std;

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

  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  while (m--) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  vector<int> ans(n);
  queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int to : g[v]) {
      if (!ans[to]) {
        ans[to] = v + 1;
        q.push(to);
      }
    }
  }
  for (int i = 1; i < n; ++i) {
    if (!ans[i]) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes\n";
  for (int i = 1; i < n; ++i) {
    cout << ans[i] << '\n';
  }

  return 0;
}


Measured memory_bytes: 10032
<?php

fscanf(STDIN, "%d", $n);
$v_arr = explode(' ', trim(fgets(STDIN)));
$c_arr = explode(' ', trim(fgets(STDIN)));

$max = 0;
for ($i = 0; $i < $n; ++$i) {
    $diff = $v_arr[$i] - $c_arr[$i];
    if ($diff > 0) {
        $max += $diff;
    }
}
echo $max;


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

int main(){
    string s;
    cin >> s;
    for(int i = 1; i < s.size(); i++){
        if((s[i] - '0') != 9){
            goto skip;
        }
    }
    cout << (s[0] - '0') + 9 * (s.size() - 1) << endl;
    return 0;
    skip:
        cout << (s[0] - '0') + 9 * (s.size() - 1) - 1 << endl;
        return 0;
}

Measured memory_bytes: 256
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
ans = []
for i in [1,-1]:
    for j in [1,-1]:
        for k in [1,-1]:
            if a + b * i + c * j + d * k == 7:
                ans = [i,j,k]
                break
print(a,end="")
print('+' if ans[0] == 1 else '-',end="")
print(b,end="")
print('+' if ans[1] == 1 else '-',end="")
print(c,end="")
print('+' if ans[2] == 1 else '-',end="")
print(d,end="=7\n")


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
  int n,m,k;
  cin>>n>>m>>k;
  long long a[n],b[m];
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<m;i++) cin>>b[i];
  long long t,s;
  for(int i=0;i<m;i++) t+=b[i];
  int j=m;
  int ans=0;
  for(int i=0;i<n+1;i++){
    while(j>0&&t>k){
      --j;
      t-=b[j];
    }
    if(t>k) break;
    ans=max(ans,i+j);
    if(i==n) break;
    t+=a[i];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 6716
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

def main():
    X = int(input())
    for i in range(X, 10**12):
        if is_prime(i):
            print(i)
            exit()




if __name__ == "__main__":
    main()

Measured memory_bytes: 38896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
#define fst first
#define snd second
const int INF = 1e9;

bool valid(const string& s, int lim) {
//  cerr << "> lim = " << lim << endl;

  const int olim = lim - (1 - lim%2), elim =  lim - (lim%2);
  int olo = 1, ohi = olim;
  int elo = 0, ehi = elim;

  for (char c: s) {
    swap(olo, elo);
    swap(ohi, ehi);

    if (c == '0' || c == '?') {
      olo = max(1, olo - 1);
      elo = max(0, elo - 1);
    } else {
      olo++;
      if (olo > lim) olo = INF;
      elo++;
      if (elo > lim) elo = INF;
    }

    if (c == '1' || c == '?') {
      ohi = min(olim, ohi + 1);
      ehi = min(elim, ehi + 1);
    } else {
      ohi--;
      if (ohi < 0) ohi = -INF;
      ehi--;
      if (ehi < 0) ehi = -INF;
    }

//    fprintf(stderr, ">> odd: [%d, %d], even: [%d, %d]\n", olo, ohi, elo, ehi);
  }

  return olo <= ohi || elo <= ehi;
}

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  string s; cin >> s;
  int lo = 1, hi = s.size();
  while (lo < hi) {
    int mid = (lo + hi) / 2;
    if (valid(s, mid)) {
      hi = mid;
    } else {
      lo = mid + 1;
    }
  }
  cout << lo << endl;

  return 0;
}


Measured memory_bytes: 4280
#include<stdio.h>
#define max(a,b) (a > b ? a : b)
int main()
{
	int a, b ,c ,d;
	scanf ("%d %d %d %d", &a, &b, &c, &d);
	long long sun_one = a * b, sun_two = c * d;
	printf ("%lld\n", max(sun_one, sun_two));
	return 0;
}

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

int main () {
  int n;
  cin >> n;
  vector<int> d (n);
  for (int i = 0; i < n; i++) {
    cin >> d[i];
  }
  sort (d.begin(), d.end());
  
  if (n % 2 == 1)
    cout << 0 << endl;
  
  else {
    int x = n/2;
    cout << d[x] - d[x-1] << endl;
  }
}

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

int main() {
	long long N, T, A[3000], B[3000], INF = 1000000000, ANS = 0;
	static long long LDP[3010][3010] = {}, RDP[3010][3010] = {};
	cin >> N >> T;
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < T; j++) {
			LDP[i + 1][j] = max(LDP[i + 1][j], LDP[i][j]);
			if (j + A[i] < T) {
				LDP[i + 1][j + A[i]] = max(LDP[i + 1][j + A[i]], LDP[i][j] + B[i]);
			}
		}
	}
	for (int i = N - 1; i >= 0; i--) {
		for (int j = 0; j < T; j++) {
			RDP[i][j] = max(RDP[i][j], RDP[i + 1][j]);
			if (j + A[i] < T) {
				RDP[i][j + A[i]] = max(RDP[i][j + A[i]], RDP[i + 1][j] + B[i]);
			}
		}
	}
	for (int i = 0; i < N; i++) {
		long long MAX = 0;
		for (int j = 0; j < T; j++) {
			MAX = max(MAX, LDP[i][j] + RDP[i + 1][T - j - 1]);
		}
		ANS = max(ANS, MAX + B[i]);
	}
	cout << ANS << endl;
}

Measured memory_bytes: 141696
import java.util.*;


public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        char chr = sc.next().charAt(0);
        if (Character.isUpperCase(chr)) {
            System.out.println("A");
        } else {
            System.out.println("a");
        }
    }
}

Measured memory_bytes: 26944
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n; cin >> n;
	int m = 0;
	vector<pair<int, int>> res;
	if (n % 2 == 1)
	{
		for (int i = 1; i < n; ++i)res.push_back({ i,n });
		--n;
	}
	for (int i = 1; i < n; ++i)for (int j = i + 1; j <= n; ++j)
	{
		if (i + j == n + 1)continue;
		res.push_back({ i,j });
	}
	cout << res.size() << endl;
	for (auto p : res)cout << p.first << " " << p.second << endl;
}

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

int main()
{
  ll n;
  cin >> n;
  ll ans = 0;
  if(n % 2 == 0)
    ans = n / 2;
  else ans = (n / 2) + 1;
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <sstream>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef pair<double,double> P;
const int MAX=1000000000;

int main() {
  vector<P> a[3];
  for(int i=0; i<3; i++) {
    for(int j=0; j<8; j++) {
      double x,y;
      cin >> x >> y;
      a[i].push_back(P(y,x));
    }
    sort(a[i].begin(),a[i].end());
  }
  vector<P> b;
  for(int i=0; i<3; i++) {
    b.push_back(P(a[i][2].first,a[i][2].second));
    b.push_back(P(a[i][3].first,a[i][3].second));
  }
  sort(b.begin(),b.end());
  for(int i=0; i<3; i++) {
    for(int j=0; j<2; j++) printf("%d %.2f\n",(int)a[i][j].second,a[i][j].first);
  }
  for(int j=0; j<2; j++) printf("%d %.2f\n",(int)b[j].second,b[j].first);
  return 0;
}


Measured memory_bytes: 1244
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")


int main() {
	
	int N;
	cin >> N;
	PRI((N + 1) / 2);
	
	return 0;
}

Measured memory_bytes: 3636