akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    if (n < 3 || (n & (n-1)) == 0) { cout << "No\n"; return 0; }
    cout << "Yes\n1 2\n2 3\n";
    cout << 3 << ' ' << 1+n << '\n'
         << 1+n << ' ' << 2+n << '\n'
         << 2+n << ' ' << 3+n << '\n';
    for (int k = 4; k+1 <= n; k+=2)
        cout << k << ' ' << k+1 << '\n'
             << k+1 << ' ' << 1 << '\n'
             << 1 << ' ' << k+n << '\n'
             << k+n << ' ' << k+n+1 << '\n';
    if (n%2==0) {
        int a = n & (n-1), b = n - a;
        cout << a+1 << ' ' << n << '\n'
             << b+n << ' ' << 2*n << '\n';
    }
}


Measured memory_bytes: 2304
def main():
    import sys
    input = sys.stdin.readline

    X, Y, A, B, C = map(int, input().split())
    P = list(map(int, input().split()))
    Q = list(map(int, input().split()))
    R = list(map(int, input().split()))

    apple = []
    for p in P:
        apple.append((p, 1))
    for q in Q:
        apple.append((q, 2))
    for r in R:
        apple.append((r, 3))
    apple.sort(key=lambda x: x[0])

    XY = X+Y
    ans = 0
    while True:
        s, flg = apple.pop()
        if flg == 1 and X == 0:
            continue
        if flg == 2 and Y == 0:
            continue
        ans += s
        if flg == 1:
            X -= 1
        elif flg == 2:
            Y -= 1
        XY -= 1
        if XY == 0:
            break
    print(ans)


if __name__ == '__main__':
    main()


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

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

  int ans = 0;
  for (int i = 0; i < n; i++)
  {
    long long x,y;
    cin >> x >> y;
    if(x*x+y*y<=d*d) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3572
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    ll ans = k;
    REP(i,n-1){
        ans *= (k-1);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define loop(times) for(int i=0;i<(times);i++)

using namespace std;

int main() {
    while(1<2){
        int n,sum=0;
        cin >>n;
        
        if(n==0)break;
   
        vector<pair<int,int> > tre(n);
        loop(n)cin>>tre.at(i).second>>tre.at(i).first;
        sort(tre.begin(),tre.end());
        loop(n){
            sum+=tre.at(i).second;
            if(sum>tre.at(i).first){
                cout<<"No"<<endl;
                break;
            }
            if(i==n-1){
                cout<<"Yes"<<endl;
                break;
            }
    }
    }
}


Measured memory_bytes: 3088
#include <iostream> 
#include <string>
using namespace std ;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a==b)
		cout<<"Draw";
	else if (a==1)
		cout<<"Alice";
	else if (b==1)
		cout<<"Bob";
	else if (a>b)
		cout<<"Alice";
	else if (b>a)
		cout<<"Bob";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf INT_MAX
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(int *)a-*(int *)b;
}

int r;

void f(int n,int m,int x,int c){
	int i;
	if(c>4){
		return ;
	}
	for(i=m;x+i*i<=n;i++){
		if(x+i*i==n){
			r++;
			return ;
		}
		else{
			f(n,i,x+i*i,c+1);
		}
	}
}

int main(void){
	int n;
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		r=0;
		f(n,1,0,1);
		print(r);
	}
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define int long long int
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int>>
#define umpii unordered_map<int,int>
#define mem(a,b) memset(a, b, sizeof a)
#define mii map<int,int>
#define pqh priority_queue<int>
#define pql priority_queue<int,vi,greater<int>>
#define setbits(x) __builtin_popcountll(x);
#define zerobits(x)__builtin_ctzll(x);
#define dbg(x) cerr<<#x<<" :: "<<x<<endl;
#define dbg2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
const int INF = 1e9;
#define mod 1000000007
int a[100005];
int n; 
int dp[100005]; 
int k;
int func(int ind)
{
	if(ind==(n-1))
		return 0;
	else if(dp[ind]!=-1) return dp[ind];
	else
	{
		int ans = 1e9+5; 
		for(int i = 1;i<=k;i++)
		{
			if(ind+i<n)
				ans = min(ans,abs(a[ind+i]-a[ind]) + func(ind+i));
 
		}
		return dp[ind] = ans; 
	}
 
}
int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
    cin >> n >> k;
    for(int i=0;i<n;i++) cin >> a[i]; 	
    mem(dp,-1); 
    cout << func(0); 

	return 0;
}

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

