akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(int i=0;i<n;i++)
#define Rip(i,n) for(int i=1;i<=n;i++)
#define RIP(i,a,b) for(int i=a;i<b;i++)
#define all(V) V.begin(),V.end()
#define sec  setprecision;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops");
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
using namespace std;
using ll = long long;
using ld = long double;
using Pa = pair<int, int>;
ll mod = 1000000007;
ll MOD = 998244353;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n) {
	x %= mod;
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return (pow((x * x) % mod, n / 2) % mod);
	else
		return (x * pow(x, n - 1)) % mod;
}
int main() {
	int n; cin >> n;
	ll ans = 0;
	for (int i = 1; i < n; i++) {
		if (n % i == 0)ans += (n / i) - 1;
		else ans += (n / i);
	}
	cout << ans << endl;
}

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

P f(int n){
    string num = to_string(n);
    int a = num[0] - '0';
    int b = num[num.length()-1] - '0';

    return make_pair(a, b);
}

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

    int n;
    cin >> n;

    map<P, int> freq;
    rep1(i, n+1){
        ++freq[f(i)];
    }

    int res = 0;
    rep1(i, n+1){
        P p = f(i);
        int a = p.first;
        int b = p.second;

        res += freq[make_pair(b, a)];
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b;
	
	scanf("%d%d",&a,&b);
	
	if(a>b){
		printf("a > b\n");
	}
	else if(a<b){
		printf("a < b\n");
	}
	else{
		printf("a == b\n");
	}
	return 0;
}

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

int main() {
  int count=0;
  int N,K,a=1000000009;
  cin>>N>>K;
  vector<int>H(N);
  rep(i,N){
    cin>>H[i];
  }
  sort(H.begin(),H.end());
  rep(i,N-K+1){
    if(H[i+K-1]-H[i]<a){
      a=H[i+K-1]-H[i];
    }
  }
  cout<<a;
}


Measured memory_bytes: 640
n=int(input())
s=input()
t=[]
u=[]
alpha2num = lambda c: ord(c) - ord('A') + 1
num2alpha = lambda c: chr(c+64)


for i in range(len(s)):
  t.append(alpha2num(s[i]))

for i in range(len(t)):
  t[i]+=n

  if t[i]>26:
    t[i]-=26
  u.append(num2alpha(t[i]))

mojiretu = ''.join(u)
print(mojiretu)




Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){
    string S;
    string T;
    int N;

    cin >> S >> T;
    cin >> N;

    int s_s, s_e, t_s, t_e;

    int s_a = 0;
    int S_asum[1000000+1];
    S_asum[0] = 0;
    for(int j=1;j<=S.length();j++){
        S_asum[j] = S_asum[j-1] + S[j -1] - 'A' + 1;
    }
    int t_a = 0;
    int T_asum[1000000+1];
    T_asum[0] = 0;
    for(int j=1;j<=T.length();j++){
        T_asum[j] = T_asum[j-1] + T[j -1] - 'A' + 1;
    }

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

        cin >> s_s >> s_e >> t_s >> t_e;
        int s_tmp = 0;
        int t_tmp = 0;

        s_tmp = S_asum[s_e] - S_asum[s_s-1];
        t_tmp = T_asum[t_e] - T_asum[t_s-1];

        string ans = "NO";
        if((s_tmp - t_tmp) % 3 == 0){
            ans = "YES";
        }
        cout << ans << endl;
    }
    return 0;
}

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

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

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 512
package main

import (
	"fmt"
)

func main() {
	var n, x, y, t, prevX, prevY, prevT int
	fmt.Scan(&n)
	abs := func (x int) int {
		if x < 0 {
			return -x
		}
		return x
	}

	for i := 0; i < n; i++ {
		fmt.Scan(&t, &x, &y)
		dx := abs(x - prevX)
		dy := abs(y - prevY)
		dt := t - prevT
		if dist := dx + dy; dt < dist || dist % 2 != dt % 2 {
			fmt.Println("No")
			return
		}
		prevX, prevY, prevT = x, y, t
	}
	fmt.Println("Yes")

}


Measured memory_bytes: 6316
// E.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;
typedef long long LL;

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

#ifdef _MSC_VER
	while (true)
