akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

/*
0のアスキー　"48"
*/

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

int main(){
    int x;
    cin >> x;
    if(x == 1)
        cout << 0 << endl;
    else
        cout << 1 << endl;
}

Measured memory_bytes: 3632
def traveling(n, m):
    t = range(1, n+1)
    for i in t:
        tdif = m[i][0] - m[i-1][0]
        xydif = abs(m[i][1] - m[i-1][1]) + abs(m[i][2] - m[i-1][2])
        if tdif < xydif:
            return 'No'
        else:
            if tdif%2 != xydif%2:
                return 'No'
    return 'Yes'
N = int(input())
deer = [[0,0,0]] + [list(map(int, input().split())) for i in range(N)]
print(traveling(N, deer))

Measured memory_bytes: 28148
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int dp[1005][1 << 15];
signed main() {
    int N,M;
    cin >> N >> M;
    for(int i = 0; i < 1005; i++) {
        for(int j = 0; j < (1 << 15); j++) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    for(int i = 0; i < M; i++) {
        int a,b;
        cin >> a >> b;
        vector<int>c(N);
        for(int i = 0; i < b; i++) {
            int C;
            cin >> C;
            C--;
            c[C] = 1;
        }
        for(int j = 0; j < (1 << N); j++) {
            dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
            int X = j;
            for(int k = 0; k < N; k++) {
                if(c[k] && !(1 & (j >> k))) {
                    X ^= 1 << k;
                }
            }
            dp[i+1][X] = min(dp[i+1][X],dp[i][j]+a);
        }
    }
    if(dp[M][(1 << N)-1] == INF) {
        cout << -1 << endl;
        return 0;
    }
    cout << dp[M][(1 << N)-1] << endl;
}


Measured memory_bytes: 260908
import copy
# a, b = map(int,input().split())

n,k = map(int,input().split())
# b_l = list(map(int,input().split()))
lr = list(input())

count = 0
sum = 0
lr_org = copy.copy(lr)
if lr[0] == 'L':
        for i in range(n):
                if lr[i] == 'R':
                        lr[i] = 'L'
                        if lr_org[i-1] == 'L':
                                count += 1
                else:
                        if count >= k:
                                break
else:
        for i in range(n):
                if lr[i] == 'L':
                        lr[i] = 'R'
                        if lr_org[i-1] == 'R':
                                count += 1
                else:
                        if count >= k:
                                break
for i in range(n-1):
        if lr[i] == lr[i+1]:
                sum += 1
print(sum)

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

vector<int> par;
vector<int> len;
vector<int> mem;

int root(int a){
  int p;
  int i=0;
  int k;
  p=a;
  while (par.at(p) != p){
    mem.at(i)=p;
    p=par.at(p);
    i++;
  }
  for (int j=0; j<i; j++){
    k=mem.at(j);
    par.at(k)=p;
  }
  return p;
}

int ask(int a, int b){
  if (root(a) == root(b))
    return 1;
  else
    return 0;
}

void join(int a, int b){
  int c, d;
  if (ask(a,b))
    return;
  else{
    c=root(a);
    d=root(b);
    if (len.at(c) < len.at(d)){
      par.at(c)=d;
      len.at(d) += len.at(c);
    }
    else{
      par.at(d)=c;
      len.at(c) += len.at(d);
    }
  }
}
  
int main() {
  int N, M;
  cin >> N >> M;
  int x, u, v;
  par.resize(N+1);
  len.resize(N+1);
  mem.resize(N+1);
  for (int i = 1; i < N+1; i++) {
    par.at(i)=i;
  }
  for (int i = 1; i < N+1; i++) {
    len.at(i)=1;
  }
  for (int i=0; i<M; i++){
    cin >> u >> v;
    join(u,v);
  }
  int max=0;
  for(int i=1;  i<N+1; i++){
    if (len.at(i) > max)
       max=len.at(i);
  }
  cout << max << endl;
}


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

//エラトステネスの篩っぽく
#define MAX 7500000       //MAX の取り方が？？？？

int main(){

    while(1){
        int m, n; cin >> m >> n;
        if(n == 0) break;

        vector<bool> p(MAX, false);
        int j = m;
        int ans;
        while(n > 0){
            if(p[j] == false){
                ans = j;
                for(int k = j; k < MAX; k += j){
                    p[k] = true;
                }
                n--;
            }
            j++;
        }
        
        while(1){
            if(p[ans] == false){
                cout << ans << endl;
                break;
            }
            ans++;
        }
    }

    return 0;
}


Measured memory_bytes: 4008
n=int(input())
li=[]
for i in range(n):
  s,p=input().split()
  p=int(p)
  li.append([i+1,s,p])
li.sort(key=lambda x:x[2], reverse=True)
li.sort(key=lambda x:x[1])
for i in range(n):
  print(str(li[i][0]))

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
using namespace std;
using ll=long long;

int main() {
	ll n, ans = 0;
	cin >> n;
	vector<int>a(n);
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
	}
	bool flag = true;
	while (true) {
		for (ll i = 0; i < n; i++) {
			if (a[i] % 2 == 0) {
				a[i] /= 2;
			} else {
				flag = false;
				break;
			}
		}
		if (!flag)break;
		ans++;
	}
	cout << ans << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int a,b;cin>>a>>b;
    rep(i,1010){
        double x=(double)i*0.1,y=(double)i*0.08;
        int c=x,d=y;
        if(c==b&&d==a){
            cout<<i<<endl;return 0;
        }
    }
    cout<<-1<<endl;
}

