akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << max(A * B, C * D) << endl;
    return 0;
}

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

int main() {
	string s ;
	cin >> s;
	long long counter = 0 , l = s.length() , temp = 0;
	for(int i = 0 ; i < l ; i++)
	{
		if(s[i]=='A' || s[i]=='T' || s[i]=='G' || s[i]=='C')
			temp++ ;
		else
			temp = 0;
		if(counter<temp)
			counter = temp;
	}
	cout << counter << endl;
	return 0;
}

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

int digit(int i)
{
    int res = 0;
    while(i){
        res += 1;
        i /= 10;
    }
    return res;
}
int main()
{
    ios::sync_with_stdio(false);
    long long N;
    cin >> N;
    long long a = 0, ans = N;
    while (a * a <= N){
        ++a;
        if (N % a != 0){
            continue;
        }
        int b = N / a;
        int rec = max(digit(a), digit(b));
        if (ans > rec) ans = rec;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main() {
    cin>>N;
    vec a(N);
    rep(i,N) cin>>a[i];
    ll ma, mi;
    rep(i,N){
        if(a[i] == *max_element(a.begin(), a.end())) ma = i;
        if(a[i] == *min_element(a.begin(), a.end())) mi = i;
    }
    cout<<N*2 - 1<<endl;
    if(a[ma] > abs(a[mi])){
        rep(i,N) cout<<ma+1<<' '<<i+1<<endl;
        rep(i,N-1) cout<<i+1<<' '<<i+2<<endl;
    }else{
        rep(i,N) cout<<mi+1<<' '<<i+1<<endl;
        rep(i,N-1) cout<<N-i<<' '<<N-1-i<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int mod=1e9+7;
void add(int &x,int y){
	x+=y;
	if(x>=mod) x-=mod;
}
int N,M,l[3000],r[3000];
int mn[3001],mx[3001];
int dp[3001][3001];
string s,so;
int main(){
	cin>>N>>M;
	cin>>s;
	so=s;
	rep(i,M) cin>>l[i]>>r[i],l[i]--;
	rep(t,2){
		s=so;
		rep(i,M){
			int c[2]={};
			for(int j=l[i];j<r[i];j++) c[s[j]-'0']++;
			for(int j=l[i];j<l[i]+c[t];j++) s[j]='0'+t;
			for(int j=l[i]+c[t];j<r[i];j++) s[j]='0'+(1-t);
		}
		if(t==0){
			rep(i,N) mn[i+1]=mn[i]+(s[i]=='1');
		}
		if(t==1){
			rep(i,N) mx[i+1]=mx[i]+(s[i]=='1');
		}
	}
	dp[0][0]=1;
	rep(i,N) rep(j,i+1) if(dp[i][j]){
		rep(k,2){
			int ni=i+1;
			int nj=j+k;
			if(mn[ni]<=nj&&nj<=mx[ni]) add(dp[ni][nj],dp[i][j]);
		}
	}
	cout<<dp[N][mn[N]]<<endl;
}


Measured memory_bytes: 12544
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()
#define MP make_pair

int main() {
	int n, m, ans = 0;
	vector<pair<int, int>> s(50);
	cin >> n >> m;
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		s[i] = MP(a - 1, b - 1);
	}
	REP(p, m) {
		int l[60][60];
		bool a = {};
		REP(i, 60) REP(j, 60) l[i][j] = INF;
		REP(i, 60) l[i][i] = 0;
		REP(i, m) {
			if (i != p) {
				l[s[i].first][s[i].second] = 1;
				l[s[i].second][s[i].first] = 1;
			}
		}
		REP(k, n) REP(i, n) REP(j, n) l[i][j] = min(l[i][j], l[i][k] + l[k][j]);
		REP(i, n) REP(j, n) if (l[i][j] == INF) a = true;
		if (a)ans++;
	}
	cout << ans << endl;
}

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



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

    Scanner cin;
    

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int M = cin.nextInt();
        long[] x = new long[N];
        long[] y = new long[N];
        long[] z = new long[N];
        for (int i = 0; i < N; i++)
        {
            x[i] = cin.nextLong();
            y[i] = cin.nextLong();
            z[i] = cin.nextLong();
        }

        long ans = 0;

        for (int a = -1; a <= 1; a+=2)
        {
            for (int b = -1; b <= 1; b+=2)
            {
                for (int c = -1; c <= 1; c+=2)
                {
                    List<long> l = new List<long>();
                    for (int i = 0; i < N; i++)
                    {
                        l.Add(x[i] * a + y[i] * b + z[i] * c);
                    }
                    l.Sort();
                    l.Reverse();

                    long tmp = 0;
                    for (int i = 0; i < M; i++)
                    {
                        tmp += l[i];
                    }
                    ans = Math.Max(ans, tmp);
                }
            }
        }

        Console.WriteLine(ans);

    }
    
}




class Scanner
{
    string[] s;
    int i;

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

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

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

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

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

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

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


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



Measured memory_bytes: 13396
n, k = map(int, input().split())
sushi = [list(map(int, input().split())) for _ in range(n)]
sushi.sort(key=lambda x: x[1], reverse=True)

leaders = []
others = []

appeared = [False] * (n + 1)
for t, d in sushi:
    if appeared[t]:
        others.append(d)
    else:
        leaders.append(d)
        appeared[t] = True

def cumsum(a):
    res = [0] * (len(a) + 1)
    for i in range(len(a)):
        res[i + 1] = res[i] + a[i]
    return res

cumsum_leaders = cumsum(leaders)
cumsum_others = cumsum(others)

ans = 0
for i in range(min(k, len(leaders)), 0, -1):
    if k - i > len(others):
        break
    score = i ** 2 + cumsum_leaders[i] + cumsum_others[k - i]
    ans = max(ans, score)

print(ans)

Measured memory_bytes: 33972
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r", stdin);
	freopen("output.txt","w", stdout);
	freopen("error.txt","w", stderr);
	#endif*/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n; string s;
	cin>>n;
	cin>>s;

	int r[n], g[n], b[n];
	r[n-1] = g[n-1] = b[n-1] = 0;
	if(s[n-1] == 'R') 
		r[n-1] = 1;
	else if(s[n-1] == 'G') 
		g[n-1] = 1;
	else if(s[n-1] == 'B') 
		b[n-1] = 1;

	for(int i = n-2; i >= 0; i--) {
		if(s[i] == 'R') {
			r[i] = r[i+1]+1;
			g[i] = g[i+1];
			b[i] = b[i+1];
		}
		else if(s[i] == 'G') {
			r[i] = r[i+1];
			g[i] = g[i+1]+1;
			b[i] = b[i+1];
		}
		else if(s[i] == 'B') {
			r[i] = r[i+1];
			g[i] = g[i+1];
			b[i] = b[i+1]+1;
		}
	}
	array<int,2> a[n];
	for(int i = 0; i < n; i++) {
		a[i][0] = i;
		if(s[i] == 'R')
			a[i][1] = 1;
		if(s[i] == 'G')
			a[i][1] = 2;
		if(s[i] == 'B')
			a[i][1] = 3;
	}

	ll ans = 0;
	
	for(int i = 0; i < n - 2; i++) {
		for(int j = i + 1; j < n - 1; j++) {
			if(s[i] != s[j]) {
				if(s[i] != 'R' && s[j] != 'R') {
					ans += r[j];
					if((2*j - i) < n && a[2*j - i][1] == 1)
						ans--;
				}
				else if(s[i] != 'G' && s[j] != 'G') {
					ans += g[j];
					if((2*j - i) < n && a[2*j - i][1] == 2)
						ans--;
				}
				else if(s[i] != 'B' && s[j] != 'B') {
					ans += b[j];
					if((2*j - i) < n && a[2*j - i][1] == 3)
						ans--;
				}
			}
		}
	}

	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3704
use std::io;
use std::str::FromStr;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    let mut it = buf.split_whitespace().map(|n| usize::from_str(n).unwrap());
    let mut s = it.next().unwrap();
    
    let h = s / 3600;
    s = s - (3600 * h);
    let m = s / 60;
    s = s - (60 * m);

    println!("{}:{}:{}",h,m,s);

    
}


Measured memory_bytes: 5032
from math import sqrt

def sd(nums):
    n   = len(nums)
    ave = sum(nums)/n

    return abs(sqrt(sum([(s - ave)**2 for s in nums])/n))

def main():
    while True:
        n = input()

        if n == '0':
            break

        nums = [int(x) for x in input().split()]
        print("{:f}".format(sd(nums)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 5716
# coding: utf-8
from fractions import gcd 
from functools import reduce
# my functions here!
def pin(type=int):
    return map(type,input().split())
#input
N,K =pin()
H = list(pin())
#solution
H.sort()
#print(H)
ans=0
if N > K:
    for i in range (K):
        H.pop()
    print(sum(H))
else:
    print(0)
#output
#print(ans)

Measured memory_bytes: 112840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1000100100;

int main() {
    ll N, M;
    cin >> N >> M;

    vector<ll> L(M), R(M);
    REP(i, M) {
        cin >> L[i] >> R[i];
    }

    ll minID = 1, maxID = N;
    REP(i, M) {
        if(L[i] > minID) {
            minID = L[i];
        } 

        if(R[i] < maxID) {
            maxID = R[i];
        }
    }

    if(maxID - minID >= 0) {
        cout << maxID - minID + 1 << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 4740
txt1 = "node {}: key = {}, "
txt2 = "parent key = {}, "
txt3 = "left key = {}, "
txt4 = "right key = {}, "

H = int(input())
A = [int(i) for i in input().split()]
A = [0] + A
for i,j in enumerate(A):
    if i==0:
        continue
    tmp = txt1.format(i, j)
    if not i == 1:
        tmp+=txt2.format(A[i//2])
    if 2*i <= H:
        tmp+=txt3.format(A[2*i])
    if 2*i+1 <= H:
        tmp+=txt4.format(A[2*i+1])
    print(tmp)


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

int main()
{
	string s, t;
	cin >> s >> t;
	bool ans = true;
	rep(i, s.size()) if(t[i] != s[i]) ans = false;

	if (ans == true) {
		cout << "Yes";
	} else {
		cout << "No";
	}

    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;
map<ll,ll>prime_factor(int m,map<ll,ll>res)
{
  //map<ll,ll>res;
  ll sqrm=sqrt(m)+1;
  for(int i=2;i<sqrm+1;i++)
  {
    while(m%i==0){res[i]++;m/=i;}
    if(m==1)break;
  }
  if(m>1)res[m]++;
  return res;
}



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout<<setprecision(10);
  int n;
  cin>>n;
  map<ll,ll>ma;

  repi(i,1,n+1)ma=prime_factor(i,ma);
  ll res=1;
  for(auto p:ma)
  {
    //cout<<p.first<<" "<<p.second<<endl;
    res*=(p.second+1);
    res%=(ll)1e9+7;
  }
  cout<<res<<endl;

  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

const int INF = 2e9;

int par[200000];
int cost[200000];

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

void unite(int x, int y) {
    par[find(x)] = find(y);
}

int main(void) {
    int i, N, Q;
    scanf("%d%d",&N,&Q);
    priority_queue<pair<int,pair<int,int>>> q;
    REP (i,N) cost[i] = INF;
    REP (i,Q) {
        int a, b, c;
        scanf("%d%d%d",&a,&b,&c);
        q.push(make_pair(-c,make_pair(a,b)));
        cost[a] = min(cost[a],c+1);
        cost[b] = min(cost[b],c+2);
    }
    REP (i,2*N) cost[(i+1)%N] = min(cost[(i+1)%N],cost[i%N] + 2);
    REP (i,N) q.push(make_pair(-cost[i],make_pair(i,(i+1)%N)));
    REP (i,N) par[i] = i;
    long long ans = 0;
    while (!q.empty()) {
        auto p = q.top(); q.pop();
        int c = -p.first;
        int a = p.second.first;
        int b = p.second.second;
        if (find(a) != find(b)) {
            unite(a,b);
            ans += c;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 9708
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)                                                                             
#define seg_size 524288
int main() {
#define int long long
	long long n, s;
	cin >> n >> s;
	if (s == n) {
		cout << n + 1 << endl;
		return 0;
	}
	else if (n < s) {
		cout << -1 << endl;
		return 0;
	}
	for (int i = 2;i <= sqrt(n);++i) {
		long long hoge = n;
		long long tmp = 0;
		while (hoge != 0) {
			tmp += hoge % i;
			hoge /= i;
		}
		if (tmp == s) {
			cout << i << endl;
			return 0;
		}
	}
	for (int p = sqrt(n);p >= 1;--p) {
		long long b = (n - s) / p + 1;
		if (b != 1) {
			long long hoge = n;
			long long tmp = 0;
			while (hoge != 0) {
				tmp += hoge % b;
				hoge /= b;
			}
			if (tmp == s) {
				cout << b << endl;
				return 0;
			}
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
const double PI=3.14159265358979323846;
const long long INF = 1LL << 60;

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

	for (size_t i = A; i <= B; i++) {
		if (i % N == 0) {
			std::cout << "OK" << '\n';
			return 0;
		}
	}
	std::cout << "NG" << '\n';
}


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

int main() {
	int n,t_point,h_point;
	string t_card,h_card;
	t_point = 0;
	h_point = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> t_card >> h_card;
		if(t_card > h_card){
			t_point += 3;
		}else if(t_card < h_card){
			h_point += 3;
		}else{
			t_point++;
			h_point++;
		}
	}
	cout << t_point << " " << h_point << endl;
	return 0;
}



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

int main()
{
	int64_t a, b, c, k;
	cin >> a >> b >> c >> k;

	int64_t ans = min(a, k);
	k -= min(a, k);

	k -= min(b, k);

	if (0 < k)
	{
		ans -= k;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {


  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] h = new int[N+10];
    for (int i = 0; i < N; i++) {
      h[i] = sc.nextInt();
    }
    int[] dp = new int[N+10];

    dp[0] = 0;
    for (int i = 1; i <N ; i++) {
      //morau dp
      dp[i] = Integer.MAX_VALUE;

      for (int j =i-K ; j <i ; j++) {
        if(j >=0) {
          dp[i] = Math.min(dp[i], dp[j] + Math.abs(h[i]-h[j]));
        }
      }

    }
//    dp[0]=0;
//    for (int i = 0; i < N; i++) {
//      dp[i+1] = Math.min(dp[i+1], dp[i] + Math.abs(h[i] - h[i+1]));
//      dp[i+2] = Math.min(dp[i+2], dp[i] + Math.abs(h[i] - h[i+2]));
//    }

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


  }


}


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

int32_t main() {
    int sm = 0;
    string s; cin >> s;
    for (auto el : s) {
        sm += el - '0';
        sm %= 9;
    }
    if (sm) cout << "No\n";
    else cout << "Yes\n";

    return 0;
}


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

struct Edge {
  int u, v, w;
};

using Node = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<Edge> edges(n - 1);
  for (auto& e : edges)
    cin >> e.u >> e.v >> e.w;

  vector<vector<Node>> nodes(n);
  for (auto& e : edges) {
    nodes[e.u - 1].emplace_back(e.v - 1, e.w);
    nodes[e.v - 1].emplace_back(e.u - 1, e.w);
  }

  vector<int> ret(n, -1);
  ret[0] = 0;

  queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int i = q.front();
    q.pop();
    for (auto& pi : nodes[i]) {
      if (ret[pi.first] >= 0)
        continue;
      ret[pi.first] = ret[i] ^ (pi.second % 2);
      q.push(pi.first);
    }
  }
  
  for (int r : ret)
    cout << r << "\n";
  return 0;
}


Measured memory_bytes: 7936
#include <iostream>

using namespace std;


int main() {

  int n,k;


  cin >> n;
  
  cin >> k;

  for(int i=0;i<k;i++) {

    int a,b;

    cin >> a >> b;

    if(n%2==0) {

      if(a>n/2) a=n+1-a;

      if(b>n/2) b=n+1-b;

    }

    else {

      if(a>n/2+1) a=n+1-a;

      if(b>n/2+1) b=n+1-b;

    }
      
    if(b<a) {

      if(b%3==0) cout << 3 << endl;

      else cout << b%3 << endl;

      continue;

    }

    switch(a%3) {
    
      //©
    case 0:

      cout << 3 << endl;

      break;

      //Ô
    case 1:

      cout << 1 << endl;

      break;

      //Â
    case 2:

      cout << 2 << endl;

      break;

    }


  }

  return 0;

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(long int I=X;I<Y;I++)
#define REP(I,X,Y) for(long int I=Y-1;I>=X;I--)
#define INF 1000000007
using namespace std;

long int pow2[] = {1,2,4,8,16,32,64,128,256,512,1024};

int main(){
  long int D,G,ans=INF;
  cin >> D >> G;
  long int p[D],c[D];
  FOR(i,0,D)cin >> p[i] >> c[i];
  FOR(i,0,pow2[D]){
    long int point = 0;
    long int solved = 0;
    bool complete[10];
    FOR(j,0,D){
      complete[j] = i&pow2[j];
      if(complete[j]){
        point += c[j] + p[j]*100*(j+1);
        solved += p[j];
      }
    }
    REP(j,0,D){
      if(!complete[j] && G > point){
        solved += min(p[j]-1,(G-point+100*(j+1)-1)/(100*(j+1)));
        point += 100*(j+1)*min(p[j]-1,(G-point+100*(j+1)-1)/(100*(j+1)));
      }
    }
    if(G <= point)ans = min(ans,solved);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    string s, t, u;
    int64_t a, b;
    cin >> s >> t >> a >> b >> u;

    if (s == u) {
        --a;
    } else {
        --b;
    }

    cout << a << " " << b << endl;
}

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

struct edge {
    int to, cost;
};

vector<edge> g[101010];
ll dist[101010];

void dfs1(int idx, int par) {
    for (edge & e : g[idx]) {
        if (e.to == par) continue;
        dfs1(e.to, idx);
        dist[idx] = max(dist[idx], dist[e.to] + e.cost);
    }
}

int dfs2(int idx, int d_par, int par) {
    vector< pair<int, int> > d_child;
    d_child.emplace_back(0, -1); // 番兵
    for (edge &e : g[idx]) {
        if (e.to == par) d_child.emplace_back(d_par + e.cost, e.to);
        else d_child.emplace_back(e.cost + dist[e.to], e.to);
    }
    sort(d_child.rbegin(), d_child.rend());
    int ret = d_child[0].first + d_child[1].first; // 最大から2つ
    for (edge &e : g[idx]) {
        if (e.to == par) continue;
        // 基本は d_child() の最大が d_par になるが，e.to の部分木が最大値のときはそれを取り除く必要がある
        ret = max(ret, dfs2(e.to, d_child[d_child[0].second == e.to].first, idx));
    }
    return ret;
}

int main() {
    int N;
    cin >> N;
    for (int i=0; i<N-1; ++i) {
        int a, b, w;
        cin >> a >> b >> w;
        g[a].push_back((edge){b, w});
        g[b].push_back((edge){a, w});
    }

    dfs1(N/2, -1);
    cout << dfs2(N/2, 0, -1) << endl;
}



Measured memory_bytes: 20360
//ヒントがっつり見た//キャストやめたら成功するようになった
using System;
namespace tst
{
    class Program
    {
        public static long Gusu(long x)
        {
            long cnt = 0;
            long bunbo = 10;
            while (x >= bunbo)
            {
                cnt += x / bunbo;
                bunbo *= 5;
            }
            return cnt;
        }
        /*public static long Kisu(long x)
        {
            long sum = 1;
            for (int i = 1; i <= ((x+1) / 2); i++)
            {
                sum *= ((2 * i)-1);
            }
            return sum;
        }*/
        public static void Main()
        {
            long n = long.Parse(Console.ReadLine());
            if (n % 2 == 1)
            {
                //val = Kisu(n);
                //奇数は0になることがない
                Console.WriteLine(0);
            }
            else if (n % 2 == 0)
            {
                //5の出てくる回数を数えよう
                Console.WriteLine(Gusu(n));
            }
        }

    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

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...));
}

int main() {
        ll a, b, c;
        scanf("%lld %lld.%lld", &a, &b, &c);

        cout << (a * (100 * b + c)) / 100 << endl;

        return 0;
}


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

using namespace std;
using ll = long long;

const int N = 15;

int p[N];
vector<int> a[N];

bool ok(vector<int> &a, int k) {
    for (int x : a) {
        if (x < k) return false;
    }
    return true;
}

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        for (int j = 0; j < m; j++) {
            int x;
            cin >> x;
            a[i].push_back(x);
        }
    }
    ll money = LLONG_MAX;
    for (int x = 0; x < (1 << n); x++) {
        ll cost = 0;
        vector<int> brain(m, 0);
        for (int i = n - 1; i >= 0; i--) {
            bool on = ((x >> i) & 1);
            if (on) {
                cost += 1LL * p[i];
                for (int j = 0; j < m; j++) {
                    brain[j] += a[i][j];
                }
            }
        }
        if (ok(brain, k)) money = min(money, cost);
    }
    if (money == LLONG_MAX) money = -1;
    cout << money << '\n';
}

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

int main() {
	int n, m, ql, qr; cin >> n >> m >> ql >> qr, ++ ql;
	vector<int> a, b;
	for(int i = 1, x ; i <= n ; ++ i) cin >> x, a.push_back(x);
	for(int i = 1, x ; i <= m ; ++ i) cin >> x, b.push_back(x);
	sort(a.begin(), a.end()), sort(b.begin(), b.end());
	int l = a.back() + 1, r = *b.begin();
	
	bool flag = ql <= qr && l <= r && !(qr < l || r < ql);
	
	if(flag) puts("No War");
	else puts("War");
}

Measured memory_bytes: 256
use proconio::input;
use proconio::marker::{Chars, Isize1};
use std::collections::{HashSet, VecDeque};

fn main() {
  input! {
    h: isize,
    w: isize,
    start: (Isize1, Isize1),
    end: (Isize1, Isize1),
    map: [Chars;h as usize]
  }

  let mut seen: HashSet<(isize, isize)> = HashSet::new();
  let mut deque: VecDeque<(isize, isize, isize)> = VecDeque::new();
  deque.push_back((start.1, start.0, 0));
  
  while !deque.is_empty() {
    let (x, y, point) = deque.pop_front().unwrap();
    if x == end.1 && y == end.0 {
      println!("{}", point);
      return
    }

    if seen.contains(&(x, y)) {
      continue
    }    
    seen.insert((x, y));
    
    for r in -2..=2isize {
      for c in -2..=2isize {
        if r == 0 && c == 0 {
          continue
        }
        
        let new_x = x + c;
        let new_y = y + r;
        if new_x < 0 || new_x >= w
          || new_y < 0 || new_y >= h {
          continue
        }
        
        if map[new_y as usize][new_x as usize] != '.' {
          continue
        }

        if seen.contains(&(new_x, new_y)) {
          continue
        }
        
        if r.abs() + c.abs() == 1 {
          deque.push_front((new_x, new_y, point));
        } else {
          deque.push_back((new_x, new_y, point+1));
        }
      }
    }  
  }
  
  println!("-1");
}

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

int main(){
    int a, b;
    cin >> a >> b;

    int r=0;
    for(int i=a;i<=b;i++){
        int s=i%10, t=i/10000 % 10;
        int u=i/10 % 10, v = i/1000%10;
        if(s==t && u == v) r++;
    }

    // int r = (b-a)/100-1;
    
    // if(a%100 <= (a/10000 + a/1000%10*10)){
    //     r++;
    // } 
    // if(b%100 >= (b/10000 + b/1000%10*10)){
    //     r++;
    // }

    cout << r << endl;
}

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

int main(){
  string ans="CODEFESTIVAL2016";
  string que;
  int cou=0;
  cin >> que;
  for(int i=0;i<16;i++){
    if(ans[i]!=que[i]){
      cou++;
    }
  }
  cout << cou << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>

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



int main() {
	
	int n;
    cin>>n;
    map<int,int> mp;
    int a;
    rep(i,n-1)
    {
        cin>>a;
        mp[a]+=1;
    }

    for(int i=1;i<=n;i++)
    {
        cout<<mp[i]<<endl;
    }
    


	return 0;
}

Measured memory_bytes: 12976
from collections import Counter
n = int(input())
a = list(map(int,input().split()))

a = Counter(a)
key = a.keys()
ans = 0
for i in key:
    if a[i] > i:
        ans += a[i] - i
    elif a[i] < i:
        ans += a[i]
print(ans)

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	int n, i, j;
	cin >> n;
	vi a(n);
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	bool flag = true;
	if (n % 2) {
		for (i = 0; i < n; i++) {
			if (a[i] != ((i + 1) / 2) * 2) {
				flag = false;
			}
		}
	}
	else {
		for (i = 0; i < n; i++) {
			if (a[i] != (i / 2) * 2 + 1) {
				flag = false;
			}
		}
	}
	if (!flag) {
		cout << 0 << endl;
		return 0;
	}
	ll ans = 1;
	for (i = 0; i < n / 2; i++) {
		ans = (ans * 2) % MOD;
	}
	cout << ans << endl;

}

Measured memory_bytes: 640
#include<stdio.h>
int p[200];

int judge(int x,int n){
    int i;
    for(i=0;i<n;i++){
        if(p[i] == x){
            return 1;
        }
    }
    return 0;
}
int main(){
    int x,n;
    scanf("%d%d",&x,&n);
    if(n == 0){
        printf("%d\n",x);
        return 0;
    }
    int i;
    for(i=0;i<n;i++){
        scanf("%d",&p[i]);
    }
    for(i=0;i<n;i++){
        if(judge(x-i,n) == 0){
            printf("%d\n",x-i);
            return 0;
        }else if(judge(x+i,n) == 0){
            printf("%d\n",x+i);
            return 0;
        }
    }
    if(x-n>=0){
        printf("%d\n",x-n);
    }else{
        printf("%d\n",x+n);
    }
    return 0;
}

Measured memory_bytes: 1708
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
 
int main() {
  int H, N;
  cin >> H >>  N;
 
  vector<int> A(N);
  rep(i, N)
    cin >> A[i];
  
  rep(i, N) {
    H -=A[i];
    if(H<=0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
 
  return 0;
}


Measured memory_bytes: 640
/* 
Rohit645
Rohit Kumar 
*/

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using db = double;
using pll = pair < ll, ll >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end() 
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;

int main() {
	fastIo();
	ll num, cnt = 0, n = 0; cin >> num;
	ll num1 = num;
	while(num1) {
		cnt++;
		num1 /= 10;
	}
	if (cnt <= 2) {
		cout << min(9ll, num) << endl;
	}
	else if (cnt <= 4) {
		cout << min(909ll, 9+num-100+1);
	}
	else if (cnt <= 6) {
		cout << min(90909ll,909+num-10000+1) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int K,X;cin >> K >> X;
  YesNo(K*500>=X);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
long long a, b, c;
long long gcd(long long a, long long b)
{
    if(a%b != 0)    return gcd(b, a%b);
    return b;
}

int main()
{
    while(scanf("%lld %lld", &a, &b) != EOF)
    {
        c = gcd(a, b);
        printf("%lld %lld\n", c, a*b/c);
    }
    return 0;
}

Measured memory_bytes: 596
def main():
    N = int(input())
    L = list(map(int, input().split()))
    r = set()
    for i in range(N-2):
        for j in range(i+1, N-1):
            for k in range(j+1, N):
                if L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[k] + L[i] > L[j]:
                    if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                        r.add((i,j,k))
    return len(r)
    #S = input()
    #a,b,c = map(int, input().split())

print(main())


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

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        //Solve();
        return;
    }

    public static string Solve()
    {
        int N = ReadInt();
        float X = N / 1.08f;
        int first = (int)Math.Floor(X);
        int second = (int)Math.Ceiling(X);
        if ((int)Math.Floor(first * 1.08f) == N)
        {
            return first.ToString();
        }
        else if((int)Math.Floor(second * 1.08f) == N)
        {
            return second.ToString();
        }
        return ":(";
    }


    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 11092
#include <stdio.h>

int main(void) {

  int n;
  scanf("%d", &n);
  int sum = 0;
  while (n > 0) {
    sum += n%10;
    n /= 10;
  }
  if (sum == 1) {
    sum = 10;
  }
  printf("%d\n", sum);

  return 0;
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

string t;

int main()
{
    _FastIO;
    cin >> t;
    int ans = 0;
    for(int i = 0; i < t.size(); i++){
        if(t[i] == '?')
            t[i] = 'D';
    }
    cout << t << endl;
    return 0;
}


Measured memory_bytes: 3740
#include <cstdio>
#include <algorithm>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(i, n) printf("%d%c", a[i], i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(i, n) REP(j, m) printf("%d%c", a[i][j], j + 1 == m ? '\n' : ' '); puts("")

//------------------------------------------------------------------------------
const int BIT_SIZE = 2000;

struct BIT {
  int n;
  int bit[BIT_SIZE + 1];

  BIT() {}
  BIT(int _n) {
    n = _n;
  }

  int sum(int i) {
    int s = 0;
    while(i > 0) {
      s += bit[i];
      i -= i & -i;
    }
    return s;
  }

  void add(int i, int x) {
    while (i <= n) {
      bit[i] += x;
      i += i & -i;
    }
  }
};

//------------------------------------------------------------------------------
const int N_MAX = 2000;
const int K_MAX = N_MAX * 2;
const int INF = 1e9;

int N, K;
int c[K_MAX];
int a[K_MAX];

BIT *bs[2];
int mv[2][N_MAX + 1][N_MAX + 1];
int dp[N_MAX + 1][N_MAX + 1];

void solve() {
  REP(i, 2) bs[i] = new BIT(N);
  REP(i, K) {
    int c1 = c[i];
    int c2 = 1 - c1;
    int num = a[i];
    int sw1 = bs[c1]->sum(N) - bs[c1]->sum(num);
    FOR(j, 0, N) {
      int sw2 = bs[c2]->sum(N) - bs[c2]->sum(j);
      if (c1 == 0) mv[c1][num - 1][j] = sw1 + sw2;
      else mv[c1][j][num - 1] = sw1 + sw2;
    }
    bs[c1]->add(num, 1);
  }

  // DUMP2D(mv[0], N + 1, N + 1);
  // DUMP2D(mv[1], N + 1, N + 1);

  fill(dp[0], dp[N + 1], INF);
  dp[0][0] = 0;
  FOR(i, 0, N) FOR(j, 0, N) {
    if (i > 0) dp[i][j] = min(dp[i][j], dp[i - 1][j] + mv[0][i - 1][j]);
    if (j > 0) dp[i][j] = min(dp[i][j], dp[i][j - 1] + mv[1][i][j - 1]);
  }
  printf("%d\n", dp[N][N]);
}

void input() {
  scanf("%d", &N);
  K = N * 2;
  REP(i, K) {
    char buf[2];
    scanf("%s%d", buf, a + i);
    c[i] = (buf[0] == 'W' ? 0 : 1);
  }
}

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


Measured memory_bytes: 47232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main()
{
    int n, p;
    cin >> n >> p;
    int even = 0, odd = 0;
    rep(i, 0, n) {
        int a;
        cin >> a;
        if (a % 2 == 0) even++;
        else odd++;
    }

    ll ans = 0;
    if (odd >= 2) {
        for (int i = 0; i <= odd; i += 2) {
            if (i == 0) {
                ans += pow(2, even);
            } else {
                ll x = 1;
                int tmp = odd;
                for (int j = 1; j <= i; j++) {
                    x *= tmp;
                    tmp--;
                    x /= j;
                }
                ans += pow(2, even) * x ;
            }
        }
    } else {
        ans += pow(2, even);
    }
    if (p == 1) {
        ans = pow(2, n) - ans;
    }
    cout << ans << endl;
}


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

const ll MOD = 1e9 + 7;
int H, W, A, B;
ll fac[200010];

ll mod_pow(ll x, ll n) {
  if (n == 0) return 1;
  ll res = mod_pow(x * x % MOD, n / 2);
  if (n & 1) res = res * x % MOD;
  return res;
}

ll comb(ll n, ll k) {
  return fac[n] * mod_pow(fac[k], MOD - 2) % MOD * mod_pow(fac[n - k], MOD - 2) % MOD;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  fac[0] = 1;
  for (int i = 1; i < 200010; i++) {
    fac[i] = fac[i - 1] * i % MOD;
  }
  cin >> H >> W >> A >> B;
  ll ans = comb(H + W - 2, H - 1);
  for (int i = 0; i <= min(A - 1, B - 1); i++) {
    ans += MOD - comb(H - A + B - 1, B - 1 - i) * comb(W - B + A - 1, A - 1 - i) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int D,E;
    cin >> D >> E;
    while(D){
        double mind = INF;
        rep(i,0,D+1){
            int dif = i * i + (D - i) * (D - i);
            mind = min(mind, abs(sqrt(dif) - E) );
        }
        cout << mind << endl;
        cin >> D >> E;
    }
}


Measured memory_bytes: 3168
#include<iostream>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<utility>
#include<stack>
#include<queue>
#include<sstream>
#include<bitset>
#include<cstdio>
#include<stdio.h>
#include<cstring>
using namespace std;
void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
}
int main()
{
	//in_out_txt();
	fast();
	int n;
	cin>>n;
	set<int>s;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		s.insert(x);
	}
	cout<<s.size()<<endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int m;
	cin>>m;
	ll sum=0,num=0;
	rep(i,m){
		ll c,d;
		cin>>d>>c;
		sum+=c*d;
		num+=c;
	}
	cout<<num-1+(sum-1)/9ll<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC172_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nmk = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            List<int> a = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            List<int> b = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            int count_a = 0;
            int count_b = 0;
            int time = 0;

            for (int i = 0; i < nmk[0]; i++)
            {
                if (time + a[i] > nmk[2])
                {
                    break;
                }
                count_a++;
                time += a[i];
            }
            int max = count_a;
            int time2 = 0;

            for (int i = 0; i < nmk[1]; i++)
            {
                if (time2 + b[i] > nmk[2])
                {
                    break;
                }
                time2 += b[i];
                count_b++;

                while (time + time2 > nmk[2])
                {
                    count_a--;
                    time -= a[count_a];
                }

                max = Math.Max(max, count_a + count_b);
            }

            Console.WriteLine(max);
        }
    }
}


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

//90度回転の方法が理解できたら、それを3回するだけ

char field[10][10];
char tmp[10][10];

void rotate(){
	for(int i=0; i < 8; i++){
		for(int j=0; j < 8; j++){
			tmp[i][j] = field[i][j];
		}
	}

	for(int i=0; i < 8; i++){
		for(int j=0; j < 8; j++){
			field[i][j] = tmp[7-j][i];
		}
	}
}

void output(){
	for(int i=0; i < 8; i++){
		for(int j=0; j < 8; j++){
			cout << field[i][j];
		}
		cout << endl;
	}
}

int main(){
	for(int i=0; i < 8; i++){
		for(int j=0; j < 8; j++){
			cin >> field[i][j];
		}
	}


	cout << 90 << endl;
	rotate();
	output();

	cout << 180 << endl;
	rotate();
	output();

	cout << 270 << endl;
	rotate();
	output();
}

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

#define f first
#define s second
#define ins insert
#define eb emplace_back
#define endl '\n'
#define ll long long
#define ld long double
#define vl vector<ll>
#define no cout << "NO" << endl
#define yes cout << "YES" << endl
#define tc ll t; cin >> t; while (t--)
#define sz(c) (ll) (c).size()
#define trav(x,c) for(auto &x : c)
#define all(c) (c).begin(), (c).end()
#define rll(c) (c).rbegin(), (c).rend()
#define _for(i,a,n) for(ll i = a ; i < n; ++i)
#define _rfor(i,a,n) for(ll i = n-1 ; i >= a; --i)
#define dx(x) cout << #x << ": " << x << endl;
#define dc(c) trav(x,c) cout << x << " "; cout << endl;
#define godspeed ios::sync_with_stdio(0); cin.tie(0);

int main() {
    godspeed;
    ll n; cin >> n;
    set<ll> s;
    ll x;
    _for(i,0,n) {cin >> x; s.ins(x);}

    if(sz(s) == n) yes;
    else no;
}

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

using namespace std;

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

    vector<int> p(N);

    for(int i = 0; i < N; i++) {
        cin >> p[i];
    }
    sort(p.begin(), p.end());

    int ans = 0;
    for(int i = 0; i < K; i++) {
        ans += p[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define se second
#define fi first
const int N=2000005;
int n,m,tot,l,x,y,z,f[N],dis[N],to[N],ne[N],fi[N],zz[N],g[N];
vector<pair<int ,int> > G[N];
vector<int> v;
void jb(int x,int y){
	ne[++tot]=fi[x];
	fi[x]=tot;
	zz[tot]=y;
}
int find(int x){
	if (x==f[x])return x;
	return f[x]=find(f[x]);
}
void up(int x){
	if (x==1)return;
	if (dis[f[x]]<dis[f[x/2]]){
		swap(f[x],f[x/2]);
		swap(g[f[x]],g[f[x/2]]);
		up(x/2);
	}
}
void down(int x){
	int i=x;
	if (x*2<=l&&dis[f[x*2]]<dis[f[x]])i=x*2;
	if (x*2<l&&dis[f[x*2+1]]<dis[f[i]])i=x*2+1;
	if (i!=x){
		swap(f[x],f[i]);
		swap(g[f[x]],g[f[i]]);
		down(i);
	}
}
int main(){
	scanf("%d%d",&n,&m);
	while (m--){
		scanf("%d%d%d",&x,&y,&z);
		G[z].push_back(mp(x,y));
	}
	for (int i=1;i<=n;i++)f[i]=i;
	int cnt=n;
	for (int i=1;i<=1000000;i++){
		v.clear();
		for (int j=0;j<G[i].size();j++)f[find(G[i][j].fi)]=find(G[i][j].se);
		for (int j=0;j<G[i].size();j++)v.push_back(G[i][j].fi),v.push_back(G[i][j].se);
		for (int j=0;j<v.size();j++)
			if (find(v[j])==v[j])to[v[j]]=++cnt;
		for (int j=0;j<v.size();j++)jb(to[find(v[j])],v[j]),jb(v[j],to[find(v[j])]);
		for (int j=0;j<v.size();j++)f[v[j]]=v[j];
	}
	dis[1]=0;
	for (int i=2;i<=cnt;i++)dis[i]=1e9;
	for (int i=1;i<=cnt;i++)f[i]=g[i]=i;
	l=cnt;
	for (int i=cnt;i;i--)down(i);
	for (int i=1;i<=cnt;i++){
		int k=f[1];
		f[1]=f[l--];
		g[f[1]]=1;
		down(1);
		for (int j=fi[k];j;j=ne[j])
			if (dis[zz[j]]>dis[k]+1){
				dis[zz[j]]=dis[k]+1;
				up(g[zz[j]]);
			}
	}
	if (dis[n]==1e9)puts("-1");
	else printf("%d\n",dis[n]/2);
	return 0;
}

Measured memory_bytes: 79616
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()
S=one_str()

length=len(S)
if length%2==0:
    if S[:length//2] == S[length//2:]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 38384