#endif
	{
		LL n = -1, k = -1, ans = 0;
		cin >> n >> k;
		if (n < 0) return 0;
		vector<LL> a(n), sum(n + 1);
		map<LL, LL> m;
		for (int i = 0; i < n; ++i) {
			cin >> a[i];
		}
		m[0] = 1;
		for (int i = 0; i < n; ++i) {
			LL x = (a[i] + k - 1) % k;
			sum[i + 1] = (sum[i] + x) % k;
			LL y = sum[i + 1];
			ans += m[y];
			m[y] += 1;
			if (i >= k - 2) {
				m[sum[i + 2 - k]] -= 1;
			}
		}
		if (k == 1) ans = 0;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 15872
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n,a[25],ans;
int main(){
	in(n);
	for(int i=1;i<=n;i++)in(a[i]);
	for(int i=2;i<n;i++){
		if((a[i-1]<a[i]&&a[i]<a[i+1])||(a[i+1]<a[i]&&a[i]<a[i-1]))ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

typedef pair<int, int> P;
typedef long long int LL;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a + b > c + d) {
        cout << "Left" << endl;
    } else if (a + b == c + d) {
        cout << "Balanced" << endl;
    } else {
        cout << "Right" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
	long long x, k, d;
	scanf("%lld%lld%lld", &x, &k, &d);
	long long s = abs(x / d);
	long long m1 = x - d * (x / d);
	long long m2 = m1;
	if (x > 0) {
		m2 -= d;
	} else {
		m2 += d;
	}
	m1 = abs(m1);
	m2 = abs(m2);
	if (m2 < m1) {
		s++;
	} else {
		swap(m1, m2);
	}
	if (k >= s) {
		if ((k - s) % 2 == 0) {
			printf("%lld\n", m2);
		} else {
			printf("%lld\n", m1);
		}
	} else {
		if (x >= 0) {
			printf("%lld\n", abs(x - k * d));
		} else {
			printf("%lld\n", abs(x + k * d));
		}
	}
	return 0;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
#include<cmath>
#include<string>
using namespace std;
#define f first
#define s second
#define MOD 1000000007
#define fast ios::sync_with_stdio(0),cout.tie(0),cin.tie(0)
#define pb push_back
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define mkt make_tuple
typedef long long ll;
typedef unsigned long long ull;
#define MAX 1000
vector<vector<char>> v(MAX,(vector<char>(MAX,'.')));
vector<vector<int>> dp(MAX,(vector<int>(MAX,0)));
int main()
{
    fast;
	ll i=0;
	int h,w;
	cin>>h>>w;
	//vector<vector<int>> v(h,(vector<int>(w,0)));
	for(int i =0;i<h;i++){
		for(int j= 0;j<w;j++){
			cin>>v[i][j];
		}
	}
	/*for(int i =0;i<h;i++){
		for(int j= 0;j<w;j++){
			cout<<v[i][j]<<" ";
		}
		cout<<"\n";
	}*/
	
	dp[0][0] =1;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(i>0 && j>0){
				if(v[i][j] == '#'){
					dp[i][j] =0;
					continue;
				}
				else{
					dp[i][j] = ((dp[i-1][j]%MOD)+(dp[i][j-1]%MOD))%MOD;
				}
			}
			else if(i>0){
				if(v[i][j]!='#'){
					dp[i][j] = dp[i-1][j];
				}
			}
			else if(j>0){
				if(v[i][j]!='#'){
					dp[i][j] = dp[i][j-1];
				}
			}
		}
	}
	cout<<dp[h-1][w-1]<<"\n";


 return 0;
}


Measured memory_bytes: 5248
import sys
import itertools

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    XY = [[int(x) for x in input().split()] for _ in range(N)]

    xset = set()
    yset = set()

    for x, y in XY:
        xset.add(x)
        yset.add(y)

    xlist = list(xset)
    ylist = list(yset)

    ans = float("inf")

    for a, b in itertools.combinations(range(len(xlist)), 2):
        maxx = max(xlist[a], xlist[b])
        minx = min(xlist[a], xlist[b])

        for c, d in itertools.combinations(range(len(ylist)), 2):
            maxy = max(ylist[c], ylist[d])
            miny = min(ylist[c], ylist[d])

            cnt = 0
            for x, y in XY:
                if minx <= x <= maxx and miny <= y <= maxy:
                    cnt += 1

            if cnt >= K:
                ans = min(ans, (maxx - minx) * (maxy - miny))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 75004
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.array;

  int n;
  rd(n);
  auto a = readln.split
    .to!(int[])
    .map!((e) => (e - 1))
    .array;

  int num = 0;
  foreach (i; 0 .. (n - 1)) {
    if (i == a[i]) {
      num++;
      swap(a[i], a[i + 1]);
    }
  }
  if (a[n - 1] == n - 1)
    num++;

  writeln(num);
}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


Measured memory_bytes: 4412
//#include <ext/pb_ds/hash_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/rope>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <ctime>

#define X first
#define Y second
#define ls rt<<1
#define rs rt<<1|1
#define getmid ((l+r)>>1)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define lowbit(x) ((x)&-(x))
#define sz(a) ((int)a.size())
#define ALL(x) x.begin(),x.end()
#define mst(x,a) memset(x, a, sizeof(x))
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep1(i,n) for(int i=1; i<=(n); i++)
using namespace std;
#ifdef LOCAL
#define dbg(args...) cout << #args << " -> ", err(args);
void err(){ cout << endl; }
template<typename T, typename... Args>
void err(T a, Args... args){ cout << a << ' '; err(args...); }
#else
#define dbg(a)
#endif // LOCAL

//using namespace __gnu_cxx;
//using namespace __gnu_pbds;
typedef double db;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
typedef pair<int,int> pii;
typedef pair<db,db> pdd;

const int N = 1e5 + 10;
const int M = 2e5 + 10;
const int maxn = 1e6 + 10;
const int mod = (int)1e9+7;
const db eps = 1e-10;
const db pi = acos(-1.0);

int n;
ll a[N];
ll dp[N];
ll fac[N];
ll inv[N];

ll qpow(ll a, ll b){
    ll res = 1;
    for(a%=mod; b; b>>=1){
        if(b&1) res = res*a%mod;
        a = a*a%mod;
    }
    return res;
}

ll C(int n, int m){
    return fac[n]*inv[n-m]%mod*inv[m]%mod;
}

void init(){
    inv[0] = fac[0] = 1;
    for(int i=1; i<N; i++){
        fac[i] = fac[i-1]*i%mod;
        inv[i] = qpow(fac[i], mod-2);
    }
}