Measured memory_bytes: 256
s=input()
if (s[:7]=="keyence" or s[:6]+s[-1:]=="keyence" or s[:5]+s[-2:]=="keyence" or s[:4]+s[-3:]=="keyence" or s[:3]+s[-4:]=="keyence" or s[:2]+s[-5:]=="keyence" or s[:1]+s[-6:]=="keyence" or s[-7]=="keyence"):
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

struct Info {
	long long x;
	long long y;
	Info(long long x, long long y) {
		this->x = x;
		this->y = y;
	}
};

// ���l x �Ń\�[�g���邽�߂̔�r���Z�q
bool cmp_x(const Info& a, const Info& b) {
	return a.x < b.x;
}

// ���l y �Ń\�[�g���邽�߂̔�r���Z�q
bool cmp_y(const Info& a, const Info& b) {
	return a.y < b.y;
}

int main() {

	long long W, H, N;
	cin >> W >> H >> N;

	vector<vector<Info>> val(4, vector<Info>());

	long long x, y, a;
	for (long long i = 0; i < N; i++) {
		cin >> x >> y >> a;
		a--;
		val[a].push_back(Info(x, y));
	}

	for (long long i = 0; i < 4; i++) {
		if (i == 0 || i == 1) {
			sort(val[i].begin(), val[i].end(), cmp_x);
		}
		else {
			sort(val[i].begin(), val[i].end(), cmp_y);
		}
	}

	long long x_min = 0;
	long long x_max = W;
	long long y_min = 0;
	long long y_max = H;
	
	if (val[0].size() != 0) {
		x_min = val[0][val[0].size() - 1].x;
	}
	if (val[1].size() != 0) {
		x_max = val[1][0].x;
	}
	if (val[2].size() != 0) {
		y_min = val[2][val[2].size() - 1].y;
	}
	if (val[3].size() != 0) {
		y_max = val[3][0].y;
	}

	if (x_min < x_max) {
		x = x_max - x_min;
	}
	else {
		x = 0;
	}

	if (y_min < y_max) {
		y = y_max - y_min;
	}
	else {
		y = 0;
	}

	cout << x * y << endl;

	return 0;
}

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

int gcd(long long int m, long long int n) { 
    if(n == 0) 
        return m; 
    else 
        return gcd(n, m % n); 
}

int main(){
	long long int n;
	long long int a[100000];
	cin >> n;
	for(int i = 0;i<n;i++){
		cin >> a[i];
	}
	for(int i = n-1;i>=1;i--){
		a[i-1] = gcd(a[i],a[i-1]);
	}
	cout << a[0];
}

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

int main() {
  int N;
  cin >> N;
  vector<string> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p.at(i);
    sort(p.at(i).begin(), p.at(i).end());
  }
  sort(p.begin(), p.end());
  long long int c = 0;
  int t = 0;
  while (t < N - 1) {
    long long int a = 1;
    for (int i = t + 1; i < N; i++) {
      if (p.at(t) == p.at(i)) {
        a++;
      }
      else {
        t = i;
        c += a * (a - 1) / 2;
        break;
      }
      if (i == N - 1) {
        c += a * (a - 1) / 2;
        t = N - 1;
      }
    }
  }
  printf("%lld\n", c);      
}


Measured memory_bytes: 7296
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::str::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::cmp::{min,max};

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let s: String = cin 
        .bytes() // Bytes
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace()) // c が whitespace である限り skip
        .take_while(|c| !c.is_whitespace()) // c が whitespace でない限り要素を返す
        .collect();
    s.parse().ok().expect("failed parsing")
}

fn main() {
    input!(n:usize);
    let mut h = HashSet::new();
    let mut p = 1;
    for i in 0..10 {
        h.insert(p);
        p *= 2;
    }
    for i in 0..n {
        let j = n - i;
        if h.contains(&j) {
            println!("{}", j);
            break;
        }
    }
}


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

using ll=long long;
int main(){
    ll n,d;
    cin>>n>>d;
    if(d!=1) cout<<(n-d+2)*(n-d+1)/2+d-3<<endl;
    else cout<<n*(n-1)/2<<endl;
    return 0;
}


Measured memory_bytes: 3116
N = int(input())
li = [[0]*9 for i in range(9)]
counter = 0

for i in range(1,N+1):
    I = str(i)
    fast = int(I[0])
    last = int(I[-1])
    if not last==0:
        li[fast-1][last-1] += 1