string s;
int a,b,c,d;

int main()
{
	cin>>s;
	a=s[0]-'0';b=s[1]-'0';c=s[2]-'0';d=s[3]-'0';
	
	for(int i=0;i<2;i++) for(int j=0;j<2;j++) for(int k=0;k<2;k++)
	{
		int res=a;
		if(i==0) res+=b; else res-=b;
		if(j==0) res+=c; else res-=c;
		if(k==0) res+=d; else res-=d;
		if(res==7)
		{
			cout<<a;
			if(i==0) putchar('+'); else putchar('-');
			cout<<b;
			if(j==0) putchar('+'); else putchar('-');
			cout<<c;
			if(k==0) putchar('+'); else putchar('-');
			cout<<d;
			puts("=7");
			return 0;
		}
	}
}

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

#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define debug(a) cout << #a << " = " << a << endl;
#define endl "\n"
#define MOD (int) 1e9+7
#define inf (int) (1e18)

void solve(){
    ll AC=0,TLE=0,WA=0,RE=0;
    long int n;
    cin>>n;
    while(n--){
        string s;
        cin>>s;
        if(s=="AC") AC++;
        else if(s=="TLE") TLE++;
        else if(s=="WA") WA++;
        else if(s=="RE") RE++;
    }
    cout<<"AC x "<<AC<<endl;
    cout<<"WA x "<<WA<<endl;
    cout<<"TLE x "<<TLE<<endl;
    cout<<"RE x "<<RE<<endl; 
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int t=1;
    // cin >> t;
    for(long int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    string str;
    cin >> str;
    int count = 0;
    for(int i = 0; i < str.size()/2; i++){
        if(str.at(i) != str.at(str.size()-1-i)){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string.h>
#include <queue>
#define in insert
using namespace std;
typedef pair<int,int>P;

bool g[252],b[252];
set<int> go[252],back[252];

void fr(int pos){
	if(g[pos])return;
	g[pos]=1;
	for(set<int>::iterator i=go[pos].begin();i!=go[pos].end();i++)fr(*i);
}

void ag(int pos){
	if(b[pos])return;
	b[pos]=1;
	for(set<int>::iterator i=back[pos].begin();i!=back[pos].end();i++)ag(*i);
}

int main(){
	
	for(int mx,n;cin>>mx,mx;){
		cin>>n;
		memset(g,0,sizeof(g));
		memset(b,0,sizeof(b));
		for(int i=0;i<252;i++)go[i].clear(),back[i].clear();
		vector<int>mass(n+2,0);
		for(int i=1;i<=n;i++)cin>>mass[i];
		for(int i=0;i<mass.size();i++){
			for(int j=1;j<=mx;j++){
				int nx=min(n+1,max(0,i+j+mass[i+j]));
				if(i==nx)continue;
				go[i].in(nx);
				back[nx].in(i);
			}
		}
		fr(0);
		ag(n+1);
		bool flag=1;
		for(int i=0;i<=n+1;i++){
			if(g[i]&&!b[i])flag=0;
		}
		
		if(flag)cout<<"OK"<<endl;
		else cout<<"NG"<<endl;
		
		
	}
	return 0;
}


Measured memory_bytes: 1328
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BChristmasEveEve solver = new BChristmasEveEve();
        solver.solve(1, in, out);
        out.close();
    }

    static class BChristmasEveEve {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int n = in.ints();
            int[] p = in.ints(n);
            Arrays.sort(p);
            long sum = IntStream.of(p).sum() - (p[n - 1] / 2);
            out.println(sum);
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

        public int[] ints(int length) {
            return IntStream.range(0, length).map(x -> ints()).toArray();
        }

    }
}



Measured memory_bytes: 26580
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,K; cin>>N>>K;
    cout<<(N-1+K-2)/(K-1)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int i,j,k,l,n,p,sum=0;
    vector<long long int >v;
    vector<long long int >::iterator it;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>p;
        v.push_back(p);
    }
    sort(v.begin(),v.end());
    for(it=v.begin();it!=v.end();it++)
    {
        sum=sum+*it;
    }
    sum=sum-v[n-1];
//    cout<<sum<<endl;
//    cout<<v[n-1];
    if(sum>v[n-1])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
W,H,N = map(int, input().split())

xya = [0]*N
for i in range(N):
    xya[i] = map(int, input().split())
WH = []
for h in range(H):
    w = [0]*W
    WH.append(w)

for x,y,a in xya:
    if a == 1:
        for w in WH:
            for i in range(0,x):
                w[i] = 1
    elif a == 2:
        for w in WH:
            for i in range(x,W):
                w[i] = 1
    elif a == 3:
        for i in range(0,y):
            w = WH[i]
            for j in range(len(w)):
                w[j] = 1
    elif a == 4:
        for i in range(y,H):
            w = WH[i]
            for j in range(len(w)):
                w[j] = 1

result = 0
for w in WH:
    result += sum(w)
print(W*H - result)

Measured memory_bytes: 40688
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b;
    cin >> a >> b;
    if(a > b) swap(a, b);
    int ans = 2;
    if(a != 1) ans = 1;
    if(b != 3) ans = 3; 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define endl '\n'
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#include "string"

const int inf = 1e18;

int32_t main(){
	boost;
	int n, m, p;
	cin >> n >> m >> p;
	vector < int > d(n + 1, inf);
	vector < array <int, 3> > edge;
	for(int i = 0, a, b, c; i < m; i++) {
		cin >> a >> b >> c;
		edge.push_back({a, b, p - c});
	}

	auto bellman = [&]() {
		for(int i = 0; i < n; i++) {
			for(auto e : edge) {
				if(d[e[0]] < inf && d[e[1]] > d[e[0]] + e[2] ) {
					d[e[1]] = d[e[0]] + e[2];
				}
			}
		}
	};

	d[1] = 0;
	bellman();
	auto tmp = d;
	bellman();

	for(int i = 1; i <= n; i++){
		if(d[i] != tmp[i])
			d[i] = -inf;
	}
	bellman();
	
	if(tmp[n] != d[n] or tmp[n] >= inf)
		cout << -1 << endl;
	else
		cout << max(-d[n],0LL) << endl;
}



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

int main() {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if (x - r >= 0 && y - r >= 0 && x + r <= W && y + r <= H) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3092
#include <unordered_set>
#include <string>
#include <iostream>
using namespace std;

int main() {
        typedef unordered_set<string> set_t;
        set_t A;
        int n;
        string s,t;
        cin >> n;
        for (int i = 0; i<n; i++){
                cin >> s >> t;
                if (s == "insert"){
                        A.insert(t);
                }
                else if (s == "find"){
                        bool find = A.count(t);
                        cout << (find?"yes":"no") << endl;
                }
        }
}

Measured memory_bytes: 32228
#include<stdio.h>

int linearSearch(int A[],int n, int key){
  int i = 0;
  A[n] = key;
  while(A[i] != key) i++;
  return (n!=i);
}

int main(){
  int i,n,A[10001],q,key,sum=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(linearSearch(A,n,key))sum++;
  }
  printf("%d\n",sum);
  
  return 0;
}


Measured memory_bytes: 2128
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
	int cards[4][13];
	int marktemp, temp, i1, i2, n;
	char markctemp;

	for (i1 = 0; i1 < 4; i1++) {
		for (i2 = 0; i2 < 13; i2++) {
			cards[i1][i2] = 0;
		}
	}
	temp = 0;

	cin >> n;

	for (i1 = 0; i1 < n; i1++) {
		cin >> markctemp >> temp;

		switch (markctemp) {
		case 'S':
			marktemp = 0;
			break;
		case 'H':
			marktemp = 1;
			break;
		case 'C':
			marktemp = 2;
			break;
		case 'D':
			marktemp = 3;
			break;
		}
		
		cards[marktemp][temp - 1] = 1;
	}

	for (i1 = 0; i1 < 4; i1++) {
		for (i2 = 0; i2 < 13; i2++) {
			if (cards[i1][i2] == 0) {
				switch (i1) {
				case 0:
					printf("S %d\n", i2 + 1);
					break;
				case 1:
					printf("H %d\n", i2 + 1);
					break;
				case 2:
					printf("C %d\n", i2 + 1);
					break;
				case 3:
					printf("D %d\n", i2 + 1);
					break;
				}
			}
		}
	}
}