int main(){
#ifdef LOCAL
    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
#endif //LOCAL
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    init();
    cin>>n;
    ll sum = 0;
    for(int i=1; i<=n; i++){
        cin>>a[i];
        sum = (sum + a[i])%mod;
    }
    ll ans = 0;
    for(int i=2; i<=n; i++){
        ll t = fac[i-1]*fac[n-i]%mod*C(n, i)%mod;
        dp[i] = (dp[i-1] + t)%mod;
        ans = (ans + dp[i]*a[i])%mod;
    }
    dp[n] = 0;
    for(int i=n-1; i; i--){
        ll t = fac[n-i]*fac[i-1]%mod*C(n, n-i+1)%mod;
        dp[i] = (dp[i+1] + t)%mod;
        ans = (ans + dp[i]*a[i])%mod;
    }
    ans = (ans + sum*fac[n])%mod;
    cout<<ans<<'\n';

    return 0;
}


Measured memory_bytes: 6760
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
typedef long long ll;
#define out(i) cout<<(i)<<endl

vector<ll> bubblesort(vector<int> vec,ll N){
    
}

int main() {
  ll N;
  bool flag=false;
  cin>>N;
  vector<string> data1(N),data2(N);
  vector<int> A(N),B(N),index1(N),index2(N);
  rep0(i,N){cin>>data1[i]; data2[i]=data1[i]; data2[i].at(0)='0'; A[i]=stoi(data2[i]); B[i]=A[i];}
  rep0(i,N){index1[i]=i; index2[i]=i;}
  rep0(i,N){
        for(ll j=N-1;j>=i+1;j--){
            if(A[j]<A[j-1]){
                ll s=A[j],t=index1[j];
                A[j]=A[j-1];
                A[j-1]=s;
                index1[j]=index1[j-1];
                index1[j-1]=t;
            }
        }
    }
  rep0(i,N){if(i!=N-1){cout<<data1[index1[i]]<<" ";} else{cout<<data1[index1[i]]<<endl;}}
  cout<<"Stable"<<endl;
  rep0(i,N){
      ll Min=i;
      for(ll j=i;j<N;j++){
          if(B[j]<B[Min]){
              ll s=Min;
              Min=j;
              j=s;
              
          }
      }
      
      ll s=B[i],t=index2[i];
      B[i]=B[Min];
      B[Min]=s;
      index2[i]=index2[Min];
      index2[Min]=t;
  }
  for(ll i=0;i<N-1;i++){if(B[i]==B[i+1]&&index2[i]>index2[i+1]){flag=true;}}
  rep0(i,N){if(i!=N-1){cout<<data1[index2[i]]<<" ";} else{cout<<data1[index2[i]]<<endl;}}
  if(flag){cout<<"Not stable"<<endl;}
  else{cout<<"Stable"<<endl;}
}


Measured memory_bytes: 3204
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
	if (!y)
		return x;
	return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
	return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
	assert(__gcd(a, m) == 1);
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m, a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
	if (y == 0)
		return 1LL;
	else if (y == 1)
		return x;
	else
	{
		ll ans = modPow(x, y / 2, m) % m;
		if (y & 1)
		{
			return (((ans * ans) % m) * x) % m;
		}
		else
		{
			return (ans * ans) % m;
		}
	}
}

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	double l;
	cin >> l;
	double ans = pow(l / 3, 3);
	cout << fixed << setprecision(12) << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MODADD(ADD_X,ADD_Y)  (ADD_X+ADD_Y)%MOD;
#define MODSUB(SUB_X,SUB_Y)  (SUB_X-SUB_Y)+MOD)%MOD;
#define MODMUL(MUL_X,MUL_Y)  (MUL_X*MUL_Y)%MOD;
#define LCM(LCM_X,LCM_Y) (LCM_X*LCM_Y)/__gcd(LCM_X,LCM_Y);
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
int dx[]= {1,0,-1,0,1,-1,1,-1};
int dy[]= {0,1,0,-1,1,-1,-1,1};
ll fact[MAX],inverse[MAX];
ll Bigmod(int a,int b)
{
    if(b==0)
        return 1%MOD;
    ll x=Bigmod(a,b/2);
    x=(x*x)%MOD;
    if(b%2==1)
        x=(x*a)%MOD;
    return x;
}
ll nCr(int x, int y)
{
    if(x<0 || y<0 || x<y)
        return 0;
    return fact[x] * (inverse[y] * inverse[x - y] % MOD) % MOD;
}
void pre_cal()
{

    fact[0]=1;
    for(int i=1; i<=MAX; i++)
        fact[i]=fact[i-1]*1LL*i%MOD;
    inverse[MAX]=Bigmod(fact[MAX],MOD-2);
    for(int i=MAX; i>0; i--)
    {
        inverse[i-1]=i* 1LL*inverse[i] % MOD;
    }
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    pre_cal();
    int x,y;
	cin>>x>>y;
	int a = (2*x-y)/3, b = (2*y-x)/3;
	if( (a<0) || (b<0) || (2*a+b != x) || (2*b+a != y) ) {
        cout<<"0"<<endl;
	}
	else
	cout<<nCr(a+b,a)<<endl;;

    return 0;
}