for i in range(9):
    for k in range(9):
        counter += li[i][k]*li[k][i]


print(counter)

Measured memory_bytes: 40428
#include<stdio.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
int n,m,dui;
const int p=998244353;
long long f[11000],inv[11000],bi[11000],ans[11000];
inline long long qpow(int a,int n){
	long long x=a,ans=1;
	while (n){
		if (n&1) ans=ans*x%p;
		x=x*x%p;
		n>>=1;
	}
	return ans;
}
inline long long C(int n,int m){
	if (m<0||m>n) return 0;
	return f[n]*inv[m]%p*inv[n-m]%p;
}
inline int wor(int n,int dui,int num){
	int w=1;long long ans=0;
	fo(i,0,dui){//not use dui
		ans+=bi[dui-i]*C(dui,i)%p*C(n+dui-i+num-1,dui-i+num-1)%p*w;//C(n+dui+num-1,dui+num-1)
		w=-w;
	}
	return (ans%p+p)%p;
}
int main(){
	scanf("%d%d",&m,&n);
	bi[0]=1;
	fo(i,1,m){
		bi[i]=bi[i-1]<<1;
		if (bi[i]>=p) bi[i]-=p;
	}
	f[0]=inv[0]=1;
	fo(i,1,n+m) f[i]=f[i-1]*i%p; 
	inv[n+m]=qpow(f[n+m],p-2);
	fd(i,n+m-1,1) inv[i]=inv[i+1]*(i+1)%p;
	//fo(i,n+m-10,n+m) printf("%d\n",f[i]*inv[i]%p);
	fo(i,2,m+1){
		if (i&1){
			dui++;
			ans[i]=wor(n,dui,m-dui*2);	
		}else{
			ans[i]=wor(n,dui,m-dui*2-1)+wor(n-1,dui,m-dui*2-1);
			if (ans[i]>=p) ans[i]-=p;
		}
		printf("%lld\n",ans[i]);
	} 
	fd(i,m,2) printf("%lld\n",ans[i]);
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
using Int = long long;
Int f(Int x, Int y) { return x < 0 ? 0 : x / y + 1; }
int main()
{
    Int a, b, x; cin >> a >> b >> x;
    cout << f(b, x) - f(a - 1, x) << endl;
    return 0;
}

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

namespace CompetitiveProgCsLib
{
	class MainProg
	{
		static string R => Console.ReadLine();
		static int RI => int.Parse(R);
		static double RD => double.Parse(R);
		static int[] RIs => R.Split(' ').Select(int.Parse).ToArray();
		static double[] RDs => R.Split(' ').Select(double.Parse).ToArray();
		static void Out(object obj) => Console.WriteLine(obj);
		static void OutLine<T>(IEnumerable<T> obj, string separateChar) => Out(String.Join(separateChar, obj));
		static void Outb(bool b) => Out(b ? "Yes" : "No");
		static void OutB(bool b) => Out(b ? "YES" : "NO");
		static bool IsIn(int y, int x, int h, int w) => 0 <= x && x < w && 0 <= y && y < h;

		static void Main(string[] args)
		{
			var n = RI;
			var s = R;
			int[] w = { 0, 0 };
			int[] e = { 0, 0 };
			for(int i = 0;i < n;i++)
			{
				if (s[i] == 'W') w[0]++;
				else e[0]++;
			}
			int min = int.MaxValue;
			for (int i = 0; i < n; i++)
			{
				if (s[i] == 'E')
				{
					min = Math.Min(min, w[1] + e[0] - 1);
					e[0]--;
					e[1]++;
				}
				else
				{
					min = Math.Min(min, w[1] + e[0]);
					w[0]--;
					w[1]++;
				}
			}
			Out(min);
		}		
	}
}


Measured memory_bytes: 14176
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  vector<int> l(N);
  for(int i=0;i<N;i++){
    cin>>l.at(i);
  }
  sort(l.begin(),l.end());
  reverse(l.begin(),l.end());
  int ans=0;
  for(int i=0;i<K;i++){
    ans+=l.at(i);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  int N,M; cin>>N>>M;

  string ans = N==M ? "Yes" : "No";
  cout << ans << endl;


  return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  int a, b = 0;
  vector<int> L(M);
  vector<int> R(M);
  for(int i = 0; i < M; i++) {
    cin >> L.at(i) >> R.at(i);
  }
  sort(L.begin(), L.end());
  sort(R.begin(), R.end());
  a = L.at(M-1);
  b = R.at(0);
  if(b-a+1 < 0) {
    cout << "0" << endl;
  }
  else {
    cout << b-a+1 << endl;
  }
}


Measured memory_bytes: 1024
///*****************************************************///
///*.......................Faiyaj Bin Amin............................*///
///*...................................................................*///
///*.........................KUET CSE 2K17......................*///
///*...................................................*///
///*****************************************************///

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define fastio      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define ret return
#define rep(q, i, n) for(int q=i; q<n; q++)
#define forn(i, n) for(int i=0; i<n; i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define ll long long
#define pb push_back
#define em emplace_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define ff first
#define ss second
#define pii pair<int,int>
#define pdd pair<double, double>

#define see(x)        cerr<< __LINE__ << ": " << (#x) << " is "<< (x) <<'\n';
#define seecontent(v) for(auto x : v) { cout << x << " ";} cout << "\n\n";

#define PI 2*acos(0.0)
#define lcm(a, b)  ((a / __gcd(a, b) ) * b)

#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)

#define mx 100005
#define INF 1e18
#define MOD 1000000007
#define MIN 0

//template <typename T>  using orderedSet =
//    tree<T, null_type, less_equal<T>,
//    rb_tree_tag, tree_order_statistics_node_update>; //find_by_order, order_of_key


/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0}; // Directional
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