Measured memory_bytes: 3152
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    ull N,A,B;
    cin>>N>>A>>B;
    if(A>=N) cout<<N<<endl;
    else if(A+B>=N) cout<<A<<endl;
    else {
        ull answer=0;
        ull N2=N;
        N2/=(A+B);
        answer+=(N2*A);
        N-=(A+B)*N2;
        answer+=min(N,A);
        cout<<answer<<endl;
    }
}

Measured memory_bytes: 768
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int x = stdIn.nextInt();
        
        int a[][]= new int[4][13];
        

        for(int k =0;k<x;k++){
                    String mark = stdIn.next();
                    int num =stdIn.nextInt();
                	
                    if(mark.equals("S")){
                  		a[0][num-1] = 1;
                    }else if(mark.equals("H")){
                 		a[1][num-1] = 1;
                    }else if(mark.equals("C")){
                        a[2][num-1] = 1;
                        
                    }else if(mark.equals("D")) {
                        a[3][num-1] = 1;
                    }else{
                        a[4][num-1] =1;
                    }
                    
                }
 		 
                             
            for(int z =0;z<4;z++){
                for(int o =0;o<13;o++){
                    
            		if(a[z][o]==0){
                        if(z==0){
                            System.out.println("S"+" "+(o+1));
                        }
                        else if(z==1){
                            System.out.println("H"+" "+(o+1));
                        }else if(z == 2){
                            System.out.println("C"+" "+(o+1));
                        }else{
                        	System.out.println("D"+" "+(o+1));                   
                   		}
                                               
                    }
          		}
         	}
    }
}
                                               


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