Measured memory_bytes: 19248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    int X, Y, Z;
    cin >> X;
    int a[X];
    for (int i = 0; i < X; i++) cin >> a[i];
    cin >> Y;
    int b[Y];
    for (int i = 0; i < Y; i++) cin >> b[i];
    cin >> Z;
    int c[Z];
    for (int i = 0; i < Z; i++) cin >> c[i];

    set<int> A, C, B;
    for (int i = 0; i < X; i++) {
        A.insert(a[i]);
    }
    for (int i = 0; i < Y; i++) {
        B.insert(b[i]);
    }
    for (int i = 0; i < Z; i++) {
        C.insert(c[i]);
    }
    set<int> s;
    for (int i = 0; i < Z; i++) {
        if (A.count(c[i]) == 0 || B.count(c[i]) != 0) {
            s.insert(c[i]);
        }
    }
    cout << s.size() << "\n";
    return 0;
}


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

int main(){
  long long n, k, h;
  cin >> n;
  k = n;
  h = 1;
  while(h * h < n + 1){
    if(n % h == 0){
      k = min(k, h + n / h - 2);
    }
    h++;
  }
  cout << k << endl;
}

Measured memory_bytes: 256
s = input().split()
a_have = int(s[0])
b_have = int(s[1])
for  i in range(int(s[2])):
    if i % 2 == 0:
        if a_have % 2 != 0:
            a_have-=1
        b_have+= a_have/2
        a_have = a_have/2
    else :
        if b_have % 2 != 0:
            b_have-=1
        a_have+= b_have/2
        b_have = b_have/2
print(int(a_have),int(b_have))


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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

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

ll nCrModp(ll n, ll r, ll p)
{
    ll C[r+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, r); j > 0; j--)
            C[j] = (C[j] + C[j-1])%p;
    }
    return C[r];
}

int main()
{
    ll A,B;
    cin >> A >> B;
    print(6-A-B);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x)  // cout << #x << " = " << (x) << endl;

long long solve(const vector<int> &v, int x, const vector<long long> &sum_a, const vector<long long> &sum_b) {
  const int n = v.size();
  D(x);
  auto it = upper_bound(v.begin(), v.end(), x);
  if (it == v.end() or it + 1 == v.end()) {
    return sum_a.back();
  }
  D(*it);

  if (it != v.begin()) {
    auto it2 = it - 1;
    D(*it2);
    if (abs((*it2) - x) <= (abs((*it) - x))) {
      it = it2;
    }
  }
  D(*it);

  int first_aoki = it - v.begin();
  int l = first_aoki;
  int r = n - 1;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    D(mid); D(v[mid]);

    int diff = v[mid] - x;
    D(diff);
    auto it = lower_bound(v.begin(), v.end(), x - diff);
    int l_mid = it - v.begin();
    D(l_mid);
    int turns = mid - l_mid + 1;
    D(turns);

    if (mid < n - turns) {
      l = mid;
      D(l);
    } else {
      r = mid;
      D(r);
    }
  }

  D(l); D(r);
  int turns_taka = (n - r);
  D(turns_taka);

  long long ans = sum_b[n - turns_taka];
  D(ans);
  int t = n - turns_taka * 2 - 1;
  D(t);
  if (t >= 0) {
    ans += sum_a[t];
    D(ans);
  }
  D(ans);

  return ans;
}