/**------------------------------------BITMASK------------------------------------------**/
//int Change(int N, int pos){return N= N^(1<<pos);}
//bool Check(int N, int pos){return (bool)(N &(1<<pos));}  /// check bit 0 or 1
/**-----------------------------------------------------------------------------------------------**/

//using namespace __gnu_pbds;
using namespace std;

int main()
{
    fastio;

    char a;
    cin >> a;

    if(a=='A')
    {
        cout << "T\n";
    }
    else if(a=='T')
    {
        cout << "A\n";
    }
    if(a=='G')
    {
        cout << "C\n";
    }
    if(a=='C')
    {
        cout << "G\n";
    }

    return 0;
}




Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned long;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

    void Solve() {
        UL N; cin >> N;
        ULL W; cin >> W;
        vector<pair<ULL, ULL>> VW(40); rep(i, N) cin >> VW[i].first >> VW[i].second;
        vector<pair<ULL, ULL>> WVS(1 << 20);
        vector<pair<ULL, ULL>> WVT(1 << 20);
        rep(i, 20) {
            rep(j, 1 << i) {
                WVS[j + (1 << i)] = { WVS[j].first + VW[i].second, WVS[j].second + VW[i].first };
                WVT[j + (1 << i)] = { WVT[j].first + VW[i + 20].second, WVT[j].second + VW[i + 20].first };
            }
        }
        sort(WVT.begin(), WVT.end());
        rep(i, (1 << 20) - 1) {
            WVT[i + 1].second = max(WVT[i + 1].second, WVT[i].second);
        }
        ULL ans = 0;
        rep(i, 1 << 20) {
            if (WVS[i].first > W) continue;
            UL l = 0, r = 1 << 20;
            while (l + 1 < r) {
                UL m = (l + r) >> 1;
                if (WVS[i].first + WVT[m].first <= W) l = m;
                else r = m;
            }
            ans = max(ans, WVS[i].second + WVT[l].second);
        }
        cout << ans << endl;
    }
};
int main() {
    unique_ptr<Problem> p(new Problem());
    cout << fixed << setprecision(10);
    p->Solve();
    return 0;
}



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