int main(){
    int N;
    scanf("%d", &N);

    char S[100001];
    scanf("%s", S);

    int ans = 1;
    char test = S[0];
    for(int i=0; i<N; i++){
        if(test != S[i]){
            ans++;
            test = S[i];
        }
    }

    printf("%d\n", ans);

    return 0;
}

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

int main() {
	string str;
	cin >> str;

	if (str[2] == str[3] && str[4] == str[5]) {
		cout << "Yes";
		return 0;
	}
	else {
		cout << "No" << endl;
		return 0;
	}




}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int n, pret=0, prex=0, prey=0, t, x, y;
  cin >> n;
  bool ans=true;
  for(int i=0;i<n;i++){
    cin >> t >> x >>y;
    int man = abs(x-prex) + abs(y-prey);
    if(t - pret< man || (t-pret)%2!=man%2)ans=false;
    pret = t;
    prex = x;
    prey = y;
  }
  cout << (ans?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, sum=0;
    cin >> n;
    int v[n], c[n];
    for (int j = 0; j < n; j++ ) cin >> v[j];
    for (int j = 0; j < n; j++ ) cin >> c[j];
    
    for (int i = 0; i < n; i++ ) {
        if (c[i] < v[i]) sum += v[i] - c[i];
    }
    
    cout << sum << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <bitset>
#include <tuple>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i <(int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i,k,n) for (int i = (int)(n)-1; i >= k; i--)
#define INF 1LL<<61
int main(){
   int n;
   cin >> n;
    cout << setprecision(10) << (double)((n+1)/2)/n << endl;
    return 0;
}


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

#define lol long long

int main() {

	lol n;
	cin >> n;
	bool flag = false;

	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			if (4 * i + 7 * j == n) flag = true;
		}
	}

	if (flag) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n;
	vll ans;
	cin >> n;
	ll cnt=0,sum=0;
	while(sum<n){
		cnt++;
		sum+=cnt;
		ans.pb(cnt);
	}
	for(auto&& e:ans){
		if(e!=sum-n) cout << e << endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A, ll x = 10){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

void solve(){
  int ans = 0;
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    if(s[i] != s[s.size()-1-i]){
      ans++;
      s[i] = s[s.size()-1-i];
    }
  }
  cout << ans << endl;
}

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


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int N,M;
    cin >> N;
    vector <string> s(N);
    for (int i = 0; i < N; ++i) {
        cin >> s.at(i);
    }
    cin >> M;
    vector <string> t(M);
    for (int i = 0; i < M; ++i) {
        cin >> t.at(i);
    }

    vector<int> red(N);
    for (int i = 0; i < N; ++i) {
        string tar = s.at(i);
        for (int j = 0; j < M; ++j) {
            if (tar == t.at(j)) {
                red.at(i)++;
            }
        }
    }

    vector<int> blue(N);
    for (int l = 0; l < N; ++l) {
        string tar = s.at(l);
        for (int i = 0; i < N; ++i) {
            if (tar == s.at(i)) {
                blue.at(l)++;
            }
        }
    }
    int max = -100;
    int sum = 0;
    for (int k = 0; k < N; ++k) {
        sum = blue.at(k) - red.at(k);
        if (max < sum) {
            max = sum;
        }
    }
    if (max < 0) {
        max = 0;
    }
    cout << max << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=0;
	cin >>n;
	Vi a(n,0);
	map<int,int>dis;
	rep(i,n){
		dis[i]+=0;
		if(i!=0){
		cin>>a[i];
		dis[a[i] - 1]++;
		}
		
	}
	repi(itr,dis){
		cout<<(itr->S)<<endl;
	}
}

