akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<set>
using namespace std;
const int INF=1111111111;
const int M=3000000;
int n,m,h[3000],w[3000],seg[8192],s,tn,ah[3000000],aw[3000000];
void init(int _n){
	s=1;
	while(s<_n)s*=2;
	for(int i=0;i<s*2-1;i++)seg[i]=0;
}
void upgrade(int k,int a){//k逡ェ逶ョ縺ョ蛟、繧誕縺ォ螟画峩
	k+=s-1;
	seg[k]=a;
	while(k>0){
	k=(k-1)/2;
	seg[k]=seg[k*2+1]+seg[k*2+2];
	}
}
//a?枌縺ョ蜷郁ィ亥?繧呈アゅａ繧?//
int sum(int a,int b,int k,int l,int r){
	if(r<=a||b<=l)return 0;
	if(a<=l&&r<=b){return seg[k];}
	else {
		int vl=sum(a,b,k*2+1,l,(l+r)/2);
		int vr=sum(a,b,k*2+2,(l+r)/2,r);
		return vl+vr;
	}
}
int main(){

	while(cin>>n>>m,n||m){
	tn=n;
	for(int i=0;i<n;i++)cin>>h[i];
	
	init(n);
	
	for(int i=0;i<n;i++){
	upgrade(i,h[i]);
	}

	for(int i=0;i<n;i++){
		for(int j=i+1;j<=n;j++){
			ah[sum(i,j,0,0,s)]++;
		}	}

	for(int i=0;i<m;i++)cin>>w[i];
	tn=m;
	init(m);
	for(int i=0;i<m;i++){upgrade(i,w[i]);}
	
	for(int i=0;i<m;i++){
		for(int j=i+1;j<=m;j++){
			aw[sum(i,j,0,0,s)]++;
		}
	}
	int ans=0;
	for(int i=1;i<3000000;i++){ans+=ah[i]*aw[i];}
	cout<<ans<<endl;
	fill(ah,ah+3000000,0);
	fill(aw,aw+3000000,0);
	}
	return 0;
}

Measured memory_bytes: 24640
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

ll csum[50][2];

const int limit = 50;

int main(void){
	ll n,k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];

	rep(j,limit){
		const ll val = 1LL << j;
		csum[j][0] = csum[j][1] = 0LL;
		rep(i,n){
			if((a[i] >> j) & 1LL)
				csum[j][0] += val;
			else
				csum[j][1] += val;
		}
	}

	ll cur = 0LL, ans = 0LL;
	rrep(j,limit){
		if((k >> j) & 1){
			ll tmp = cur + csum[j][0];
			rrep(bit,j) tmp += max(csum[bit][0], csum[bit][1]);
			chmax(ans, tmp);
			cur += csum[j][1];
		} else {
			cur += csum[j][0];	
		}
	}
	chmax(ans, cur);
	cout << ans << endl;

	return 0;
}

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

using namespace std;
using ll = long long;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

bool is_prime(int n) {
    if (n == 1) return false;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return true;
}

int main() {
    int a, d, n;
    while (cin >> a >> d >> n, a) {
        while (n--) {
            while (!is_prime(a)) a += d;
            a += d;
        }
        a -= d;
        cout << a << endl;
    }
    return 0;
}

Measured memory_bytes: 2988
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  
  if((100*a+10*b+c)%4==0){
    cout << "YES" << endl;
  }
  
  else{
    cout << "NO" << endl;
  }
}


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

using namespace std;

long long k, a ,b, ans;

int main(){
    cin >> k >> a >> b;
    if(a >= b || b - a == 1 || k <= a){
        cout << k + 1;
    }else{
        k -= a - 1;
        if(k % 2 == 0){
            ans = a + (b - a) * (k / 2);
        }else{
            ans = a + (b - a) * (k / 2) + 1;
        }
        cout << ans;
    }
}


Measured memory_bytes: 256
import Control.Monad

main = do
    [h, w] <- map read . words <$> getLine
    as <- replicateM h getLine
    putStrLn . concat $ replicate (w + 2) "#"
    mapM_ (putStrLn . ("#" ++) . (++ "#")) as
    putStrLn . concat $ replicate (w + 2) "#"

Measured memory_bytes: 1404
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var nm = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var digits = new int[nm[0]];
            var checker = new bool[nm[0]];
            for (var i = 0; i < nm[1]; i++)
            {
                var sc = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
                if (checker[sc[0] - 1] && digits[sc[0] - 1] != sc[1])
                {
                    Console.WriteLine(-1);
                    return;
                }
                digits[sc[0] - 1] = sc[1];
                checker[sc[0] - 1] = true;
            }

            if (digits[0] == 0 && nm[0] != 1)
            {
                if (checker[0])
                {
                    Console.WriteLine(-1);
                    return;
                }
                else
                {
                    digits[0] = 1;
                }
            }

            Console.WriteLine(int.Parse(string.Join("", digits)));
        }
    }
}


Measured memory_bytes: 13396
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 問題：https://atcoder.jp/contests/abc127/tasks/abc127_d
# プライオリティキュー　解説を見ながら実装


import heapq

n, m = map(int, input().strip().split())

q = []
a = list(map(int, input().strip().split()))
for i in range(n):
    heapq.heappush(q,(a[i]*(-1), 1))
for i in range(m):
    b, c = map(int, input().strip().split())
    heapq.heappush(q,(c*(-1), b))

res = 0
for _ in range(n):
    c, b = heapq.heappop(q)
    res += c * (-1)
    if b > 1:
        b -= 1
        heapq.heappush(q, (c, b))

print(res)


Measured memory_bytes: 38592
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
        if (a.equals(b)) {
            System.out.println(c);    
        } else if (b.equals(c)) {
            System.out.println(a);
        } else if (a.equals(c)) {
            System.out.println(b);
        }
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
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...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