int main()
{
    int a,b,t;
    scanf("%d%d",&a,&b);
    if(a<b)
    {
        t=a;
        a=b;
        b=t;
    }
    if((a-b)>=2)
    {
        printf("%d",2*a-1);
    }
    else
    {
        printf("%d",a+b);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> vi;

template<class T> inline T re(){
	T N = 0; char c = getchar(); bool neg = 0;
	for (; c < '0' || c > '9'; c = getchar()) neg |= c == '-';
	for (; c >= '0' && c <= '9'; c = getchar())
		N = (N<<3)+(N<<1) + c - '0';
	return neg ? -N : N;
}

const int mxsz = 505;
int n, k, tot;
int a[mxsz];
int rem[mxsz];
int ans = 0;

void test(int x){
	for (int i = 1; i <= n; i++){
		rem[i] = a[i] % x;
	}
	sort(rem + 1, rem + n + 1);
	int i = 1, j = n;
	int cur = 0;
	while (i < j){
		int u = min(rem[i], x - rem[j]);
		rem[i] -= u; rem[j] += u;
		cur += u;
		if (rem[i] == 0) i++;
		if (rem[j] == x) j--;
	}
	if (i == j && rem[i] != 0 && rem[i] != x) return;
	if (cur <= k) ans = max(ans, x);
}

int main(){
	n = re<int>(); k = re<int>();
	for (int i = 1; i <= n; i++)
		tot += (a[i] = re<int>());
	for (int f = 1; f * f <= tot; f++){
		if (tot % f) continue;
		test(f);
		test(tot / f);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
from fractions import gcd


def solve():
    N, X, *x = map(int, open(0).read().split())
    
    d = [abs(X - xi) for xi in x]
    ans = d[0]
    for di in d[1:]:
        ans = gcd(ans, di)
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 16104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

const ll MOD = 1e9 + 7;

int main(){
    int n, q;
    cin >> n >> q;
    vec<vec<int>> g(n);
    rep(i, n-1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    queue<int> que;
    vec<int> parent(n, -1);
    vec<int> seen(n, 0);
    que.push(0);
    seen[0] = 1;
    while(!que.empty()) {
        int v = que.front(); que.pop();
        for (int nv : g[v]) {
            if (seen[nv] > 0) continue;
            parent[nv] = v;
            que.push(nv);
            seen[nv] = 1;
        }
    }
    vec<int> query(n);
    rep(i, q) {
        int p, x;
        cin >> p >> x;
        p--;
        query[p] += x;
    }

    queue<P<int, int>> que2;
    vec<int> seen2(n, 0);
    vec<int> ans(n);
    que2.push(P<int, int>(0, query[0]));
    seen2[0] = 1;
    ans[0] = query[0];
    while(!que2.empty()) {
        int v = que2.front().first;
        int cost = que2.front().second;
        que2.pop();
        for (int nv : g[v]) {
            if (seen2[nv] > 0) continue;
            if (nv == parent[v]) continue;
            int ncost = cost + query[nv];
            que2.push(P<int, int>(nv, ncost));
            ans[nv] = ncost;
            seen2[nv] = 1;
        }
    }
    rep(i, n) cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 19444
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		// your code goes here
		
		var c = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
		int a = c[0];
		int b = c[1];
		int counter = 0;
		int sum = 1;
		
		for(int i=0; sum<b; i++){
			sum += a-1;
			counter++;
		}
		
		Console.WriteLine(counter);
		
	}
}

Measured memory_bytes: 13396
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.NoSuchElementException;
 
public class Main implements Runnable{
    static final int INF = (int)1e9 + 7;
	int V,E;
	int[][] cap;
    boolean[] used;
 
    public int dfs(int v,int t,int f){
 
        if(v == t)return f;
 
        used[v] = true;
        for(int i = 0;i < V;i++){
			//if(cap[v][i] == 0 && cap[i][v] == 0)continue;
            if(!used[i] && cap[v][i] > 0){
                int d = dfs(i,t,Math.min(f, cap[v][i]));
                if(d > 0){
                    cap[v][i] -= d;
                    cap[i][v] += d;
                    return d;
                }
            }
 
        }
 
        return 0;
    }
 
    public int max_flow(int s,int t){
        int flow = 0;
        for(;;){
 
            Arrays.fill(used, false);
            int f = dfs(s,t,INF);
            if(f == 0)return flow;
            flow += f;
        }
    }
 
    @SuppressWarnings("unchecked")
    public void solve() {
        V = nextInt();
        E = nextInt();
		
		cap = new int[V][V];
		
        used = new boolean[V];
		
        for(int i = 0;i < E;i++){
 
            int u = nextInt();
            int v = nextInt();
            int c = nextInt();
			
			cap[u][v] = c;
        }
 
        out.println(max_flow(0,V-1));
    }
 
    public static void main(String[] args) {
        new Thread(null,new Main(),"",32 * 1024 * 1024).start();
    }
 
    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;
 
    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }
 
    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }
 
    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }
 
    public int nextInt() {
        return Integer.parseInt(next());
    }
 
    public long nextLong() {
        return Long.parseLong(next());
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
 
    @Override
    public void run() {
        out.flush();
        new Main().solve();
        out.close();
 
    }
}

Measured memory_bytes: 26260
import sys, copy

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

l = [a,b,c,d,e]
for n, i in enumerate(l):
    ll = copy.copy(l)
    del ll[n]
    for j in range(4):
        if not abs(i - ll[j]) <= k:
            print(':(')
            sys.exit()
print('Yay!')

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

int main() {
  std::string alphabet = "abcdefghijklmnopqrstuvxwyz";
  char in;
  std::cin >> in;
  for(size_t i = 0; i < alphabet.size(); ++i) {
    if(alphabet.at(i) == in) {
      std::cout << alphabet.at(i+1);
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll; ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);
ll fac(ll x){if(x==0) return 1;  return x*fac(x-1);}

int main(){
  ll n,k,ans=0;
  cin>>n>>k;
  vector<ll>v(n);
  rep(i,n){
    cin>>v[i];
  }
  sort(all(v));
  reverse(all(v));
  if(k>n)
    cout<<0<<endl;
  else{
  for(ll i=k;i<n;i++){
  ans+=v[i];
  }
  cout<<ans<<endl;
  }
} 

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

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// print(x, y, z);
// printVec(va.begin(), va.end());
void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}

int main()
{
  ll N;
  std::cin >> N;
  std::vector< ll > va(N, 0LL);

  ll sum = 0LL;
  ll min_val = INF;
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
    sum += va[i];
    if (va[i] % 10 != 0) min_val = std::min(min_val, va[i]);
  }

  ll ans = sum;
  if (min_val == INF) {
    ans = 0LL;
  } else if (sum % 10 == 0) {
    ans -= min_val;
  }

  print(ans);
  return 0;
}


Measured memory_bytes: 256
a,b=map(int,input().split())

mn=max(b*10,a*12.5)
if mn==a*12.5 and a%2==1:
    mn=int(mn)+1
mx=min((b+1)/0.1,(a+1)/0.08)
if mn<mx:
    print(int(mn))
else:
    print(-1)

Measured memory_bytes: 38484
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
  ll int n, k;
  cin >> n >> k;
  vector<int> vc;
  while (n--) {
    ll int x;
    cin >> x;
    vc.push_back(x);
  }
  if (n <= k) {
    sort(vc.begin(), vc.end());
    ll int size = vc.size();
    // cout << size << endl;
    ll int sum = 0;
    for (ll int i = 0; i < size - k; i++) {
      sum = sum + vc[i];
    }
    cout << sum;
  } else {
    cout << 0;
  }
  return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 60) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int main() {
	string s;
	int ans = 0;
	cin >> s;
	rep(i, s.size()) {
		ans += (s[i] == '1');
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <functional>
#include <deque>
typedef long long ll;
using namespace std;
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main(){
    ll n;
    int m;
    cin >> n >> m;

    UnionFind uf(n);

    stack<pair<ll,ll>> stk;
    for(int i = 0;i < m;i++){
        ll a,b;
        cin >> a >> b;
        a--,b--;
        stk.emplace(a,b);
    }

    ll now = n * (n-1) / 2;
    vector<ll> ans;
    while(stk.size()){
        ans.push_back(now); 
        pair<ll,ll> p = stk.top();
        stk.pop(); 

        if(!uf.issame(p.first,p.second)){
            ll a = uf.size(p.first);
            ll b = uf.size(p.second);
            uf.merge(p.first,p.second);
            now -= a * b;
        }
    }

    reverse(ans.begin(),ans.end());
    for(int i = 0;i < m;i++)cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 4908
//****************************//
/**********  main *************/
//****************************//
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i, n) for(i = 0; i < n; i++)
#define FOR(i, a, b) for(i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())

double pi = 3.141592653589793;

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

int main() {

    std::cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b, c, k;
    int res,count=0;
    bool flag = false;

    cin >> a >> b >> c >> k;

    while(!flag) {
        if(b <= a) {
            b = b * 2;
            count++;
        } else {
            flag = true;
        }
    }
    
    flag = false;

    while(!flag) {
        if(c <= b) {
            c = c * 2;
            count++;
        } else {
            flag = true;
        }
    }


    if(a < b && b < c && count <= k){
        cout << "Yes" << endl;
    } else {
         cout << "No" << endl;
    }


    // cout << res << endl;

    return 0;
}


Measured memory_bytes: 3652
fn main() {
    proconio::input! {
        h: usize,
        w: usize,
        m: usize,
        b: [(proconio::marker::Usize1, proconio::marker::Usize1); m]
    };
    let mut cnt_h = vec![0; h];
    let mut cnt_w = vec![0; w];
    for &p in &b {
        cnt_h[p.0] += 1;
        cnt_w[p.1] += 1;
    }
    let max_h = *cnt_h.iter().max().unwrap();
    let max_w = *cnt_w.iter().max().unwrap();
    let overlap :i64 = cnt_h.iter().fold(0, |a, &x| a + if x == max_h { 1 } else { 0 }) * cnt_w.iter().fold(0, |a, &x| a + if x == max_w { 1 } else { 0 });
    let cover = b.iter().fold(0, |a, &(x, y)| a + if cnt_h[x] == max_h && cnt_w[y] == max_w { 1 } else { 0 });
    println!("{}", max_h + max_w - if cover == overlap { 1 } else { 0 });
}


Measured memory_bytes: 13008
N,A,B,C=map(int, raw_input().split())

mod=10**9+7
fact, inv_fact = [1], [1]
fact_tmp = 1
for i in range(1, 2*N):
	fact_tmp *= i
	fact_tmp %= mod
	fact.append(fact_tmp)
	inv_fact.append(pow(fact_tmp, mod-2, mod))
 
def ncr(n,r):
	if n < 0 or r < 0 or n < r:	return 0
	else:	return (fact[n] * inv_fact[r] * inv_fact[n-r]) %mod


P=0
for g in range(N, 2*N):
	P+=pow( A+B , (2*N-1-g) , mod) * g*pow(A,N,mod)* pow(B,g-N,mod) *ncr(g-1,(N-1))
	P%=mod
	P+=pow( A+B , (2*N-1-g) ,mod) * g*pow(A,g-N,mod) * pow(B,N,mod) *ncr(g-1,(N-1))
	P%=mod

Q=pow( A+B , 2*N-1,mod) 

hikiwake=100*pow(100-C,mod-2, mod) 
print ( P*pow(Q, mod-2 , mod) *hikiwake )%mod


Measured memory_bytes: 61724
import java.util.Scanner;
import java.lang.Math;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Vector v = new Vector();
		for(int i = 0 ; i < n ; i ++){
			v.x[i]=sc.nextDouble();
		}
		for(int i = 0 ; i < n ; i ++){
			v.y[i]=sc.nextDouble();
		}
		v.p1(n);
		v.p2(n);
		v.p3(n);
		v.pInfinit(n);
	}
}
class Vector{
	public double[] x = new double[100];
	public double[] y = new double[100];
	private double ans = 0;
	void p1(int n){
		for(int i = 0 ; i < n ; i ++){
			ans+=Math.abs(x[i]-y[i]);
		}
		System.out.println(ans);
		ans=0;
	}
	void p2(int n){
		for(int i = 0; i < n ; i ++){
			ans+=Math.pow((x[i]-y[i]), 2);
		}
		System.out.println(Math.sqrt(ans));
		ans=0;
	}
	void p3(int n){
		double q=0;
		for(int i = 0; i < n ; i ++){
			q = Math.abs(x[i]-y[i]);
			ans+=Math.pow(q, 3);
		}
		System.out.println(Math.cbrt(ans));
		ans=0;
	}
	void pInfinit(int n){
		double max = 0;
		for(int i = 0 ; i < n ; i ++){
			if(max<Math.abs(x[i]-y[i]))
				max=Math.abs(x[i]-y[i]);
		}
	System.out.println(max);
	}
}

Measured memory_bytes: 21388
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+5;
vector<ll> V;
int pre[maxn],a[maxn],b[maxn];
int n,m;
struct EGDE{
    int v,nex;
}edge[maxn];
int head[maxn],ecnt;
inline void add_edge(int u,int v){
    edge[++ecnt]={v,head[u]};head[u]=ecnt;
    edge[++ecnt]={u,head[v]};head[v]=ecnt;
}
int ans[maxn];
void bfs(){
    queue<int> Q;Q.push(1);ans[1]=1;
    while ((!Q.empty())){
        int x=Q.front();Q.pop();
        for(int i=head[x];i;i=edge[i].nex){
            int v=edge[i].v;if(ans[v]) continue;
            ans[v]=x;Q.push(v);
        }
    }
}
int main() {
    cin>>n>>m;
    for(int i=1;i<=m;i++) {
        int u,v;cin>>u>>v;
        add_edge(u,v);
    }
    bfs();
    for(int i=2;i<=n;i++) if(!ans[i]) {puts("No");return 0;}
    puts("Yes");for(int i=2;i<=n;i++) cout<<ans[i]<<endl;
    return 0;
}

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

int main(){
 long long a,b,c,d;
 cin>>a>>b>>c>>d;
 long long ans=a*c;
 if(ans<a*d) ans=a*d;
 if(ans<b*c) ans=b*c;
 if(ans<b*d) ans=b*d;
 cout<<ans<<endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a > b) {
			for(int i=0; i<a; i++) {
				System.out.print(b);
			}
		}else {
			for(int i=0; i<b; i++) {
				System.out.print(a);
			}
		}
	}

}