Measured memory_bytes: 13552
#include<stdio.h>
#include <stdlib.h>
int main()
{
  char N[200001]={"0"};
  int n;
  int sum = 0;
  scanf("%s",N);
  
  for(int i=0;N[i]!='\0';i++){
    n = (int)(N[i]-'0');
    sum += n;
    sum %= 9;
  }

  if(sum == 0){printf("Yes");}else{printf("No");}
}

Measured memory_bytes: 1920
## input 
N,M = map(int,input().split())
num = list(map(int,input().split()))
#print(num)

## 
num_sum = sum(num)
thresh = num_sum / (4 * M)
#print(thresh)

i = 0 
for x in num:
  if float(x) >= thresh:
    #print(float(x))
    i += 1

if i >= M:
  print("Yes")
else:
  print("No")



Measured memory_bytes: 3060
N = int(input())

A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))
C_list = list(map(int, input().split()))

manzoku = sum(B_list)

before = A_list[0]
for i in range(1, N):
  if A_list[i] == before + 1:
    manzoku += C_list[before-1]
  before = A_list[i]

print(manzoku)

Measured memory_bytes: 3064
N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]

ans = 10 ** 10

# 4bit search
for i in range(4**N):
    mask = i
    NowCost = 0
    Group0 = []
    Group1 = []
    Group2 = []
    NonGroup = []
    for j in range(N-1, -1, -1):
        if mask % 4 == 0:
            Group0.append(L[j])
            mask //= 4
        elif mask % 4 == 1:
            Group1.append(L[j])
            mask //= 4
        elif mask % 4 == 2:
            Group2.append(L[j])
            mask //= 4
        else:
            NonGroup.append(L[j])
            mask //= 4
    if len(Group0) == 0 or len(Group1) == 0 or len(Group2) == 0:
        continue
    NowCost += 10 * (len(Group0) - 1)
    LengthGroup0 = sum(Group0)
    NowCost += 10 * (len(Group1) - 1)
    LengthGroup1 = sum(Group1)
    NowCost += 10 * (len(Group2) - 1)
    LengthGroup2 = sum(Group2)
    NowCost += abs(A - LengthGroup0)
    NowCost += abs(B - LengthGroup1)
    NowCost += abs(C - LengthGroup2)
    ans = min(ans, NowCost)