int32_t main()
{
	fastIO
	inp_out();
	int n,m,x;
	cin>>n>>m>>x;
	vi cost(n);
	vector<vi> a(n,vi(m));
	for(int i=0;i<n;++i)
	{
		cin>>cost[i];
		for(int j=0;j<m;++j)
		{
			cin>>a[i][j];
		}
	}

	int rg=pow(2,n);
	int ans=inf;
	for(int i=1;i<rg;++i)
	{	
		int val=i;
		vi know(m);
		int t=0,temp=0;
		while(val>0)
		{
			if(val&1)
			{
				temp+=cost[t];
				for(int j=0;j<m;++j)
				{
					know[j]+=a[t][j];
				}
			}
			val/=2;
			++t;
		}

		int flag=1;
		for(int j=0;j<m;++j)
			if(know[j]<x)
				flag=0;
		if(flag)
			ans=min(ans,temp);

	}

	cout<<(ans==inf?-1:ans);

	return 0;
}

Measured memory_bytes: 4108
#include <bits/stdc++.h>
using namespace std;
map<string,int> mp;
int main() {
    long test=1;
    // cin>>test;
    while(test--)
    {
	long long t,i,j,n,a,b,c,d,ans,A,B,x,y,one,q,l,r;
	string s,s1,s2,s3;
	cin>>s1>>s2;
	long io=0,ie=0;
	for(i=0;i<(s1.length()+s2.length());i++)
	{
	    if(i%2==0)
	    {
	        cout<<s1[io];
	        io++;
	    }
	    else
	    {
	        cout<<s2[ie];
	        ie++;
	    }
	}
	
	
	
    }

}

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