Measured memory_bytes: 21716
import java.util.*;
public class Main {
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());
		int[] a = new int[n];
		for(int i = 0;i < n; ++i){
			a[i] = Integer.parseInt(scan.next());
		}
		int ans = 0;
		for(int i =0;i < n; ++i){
			if (a[a[i]-1] == i+1)++ans;
		}
		System.out.println(ans/2);
	}

}
//end

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

using VI = vector<int>;

int main(void){
    int n;
    int ii;
    int firstSum, secondSum;
    secondSum = 0;
    firstSum = 0;
    cin >> n;
    VI vi(n, 0);
    rep(ii, n){
        cin >> vi[ii];
    }
    rep(ii, n){
        // cout << vi[ii];
    }
    vector<int>::iterator head, tail;
    head = vi.begin();
    tail = vi.end();
    tail--;
    /*
    cout << "head: " << *head << endl;
    cout << "tail: " << *tail << endl;
     */

    while(head != tail){
        if(firstSum < secondSum){
      //      cout << *head << endl;
            firstSum += *head;
            head++;
        }else{
       //     cout << *tail << endl;
            secondSum += *tail;
            tail--;
        }
        // cout << "firstSum and secondSum:"  << firstSum << "," << secondSum << endl;
    }
    if(firstSum < secondSum){
        firstSum += *head;
    }else{
        secondSum += *tail;
    }

    // cout << "firstSum and secondSum" << firstSum << "," << secondSum << endl;
    cout << abs(firstSum - secondSum) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <array>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <random>
#include <bitset>
#include <cassert>
#include <tuple>
#include <list>
#include <iterator>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;
typedef long double ld;

template<class htpe, class cmp>
using heap = priority_queue<htpe, vector<htpe>, cmp>;

template<class htpe>
using min_heap = heap<htpe, greater<htpe> >;

template<class htpe>
using max_heap = heap<htpe, less<htpe> >;

#define mp make_pair
#define pb push_back
#define mt make_tuple
#define ff first
#define ss second

#define forn(i, n) for (int i = 0; i < ((int)(n)); ++i)
#define forrn(i, s, n) for (int i = (int)(s); i < ((int)(n)); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

#define PYMOD(a, m) ((((a) % (m)) + (m)) % (m))

const int INF = 1791791791;
const ll INFLL = 1791791791791791791ll;


int main() {
    // Code here:

    int a, b;
    cin >> a >> b;
    if ((a * b) % 2 == 0)
        cout << "Even" << endl;
    else
        cout << "Odd" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <utility>
#include <string>
using namespace std ;
using psi = pair<string,int> ;

int main(){
	queue<psi> qp ;
	int n,q ; cin >> n >> q ;
	int t = 0 ;
	psi sub ;
	for(int i=0;i<n;i++){
		cin >> sub.first >> sub.second ;
		qp.push(sub) ;
	}
	while(!qp.empty()){
		sub = qp.front() ;
		if(sub.second<=q){
		    t += sub.second ;
			cout << sub.first << " " << t << endl ;
			qp.pop() ;
		}else{
			qp.pop() ;
			sub.second -= q ;
			t += q ;
			qp.push(sub) ;
		}
	}
}


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

// DP (rec + memo) version
int dp[21][11][156];
void init(){
  // not yet computed
  for(int i = 0; i < 21; i++) {
    for(int j = 0; j < 11; j++) {
      for(int k = 0; k < 156; k++) {
        dp[i][j][k] = -1;
      }
    }
  }
}
int rec(int n, int k, int s)
{
  if(s < 0) return 0;  // no answer
  if(k == 0) return s == 0 ? 1 : 0; // 0 by 0?
  if(dp[n][k][s] >= 0) return dp[n][k][s];
  int cnt = 0;
  if(n > k) {
    // using n, or not using n
    cnt = rec(n-1, k-1, s-n) + rec(n-1, k, s);
  } else if(n == k) {
    if( s == n * (n+1) / 2 ) cnt = 1;
  }
  dp[n][k][s] = cnt;
  return cnt;
}
int main(int argc, char *argv[])
{
  init();
  for(;;) {
    int n, k, s;
    cin >> n >> k >> s;
    if(n == 0 && k == 0 && s == 0) break;
    int cnt = 0;
    if(k <= n) {
      cnt = rec(n, k, s);
    }
    cout << cnt << endl;
  }
  return 0;
}



Measured memory_bytes: 3232
#include <iostream>
using namespace std;
int main()
{
    int N;
    cin >> N;
    switch(N % 10)
    {   
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon";
            break;

        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon";
            break;

        case 3:
            cout << "bon";
            break;
    }
    
    return 0;
}

Measured memory_bytes: 3676
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    そう甘くはないんだな〜w
*/

// from std...
use std::cmp::{
    max, min, Ordering,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::convert::TryInto;
use std::mem::swap;
use std::num::{NonZeroU32, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Index, IndexMut, Mul, MulAssign, Neg, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub,
    SubAssign,
};
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, multinomial, Integer};
use num_rational::Rational;
use num_traits::{clamp, one, pow, zero, Num, NumAssignOps, NumOps, One, Pow, Zero};
use permutohedron::Heap;
use proconio::{
    fastout, input, is_stdin_empty,
    marker::{Bytes, Chars, Isize1, Usize1},
};
use rand::random;

pub const MOD10E9_7: usize = 1000000007;
pub const MOD99_: usize = 998244353;
pub const MAX: usize = std::usize::MAX;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 65;

// code...
// #[fastout]
fn main() {
    input! {
        x: usize, y: usize, z: usize, k: usize,
        mut a: [usize; x],
        mut b: [usize; y],
        mut c: [usize; z]
    }

    a.sort_by(|p, q| q.cmp(p));
    b.sort_by(|p, q| q.cmp(p));
    c.sort_by(|p, q| q.cmp(p));

    let mut heap = BinaryHeap::new();
    heap.push((a[0] + b[0] + c[0], (0, 0, 0)));

    let mut used = HashSet::new();
    used.insert((0, 0, 0));
    for _ in 0..k {
        let p = heap.pop().unwrap();
        // dbg!(p);
        println!("{}", p.0);
        let (s, t, u) = p.1;
        if s + 1 < x && !used.contains(&(s + 1, t, u)) {
            used.insert((s + 1, t, u));
            heap.push((a[s + 1] + b[t] + c[u], (s + 1, t, u)));
        }
        if t + 1 < y && !used.contains(&(s, t + 1, u)) {
            used.insert((s, t + 1, u));
            heap.push((a[s] + b[t + 1] + c[u], (s, t + 1, u)));
        }
        if u + 1 < z && !used.contains(&(s, t, u + 1)) {
            used.insert((s, t, u + 1));
            heap.push((a[s] + b[t] + c[u + 1], (s, t, u + 1)));
        }
    }
}


Measured memory_bytes: 2892