akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());

    if (s < t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846
#define pb push_back

void solve()
{
    int n;cin>>n;
    int a[n],b[n];
    int x=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        x=(x^a[i]);
    }
    for(int i=0;i<n;i++)
    {
        b[i]=(x^a[i]);
        cout<<b[i]<<" ";
    }
    cout<<nl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 6724
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.math;

import std.typecons;
alias Seg = Tuple!(int, "l", int, "r", int, "len");

void main() {
    int n, m;
    scan(n, m);

    auto p = new Seg[](n);

    foreach (i ; 0 .. n) {
        int li, ri;
        scan(li, ri);
        p[i] = Seg(li, ri, ri - li + 1);
    }

    p.sort!"a.len < b.len"();

    writeln(n);

    auto ft = FenwickTree(m + 2);

    foreach (d ; 2 .. m + 1) {
        while (!p.empty && p.front.len < d) {
            ft.add(p.front.l, 1);
            ft.add(p.front.r + 1, -1);
            p.popFront();
            n--;
        }

        int ans = n;

        for (int i = 0; i <= m; i += d) {
            ans += ft.sum(i + 1);
        }

        writeln(ans);
    }
}


struct FenwickTree {
    private {
        int N;
        int[] data;
    }

    this(int n) {
        N = n;
        data = new int[](N + 1);
    }

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

    int sum(int r) {
        int res;
        while (r > 0) {
            res += data[r];
            r -= r & (-r);
        }
        return res;
    }
}


void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


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

public class Main {

	Scanner sc = new Scanner(System.in);

	void run() {
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = sc.nextInt();

		int[] dp = new int[n];
		Arrays.fill(dp, Integer.MAX_VALUE / 2);

		for (int i = 0; i < n; i++) {
			int insert = lower_bound(dp, a[i]);
			if (insert < n) {
				dp[insert] = a[i];
			}
		}
		System.out.println(lower_bound(dp, Integer.MAX_VALUE / 2));
	}

	// find minimum i (a[i] >= border)
	int lower_bound(int a[], int border) {
		int l = -1;
		int r = a.length;
		while (r - l > 1) {
			int mid = (l + r) / 2;
			if (border <= a[mid]) {
				r = mid;
			} else {
				l = mid;
			}
		}
		// r = l + 1
		return r;
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 70852
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1000000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;
int a[N];
int main() {
    int n,t;
    scanf("%d%d",&n,&t);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);

    int maxx=-INF,temp=-INF;
    for(int i=n;i>=1;i--){
        temp=max(temp,a[i]);//
        maxx=max(maxx,temp-a[i]);//最大贸易差

    }

    int res=0;
    temp=-INF;
    for(int i=n;i>=1;i--){
        temp=max(temp,a[i]);
        if(maxx==(temp-a[i]))
            res++;
    }
    printf("%d\n",res);

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#define rep(i,n) for(i=0;i<n;i++)
#define INF 100000000
#define min(a,b) (a<b?a:b)
int main(){
	int i,j,k,n,m,bit,next,cur,r,newCost,ret,f;
	int land[200][200] , ship[200][200] , R[1000] ,dp[2][200];
	while(scanf("%d%d",&n,&m) && n){
		rep(i,200)rep(j,200)land[i][j] = ship[i][j] = INF;
		rep(i,200)land[i][i] = ship[i][i] = 0;
		
		rep(i,m){
			char t;
			int a,b,c;
			scanf("%d %d %d %c\n",&a,&b,&c,&t);
			a--,b--;
			if(t=='L')land[a][b] = land[b][a] = min(c,land[a][b]);
			else  ship[a][b] = ship[b][a] = min(c,ship[a][b]);
		}
		rep(k,n)rep(i,n)rep(j,n)land[i][j] = min(land[i][j],land[i][k]+land[k][j]);
		rep(k,n)rep(i,n)rep(j,n)ship[i][j] = min(ship[i][j],ship[i][k]+ship[k][j]);
		
		scanf("%d",&r);	
		rep(i,r)scanf("%d",&R[i]) , R[i]--;
		
		rep(j,2)rep(k,200)dp[j][k] = INF;
		dp[0][R[0]] = 0;
		
		f = 0;
		rep(bit,r-1){
			rep(cur,n){
				rep(next,n){
					newCost = dp[f][cur] + land[R[bit]][cur] + ship[cur][next] + land[next][R[bit+1]];
					dp[f^1][next] = min( dp[f^1][next],newCost);
				}
				dp[f^1][cur] = min(dp[f^1][cur],dp[f][cur]+land[R[bit]][R[bit+1]]);
			}
			rep(j,200)dp[f][j] = INF;
			f^=1;
		}
		ret = INF;
		rep(i,n)ret = min(dp[f][i],ret);
		printf("%d\n",ret);
	}
	return 0;
}

Measured memory_bytes: 732
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define FOR(i,a,b) for(long long i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(long long i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

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

int main() {
	ll n,a[100010]={0},b[100010]={0};
    //vector<pair<pll,int>>c;
    vector<pll>c;

    cin>>n;
    REP(i,n){
        cin>>a[i]>>b[i];
        if(a[i]>=b[i]){
            //c.push_back(make_pair(pll(a[i]+b[i],a[i]),1));
        }
        else{
            //c.push_back(make_pair(pll(b[i]+a[i],b[i]),-1));
        }
        c.push_back(pll(a[i]+b[i],a[i]));
    }
    sort(c.begin(),c.end());
	ll ans=0;
    /*
    REP(i,n){
        if(i%2==0){
            if(c[n-i-1].second==1){
                ans+=c[n-i-1].first.second;
            }
            else{
                ans+=c[n-i-1].first.second;
            }
        }
        else{
            if(c[n-i-1].second==1){
                ans-=c[n-i-1].first.second;
            }
            else{
                ans-=c[n-i-1].first.first;
            }
        }
    }
    */
   REP(i,n){
       if(i%2==0){
           ans+=c[n-i-1].second;
       }
       else{
           ans-=(c[n-i-1].first-c[n-i-1].second);
       }
   }
	
    cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3956
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#define MY_DEBUG(s)      s
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#define MY_DEBUG(s)      
#endif

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define EPS (1e-7)
#define IINF ((int)1e9)


MY_NAMESPACE(testbed)
class ModComb
{
public:
	ModComb(int max_n, ll mod) : m_mod(mod)  // mod and any i (1<i<=max_n) must be mutually prime. in reality mod must be a prime number and mod>max_n
	{
		m_fac.resize(max_n + 1);
		m_inv.resize(max_n + 1);
		m_fin.resize(max_n + 1);
		m_fac[0] = 1;
		m_fac[1] = 1;
		m_inv[0] = 0;  // dummy
		m_inv[1] = 1;
		m_fin[0] = 1;
		m_fin[1] = 1;
		for (int i = 2; i <= max_n; i++)
		{
			m_fac[i] = m_fac[i - 1] * i % mod;
			m_inv[i] = mod - m_inv[mod % i] * (mod / i) % mod;
			m_fin[i] = m_fin[i - 1] * m_inv[i] % mod;
		}
	}

	ll nCk(int n, int k)
	{
		if (n < 0 || k < 0)
			return 0;
		if (n < k)
			return 0;
		return m_fac[n] * (m_fin[k] * m_fin[n - k] % m_mod) % m_mod;
	}

	ll nPk(int n, int k)
	{
		if (n < 0 || k < 0)
			return 0;
		if (n < k)
			return 0;
		return m_fac[n] * m_fin[n - k] % m_mod;
	}

private:
	ll m_mod;
	vector<ll> m_fac;  // factorial
	vector<ll> m_inv;  // inverse element
	vector<ll> m_fin;  // factorial of inverse
};

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

	ll modval = 1000000007;  // 10^9 + 7

	int n, m;
	cin >> n >> m;
	ModComb c(max(n, m), modval);

	ll res = 0;
	for (int k = 0; k <= n; k++)
	{
		ll this_res = c.nCk(n, k) * c.nPk(m, k) % modval;
		this_res *= c.nPk(m - k, n - k);
		this_res %= modval;
		this_res *= c.nPk(m - k, n - k);
		this_res %= modval;

		if (k % 2 == 0)
		{
			res += this_res;
			res %= modval;
		}
		else
		{
			res -= this_res;
			res %= modval;
			res += modval;
			res %= modval;
		}
	}
	cout << res << "\n";
	return 0;
}
MY_NAMESPACE_

Measured memory_bytes: 15000
a, b, k = STDIN.gets.split(' ').map(&:to_i)

k.times do |i|
  if i % 2 == 0
    if a % 2 == 1
      a -= 1
    end
    exchange = a/2
    a -= exchange
    b += exchange
  else
    if b % 2 == 1
      b -= 1
    end
    exchange = b/2
    b -= exchange
    a += exchange
  end
end


puts "#{a} #{b}"


Measured memory_bytes: 1788
/*package whatever //do not write package name here */

import java.io.*;
import java.util.Scanner;


class Main {
	public static void main (String[] args) {
	    Scanner in = new Scanner(System.in);
	    int n = in.nextInt();
        long d = in.nextLong();
        d = (long ) d * d;
        
        int answer = 0;
        for (int i=0;i<n;i++) {
            long x = in.nextLong();
            long y = in.nextLong();
            if (x * x + y * y <= d)
                answer++;
        }

        System.out.println(answer);
	}
}

Measured memory_bytes: 61100
import java.util.*

fun main(args: Array<String>) {
	val (n, k) = readLine()!!.split(" ").map({ it -> it.toLong() })
	val size = 100000
	val counts = LongArray(size + 1) { 0 }
	for (i in 1..n) {
		val (a, b) = readLine()!!.split(" ").map({ it -> it.toInt() })
		counts[a] += b.toLong()
	}
	var sum = 0L
	var index = 0
	while (sum < k) {
		index += 1
		sum += counts[index]
	}
	println(index)
}


Measured memory_bytes: 54220
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
#define vecout(v,n) for(int i=0; i<n; i++)cout<<v[i]<<" "; cout<<endl;

const int mod =998244353;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 998244353;
long long fac[MAX], finv[MAX], inv[MAX];


// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}

//x未満の要素数を返す二分探索関数
int b_s(vector<int>&vecxx, int xx) {
	if (xx <= vecxx[0]) { //x以下の要素数を返させる時は"<"に変える
		return 0;
	}
	if (vecxx.back() < xx) { //x以下の要素数を返させる時は"<="に変える
		return vecxx.size();
	}
	int aa1 = 0, aa2 = vecxx.size() - 1, aa3;
	while (aa1 + 1 < aa2) {
		aa3 = (aa1 + aa2) / 2;
		if (vecxx[aa3] >= xx) { //x以下の要素数を返させる時は">"に変える
			aa2 = aa3;
		}
		else {
			aa1 = aa3;
		}
	}
	return aa2;
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
//グループが0個でもいいときはnにxを足す

int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	cout<<a+b+c+max(a,max(b,c))*(jousu(2,k)-1)<<endl;
}


Measured memory_bytes: 256
import sys
def gcm(a, b):
    if a<b: a,b=b,a
    if (a%b==0):
        return b
    else:
        return gcm(b,a%b)

for s in sys.stdin:
    a,b=map(int,s.split())
    c=gcm(a,b)
    print "%d %d" %(c,a/c*b)

Measured memory_bytes: 4204
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

class Main {
	public static void main(String[] args) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try {
			int H, W;
			ArrayList<int[]> list = new ArrayList<int[]>();
			do {
				int[] ret = new int[2];
				String[] input = br.readLine().split(" ");
				H = Integer.parseInt(input[0]);
				W = Integer.parseInt(input[1]);
				if (H == 0 && W == 0) {
					break;
				} else {
					ret[0] = H;
					ret[1] = W;
					list.add(ret);
				}
			} while (true);

			int x, y;
			for (int[] e : list) {
				H = e[0];
				W = e[1];
				for (x = 0; x < H; x++) {
					for (y = 0; y < W; y++) {
						if (x == 0 || x == H - 1 || y == 0 || y == W - 1) {
							System.out.print("#");
						} else {
							System.out.print(".");
						}
					}
					System.out.println();
				}
				System.out.println();
			}

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 24596
#include "bits/stdc++.h"
#include <string>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
// #define mod  1000000007
#define N 100005
// #define MAX 200005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcount
#define PI acos(-1)
//#define endl "\n"
// const int inf = (int)1e18 + 10;
const int mod = 1e9 + 7;

const int inf = 1e15;
const int MAX = 1000000;
signed main(){
  fast;
 
  int k , x;
  cin >> k >> x;
  for(int i = max(-MAX , x - k + 1) ; i <=min(x + k-1 , MAX) ; i++)
    cout << i << " ";








}


Measured memory_bytes: 256
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-11
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 500031;

int a,b,c,d,e,f,reach_w[N],reach_s[N];
int ans;
int ai,aj;

int main(){
	//freopen("tree.in","r",stdin);
	//freopen("tree.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin>>a>>b>>c>>d>>e>>f;

	double best_rat=-1e9;

	reach_w[0]=1;
	reach_s[0]=1;

	for (int i=0;i<=3000;i++)
	{
		if (reach_w[i])
		{
			reach_w[i+a]=1;
			reach_w[i+b]=1;
		}
		if (reach_s[i])
		{
			reach_s[i+c]=1;
			reach_s[i+d]=1;
		}
	}

	for (int i=100;i<=f;i++)
	{
		for (int j=0;j+i<=f;j++)
		{
			if (i%100)
				continue;
			if (reach_w[i/100]==0||reach_s[j]==0)
				continue;
			if (j>i/100*e)
				continue;
			if (j*1.0/i>best_rat){
				best_rat=j*1.0/i;
				ai=i;
				aj=j;
			}
		}
	}

	cout<<ai+aj<<" "<<aj<<endl;

	cin.get(); cin.get();
	return 0;
}



Measured memory_bytes: 256
l = list(map(int,input().split()))
ans = 0
if l[0] == l[1] == l[2] and all(i % 2 == 0 for i in l):
  print(-1)
  exit()
while all(i % 2 == 0 for i in l):
  a = l[0]//2; b = l[1]//2; c = l[2]//2;
  l[0] = b + c
  l[1] = a + c
  l[2] = a + b
  ans += 1
print(ans)

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

int main(){
    ll x,y;
    cin>>x>>y;
    ll ans=1e10;
    for(int i=0;i<(1<<2);i++){
        ll r=0,a=x,b=y;
        for(int j=0;j<2;j++){
            if(i&(1<<j)){
                if(j==0) a=-a,r++;
                if(j==1) b=-b,r++;
            }
        }
        if(a<=b) ans=min(r+b-a,ans);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3544
import collections
n = int(input())
v = list(map(int, input().split()))
even = [v[2*i] for i in range(n//2)]
odd = [v[2*i+1] for i in range(n//2)]
dEven = collections.Counter(even).most_common()
dOdd = collections.Counter(odd).most_common()
if dEven[0][0] != dOdd[0][0]:
    ans = n - dEven[0][1]  - dOdd[0][1]
else:
    if len(dEven) >=2 and len(dOdd) >= 2:
        ans = n - max(dEven[0][1]+dOdd[1][1], dEven[1][1]+dOdd[0][1])
    elif len(dEven) < len(dOdd):
        ans = n - (dEven[0][1]+dOdd[1][1])
    elif len(dEven) > len(dOdd):
        ans = n - (dEven[1][1]+dOdd[0][1])
    else:
        ans = n//2
print(ans)

Measured memory_bytes: 21084
#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){
  while(x->left != NIL)
    x = x->left;
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL)
    x = x->right;
  return x;
}

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

Node treeSuccessor(Node x){
  Node y;
  
  if(x->right != NIL)
    return treeMinimum(x->right); // case 1
  
  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y; // case 2
}

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

  if(z->left == NIL || z->right == NIL)
    y = z;
  else
    y = treeSuccessor(z);

  if(y->left != NIL)
    x = y->left;
  else
    x = y->right;

  if(x != NIL)
    x->parent = y->parent;

  if(y->parent == NIL)
    root = z;
  else if(y == y->parent->left)
    y->parent->left = x;
  else
    y->parent->right = x;

  if(y != z)
    z->key = y->key;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

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

  while(x != NIL){
    y = x;
    if(z->key < x->key)
      x = x->left;
    else
      x = x->right;
  }
  z->parent = y;
  if(y == NIL)
    root = z;
  else if(z->key < y->key)
    y->left = z;
  else
    y->right = z;
}

void inorder(Node u){
  if(u == NIL)
    return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u == NIL)
    return;
  printf(" %d", u->key);
  preorder(u->left);
  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: 24040
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////

ll ord(ll n) {
	if (n < 0) { return ord(abs(n)); }
	if (n == 0) { return INF; }
	if (n % 2 == 1) { return 0; }
	else { return ord(n / 2) + 1; }
}

int main() {
	
	ll A, B, C;
	cin >> A >> B >> C;

	if (A % 2 != 0 || B % 2 != 0 || C % 2 != 0) {
		cout << 0;
	}

	else {
		ll ans= min(ord(A - B), min(ord(B - C), ord(C - A)));
		if (ans == INF) { ans = -1; }
		cout << ans;
	}
	

	system("PAUSE");

}





Measured memory_bytes: 504
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  vector<int> v(10, 0);
  int a, b, c; cin >> a >> b >> c;
  v[a]++;
  v[b]++;
  v[c]++;
  if(v[5] == 2 && v[7] == 1) cout << "YES\n";
  else cout << "NO\n";
  return;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

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

	ll n;
	cin >> n;
	vector<ll> a(n),r(n);
	FOR(i,0,n) cin>>a[i];
	ll q;
	cin >> q;
	FOR(i,0,q){
		ll b,m,e;
		cin >> b >> m >> e;
		r = a;
		FOR(k,0,e-b){
			r[b+((k+(e-m)) % (e-b))] = a[b+k];
		}
		a = r;
	}
	cout << a[0];
	FOR(i,1,n){
		cout << " " << a[i];
	}
	cout << endl;
}


Measured memory_bytes: 3204
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
typedef long long ll;

int main() {
	string A, B;
	cin >> A >> B;//A>BでGREATER 小さくてLESS 等しくてEQUAL
	if (A.size() > B.size()) cout << "GREATER" << endl;
	else if (A.size() < B.size()) cout << "LESS" << endl;
	else {
		if (A > B) cout << "GREATER" << endl;
		else if (A < B) cout << "LESS" << endl;
		else cout << "EQUAL" << endl;
	}
}

Measured memory_bytes: 3544
def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    print(solve(N,K,A))
def maxBitNum(num):
    # q,r = divmod(num,2)
    q = num//2
    if q==0:
        return(1)
    else:
        return(1+maxBitNum(q))
def solve(N,K,A):
    #Aの最大値とその２進数桁数を求めておく
    maxA = 10**12
    maxDigit = maxBitNum(maxA)
    #Kの２進数表示を４０桁まで求めておく
    kString = format(K,'0'+str(maxDigit)+'b')
    #Aの要素のうち、下からd桁目(0-indexed, 0-39)のビットが立っているものの数をカウントしておく
    bitNumList = [countBitForGivenDigit(A,i) for i in range(maxDigit)]
    #下からd桁目まで(0-indexed)を貪欲に選ぶときの部分和の値
    greedySolutions = [0 for _ in range(maxDigit)]
    greedySolutions[0] = getGreedNum(0,bitNumList[0],N)
    for i in range(1,maxDigit):
        greedySolutions[i] = greedySolutions[i-1] + getGreedNum(i,bitNumList[i],N)
    # print("bitNumList",bitNumList)
    # print("greedy",greedySolutions)
    ans = 0
    #上からx桁目ではじめて最大値よりも小さい値をとるXの場合の解を、x=1~41で全探索する
    #x=41はすべてX=Kの場合を意味する
    #X=Kの場合の解および上からx桁目までKと等しい値を選んだ場合の部分和を先に求めておく
    partialSumForXeqK = [0 for _ in range(maxDigit + 1)]
    for x in range(1,maxDigit+1):
        bitKx = int(kString[x-1])
        # print("Kの上からx桁目",bitKx)
        #下からの桁数
        d = maxDigit - x
        if bitKx == 1:
            xDiff = (N - bitNumList[d]) * pow(2,d)
        else:
            xDiff = bitNumList[d] * pow(2,d)
        partialSumForXeqK[x] = partialSumForXeqK[x-1] + xDiff
    #上からx桁目(1-indexed)で初めてKよりも小さい値をとる場合の解
    for x in range(1,maxDigit+1):
        #Kの上からx桁目が0だったら最大値をとるしかない
        bitKx = int(kString[x-1])
        if bitKx == 0:
            continue
        #Kの上からx桁目のbitは立っているので、そこが0の場合の解を計算する
        d = maxDigit - x
        if d != 0:
            candidate = partialSumForXeqK[x-1] + pow(2,d) * bitNumList[d] + greedySolutions[d-1]
        else:
            candidate = partialSumForXeqK[x-1] + pow(2,d) * bitNumList[d] 
        # print(candidate,x)
        ans = max(ans,candidate)
    #全部最大値を選んだ時の解を検討する
    # print("max", partialSumForXeqK[maxDigit])
    ans = max(ans,partialSumForXeqK[maxDigit])

    return(ans)

def getGreedNum(d,bitNum,N):
    ans = pow(2,d) * max(bitNum,N-bitNum)
    # print(d,"桁目の貪欲",ans)
    return(ans)

def countBitForGivenDigit(alist,digit):
    #下から2進数でdigit桁目のビットが立っている要素の数を数えて返却する
    #０桁目から数えるつまり桁数は0-indexedとする
    num = pow(2,digit)
    bitNum = 0
    for x in alist:
        bitNum += (x & num)//num
    return(bitNum)


main()

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


int main(int argc, char const *argv[]){

	int N;
	std::cin >> N;
	std::vector<int> fig(N);
	for (int i = 0; i < N; ++i){
		std::cin >> fig[i];
	}

	int num = 0;

	for (int i = 0; i < N; ++i){
		for (int j = N-1; j > i ; --j){
			if(fig[j]<fig[j-1]){
				int buff = fig[j];
				fig[j] = fig[j-1];
				fig[j-1] = buff;
				num += 1;
			}
		}
	}

	for (int i = 0; i < N; ++i){
		std::cout << fig[i];
		if(i<N-1) std::cout << " ";
	}
	std::cout << std::endl;
	std::cout << num << std::endl;

	return 0;
}


Measured memory_bytes: 3104
while True:
    n, k = map(int, input().split())
    if n == k == 0:
        break
    a_sum = [0]
    now = 0
    for i in range(n):
        now += int(input())
        a_sum.append(now)
    maximum = a_sum[k]-a_sum[0]
    for i in range(n-k):
        maximum = max(a_sum[k+i]-a_sum[i], maximum)
    print(maximum)


Measured memory_bytes: 9644
using System;
using System.Collections;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
namespace Collections
{
	class program
	{
    //static long MAX_LONG = 5000000000000000;
		static void Main(string[] args)
		{
			// 入力
      string S = Console.ReadLine();
      long K = long.Parse(Console.ReadLine());
			//int N = Int32.Parse(Console.ReadLine());
			//string[] input = Console.ReadLine().Split(' ');
      // 要素数１〜Nの部分数列を取得する

      int num = 0;
      for(int i = 0; i<S.Length; i++)
      {
        if(S[i] == '1')
        {
          num++;
        }
        else
        {
          Console.WriteLine(S[i]); //2以降は５０００兆日後かならずKを超える
          return;
        }
        if(num >= K)
        {
          Console.WriteLine(S[i]); // 1だけで超えるかもしれない
          return;
        }
      }
    }
	}
}


Measured memory_bytes: 13140
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
const int M = 1e5 + 10;
int a[M] , b[M] , ha[M] , hb[M];
bool vis[M] , have[M];
vector<int>vc[M];
void dfs(int u) {
    vis[u] = true;
    int len = vc[u].size();
    for(int i = 0 ; i < len ; i++) {
        int v = vc[u][i];
        if(vis[v]) continue;
        dfs(v);
    }
}
int main() {
    int n;
    cin >> n;
    a[0] = 0;
    for(int i = 1 ; i <= n ; i++) {
        cin >> a[i];
        a[0] ^= a[i];
        ha[i] = a[i];
    }
    ha[0] = a[0];
    b[0] = 0;
    for(int i = 1 ; i <= n ; i++) {
        cin >> b[i];
        b[0] ^= b[i];
        hb[i] = b[i];
    }
    hb[0] = b[0];
    sort(ha , ha + n + 1);
    sort(hb , hb + n + 1);
    for(int i = 0 ; i <= n ; i++) {
        if(ha[i] != hb[i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    for(int i = 0 ; i <= n ; i++) {
        a[i] = lower_bound(ha , ha + 1 + n , a[i]) - ha;
        b[i] = lower_bound(hb , hb + 1 + n , b[i]) - hb;
    }
    int ans = 0;
    memset(have , false , sizeof(have));
    memset(vis , false , sizeof(vis));
    for(int i = 0 ; i <= n ; i++) {
        if(a[i] != b[i] || i == 0) {
            if(i) ans++;
            have[a[i]] = true , have[b[i]] = true;
            vc[a[i]].push_back(b[i]);
        }
    }
    for(int i = 0 ; i <= n ; i++) {
        if(!vis[i] && have[i]) {
            dfs(i) , ans++;
        }
    }
    ans--;
    ans = max(ans , 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10624
N = int(input())
nums = [int(input()) for _ in range(N)]
nums_copy = sorted(nums[:], reverse=True)
max_1 = nums_copy[0]
max_2 = nums_copy[1]

for n in nums:
    if n == max_1:
        print(max_2)
    else:
        print(max_1)

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

int main() {
    vector<long long> city(5, 0);
    long long n; cin >> n;
    for(int i = 0; i < 5; i++) cin >> city[i];
    sort(city.begin(), city.end());
    long long rtn = 0;
    if(n % city[0] == 0) {
        rtn += n / city[0];
    } else {
        rtn += n / city[0] + 1;
    }
    rtn += 4;
    
    cout << rtn << endl;
}



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

int gcd(int a, int b, int c){
	int x=1;
	int result = 1;
	while(x<=a && x<=b && x<=c){
		if(a%x==0 && b%x==0 && c%x==0){
			if(x > result){
				result = x;
			}
		}
		x++;
	}
	//cout << "gcd(" << a << "," << b << "," << c << ") is" << result << endl;
	return result;
}


int main(){
	int n;
	cin >> n;
	int sum = 0;
	
	rep(i,n){
		rep(j,n){
			rep(k,n){
				sum += gcd(i+1,j+1,k+1);
			}
		}
	}
	
	cout << sum << endl;
		
}


Measured memory_bytes: 3616
N, M = map(int, input().split())
dp = [[0]*(6*N+1) for _ in range(3*N+1)]
dp[0][3*N] = 1
for i in range(3*N):
    for j in range(-3*N+1, 3*N):
        if i+1 <= 3*N:
            dp[i+1][j+1+3*N] += dp[i][j+3*N]
            dp[i+1][j+1+3*N] %= M
        if i+2 <= 3*N:
            dp[i+2][j-1+3*N] += (i+1)*dp[i][j+3*N]
            dp[i+2][j-1+3*N] %= M
        if i+3 <= 3*N:
            dp[i+3][j+3*N] += (i+1)*(i+2)*dp[i][j+3*N]
            dp[i+3][j+3*N] %= M
r = 0
for i in range(3*N, 6*N+1):
    r += dp[3*N][i]
print(r%M)


Measured memory_bytes: 599432
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[200005],b[200005];
int main()
{
    ll n,m,k;
    cin >> n >> m >> k;
    for(ll i=0;i<n;i++)
    {
        cin >> a[i];
        if(i)
            a[i]+=a[i-1];
    }

    for(ll i=0;i<m;i++)
    {
        cin >> b[i];
        if(i)
            b[i]+=b[i-1];
    }
    ll ans = upper_bound(b,b+m,k)-b;
    for(ll i=0;i<n;i++)
    {
        if(k>=a[i])
            ans = max(ans,(upper_bound(b,b+m,k-a[i])-b)+i+1);
    }

    cout << ans << endl;
}


Measured memory_bytes: 6756
//k_k_dubey_
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define inf 999999999999
#define mx 200005
#define gcd __gcd
#define pb push_back
#define mk make_pair
#define bs binary_search
#define ub upper_bound
#define lb lower_bound
#define endl "\n"
#define vl vector<ll>
#define vs vector<string>
#define non __builtin_popcount
#define ml map<ll, ll> 
#define ms map<string , ll> 
using namespace std;

bool isp[mx];

void sv(){

	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}

ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	//sv();
	
	ll a,b,c,d,i,j,x,y;
	cin>>a>>b>>c>>d;
	ll an1= b/c - (a-1)/c;
	ll an2= b/d - (a-1)/d;
	x= (c*d)/__gcd(c,d);
	
	ll an3= b/x - (a-1)/x;
	ll an= an1 + an2 - an3;
	ll ans= b - a +1 - an;
	cout<<ans;
    return 0;
}























Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
amin = min(A)
indmin = A.index(amin)+1
amax = max(A)
indmax = A.index(amax)+1
if amin>=0:
    print(N-1)
    for i in range(1,N):
        print(i,i+1)
elif amax<=0:
    print(N-1)
    for i in range(N,1,-1):
        print(i,i-1)
elif amax+amin>=0:
    print(2*(N-1))
    for i in range(1,N+1):
        if i!=indmax:
            print(indmax,i)
    for i in range(1,N):
        print(i,i+1)
elif amax+amin<0:
    print(2*(N-1))
    for i in range(1,N+1):
        if i!=indmin:
            print(indmin,i)
    for i in range(N,1,-1):
        print(i,i-1)


Measured memory_bytes: 38384
#!/usr/bin/env python3

def main():
    H, N = map(int, input().split())
    A = [None] * N
    B = [None] * N
    for i in range(N):
        A[i], B[i] = map(int, input().split())

    #1次元DPに書き換え
    INF = 10**12
    dp = [INF] * (H+1)
    dp[0] = 0
    for i in range(N):
        for j in range(H+1):
            dp[min(j+A[i],H)] = min(dp[min(j+A[i],H)],dp[j]+B[i])
    print(dp[H])

if __name__ == "__main__":
    main()


Measured memory_bytes: 68192
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    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);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        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)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k % 2 == 1) {
        cout << b - a << endl;
    }
    else cout << a - b << endl;
}

Measured memory_bytes: 256
// Legends Never Die.

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef pair<int, int> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

namespace fastIO
{
	const UI BUFFER_SIZE = (UI) 1 << 15;
	char buffer[BUFFER_SIZE], *cur, *ed;

	inline char getc() { return *(cur == ed ? ed = buffer + fread(buffer, 1, BUFFER_SIZE, stdin), cur = buffer : cur)++; }
}
using fastIO::getc;

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getc());
	for(; !isdigit(ch); ch = getc()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

template<typename T> inline T sqr(const T &val) { return val * val; }
template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }

// END tpl.

const int MAXN = (int) 1e3, MAXM = 30;

int n;

int X[MAXN + 5], Y[MAXN + 5];

inline void input()
{
	n = read<int>();
	for(int i = 1; i <= n; ++i) X[i] = read<int>(), Y[i] = read<int>();
}

int m;

LL d[MAXM + 5];

inline void construct(LL x, LL y)
{
	static vector<char> s;
	s.clear();

	for(int i = m; i >= 1; --i)
	{
		if(abs(x) > abs(y)) { if(x > 0) s.push_back('R'), x -= d[i]; else s.push_back('L'), x += d[i]; }
		else { if(y > 0) s.push_back('U'), y -= d[i]; else s.push_back('D'), y += d[i]; }
	}

	reverse(ALL(s));
	for(auto i : s) putchar(i);
	putchar('\n');
}

inline void solve()
{
	int S = 0;
	for(int i = 1; i <= n; ++i) S |= 1 << (abs(X[i] + Y[i]) % 2);
	if(__builtin_popcount(S) == 2) { puts("-1"); return; }

	m = 0;
	if(S & 1) d[++m] = 1;
	for(int i = 0; i <= 30; ++i) d[++m] = 1ll << i;

	printf("%d\n", m);
	for(int i = 1; i <= m; ++i) printf("%lld ", d[i]);
	puts("");

	for(int i = 1; i <= n; ++i) construct(X[i], Y[i]);
}

int main()
{
#ifdef K_ON // K-ON!
	freopen("D.in", "r", stdin);
	freopen("D.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}



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

int main(){
  int n, k, q;
  cin >> n >> k >> q;
  vi score(n+1, k-q);
  rep(i,q){
    int a;
    cin >> a;
    score[a]++;
  }
  rep(i,n){
    if(score[i+1] > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


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

int main() {
  int n, m, a;
  vector<int> v;
  while (1) {
    cin >> n >> m;
    if (!n && !m) break;
    v.clear();
    a = 0;
    for (int i=0; i<n; i++) v.push_back(i);
    while (v.size() > 1) {
      a = (a + m - 1) % v.size();
      v.erase(v.begin()+a);
    }
    cout << v[0]+1 << endl;
  }
  return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

	lli n;
	cin>>n;

	vector<lli> a(n);
	map<lli,lli> cnt;
	REP(i,0,n){
		cin>>a[i];
		cnt[a[i]-1]++;
		cnt[a[i]]++;
		cnt[a[i]+1]++;
	}

	lli ans = 0;
	for(auto e:cnt){
		ans = max(ans,e.second);
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 6912
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;

int dp[3001][3001][2];
/*dp[i][j][k]は、
「いまからi番目を頼むかどうか検討するところで、残り時間がj分で、
k=1→最後の料理を決めた、k=0→最後の料理をまだ決めてない ときの(それ以降の)満足度の最大値」
求めるものは、
dp[0][T-1][0]である。
*/

int N, T, A[3000], B[3000];

int dp_(int i, int j, int k) {
	if (dp[i][j][k] != -1) { return dp[i][j][k]; }

	int ret = 0;
	if (i == N) { dp[i][j][k] = 0; return 0; }
	if (j >= A[i]) {/*頼む*/
		ret = B[i] + dp_(i + 1, j - A[i], k);
	}
	if (k == 0) {/*最後に頼む*/
		if (ret < B[i] + dp_(i + 1, j, 1)) {
			ret = B[i] + dp_(i + 1, j, 1);
		}
	}
	/*頼まない*/
	if (ret < dp_(i + 1, j, k)) {
		ret = dp_(i + 1, j, k);
	}
	dp[i][j][k] = ret;
	return dp[i][j][k];

}

int main() {
	cin >> N >> T;
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
	}

	for (int i = 0; i < N+1; i++) {
		for (int j = 0; j < T; j++) {
			for (int k = 0; k < 2; k++) {
				dp[i][j][k] = -1;
			}
		}
	}

	cout << dp_(0, T - 1, 0);
}

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

using namespace std;
using ll = long long;
using pi = pair<int,int>;
int main() {
    const vector<int> dy={+0,+1,+0,-1};
    const vector<int> dx={-1,+0,+1,+0};

    int h,w,k;
    cin>>h>>w>>k;

    int sx,sy,gx,gy;
    cin>>sx>>sy>>gx>>gy;
    vector<string> mp(h+2);
    mp[0]=string(w+2,'@');
    mp[h+1]=string(w+2,'@');
    for(int i = 1;i <= h;++i) {
        mp[i].push_back('@');
        string s;
        cin>>s;
        mp[i]+=s;
        mp[i].push_back('@');
        //cerr<<mp[i]<<endl;
    }
    vector<vector<vector<pi>>> dp(h+2,vector<vector<pi>>(w+2,vector<pi>(4,pi(h*w,k+1))));

    priority_queue<pair<pair<int,pi>,pi>> pq;
    for(int i = 0;i < 4;++i) {
        dp[sx][sy][i]=pi(0,0);
        int nx=sx+dx[i];
        int ny=sy+dy[i];
        if(mp[nx][ny]=='@')continue;
        pq.emplace(make_pair(-1,pi(1,(i+2)%4)),pi(nx,ny));
        dp[nx][ny][i]=pi(1,1);
    }
    while(!pq.empty()){
        auto t=pq.top();
        int tc=-t.first.first;
        int tk=t.first.second.first;
        int td=t.first.second.second;
        int tx=t.second.first;
        int ty=t.second.second;
//cerr<<tx<<" "<<ty<<" "<<tc<<" "<<tk<<endl;
        if(tx==gx&&ty==gy)break;
        pq.pop();

        for(int d = 0;d < 4;++d) {
            int nx=tx+dx[d];
            int ny=ty+dy[d];
            if(mp[nx][ny]=='@')continue;
            int nc=tc;
            int nk;
            if(tk<k&&abs(td-d)==2){
                nk=tk+1;
            }
            else {
                ++nc;
                nk=1;
            }
            if(dp[nx][ny][d]<=pi(nc,nk))continue;
            dp[nx][ny][d]=pi(nc,nk);
            pq.emplace(make_pair(-nc,pi(nk,(d+2)%4 )),pi(nx,ny));
        }
    }
    if(pq.size()==0)cout<<-1<<endl;
    else {
        int ans=h*w;
        for(int i = 0;i < 4;++i) {
            ans=min(ans,dp[gx][gy][i].first);
        }
        cout<<ans<<endl;
    }

    return 0;
}


Measured memory_bytes: 287376
n = int(input())
s = ['']*n
t = [0]*n
for i in range(0,n):
    s[i],t[i] = input().split()
    t[i] = int(t[i])
x = input()
index = 0
time = 0
for i in range(0,n):
    if x == s[i]:
        index = i
for i in range(index+1,n):
    time += t[i]
print(time)


Measured memory_bytes: 3060