int main() {
    int N, M;
    std::cin >> N >> M;

    int H[N];
    bool isGood[N];
    for (int i = 0; i < N; ++i) {
        std::cin >> H[i];
        isGood[i] = true;
    }

    int A, B;
    for (int i = 0; i < M; ++i) {
        std::cin >> A >> B;
        --A;
        --B;
    
        if (H[A] <= H[B]) {
            isGood[A] = false;
        }

        if (H[B] <= H[A]) {
            isGood[B] = false;
        }
    }

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        if (isGood[i]) {
            ++ans;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 4080
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int>d(n);
  for(int i=0;i<n;i++)cin>>d[i];
  sort(d.begin(),d.end());
  int ans=0;
  while(d[(n/2)-1]<d[n/2]){
    d[(n/2)-1]++;
    ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll n,i,a[101010],D[101010],R,ta,tb;
vector<ll> v[101010];
ll dfs(ll aa,ll bb)
{
	if(D[aa]==1)
		return a[aa];
	ll ii;
	vector<ll> isi;
	for(ii=0;ii<v[aa].size();ii++)
	{
		if(v[aa][ii]!=bb)
			isi.pb(dfs(v[aa][ii],aa));
	}
	sort(isi.begin(),isi.end());
	ll sz=isi.size(),jum=0,sisa;
	for(ii=0;ii<sz;ii++)
		jum+=isi[ii];
	sisa=jum-a[aa];
	//cout<<aa<<" "<<jum<<" "<<a[aa]<<" "<<D[aa]<<"_\n";
	//cout<<sisa<<"\n";
	if(sisa<0)
	{
		cout<<"NO\n";
		exit(0);
	}
	ll Z=a[aa]-sisa;
	jum-=Z;
	if((jum%2)==1)
	{
		cout<<"NO\n";
		exit(0);
	}	
	//cout<<isi[sz-1]<<" "<<
	//cout<<jum<<"\n";
	if((isi[sz-1]-Z)>(jum/2))
	{
		cout<<"NO\n";
		exit(0);
	}
	if(Z<0)
	{
		cout<<"NO\n";
		exit(0);
	}
	//cout<<aa<<" "<<Z<<"\n";
	return Z;
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>a[i];
	if(n==2)
	{
		if(a[1]==a[2])
			cout<<"YES\n";
		else 
			cout<<"NO\n";
		return 0;
	}
	for(i=1;i<n;i++)
	{
		cin>>ta>>tb;
		v[ta].pb(tb);
		v[tb].pb(ta);
		D[ta]++;
		D[tb]++;
	}
	R=1;
	for(i=1;i<=n;i++)
		if(D[i]>1)
		{
			R=i;
			break;
		}
	//cout<<R<<"\n";
	//for(i=1;i<=n;i++)
	//	cout<<i<<"_"<<D[i]<<"\n";
	if(dfs(R,R)==0)cout<<"YES\n";
	else cout<<"NO\n";
}

Measured memory_bytes: 15360
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

const int MAXV = 100100;
vector<int> children[MAXV];
int parent[30][MAXV];
int depth[MAXV];

int n;

void dfs(int v, int d) {
    depth[v] = d;
    for (int i = 0; i < children[v].size(); i++) {
        dfs(children[v][i], d+1);
    }
}

void init(int V) {
    dfs(0, 0);
    for (int k = 0; k < 30; k++) {
        for (int v = 0; v < V; v++) {
            if (parent[k][v] < 0) parent[k+1][v] = -1;
            else parent[k+1][v] = parent[k][parent[k][v]];
        }
    }
}

int lca(int u, int v) {
    if (depth[u] > depth[v]) swap(u, v);
    for (int k = 0; k < 30; k++) {
        if ((depth[v] - depth[u]) >> k & 1) {
            v = parent[k][v];
        }
    }
    if (u == v) return u;
    for (int k = 29; k >= 0; k--) {
        if (parent[k][u] != parent[k][v]) {
            u = parent[k][u];
            v = parent[k][v];
        }
    }
    return parent[0][u];
}

int main(void) {
    cin >> n;
    for (int i = 0; i < n; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int c;
            cin >> c;
            children[i].push_back(c);
            parent[0][c] = i;
        }
    }
    init(n);
    int q;
    cin >> q;
    while (q--) {
        int u, v;
        cin >> u >> v;
        cout << lca(u, v) << endl;
    }
    return 0;
}

Measured memory_bytes: 21908
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n,a,i,AC=0,TLE=0,RE=0,WA=0;
	cin>>n;
    string s;
    for(i=0;i<n;i++)
    {
    	cin>>s;
     	if(s=="WA")
    	{
    		WA++;}
    		else if(s=="TLE")
    		{
    			TLE++;
    		}
    		else if(s=="RE")
    		{
    			RE++;
    		}
    		else if(s=="AC")
    		{
    			AC++;
    		}
    }
    	cout<<"AC x "<<AC<<endl;
    	cout<<"WA x "<<WA<<endl;
    	cout<<"TLE x "<<TLE<<endl;
    	cout<<"RE x "<<RE<<endl;
	
	return 0;
}

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

int main(){
    int N; cin >> N;
    vector<int> H(N);

    for(int i = 0; i < N; i++){
        cin >> H[i];
    }

    if(N == 1){
        cout << "Yes" << endl;
        exit(0);
    }

    bool flag = true;
    for(int i = N - 1; i > 0; i--){
        int count = 0;
        while(H[i - 1] > H[i]){
            H[i - 1]--;
            count++;
            if(count >= 2){
                flag = false;
                break;
            }
        }
    }

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


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define MEM 100009
#define sanic ios_base::sync_with_stdio(0)
using namespace std;
const long long MOD = 1e9+9;
long long a,b,t;
long long p[MEM];
int main() {
    cin >> a >> b;
    for(int i=1; i<=b; i++){
        cin >> p[i];
        p[i] += p[i-1];
    }
    cout << (a>p[b] ? "No":"Yes");
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

#define LOCAL

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
#else
    #define dbg(x)
#endif

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    cout << "\n";
    return a;
}

const int INF = 1e18;
//const int mod = 2600000069;
//const int p = 179;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    if (n == m) cout << "Yes\n";
    else cout << "No\n";
}
/*
*/


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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  vector<long> V(N);
  map<long, int> MA;
  for (int i = 0; i < N; i++) {
    cin >> V.at(i);
    MA[V.at(i)]++;
  }

  sort(V.rbegin(), V.rend());
  long double ave = accumulate(V.begin(), V.begin() + A, 0L) / (long double) A;
  cout << fixed << setprecision(6) << ave << "\n";
  
  vector com(N + 1, vector(N + 1, 0L));
  com.at(0).at(0) = 1;
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j <= i; j++) {
      com.at(i).at(j) += com.at(i - 1).at(j);
      if (j) com.at(i).at(j) += com.at(i - 1).at(j - 1); 
    }
  }
  
  long ans = 0;
  for (int i = A; i <= B; i++) {
    long double tmp = accumulate(V.begin(), V.begin() + i, 0L) / (long double) i;
    if (tmp != ave) continue;
    tmp = 1;
    map<long, int> cnt;
    for (int j = 0; j < i; j++) cnt[V.at(j)]++;
    for (auto [a, b] : cnt) tmp *= com.at(MA[a]).at(b);
    ans += tmp;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3808
/*できずC: Half and Half
まず、AB ピザを奇数枚買って 1 枚余らせるのは無意味なので、AB ピザは 2 枚 1 組で考えます。つまり、
2C 円で A ピザ 1 枚と B ピザ 1 枚を買えると考えることにし、この 2 枚の組み合わせをこれ以降 AB セッ
トと呼ぶことにします。
この問題の重要な制約は、X, Y ≤ 105 です。これは、A ピザ、B ピザ、AB セットのどれについても、買
う個数は 10 万個以下でよいことを意味します。したがって、この三種類のうちどれか一種類を選んで、それ
を買う個数を 0 から 10 万まですべて試す、という方針が考えられます。*4
さて、三つのうちどれについて購入個数を全列挙するべきでしょうか？結論を述べると、AB セットです。
AB セットを i 個 (0 ≤ i ≤ 105
) 購入した場合、i ≥ X であれば A ピザを買い増す必要はなく、i < X であれ
ば A ピザを X −i 枚買い増す必要があります。これらをまとめて、買い増すべき A ピザの数は max(0, X −i)
枚であるということもできます。同様に、B ピザを max(0, Y − i) 枚買い増す必要があります。以上から、
AB セットを i 枚購入した場合の所要金額は i × 2C + max(0, X − i) × A + max(0, Y − i) × B 円であり、こ
の値を 0 以上 10 万以下のすべての整数 i について計算して最小値を取ることで答えが求まります。
なお、定数時間で答えを求めることもできます。練習問題として解説は省きます。*/
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  if(2*c < a+b){
    int ans = 0;
    if(x < y){
      if(b < 2*c){
        cout << (2*c*x + (y-x)*b) << endl;
        return 0;
      }else{
        cout << 2*c*y << endl;
        return 0;
      }
    }else{
      if(a < 2*c){
        cout << (2*c*y + (x-y)*a) << endl;
        return 0;
      }else{
        cout << 2*c*x << endl;
        return 0;
      }
    }
  }else{
    cout << (a*x + b*y) << endl;
    return 0;
  }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>

struct node{
	struct node *right;
	struct node *left;
	struct node *parent;
	int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeSearch(Node u, int k){
	if (u == NIL){return NIL;}
	if (u->key == k){ return u; }
	else if (u->key > k){
		return treeSearch(u->left, k);
	}
	else{
		return treeSearch(u->right, k);
	}
}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
	Node y; // node to be deleted
	Node x; // child of y



}

Node sss(int k, Node x){
	if (x == NIL){ return x; }
	if (k < x->key){
		if (x->left != NIL){
			return sss(k, x->left);
		}
		else{
			return x;
		}
	}
	else{
		if (x->right != NIL){
			return sss(k, x->right);
		}
		else{
			return x;
		}
	}
}

void insert(int k){
	Node y = sss(k,root);
	Node z;

	z = malloc(sizeof(struct node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	z->parent = y;

	if (y == NIL){ root=z; }
	else if (y->key < k){
		y->right = z;
	}
	else{
		y->left = z;
	}
}

void inorder(Node u){
	if (u->left != NIL)
		inorder(u->left);
	printf(" %d", u->key);
	if (u->right != NIL)
		inorder(u->right);	
}
void preorder(Node u){
	printf(" %d", u->key);
	if (u->left != NIL)
		preorder(u->left);
	if (u->right != NIL)
		preorder(u->right);
}


int main(){
	int n, i, x;
	char com[20];
	scanf("%d", &n);

	for (i = 0; i < n; i++){
		scanf("%s", com);
		if (com[0] == 'f'){
			scanf("%d", &x);
			Node t = treeSearch(root, x);
			if (t != NIL) printf("yes\n");
			else printf("no\n");
		}
		else if (com[0] == 'i'){
			scanf("%d", &x);
			insert(x);
		}
		else if (com[0] == 'p'){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
		else if (com[0] == 'd'){
			scanf("%d", &x);
			treeDelete(treeSearch(root, x));
		}
	}

	return 0;
}

Measured memory_bytes: 19364
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  if (N % 1000 == 0)
  {
    cout << 0 << endl;
  }
  else
  {
    cout << 1000 - N % 1000 << endl;
  }
}

Measured memory_bytes: 3588
#include <algorithm>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
using namespace std;
typedef long long ll;
typedef vector<int> vertex;
typedef vector<vertex> graph;
 
ll n, m;
graph g;
 
void add_edge(int a, int b){
	g[a].push_back(b);
	g[b].push_back(a);
}
 
int used[100000];
 
ll cnt(ll u, ll d, bool &tr){
	if(used[u]){
		if(used[u]!=2-d) tr = true;
		return 0;
	}
	used[u] = 2-d;
	ll res = 0;
	if(d==0) res++;
	for(int v: g[u]){
		res += cnt(v, !d, tr);
	}
	return res;
}
 
int main(){
	cin>>n>>m;
	g = graph(n);
	rep(i, m){
		int a, b;
		cin>>a>>b;
		a--; b--;
		add_edge(a, b);
	}
	bool tr = false;
	ll t = cnt(0, 0, tr);
	if(tr) cout<<n*(n-1)/2-m<<endl;
	else cout<<t*(n-t)-m<<endl;
	return 0;
}

Measured memory_bytes: 6656
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
ll modExp(ll base, ll power) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}

ll inv(ll base) {
    int g = MOD, r = base, x = 0, y = 1;
    while (r != 0) {
        int q = g / r;
        g %= r; swap(g, r);
        x -= q * y; swap(x, y);
    }
    return x < 0 ? x+MOD : x;
}

ll mul(ll A, ll B) {
	return (A*B)%MOD;
}

ll add(ll A, ll B) {
	return (A+B)%MOD;
}

ll dvd(ll A, ll B) {
    return mul(A, inv(B));
}

ll sub(ll A, ll B) {
    return (A-B+MOD)%MOD;
}


vi primes, leastFac;
void compPrimes(int N) {
	F0R(i, N) {
		leastFac.pb(0);
	}
	leastFac[0] = 1; leastFac[1] = 1;
	FOR(i, 2, N) {
		if (leastFac[i] == 0) {
			primes.pb(i);
			leastFac[i] = i;
		}
		for (int j = 0; j < sz(primes) && i*primes[j] < N && primes[j] <= leastFac[i]; j++) {
			leastFac[i*primes[j]] = primes[j];
		}
	}
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    compPrimes(1000);

    map<ll, ll> facs;
    int N; cin >> N;
    vl data(N);
    F0R(iter, N) {
        ll X; cin >> X;
        data[iter] = X;

        F0R(x, sz(primes)) {
            int cur = primes[x];
            int cnt = 0;
            while (X % cur == 0) {
                X /= cur; cnt++;
            }
            if (cnt > 0) {
                facs[cur] = max(facs[cur], (ll) cnt);
            }
        }
        if (X > 1) {
            facs[X] = 1;
        }
    }

    ll lm = 1;
    for (auto it = facs.begin(); it != facs.end(); it++) {
        lm *= modExp(it->f, it->s);
        lm %= MOD;
    }
    ll ans = 0;
    F0R(i, N) {
        ans += inv(data[i]); ans %= MOD;
    }
    ans *= lm; ans %= MOD;
    cout << ans << endl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



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

int N, H[1 << 18], C[1 << 18];

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> H[i];
	for (int i = N - 1; i >= 1; i--) {
		if (H[i] < H[i + 1]) C[i] = 0;
		else C[i] = C[i + 1] + 1;
	}
	int maxn = 0;
	for (int i = 1; i <= N; i++) maxn = max(maxn, C[i]);
	cout << maxn << endl;
	return 0;
}

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

int main()
{
	int a, b, c;
	int tmp;

	scanf("%d%d%d", &a, &b, &c);
	if (a > b) tmp = a, a = b, b = tmp;
	if (b > c) {
		tmp = b, b = c, c = tmp;
		if (a > b) tmp = a, a = b, b = tmp;
	}
	printf("%d %d %d\n", a, b, c);
	return 0;
}



Measured memory_bytes: 2116
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

struct edge{int to, cost;};

class Graph
{
public:
    int V;
    vector<vector<edge>> G;

    Graph(int V): V(V){
        G = vector<vector<edge>>(V, vector<edge>(0));
    }

    void add_edge(int from, int to, int cost){
        G[from].push_back(edge({to, cost}));
    }

    void add_edge2(int v1, int v2, int cost){
        add_edge(v1, v2, cost);
        add_edge(v2, v1, cost);
    }

    void erase_edge(int from, int to){
        vec e(0);
        REP(i, G[from].size()){
            if(G[from][i].to == to) e.push_back(i);
        }
        IREP(i, e.size()) G[from].erase(G[from].begin() + e[i]);
    }

    void erase_edge2(int v1, int v2){
        erase_edge(v1, v2);
        erase_edge(v2, v1);
    }

    void dfs(int v, vector<bool> &used, vec &ans){
        REP(k, G[v].size()){
            if(!used[G[v][k].to]){
                used[G[v][k].to] = true;
                ans.push_back(G[v][k].to);
                dfs(G[v][k].to, used, ans);
                break;
            }
        }
    }
};

signed main(){

    int N, M; cin >> N >> M;
    Graph G(N);
    int A, B;
    REP(i, M){
        cin >> A >> B;
        G.add_edge2(A - 1, B - 1, 0);
    }

    vec ans({0});
    vector<bool> used(N, false);
    used[0] = true;
    G.dfs(0, used, ans);
    REVERSE(ans);
    G.dfs(0, used, ans);
    
    cout << ans.size() << endl;
    REP(i, ans.size()) cout << ans[i] + 1 << " ";
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

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

#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound
 
namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) {int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) {  for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0;}
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void gp (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::gp;
 
void scan() {
	return;
}
 
template<class T, typename... Args>
void scan(T &a, Args&&... args) {
	gi(a);
	scan(args...);
	return;
}

template<typename T>
void scann(T a, T b) {
	for (auto it = a; it != b; ++it)
		scan(*it);
}
 
template<typename T>
void scerr(T a, T b) {
	for (auto it = a; it != b; ++it)
		cerr << *it << " ";
	cerr << '\n';
}

void print() {
	return;
}
 
template<class T, typename... Args>
void print(T a, Args... args) {
	gp(a);
	pc(' ');
	print(args...);
	return;
}
 
void cer() {
	return;
}
 
template<class T, typename... Args>
void cer(T a, Args... args) {
	cerr << " " << a;
	cer(args...);
	return;
} 
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, int> mll;
 
const int N = 2e5 + 2;
const int M = 4e6 + 2;
const int mod = 998244353;
const ll inf = 1e6;
const ll INF = 1e18;

void data() {
	#ifdef PC
		freopen("d.in", "r", stdin);
		freopen("d.out", "w", stdout);
	#endif
}

ll n, k, p[N], gl[N];

int main() {
	data();
	scan(n, k);
	scann(p + 1, p + n + 1);
	ll pos = 1, d = 1;
	while (k > 0) {
		if (gl[pos]) {
			k %= (d - gl[pos]);
			if (k == 0)
				break;
		}
		--k;
		gl[pos] = d++;
		pos = p[pos];
	}
	print(pos);
}		

Measured memory_bytes: 8008
#include <stdio.h>

int main()
{
  int h,w;
  char a[101][101];
  scanf("%d %d",&h,&w);
  int i,j;
  for(i=0;i<=h;i++)
  {
  	for(j=0;j<=w;j++)
    {
     scanf("%c",&a[i][j]);
    }
  }

  int t,flag;
  t=0;
  do
  {
    flag=1;
    for(i=0;i<=w;i++)
    {
     if(a[t][i]=='#')
     {flag=0;}
    }
    
    if(flag==1)
    {
     for(i=t;i<h;i++)
     {
     	for(j=0;j<=w;j++)
     	{
      	a[i][j]=a[i+1][j];
     	}
     }
      h--;
    }else{t++;}
  }while(t<=h);
  
  t=0;
  do
  {
    flag=1;
    for(i=0;i<=h;i++)
    {
     if(a[i][t]=='#')
     {flag=0;}
    }
    
    if(flag==1)
    {
     for(i=t;i<w;i++)
     {
     	for(j=0;j<=h;j++)
     	{
      	a[j][i]=a[j][i+1];
     	}
     }
      w--;
    }else{t++;}
  }while(t<=w);
  
  for(i=0;i<=h;i++)
  {
  	for(j=0;j<=w;j++)
    {
     printf("%c",a[i][j]);
    }
    printf("\n");
  }
  
  return  0;
}

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

int keta(long n){
	int res=0;
	while(n){
		res++;
		n>>=1;
	}
	return res;
}

long calc(long x){
	long res=0;
	int k=keta(x);
	for(int i=0;i<k;i++){
		if(i==0) if(((x/2)%2)^(x&1)) res+=1;
		if((x>>i)&1){
			if(i!=0) res+=(x%(1L<<i))%2?0:(1L<<i);
		}
	}
	return res;
}

int main(){
	long a,b;
	cin >> a >> b;
	if(a==0) a++;
	cout << (calc(a-1)^calc(b)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
ll euclidean_gcd(ll a, ll b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}


int main() {
  int n, d, x;
  cin >> n >> d >> x;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
  }
  int ans = x;
  rep(i,n){
    int day = (d-1)/a[i]+1;
    ans += day;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int a[252];
int main()
{
	int n,out=0;
	cin>>n;
	rep(i,n*2) cin>>a[i];
	sort(a,a+2*n);
	rep(i,n) out+=min(a[i*2],a[i*2+1]);
	cout<<out<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
  int r;
  cin >> r;
  if(r < 1200) {
    cout << "ABC";
  }else if(r < 2800) {
    cout << "ARC";
  }else {
    cout << "AGC";
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>	
 
using namespace std;
 
int main() {
	long long N;
	scanf("%lld", &N);
	vector<vector<string>> vec(N);
	vector<string> vecS(N);
	for (long long i = 0; i < N; ++i) {
		char s[10];
      	scanf("%s", s);
		vec[i].resize(10);
		for (int j = 0; j < 10; ++j) {
			vec[i][j] += s[j];
		}
		sort(vec[i].begin(), vec[i].end());
		for (int j = 0; j < 10; ++j) {
			vecS[i] += vec[i][j];
		}
	}
	sort(vecS.begin(), vecS.end());
 
 
	long long ans = 0;
 	map<string, int> mp;
	for (long long i = 0; i < N; ++i) {
      	ans += mp[vecS[i]];
       	++mp[vecS[i]];
	}
 
	cout << ans << endl;
 
	return 0;
}

Measured memory_bytes: 72064
#include <cstdio>
using namespace std;
int main(){
	long a,b,i;
	while(scanf("%ld %ld",&a,&b)!=EOF){
		i=1;a+=b;b=1;
		while(b<=a){i++;b*=10;}
		printf("%ld\n",i-1);
	}
	return 0;
}

Measured memory_bytes: 1028
from bisect import bisect_right

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

SA = [0] * (N + 1)
SB = [0] * (M + 1)
for i in range(N):
    SA[i + 1] = SA[i] + A[i]
for i in range(M):
    SB[i + 1] = SB[i] + B[i]

ans = 0
for i in range(N + 1):
    cntA = i
    rest = K - SA[i]
    if rest < 0:
        break
    cntB = bisect_right(SB, rest) - 1
    ans = max(ans, cntA + cntB)
print(ans)


Measured memory_bytes: 47432
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int64
	scanner.Scan()
	N, _ = strconv.ParseInt(scanner.Text(), 10, 64)
	fmt.Println(solve(N))
}
func solve(N int64) string {
	digits := lib_ToDigitSliceInt64(N)
	if digits[0] == 7 || digits[1] == 7 || digits[2] == 7 {
		return "Yes"
	}
	return "No"
}
func lib_ToDigitSliceInt64(n int64) (digits []int8) {
	nn := int64(n)
	for {
		if nn <= 0 {
			return lib_ReverseInt8(digits)
		}
		digit := int8(nn % 10)
		digits = append(digits, digit)
		nn /= 10
	}
}
func lib_ReverseInt8(values []int8) []int8 {
	newValues := lib_CopyInt8(values)
	for i, j := 0, len(values)-1; i < j; i, j = i+1, j-1 {
		newValues[i], newValues[j] = values[j], values[i]
	}
	return newValues
}
func lib_CopyInt8(values []int8) []int8 {
	dst := make([]int8, len(values))
	copy(dst, values)
	return dst
}


Measured memory_bytes: 1756
#include<stdio.h>
int n,i,p,c,ans=0;
int a[100000];
int x[100000];
int y[100000];

int main(){
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    x[i]=-1;
    y[i]=-1;
  }
  for(i=0;i<n;i++){
    p=i;
    c=0;
    while(x[p]==-1){
      x[p]=c++;
      y[p]=i;
      p=(p+a[p])%n;
    }
    if(y[p]==i)ans+=(c-x[p]);
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 3876
x1, y1, x2, y2 = map(int, input().split())

a = x2 - x1
b = y2 - y1

x3 = x2 - b
y3 = y2 + a

x4 = x3 - a
y4 = y3 - b

print(x3, y3, x4, y4)

Measured memory_bytes: 3060
a,b,c = map(int,input().split())
if a == b :
    if a != c:
        print('Yes')
    else:
        print('No')
elif a ==c:
    if a!=b:
        print('Yes')
    else:
        print('No')
elif b ==c:
    if b != a:
        print('Yes')
    else:
        print('No')
else:
    print('No')


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(){
    int n;
  	cin >> n;
    unsigned long long a[n];
    unsigned long long b[n] = {};
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<n; i++) b[a[i]-1]++;
    unsigned long long c=0;
    for(int i=0; i<n; i++) c += (b[i]*(b[i]-1))/2;
    for(int i=0; i<n; i++){
      cout << c - b[a[i]-1] + 1 << endl;
    }
 
}

Measured memory_bytes: 6768
#include <cstdio>

#define min(a, b) (a) < (b)?(a):(b)

const int N = 1e5 + 7, M = 22;
int n, otp, state, w[N], corder[M], dp[(1<<15) + 7], XOR[(1<<15) + 7];

inline void init(){
	for (register int i = 1;i < (1<<15);i ++)dp[i] = dp[i>>1] + (i&1);
	for (register int i = 1;i < (1<<15);i ++)dp[i] --;
	for (register int i = 1;i < (1<<15);i ++)
		for (register int j = 0;j < 15;j ++)
			if ((i>>j)&1)XOR[i] ^= (j + 1);
	for (register int i = 1;i < (1<<15);i ++)
		if (!XOR[i])
			for (register int j = i&(i - 1);j;j = i&(j - 1))
				if (!XOR[j])dp[i] = min(dp[i], dp[i^j] + dp[j]);
	scanf("%d", &n);
	for (register int i = 1, x, y, z;i < n;i ++){
		scanf("%d %d %d", &x, &y, &z);
		w[x + 1] ^= z, w[y + 1] ^= z;
	}
}

int main(){
	init();
	for (register int i = 1;i <= n;i ++)corder[w[i]] ++;
	for (register int i = 1;i <= 15;i ++){
		otp += (corder[i]>>1);
		state |= ((corder[i]&1)<<(i - 1));
	}
	return !printf("%d", otp + dp[state]);
}

Measured memory_bytes: 2376
import math

n = int(input())
for i in range(0,n):
    x1,y1,r1,x2,y2,r2 = (float(x) for x in input().split())
    ans = 1
    # Bが Aの中にあるとき2、
    # AがBの中にあるとき-2、
    # AとBが共有点をもつとき1、
    # AとBが重なっていないとき0
    # 円の中心からの距離
    l = math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1))
    if l < abs(r1 - r2):
        if r1 > r2:
            ans = 2
        elif r2 > r1:
            ans = -2
    if l > r1 + r2:
        ans = 0
    print(ans)


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

int main(){
    int N;
    std::cin >> N;
    std::vector< std::vector< int > > AB(N);
    std::vector< std::vector< int > > ABinNo(N);
    for(int i=0; i<N-1; i++){
        int tmp1, tmp2;
        std::cin >> tmp1 >> tmp2;
        AB[tmp1 - 1].push_back(tmp2 - 1);
        AB[tmp2 - 1].push_back(tmp1 - 1);
        ABinNo[tmp1 - 1].push_back(i);
        ABinNo[tmp2 - 1].push_back(i);
    }
    
    std::deque< int > deq_No;
    std::deque< int > deq_preNo;
    std::deque< int > deq_preColor;
    deq_No.push_back(0);
    deq_preNo.push_back(-1);
    deq_preColor.push_back(-1);
    
    std::vector< int > color_ans(N-1);
    int max = 0;
    while(!deq_No.empty()){
        int cur_No = deq_No[0];
        int cur_preNo = deq_preNo[0];
        int cur_preColor = deq_preColor[0];
        deq_No.pop_front();
        deq_preNo.pop_front();
        deq_preColor.pop_front();
        
        int color_cnt = 1;
        for(int i=0; i<AB[cur_No].size(); i++){
            if(AB[cur_No][i] == cur_preNo){
                continue;
            }
            if(color_cnt == cur_preColor){
                color_cnt++;
            }
            color_ans[ABinNo[cur_No][i]] = color_cnt;
            deq_No.push_back(AB[cur_No][i]);
            deq_preNo.push_back(cur_No);
            deq_preColor.push_back(color_cnt);
            color_cnt++;
        }
        if(max < color_cnt-1){
            max = color_cnt-1;
        }
    }
    
    std::cout << max << std::endl;
    for(int i=0; i<N-1; i++){
        std::cout << color_ans[i] << std::endl;
    }
    
    return 0;
}



Measured memory_bytes: 12160
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
using namespace std;



int main()
{
  int n;
  long long int t,be,ans;
  cin >> n >> t >> be;

  ans = 0;

  for(int i=1;i<n;i++){
    long long int tmp;
    cin >> tmp;
    if(tmp - be > t ){
      ans += tmp - be -  t;
    }
    be = tmp;
  }
  cout << be + t - ans << endl;

  return 0;
}

Measured memory_bytes: 256
n, W = map(int, input().split())
w = [0]*n
v = [0]*n
for i in range(n):
    w[i], v[i] = map(int, input().split())
    
INF = 10 ** 15
dp = [[INF]*(10**5+1) for _ in range(n+1)]
dp[0][0] = 0

for i in range(n):
    for sum_v in range(10**5+1):
        if sum_v - v[i] >= 0:
            dp[i+1][sum_v] = min(dp[i][sum_v], dp[i][sum_v - v[i]]+w[i] )
        else:
            dp[i+1][sum_v] = dp[i][sum_v]

max_v =0
for sum_v in range(10**5+1):
    if dp[n][sum_v] <= W:
        max_v = sum_v

print(max_v)

Measured memory_bytes: 120044
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        mut abc: [u8; 3],
    }

    abc.sort();
    let mut ans = 0;
    if abc.iter().all(|&x| x % 2 == 0) || abc.iter().all(|&x| x % 2 == 1) {
        ans = (abc[2] - abc[0]) / 2 + (abc[2] - abc[1]) / 2;
    } else {
        if abc[0] % 2 == abc[1] % 2 {
            abc[0] += 1;
            abc[1] += 1;
        } else if abc[0] % 2 == abc[2] % 2 {
            abc[0] += 1;
            abc[2] += 1;
        } else {
            abc[1] += 1;
            abc[2] += 1;
        }
        ans = (abc[2] - abc[0]) / 2 + (abc[2] - abc[1]) / 2 + 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2116
#include<iostream>
#include<algorithm>
using namespace std;
signed main()
{
  int a,b,c,d,e,f,g,h,i,j,z;
  cin>>a>>b>>c>>d>>e>>f>>g>>h>>i>>j;
  z=a+b+c+d+e+f+g+h+i+j;
  cout<<z<<"\n";
  return(0);
}



Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>

using namespace std;

int main(){
	vector<pair<long long,long long> >v;
	long long k,n;
	long long x = 1;
	for(int i=0;i<4;i++){
		cin >> k;
		v.push_back(make_pair(k*8/x,x));
		x*=2;
	}
	sort(v.begin(),v.end());
	cin >> n;
	n *= 4;
	long long ans=0;
	for(int i=0;i<4;i++){
		ans += (n/v[i].second)*(v[i].first*v[i].second/8);
		if(n%v[i].second==0)break;
		n = n%v[i].second;
	}
	cout << ans << endl;
	return 0;
}

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

const int mx=1e6+5;

typedef long long ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;

int par[mx], rnk[mx];

void init(int n) {
	for (int i=0; i<n; i++)
		par[i]=i, rnk[i]=0;
}

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

void unite(int x, int y) {
	x=find(x);
	y=find(y);
	if(x==y) return;
	if(rnk[x]<rnk[y]) par[x]=y;
	else {
		par[y]=x;
		if(rnk[x]==rnk[y]) rnk[x]++;
	}
}

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N; cin>>N;
	vector<iii> v(N);
	for (int i=0; i<N; i++) {
		int x,y; cin>>x>>y;
		v[i]={{x,y},i+1};
	}
	vector<iii> edges;
	sort(v.begin(),v.end(),[&](const iii &a, const iii &b) {
		return a.first.first<b.first.first;
	});
	for (int i=1; i<N; i++) {
		int x=v[i].second, y=v[i-1].second, w=v[i].first.first-v[i-1].first.first;
		edges.push_back({{x,y},w});
	}
	sort(v.begin(),v.end(),[&](const iii &a, const iii &b) {
		return a.first.second<b.first.second;
	});
	for (int i=1; i<N; i++) {
		int x=v[i].second, y=v[i-1].second, w=v[i].first.second-v[i-1].first.second;
		edges.push_back({{x,y},w});
	}
	sort(edges.begin(),edges.end(),[&](const iii &a, const iii &b) {
		return a.second<b.second;
	});
	init(N+1);
	ll ret=0;
	for (auto e : edges) {
		int x=e.first.first, y=e.first.second, w=e.second;
		if(same(x,y)) continue;
		unite(x,y);
		ret+=w;
	}
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 13420
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long N;
struct wrk{
  long A;
  long B;
};

vector<wrk> w;
string result = "Yes";

void load_vars(){
  cin >> N;
  for(int i = 0; i < N; i++){
    int a, b;
    cin >> a >> b;
    wrk ww = {a, b};
    w.push_back(ww);
  }
  sort(w.begin(), w.end(), 
     [](const wrk& x, const wrk& y) { return x.B < y.B;});
}

int main(){
  load_vars();
  /*
  for(int i = 0; i < N; i++){
    cout << w[i].A << w[i].B << endl;
  }
  */
  
  long buf = 0, end_tmp = 0;
  
  for(int i = 0; i < N; i++){
    buf = buf + w[i].B - end_tmp - w[i].A;
    end_tmp = w[i].B;
    if (buf < 0){
      result = "No";
      break;
    }
    //cout << w[i].A << w[i].B << " " << buf << endl;
  }

  cout << result << endl;
}

Measured memory_bytes: 6512
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		int C = Integer.parseInt(sc.next());
		int[] B = new int[M];
		for(int i=0;i<M;i++){
			B[i] = Integer.parseInt(sc.next());
		}
		int ans = 0;
		for(int i=0;i<N;i++){
			int sum=C;
			for(int j=0;j<M;j++){
				sum += Integer.parseInt(sc.next())*B[j];
			}
			if(sum>0)ans++;
		}
		
		System.out.println(ans);
		sc.close();
	}
	

}

Measured memory_bytes: 21844
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <random>
#include <iomanip>
#include <limits>
 
using namespace std;
 
typedef long long ll;
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
ll 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,k,l,ii,jj;
ll n,m,a,b,c,d,ans,num,sum;
ll x[100005],y[100005];
 
int main(){
    cin>>a>>b; 
	num = b-a;
	for(i=1;i<=num;i++){
		sum += i;
	}
	p(sum-b);
    return 0;
}

Measured memory_bytes: 4992
def main():
    import math

    a, b, c, x, y = map(int, input().split())
    d = [a, b]
    i, j = min(x, y), max(x, y)
    n = math.ceil(i / 2)
    f = j == x
    if 2 * c > (a + b):
        ans = a * x + b * y
    else:
        ans = 2 * c * i + (j - i) * min(c * 2, d[not f])

    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
  int n, s = 0;
  cin >> n;
  vector<int> a(n), b(n);
  for(int i = 0; i < n; i++)
    cin >> a.at(i);
  for(int i = 0; i < n; i++)
    cin >> b.at(i);
  for(int i = 0; i < n; i++){
    if(a.at(i) - b.at(i) >= 0)
      s += (a.at(i) - b.at(i));
  }
  cout << s << endl;
}

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

int arr[100010];
int cta[100010], ctb[100010];

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d", arr + i);
	for (int i = 0; i < n; ++i) {
		if (i % 2) ++ctb[arr[i]];
		else ++cta[arr[i]];
	}
	int mx1 = 0, mx2 = 0;
	for (int i = 1; i <= 100000; ++i)
		if (cta[i] > cta[mx1])
			mx1 = i;
	for (int i = 1; i <= 100000; ++i)
		if (ctb[i] > ctb[mx2])
			mx2 = i;
	if (mx1 != mx2)
		printf("%d\n", n - cta[mx1] - ctb[mx2]);
	else {
		int smx1 = 0, smx2 = 0;
		for (int i = 1; i <= 100000; ++i)
			if (i != mx1 && cta[i] > cta[smx1])
				smx1 = i;
		for (int i = 1; i <= 100000; ++i)
			if (i != mx2 && ctb[i] > ctb[smx2])
				smx2 = i;
		printf("%d\n", min(n - cta[mx1] - ctb[smx2], n - cta[smx1] - ctb[mx2]));
	}
	return 0;
}


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

int main(){
  long long int x;
  cin >> x;
  long long int A_5,B_5;
  for(long long int i=-1000;i<=1000;i++){
    A_5=i*i*i*i*i;
    
    for(long long int j=-1000;j<=1000;j++){
        B_5=j*j*j*j*j;
        if(A_5-B_5==x){
         
          cout << i << " " << j << endl;
          return 0;
        }
    }
  }
    
}


Measured memory_bytes: 3588