print(ans)


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main()
{
	int a,b,k,i,person=1;
	cin>>a>>b>>k;
	for(i=0;i<k;i++)
	{
		person=(person+1)%2;
		if(person==0)
		{
			if(a%2==1)  a--;
			b+=a/2;
			a/=2;
		}
		else
		{
			if(b%2==1)  b--;
			a+=b/2;
			b/=2;
		}
	}
	cout<<a<<' '<<b;
	return 0;
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
const int MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
struct edge { int v, w; };

int main() {
	int N; cin >> N;
	vector<int> b(100001);
	while (N--) {
		int x; cin >> x;
		b[x]++;
	}
	int ma = 0;
	rep(x, 100001) {
		int sum = b[x];
		if (x - 1 >= 0) sum += b[x - 1];
		if (x + 1 <= 100000) sum += b[x + 1];
		ma = max(ma, sum);
	}
	cout << ma << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef vector<int> V;
typedef pair<int,int> P;
typedef vector<vector<int>> Graph;

int main() {
    ll n;
    cin >> n;
    string s = "zabcdefghijklmnopqrstuvwxy";
    string ans = "";
    ll tmp=0,cnt=1;
    while(n>0){
        tmp = n%26;
        if(tmp==0) n--;
        ans += s[tmp];
        n /= 26;
    }
    reverse(ALL(ans));
    cout << ans << endl;
}

Measured memory_bytes: 3624
//http://abc058.contest.atcoder.jp/tasks/abc058_a
#include <iostream>
using namespace std;

int a,b,c;

void read_input(){
    cin >> a >> b >> c;
}

int main(void){
    read_input();
    if (b-a == c-b){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n,s;cin>>n>>s;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    vector<vector<ll> >dp(n+1,vector<ll>(s+1));
    dp[0][0]=1;
    rep(i,n){
        rep(j,s){
            dp[i+1][j]=(dp[i][j]+dp[i+1][j])%mod;
            if(j>0)if(j+a[i]<=s)dp[i+1][j+a[i]]=(dp[i+1][j+a[i]]+dp[i][j])%mod;
            if(j==0&&a[i]<=s){
                dp[i+1][a[i]]=(dp[i+1][a[i]]+i+1)%mod;
            }
        }
    }
    ll ans=0;
    rep(i,n+1){
        ans=(ans+dp[i][s]*(n+1-i))%mod;
        //cout<<i<<' '<<dp[i][s]<<endl;
    }
    cout<<ans<<endl;
}

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

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

//jから始まる長さiのスタックの最小コスト
ll dp[110][110];

int main(){
    int n;
    cin >> n;
    vector<pair<ll,ll>> v;
    REP(i,n) {
        int t,b;
        cin >> t >> b;
        v.pb({t,b});
    }
    REP(i,110) REP(j,110) dp[i][j] = inf;
    for (int w = 1; w <= n; w++) {
        for (int from = 0; from + w - 1 < n; from++) {
            int to = from + w - 1;
            if (from == to) {
                dp[w][from] = 0;
                continue;
            }
            for (int l1 = 1; l1 < w; l1++) {
                int l2 = w - l1;
                dp[w][from] = min(dp[w][from], dp[l1][from] + dp[l2][from + l1] + v[from].fi * v[from + l1 - 1].se * v[from + l1].fi * v[to].se);
            }
        }
    }
    // for (int i = 0; i <= n; i++) {
    //     for (int j = 0; j <= n; j++) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    cout << dp[n][0] << endl;
}


Measured memory_bytes: 3160
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        long sum = 0;
        for (int i = 0; i < m; i++) {
            sum += Integer.parseInt(sc.next());
        }
        if (sum > n) {
            System.out.println(-1);
        } else {
            System.out.println(n - sum);
        }
    }
}

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

using int64 = long long;
using i64 = int64;

template<typename T>
using p_que = priority_queue<T>;
template<typename T>
using rp_que = priority_queue<T, vector<T>, greater<T>>;

constexpr int INF = (1 << 30) - 1;
constexpr int64 INF64 = (1ll << 60) - 1;

#define rep(i, N) for(int i=0;i<(int)(N);++i)
#define rep1(i, N) for(int i=1;i<=(int)(N);++i);
#define fs first
#define sc second
#define e_b emplace_back
#define m_p make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()

template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	return os << "P(" << p.first << ", " << p.second << ")";
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "[";
	for (auto& e : v) os << e << ", ";
	return os << "]";
}
template <typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& m) {
	os << "{" << endl;
	for (auto& e : m) os << "(" << e.first << ", " << e.second << ")" << endl;
	return os << "}";
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& s) {
	os << "{" << endl;
	for (auto& e : s) os << ", " << e << endl;
	return os << "}";
}

template<typename T>
vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int64 gcd(int64 x, int64 y) {
	if (x == 0 || y == 0) return 0;
	int64 r;
	while ((r = y % x) != 0) {
		y = x;
		x = r;
	}
	return x;
}
int64 lcm(int64 x, int64 y) {
	if (x == 0 || y == 0) return 0;
	return x / gcd(x, y) * y;
}

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

void Main();
signed main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	Main();
}

/*----------------------------Insert from here!----------------------------*/