int main() { IO;
  int n, q;
  cin >> n >> q;

  vector<int> v(n);
  for (auto &x : v) cin >> x;

  vector<int> x(q);
  for (auto &xi : x) cin >> xi;

  vector<long long> sum_a(n);
  for (int i = 0; i < n; ++i) {
    sum_a[i] = v[i];
    if (i >= 2) {
      sum_a[i] += sum_a[i - 2];
    }
  }

  // cout << "sum_a:"; for (auto x : sum_a) cout << " " << x; cout << endl;

  vector<long long> sum_b(n);
  for (int i = n - 1; i >= 0; --i) {
    sum_b[i] = v[i];
    if (i < n - 1) {
      sum_b[i] += sum_b[i + 1];
    }
  }

  // cout << "sum_b:"; for (auto x : sum_b) cout << " " << x; cout << endl;

  for (auto xi : x) {
    long long ans = solve(v, xi, sum_a, sum_b);
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 4096
# AGC036A - Triangle
s=int(input())
x1,y1=0,0
x2,y2=10**9,1
x3,y3=0,0
m=10**9
r=(m-s%m)%m
q=(s+r)/m
x3=int(r)
y3=int(q)
print(x1,y1,x2,y2,x3,y3)

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

const int M = 100001;
int n, t[M], x[M], y[M];

int main() {
	cin >> n;
	inc1(i, n) { cin >> t[i] >> x[i] >> y[i]; }
	
	bool f = true;
	inc1(i, n) {
		int d = t[i] - t[i - 1];
		int z = abs(x[i]  -x[i - 1]) + abs(y[i] - y[i - 1]);
		if(d % 2 == z % 2 && z <= d) { } else { f = false; }
	}
	
	cout << (f ? "Yes" : "No") << endl;
	
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int MOD =2019;

int main(){
    string S;
    cin >> S;
    int dp[MOD] = {};
    int ans =0;
    for(int i=0;i<S.size();i++){
        int t = S[i] -'0';
        int temp[MOD] = {};
        temp[t] += 1;
        for(int j=0;j<2019;j++){
            temp[(j*10+t)%MOD] += dp[j];
        }
        for(int j=0;j<MOD;j++){
            dp[j] = temp[j];
        }
        // cerr << "i=" << i+1 <<"val=" << dp[i+1][0] << endl;
        ans += dp[0];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int main(){
    cin>>n;
    vector<int> v(n,0);
    for(int i = 0;i < n; i++){
        cin>>v[i];
    }
    int sum=0;
    
    for(int i = 0;i < n; i++){
        for(int j = 0;j < n; j++){
            if(i==j) continue;
            else{
                sum+=v[i]*v[j];
            }
        }
    }
    cout<<sum/2<<endl;
    return 0;
}

Measured memory_bytes: 256
N,t,i,j,a[50][20];
int main(){
    char c[2]="",s[4]="SHCD";
    for(scanf("%d",&N);N--;){
        scanf("%s%d",c,&t);
        switch(c[0]){
            case'S':a[0][t-1]=1;break;
            case'H':a[1][t-1]=1;break;
            case'C':a[2][t-1]=1;break;
            case'D':a[3][t-1]=1;break;
        }
    }
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            if(a[i][j]==0)
            printf("%c %d\n",s[i],j+1);
        }
    }
}

Measured memory_bytes: 1852
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt(), b = stdIn.nextInt();
		System.out.println(a*b+" "+2*(a+b));

	}

}

Measured memory_bytes: 17156
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

const int MOD = 1000000007;
typedef long long ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin>>S;
  int N=S.length(),ans=N;
  for(int i=0;i<N-1;i++){
    if(S[i+1]!=S[i]){
      ans=min(ans,(max(i+1,N-i-1)));
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
typedef long long ll;
typedef double dd;
#define pb push_back
#define mp make_pair
#define endl "\n"
#define M 1000000007
#define pi acos(-1)
/*ll power(ll a,ll b)
{
    ll res = 1;
    while(b > 0)
    {
        if(b & 1)
            res = (res*a)%M;
        a = (a*a)%M;
        b = b >> 1;
    }
    return res;
}*/
/*ll modinv(ll a)
{
   return power(a,M - 2); 
}*/
/*vector<ll> primes(ll n)
{
    bool *sieve = new bool[n + 1];
    ll i,j;
    vector<ll> v;
    for(i = 3; i <= n; i+=2)
        sieve[i] = true;
    sieve[2] = true;
    for(i = 3; i*i <= n; i+=2)
    {
        if(sieve[i])
            for(j = i*i; j <= n; j+=i)
                sieve[j] = false;
    }
    if(n >= 2)
    {
        v.pb(2);
        for(i = 3; i <= n; i+=2)
        {
            if(sieve[i])
                v.pb(i);
        }
    }
    return v;
}*/

/*class graph{
public:
    vector<ll> *g;
    ll n;
    graph(ll v)
    {
        n = v + 1;
        g = new vector<ll> [n];
    }
    void addegde(ll f,ll s)
    {
        g[f].pb(s);
        g[s].pb(f);
    }
    void dfs(bool *visited,ll sv)
    {
        visited[sv] = true;
        for(auto x: g[sv])
        {
            if(!visited[x])
            {
                dfs(visited,x);
            }
        }
    }
    void bfs(ll sv){
       queue<ll> q;
       bool visited[n] = {};
       q.push(sv);
       visited[sv] = true;
       while(!q.empty())
       {
           ll node = q.front();
           q.pop();
           for(auto x : g[node])
           {
               if(!visited[x])
               {
                   visited[x] = true;
                   q.push(x);
               }
           }
       }
    }
};*/
int main()
{
    fast;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    ll i,j,t;
    ll n,a,b;
    cin >> n >> a >> b ;
    cout<<min(n*a,b);
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

typedef long long ll;
template<typename T>
T GCD(T p, T q);

int main()
{
	using namespace std;
	ll a, b;
	cin >> a >> b;
	if (a < b)
	{
		ll temp = a;
		a = b;
		b = temp;
	}
	cout << GCD(a, b) << endl;
	return 0;
}


template<typename T>
T GCD(T p, T q)
{
	if (q == 0)
	{
		return p;
	}
	return GCD(q, p % q);
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define endl '\n'
#define fast_in ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp  make_pair
#define pb  push_back
#define  all(x)  x.begin(), x.end()
#define  sz(x)   (int)x.size()
#define  bit(x)  __builtin_popcountll(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int,int> pii;
const int inf = (int) 1e9+99999, mod = (int)1e9+7;
const ll linf = (ll) 2e18+99999;
int mul (int x, int y) { return ((ll)x * y) % mod; } 
int sub (int x, int y) { x -= y; if (x < 0) return x + mod; return x; } 
int add (int x, int y) { x += y; if (x >= mod) return x - mod; return x; }
 
const int maxn = (int) 100001;
 
ll d[101][maxn];
ll w[101], c[101];

void solve () {
	int n, s;
	cin >> n >> s;
	for (int i = 0; i < n; i ++) {
		cin >> w[i] >> c[i]; 
	}

	d[0][0] = 0;
	if (w[0] < maxn)
		d[0][w[0]] = c[0];

	for (int i = 1; i < n; i ++) {
		if (w[i] < maxn)
			d[i][w[i]] = c[i];
		
		for (int k = s; k >= 0; k --) {
			d[i][k] = d[i-1][k];
			if (k - w[i] >= 0) {
				d[i][k] = max (d[i][k], d[i-1][k-w[i]] + c[i]);
			}
		}
	}

	ll res = 0;
	for (int k = s; k >= 0; k --) {
		res = max (res, d[n-1][k]);
	}

	cout << res;

}

main () { fast_in;
	//freopen (".in", "r", stdin);
    int t = 1; //cin >> t;
    while (t --) {
    	solve ();    
    }
	return 0;
}

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

int main() {
    ll min, max;
    cin >> min >> max;

    vector<ll> A;
    A.push_back(min);
    ll n = min;

    for(;;) {
        n *= 2;
        if(n > max) {
            break;
        }
        A.push_back(n);
    }
    cout << A.size() << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
char s[100050];
int l,i,j;
int main()
{
	gets(s);
	l=strlen(s);
	if(l%2){
		puts("No");
		return 0;
	}
	for(i=0,j=l-1;i<j;i++,j--){
		if(s[i]=='p'&&s[j]!='q'){
			puts("No");
			return 0;
		}
		else{
			if(s[i]=='q'&&s[j]!='p'){
				puts("No");
				return 0;
			}
			else{
				if(s[i]=='b'&&s[j]!='d'){
					puts("No");
					return 0;
				}
				else{
					if(s[i]=='d'&&s[j]!='b'){
						puts("No"); 
						return 0;
					}
				}
			}
		}
	}
	puts("Yes");
	return 0;
}

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

int a[101];

bool cmp(int x,int y)
{
	return x>y;
}

int main()
{
	int n;
	while(cin>>n)
	{
		for(int i=0;i<n;i++)
			cin>>a[i];
	
		sort(a,a+n,cmp);
		int alice_score=0,bob_score=0;
		
		for(int i=0;i<n;i++)
		{
			if(i%2==0)
				alice_score+=a[i];
			else
				bob_score+=a[i];
		}
		cout<<alice_score-bob_score<<endl;
	}
	
	return 0;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n, p, sum=0, mx=0;
	cin>>n;
	while(n--) {
		cin>>p;
		sum+=p;
		mx=max(mx,p);
	}
	cout << sum-mx/2 << endl;
	return 0;
}


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

#define REP(i,s,n) for(int (i)=s; (i)<(int)(n);(i)++)
#define RIT(it,c) for(__typeof(c.begin()) it = c.begin();it!=c.end();it++)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)(x).size()
#define MSET(m,v) memset(m,v,sizeof(m))


using namespace std;


typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<LL> vL;
typedef vector<bool> vb;
typedef pair<int,vi> iv;
typedef pair<LL,LL> pLL; 
typedef long double LD;

const LL MOD = 1000000007;
int N;
string S1,S2;

/*
0 : AA
1 : AB
2 : AC
3 : BA
4 : BB
5 : BC
6 : CA
7 : CB
8 : CC
*/

inline LL Add(LL x, LL y){
	return (x+y)%MOD;
}
void Ad(LL &x, LL y){
	x += y;
	if(x>=MOD) x -= MOD;
}
int main(){
	cin>>N>>S1>>S2;
	vector<vector<vL>> dp(N,vector<vL>(3,vL(3,0)));
	if(S1[0]==S2[0]) for(int k=0;k<3;++k) dp[0][k][k] = 1;
	else for(int k1=0;k1<3;++k1) for(int k2=k1+1;k2<3;++k2) dp[0][k1][k2] = dp[0][k2][k1] = 1;
	for(int i=1;i<N;++i){
		for(int j=0;j<3;++j) for(int k=0;k<3;++k){
			if(S1[i] == S2[i] && j != k) continue;
			if(S1[i] != S2[i] && j == k) continue;
			for(int r=0;r<3;++r) for(int t=0;t<3;++t){
				if(S1[i-1] == S2[i-1] && r != t) continue;
				if(S1[i-1] != S2[i-1] && r == t) continue;
				if(S1[i] == S1[i-1] && r != j) continue;
				if(S1[i] != S1[i-1] && r == j) continue;
				if(S2[i] == S2[i-1] && t != k) continue;
				if(S2[i] != S2[i-1] && t == k) continue;
				dp[i][j][k] += dp[i-1][r][t];
			}
			dp[i][j][k]%=MOD;
		}
	}
	LL ans = 0;
	for(int j=0;j<3;++j) for(int k=0;k<3;++k) Ad(ans, dp[N-1][j][k]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import Data.Maybe (fromJust)
import Control.Monad
import Data.List
import Debug.Trace

toYesNo :: Bool -> String
toYesNo True = "yes"
toYesNo _ = "no"

isAllDifferent :: String -> Bool
isAllDifferent "" = True
isAllDifferent (x:xs)
    | elem x xs = False
    | otherwise = isAllDifferent xs

solve :: String -> String
solve = toYesNo . isAllDifferent

main :: IO ()
main = do
    s <- getLine
    putStrLn $ solve s


Measured memory_bytes: 380
# coding: utf-8
# Your code here!

# ITP1_5_D


# 130の場合
# 10で割ると、13
# これにまた判定をかける

# 127の場合

# 131
# 13

import math


def judge(i):
    if i%3==0:
        return str(i)
        
    newi=i
    # print(newi)
    while(newi>10):
        if newi%10==3:
            # print(newi)
            # print("ここです")
            return str(i)
        elif newi//10==3:
            # print(newi)
            # print("そこです")
            return str(i)
        newi=math.floor(newi/10)
        # print(newi)
    return False


x=int(input())
result=[]
for num in range(1,x+1):
    if(judge(num)):
        result.append(judge(num))

print(" "+" ".join(result))

    
    
    
    
    
    
    
    
    


Measured memory_bytes: 5992
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <climits>
#include <queue>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
template<typename T1, typename T2>
inline void chmin(T1& a, T2 b){if (a > b) a = b;}
template<typename T1, typename T2>
inline void chmax(T1& a, T2 b){if (a < b) a = b;}
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

char map[1010][1010];
//0で初期化
ll dp[1010][1010] = {0};

int main()
{
	int H, W;
	cin >> H >> W;
	rep(i, H) {
		rep(j, W) {
			//初期条件のために座標を1ずらす
			cin >> map[i+1][j+1]; //charなので一文字ずつ読み込まれる
		}
	}


	rep(i, H) {
		rep(j, W) {
			//初期条件(スタート)
			if(i == 0 && j == 0)
				dp[i + 1][j + 1] = 1;
			else if (map[i + 1][j + 1] == '#')
				dp[i + 1][j + 1] = 0;
			else
				dp[i + 1][j + 1] = (dp[i+1][j] + dp[i][j+1]) % MOD;
		}
	}

	cout << dp[H][W] << endl;
}

Measured memory_bytes: 9216
#include<stdio.h>
int main()
{
	double a,b,c,d,e,f,x,y,num;
	while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){    
		num = a * e - b * d;
		if(num != 0){
            x = (e * c - b * f) / num;
			y = (a * f - d * c) / num;
		}
		if(x==-0){
			x=0;
		}
		else if(y==-0){
			y=0;
		}    
		printf("%.3lf %.3lf\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
using namespace std;



int main(){
	int a[3];
	pan(i,3) cin>>a[i];

	bool flag=false;
	if(a[0]==a[1] && a[2]!=a[0]) flag=true;
	else if(a[2]==a[1] && a[0]!=a[1]) flag=true;
	else if(a[0]==a[2] && a[1]!=a[0]) flag=true;

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

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y), C(Z);
    REP(i, X) {
        cin >> A[i];
    }
    REP(i, Y) {
        cin >> B[i];
    }
    REP(i, Z) {
        cin >> C[i];
    }
    vector<ll> S(X * Y);
    REP(i, X) {
        REP(j, Y) {
            S[i * Y + j] = A[i] + B[j];
        }
    }
    SORT(S), REVERSE(S);
    vector<ll> T(K * Z, 0);
    REP(i, min(X * Y, K)) {
        REP(j, Z) {
            T[i * Z + j] = S[i] + C[j];
        }
    }
    SORT(T), REVERSE(T);
    REP(i, K) {
        cout << T[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(a, b) for (int i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template <class T>inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}

int main()
{
    int h,n;
    cin >> h >> n;
    vector<pair<int,int>> v(n);
    REP(i,n){
        cin >> v[i].first >> v[i].second;
    }
    vector<ll> dp(h+1,INF);
    dp[0]=0;
    REP(i,h+1){
        REP(j,n){
            int now=min(i+v[j].first,h);
            dp[now]=min(dp[now],dp[i]+v[j].second);
        }
    }
    cout << dp[h] << endl;
}

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

int main() {
    int N;
    cin >> N;
    long long L[N+1];
    L[0] = 2;
    L[1] = 1;
    if (N == 1){
        cout << L[N] << endl;
        return 0;
    }
    for (int i=2; i<=N; i++){
        L[i] = L[i-1] + L[i-2];
    }
    cout << L[N] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif

  int n, k;
  scanf("%d%d", &n, &k);
  vector<bool> dp(k + 1, false);
  vector<int> a(n);
  for (int i = 0; i < n; ++i)
    scanf("%d", &a[i]);
  for (int i = 0; i <= k; ++i) {
    for (int v : a) {
      if (v > i)
        break;
      if (!dp[i - v]) {
        dp[i] = true;
        break;
      }
    }
  }
  puts(dp[k] ? "First" : "Second");

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


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

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

  vector<string> S(N);
  rep(i, N) cin >> S[i];

  sort(S.begin(), S.end());
  rep(i, N) cout << S[i];
  return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>

/* {1,2,3} -> ... -> {3,2,1} */
int next_permutation(int arr[],int n) {
	int target;
	int i;
	int temp;
	for (i = n - 2; i >= 0; i--) {
		if (arr[i] < arr[i + 1]) break;
	}
	if (i < 0) return 0;
	target = i;

	for (i = 0; target + i + 1 < n - i - 1; i++) {
		temp = arr[target + 1 + i];
		arr[target + 1 + i] = arr[n - 1 - i];
		arr[n - i - 1] = temp;
	}

	for (i = target + 1; i < n; i++) {
		if (arr[i] > arr[target]) break;
	}
	temp = arr[i];
	arr[i] = arr[target];
	arr[target] = temp;
	return 1;
}

int N, M, R;
int r[16];

int map[256][256];

int main(void) {
	int i, j, k;
	int order[16];
	int answer = 999999999;
	if (scanf("%d%d%d", &N, &M, &R) != 3) return 1;
	for (i = 0; i < R; i++) {
		if (scanf("%d", &r[i]) != 1) return 1;
	}
	for (i = 1; i <= N; i++) {
		for (j = 1; j <= N; j++) map[i][j] = 999999999;
		map[i][i] = 0;
	}
	for (i = 0; i < M; i++) {
		int A, B, C;
		if (scanf("%d%d%d", &A, &B, &C) != 3) return 1;
		map[A][B] = map[B][A] = C;
	}
	for (k = 1; k <= N; k++) {
		for (i = 1; i <= N; i++) {
			for (j = 1; j <= N; j++) {
				int candidate = map[i][k] + map[k][j];
				if (map[i][j] > candidate) map[i][j] = candidate;
			}
		}
	}
	for (i = 0; i < R; i++) order[i] = i;
	do {
		int candidate = 0;
		for (i = 1; i < R; i++) {
			candidate += map[r[order[i - 1]]][r[order[i]]];
		}
		if (candidate < answer) answer = candidate;
	} while (next_permutation(order, R));
	printf("%d\n", answer);
	return 0;
}


Measured memory_bytes: 384
import numpy as np

n, m, x = map(int, input().strip().split())
cs = []
aij = []
for _ in range(n):
    row = list(map(int, input().strip().split()))
    cs.append(row[0])
    aij.append(row[1:])


def check(bits, n, m, x):
    cost = 0
    skills = np.zeros(m, dtype=np.int)
    for i in range(n):
        bit = bits & (2 ** i)
        if bit:
            cost += cs[i]
            skills += aij[i]

    if np.all(skills >= x):
        return cost
    else:
        return False


min_cost = 1e30


for bits in range(2**n):
    result = check(bits, n, m, x)
    if not result:
        continue

    min_cost = min(min_cost, result)


if min_cost == 1e30:
    print(-1)
else:
    print(min_cost)


Measured memory_bytes: 27216
#include<iostream>
#include<algorithm>
#include<cstdio>
#define int long long
using namespace std;
void wk();
main(){int test=1;//scanf("%d",&test);
while(test--)wk();}
void wk(){
	int x;cin>>x;
	int ans=0;
	ans+=(x/500)*1000;x%=500;
	ans+=(x/5)*5;cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#define ll long long
using namespace std;
const int maxn = 500010, inf = 1e9 + 233;
int n;
char s[maxn];

template<typename T>
inline void read(T &k)
{
    int f = 1; k = 0; char c = getchar();
    while (c < '0' || c > '9') c == '-' && (f = -1), c = getchar();
    while (c <= '9' && c >= '0') k = k * 10 + c - '0', c = getchar();
    k *= f;
}

int main()
{
    int a, b, c;
    read(a); read(b); read(c);
    puts(a == b && b == c ? "Yes" : "No");
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i).sort.reverse
edge1 = nil
edge2 = nil
prev = nil
a.each do |v|
  if v == prev
    if edge1.nil?
      edge1 = v
      prev = nil
    else
      edge2 = v
      break
    end
  else
    prev = v
  end
end
if edge1.nil? || edge2.nil?
  puts 0
else
  puts edge1 * edge2
end


Measured memory_bytes: 22204
#include <iostream>
 
using namespace std;
 
int main()
{
  long long N, K;
  long long ans = 0;
  cin >> N >> K;
  if(N % K < abs(N % K - K)){
    ans = (N % K);
  }
  else{
    ans = abs(N % K -K);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
use std::cmp;

fn main(){
    let mut sc = Scanner::new();
    while let Ok(a) = sc.wrapped::<i64>() {
        let b:i64 = sc.next();
        let c:i64 = sc.next();
        let mut res = 1000000000i64 * 1000000000;
        res = cmp::min(res, c%2 * (a*b));
        res = cmp::min(res, a%2 * (b*c));
        res = cmp::min(res, b%2 * (c*a));
        println!("{}", res);
    }
}

// Scanner

#[allow(dead_code)]
struct Scanner {
    token_buffer : Vec<String>,
    index : usize,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner{
        Scanner { token_buffer: vec![], index: 0 }
    }

    fn wrapped<T>(& mut self) -> Result<T,&str> where T: std::str::FromStr {
        let s = try!(self.fetch_token());
        let t = try!(s.parse::<T>().map_err(|_| "Parse error"));
        Ok(t)
    }
    fn next<T>(& mut self) -> T where T: std::str::FromStr {
        self.wrapped::<T>().unwrap()
    }

    fn fetch_token(&mut self) -> Result<&String,&str> {
        while self.index >= self.token_buffer.len() {
            let mut st = String::new();
            while st.trim() == "" {
                match std::io::stdin().read_line(&mut st) {
                    Ok(l) if l > 0 => continue,
                    Ok(_)  => return Err("End of file"),
                    Err(_) => return Err("Failed to read line"),
                }
            }
            self.token_buffer = st.split_whitespace()
                .map(|x| x.to_string())
                .collect();
            self.index = 0;
        }

        self.index += 1;
        Ok(&self.token_buffer[self.index - 1])
    }
}


Measured memory_bytes: 380
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

  static class CAntiDivision {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
      long a = in.nextLong() - 1;
      long b = in.nextLong();
      long c = in.nextLong();
      long d = in.nextLong();

      long n = b - a, l = lcm(c, d);
      out.println(n - (sum(a, b, c) + sum(a, b, d) - sum(a, b, l)));
    }

    private long sum(long a, long b, long l) {
      return b / l - a / l;
    }

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

    private long gcd(long a, long b) {
      return b == 0 ? a : gcd(b, a % b);
    }

  }


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

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

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

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

  }
}



Measured memory_bytes: 23380