map< int64_t, int > prime_factor(int64_t n) {
	map< int64_t, int > ret;
	for (int64_t i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

struct UnionFind {
	vector< int > data;

	UnionFind(int sz) {
		data.assign(sz, -1);
	}

	bool unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) return (false);
		if (data[x] > data[y]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
		return (true);
	}

	int find(int k) {
		if (data[k] < 0) return (k);
		return (data[k] = find(data[k]));
	}

	int size(int k) {
		return (-data[find(k)]);
	}
};

/*----------------------------Insert above here----------------------------*/

//const int MOD = 998244353;
//const int MOD = 1e9 + 7;

void Main() {
	int H, A, B; cin >> H >> A >> B;

	int ans = 0;
	for (int i = A; i <= B; ++i) {
		if (H % i == 0) {
			ans++;
		}
	}

	cout << ans << endl;
}


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

#define DIV 1000000007

long long N;
// a, b; count(a,b), count(a,-b)
map<pair<long long, long long>, pair<long long, long long> > memo;


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

long lcm( long m, long n ){
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	return ((m / gcd(m, n)) * n); 
}

long long modpow(long long ori, long long po){
	long long res = 1;
	while(po > 0){
		if(po&1){
			res *= ori;
			res %= DIV;
		}
		ori *= ori;
		ori %= DIV;
		po >>= 1;
	}
	return res;
}

int main(){
	cin >> N;
	long long one = 0;
	for(long long i = 0; i < N; i++){
		long long a, b;
		cin >> a >> b;
		if(a  == 0 && b == 0){
			one++;
			continue;
		}
		if(a == 0) {
			memo[make_pair(0, 0)].first++;;
			continue;
		}
		if(b == 0) {
			memo[make_pair(0, 0)].second++;;
			continue;
		}

		long long divi = gcd(a, b);
		a/=divi;
		b/=divi;
		if(a  > 0 && b > 0){
			memo[make_pair(a, b)].first++;;
			continue;
		}

		if(a  < 0 && b < 0){
			memo[make_pair(-1 * a, -1 * b)].first++;;
			continue;
		}

		memo[make_pair(abs(b), abs(a))].second++;;
	}

	long long ans = 1;
	for (const auto& [key, value] : memo){
		ans *= (modpow(2, value.first) + modpow(2, value.second) - 1);
		ans %= DIV;
	}
	cout << (ans - 1 + DIV + one)%DIV << endl;
}


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

int main()
{
    int H, W, M;
    cin >> H >> W >> M;
    vector<int> H_bomb_vec(H, 0);
    vector<int> W_bomb_vec(W, 0);
    set<pair<int, int>> bomb_set;  
    int h, w;
    for (int i = 0; i < M; ++i) {
        cin >> h >> w;
        --h; --w;
        ++H_bomb_vec.at(h);
        ++W_bomb_vec.at(w);
        bomb_set.insert({h, w});
    }
    int max_h = *max_element(H_bomb_vec.begin(), H_bomb_vec.end());
    int max_w = *max_element(W_bomb_vec.begin(), W_bomb_vec.end());
    vector<int> H_candi;
    vector<int> W_candi;
    for (int i = 0; i < H; ++i) {
        if (max_h == H_bomb_vec.at(i)) {
            H_candi.push_back(i);
        }
    }
    for (int i = 0; i < W; ++i) {
        if (max_w == W_bomb_vec.at(i)) {
            W_candi.push_back(i);
        }
    }
    int num = max_h + max_w;
    for (int h : H_candi) {
        for (int w : W_candi) {
            if (!bomb_set.count({h, w})) {
                cout << num << endl;
                return 0;
            }
            --M;
            if (M <= 0)
                break;
        }
    }
    cout << num - 1 << endl;
}


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

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    long h = sc.nextLong();
    int a = 0;
    long ans = 1;
    int i = 1;
    while(h != 1){
      h /= 2;
      ans += (long)(Math.pow(2,i));
      i++;
    }
    System.out.println(ans);    
  }
}

Measured memory_bytes: 21972
import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.*;
import java.math.BigInteger;

public class Main {
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = in.nextInt();
        int m = in.nextInt();
        int k = in.nextInt();
        int count = 0;
        int[] a = {n,m,k};
        Arrays.sort(a);
        if(a[0]%2==0 && a[1]%2==0 && a[2]%2==0 || a[0]%2==1 && a[1]%2==1 && a[2]%2==1 ){
            out.print((a[2]-a[1])/2 + (a[2]-a[0])/2);
        }
        else{
            int evencount = 0;
            int oddcount = 0;
            for(int i = 0; i<3; i++){
                if(a[i]%2==0) ++evencount;
                else ++oddcount;
            }
            if(evencount>oddcount){
                for(int i = 0; i<3; i++){
                    if(a[i]%2==0) ++a[i];
                }
            }
            else{
                for(int i = 0; i<3; i++){
                    if(a[i]%2==1) ++a[i];
                }
            }
            out.print((a[2]-a[1])/2 + (a[2]-a[0])/2 + 1);
        }
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext() {
            String next = null;
            try {
                next = reader.readLine();
            } catch (Exception e) {
            }
            if (next == null) {
                return false;
            }
            tokenizer = new StringTokenizer(next);
            return true;
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
    }
}



Measured memory_bytes: 32848
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int n, m, a[50], b[50], k;
  scanf("%d %d", &n, &m);
  for(int i = 0; i < m; i++) scanf("%d %d", &a[i], &b[i]);
  
  for(int i = 1; i <= n; i++){
    k = 0;
    for(int j = 0; j < m; j++){
      if(i == b[j] || i == a[j]) k++;
    }
    printf("%d\n", k);
  }
  
  return 0;
}


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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n,ans=INF;
  string s;
  cin >> n >> s;
  vector<ll> W(n+1,0), E(n+1,0);
  rep(i,n){
    W[i+1] = W[i];
    E[i+1] = E[i];
    if(s[i]=='W') W[i+1]++;
    else E[i+1]++;
  }
  rep(i,n){
    ans = min(ans, W[i]+(E[n]-E[i+1]));
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 5396
#include <stdio.h>
#include <math.h>
#include<bits/stdc++.h>
using namespace std;
#define int long long int

int i,j,k,m;
main()
{
  int n;
  cin>>n;
  int m=0;
  for(i=sqrt(n);i>=2;i--)
  {
      if(n%i==0) {m=i;break;}
  }
  if(!m)
  {
      int t=0;
      while(n>0)
      {
          n=n/10;
          t++;
      }
      cout<<t<<endl;
  }
  else
  {
      int k=n/m;
       int t=0,t1=0;
      while(m>0)
      {
          m=m/10;
          t++;
      }

      // int t=0;
      while(k>0)
      {
          k=k/10;
          t1++;
      }
      cout<<max(t,t1)<<endl;
  }
}



Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
const int N=1e5+3;
ll a[N];
int main()
{
    ft
    ll t,i,j,n,m,l,x,y,s=0;
    cin>>n>>x;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    for(i=1; i<n; i++)
    {
        if(a[i-1]+a[i]>x)
        {
            m=a[i]+a[i-1]-x;
            m=min(a[i],m);
            a[i]-=m;
            s+=m;
            if(a[i-1]+a[i]>x)
            {
                m=a[i]+a[i-1]-x;
                s+=m;
                a[i-1]-=m;
            }
        }
    }
    cout<<s<<"\n";
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
	int used[31];
	memset(used, 0, sizeof(used));

	rep(i, 28) {
		int x;
		cin >> x;

		used[x]++;
	}

	REP(i, 1, 31) {
		if(used[i]) continue;
		cout << i << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <climits>
#include <bits/stdc++.h>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;
typedef long long ll;


typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする

vector<int> G[100005];
std::vector<P> tree[100010];

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

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)

ll i,j,ii,jj;
ll n,m;
ll num,sum;
bitset<2000005> dp;

int main(){
    cin>>n;
    dp[0]=1;
    for(i=0;i<n;i++){
        cin>>m;
        sum+=m;
        dp |= dp<<m;
    }
    for(i=(sum+1)/2;i<=2000004;i++){
        if(dp[i]){
            p(i);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 5632
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
using namespace std;

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

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

const UINT mod = 1000000007;

UINT PowMod(UINT x, UINT y)
{
	if (y == 0)
	{
		return 1;
	}
	else if (y == 1)
	{
		return x % mod;
	}
	else if (y % 2 == 0)
	{
		auto tmp = PowMod(x, y / 2);
		return tmp * tmp % mod;
	}
	else
	{
		auto tmp = PowMod(x, y / 2);
		return (tmp * tmp % mod) * x % mod;
	}
}

UINT getModInv(UINT N)
{
	return PowMod(N, mod - 2);
}

struct uf
{
	vector<INT> p;

	uf(INT n) : p(n)
	{
		for (size_t i = 0; i < n; i++)
		{
			p[i] = i;
		}
	}

	INT rt(INT n)
	{
		return p[n] == n ? n : p[n] = rt(p[n]);
	}

	void un(INT n, INT m)
	{
		p[rt(n)] = p[rt(m)];
	}

	bool eq(INT n, INT m)
	{
		return rt(n) == rt(m);
	}
};

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

	uf u(n);

	for (size_t i = 0; i < m; i++)
	{
		INT x, y, z;
		cin >> x >> y >> z;
		x--;
		y--;
		u.un(x, y);
	}

	INT ans = 0;
	for (size_t i = 0; i < n; i++)
	{
		if (u.rt(i) == i)
		{
			ans++;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[200005];
int main()
{
    ll n,d;
    cin>>d>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll x=0,y=0;
    x=d-(a[n-1]-a[0]);
    for(ll i=1;i<n;i++)
    {
        x=max(x,(a[i]-a[i-1]));
    }
        cout<<d-x<<endl;
    return 0;
}


Measured memory_bytes: 1792