akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18+5
#define mod 1000000007
#define MAXN 100005
#define ll long long
#define pb push_back
#define sortv(v) sort(v.begin(),v.end())
#define tc(t) int t;cin>>t;while(t--)
#define copy copy_n
#define fr(i,a,b) for(long long i=a;i<b;i++)
#define frr(i,a,b) for(long long i=a;i>=b;i--)
#define frn(i,a,b,n) for(long long i=a;i<=b;i=i+n)
#define gcd(x,y) __gcd(x,y)
#define ld long double
#define um unordered_map
#define mkp make_pair
#define b_s binary_search
#define nob __builtin_popcount
#define des greater<ll>()
#define fi first
#define se second
ll mul(ll a, ll b, ll p = mod) {return ((a % p) * (b % p)) % p;}
ll add(ll a, ll b, ll p = mod) {return (a % p + b % p) % p;}
void input(ll a[], ll sz) {fr(i, 0, sz) cin >> a[i];}
void print(ll a[], ll sz) {fr(i, 0, sz) {if (i == sz - 1) cout << a[i] << "\n"; else cout << a[i] << " ";}}
ll maxr(ll a[], ll sz) {ll ma; fr(i, 0, sz) {if (i == 0) ma = a[i]; else if (a[i] > ma) ma = a[i];} return ma;}
ll minr(ll a[], ll sz) {ll mi; fr(i, 0, sz) {if (i == 0) mi = a[i]; else if (a[i] < mi) mi = a[i];} return mi;}
ll isprm(ll n) {
    if (n <= 1)  return 0;
    if (n <= 3)  return 1;
    if (n % 2 == 0 || n % 3 == 0) return 0;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return 0;
    return 1;
}
/*ll spf[MAXN];
void sieve()
{
    spf[1]=1;
    for (ll i=2; i<MAXN; i++)
        spf[i] = i;
    for (ll i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for(ll i=3;i*i<MAXN;i++)
    {
        if (spf[i]==i)
        {
            for (int j=i*i;j<MAXN;j+=i)
                if (spf[j]==j)
                    spf[j]=i;
        }
    }
}*/
ll power(ll x, ll y, ll p = mod)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p = mod)
{
    return power(n, p - 2, p);
}
ll ncrMod(ll n, ll r, ll p = mod)
{
    if (r == 0)
        return 1;
    ll fac[n + 1];
    fac[0] = 1;
    for (ll i = 1 ; i <= n; i++)
        fac[i] = fac[i - 1] * i % p;
    return (fac[n] * modInverse(fac[r], p) % p *
            modInverse(fac[n - r], p) % p) % p;
}
//a+b=xor(a,b)+2*(a&b)//
struct comp
{
    bool operator()(const pair<ll, ll> &a,
                    const pair<ll, ll> &b)const
    {
        if (a.fi == b.fi)
        {
            return (a.se > b.se); //second elem in descending
        }
        return (a.first < b.first);//first elem in ascending
    }
};




int main()
{
    fio;
    string s,t;
    cin>>s>>t;
    ll n1=s.length();
    ll n2=t.length();
    ll ans=inf;
    fr(i,0,(n1-n2+1))
    {
        ll f=0;
        fr(j,i,i+n2)
        {
            if(s[j]==t[j-i])
            f++;
        }
        ans=min(ans,(n2-f));
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db; 
typedef string str; 
typedef pair<ll,ll> pl; 
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
#define mp make_pair
#define se second
#define pb push_back
#define pf push_front
#define nn <<"\n"
#define F0R(i,a) for(ll i=0;i<a;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
int INF=0x3f3f3f3f;
ll MOD=1000000007;

ll binpow(ll a,ll b, ll c=1e18){
	ll res=1;
	while(b>0){
		if(b & 1){
			res*=a;
			res%=c;
		}
		a*=a;
		a%=c;
		b>>=1;
	}
	return res;
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//ifstream cin("name.in");
	//ofstream cout("name.out");
	int n;
	cin>>n;
	cout<<(1000-n%1000)%1000 nn;
}


Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;

int main() {
  int n; cin >> n;
  double sum = 0.0;
  for(int i=0; i<n; i++){
    string s;
    double a;
    cin >> a >> s;
    if(s == "JPY"){
      sum += a;
    }else{
      sum += a * 380000;
    }
  }
  printf("%.10lf\n", sum);

  return 0;
}


//


Measured memory_bytes: 256
n = int(input())
a = [list(map(int, input().split())) for _ in range(2)]
x = sum(a[1])+a[0][0]
ans = x
for i in range(1,n):
  x += a[0][i] -a[1][i-1]
  if ans < x: ans = x
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    string S;
    cin >> S;
    reverse(ALL(S));

    ll now = 0;
    rep(i, len(S)){
        if(now == len(S)) break;
        string tp5 = "", tp6 = "", tp7 = "";
        if(now + 4 < len(S)) tp5 = S.substr(now, 5);
        if(now + 5 < len(S)) tp6 = S.substr(now, 6);
        if(now + 6 < len(S)) tp7 = S.substr(now, 7);

        if(tp7 == "remaerd") now += 7;
        else if(tp6 == "resare") now += 6;
        else if(tp5 == "maerd" || tp5 == "esare") now += 5;
        else drop("NO");
    }

    drop("YES");

    return 0;
}

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

int main() {
    large n;
    cin >> n;

    // N  =  (1+xK)(K^y)  =  (K^y) + x(K^(y+1))
    // x : subtractions
    // y : divisions

    // when y==0, N = 1+xK, then K = (N-1)/x
    // when y!=0,

    auto divisor = vector<large>();
    for (auto div = 2LL; div * div <= n; ++div) {
        if (n % div == 0) {
            divisor.emplace_back(div);
            if (div * div != n)
                divisor.emplace_back(n / div);
        }
    }
    if (divisor.empty() || divisor.back() != n)
        divisor.emplace_back(n);

    auto cnt = 0LL;
    for (auto div = 1LL; div * div <= n - 1; ++div) {
        if ((n - 1) % div != 0)
            continue;

        if (div != 1)
            ++cnt;

        auto div2 = (n - 1) / div;
        if (div2 != 1 && div2 != div)
            ++cnt;
    }

    for (auto k : divisor) {
        auto x = n;
        while (x % k == 0)
            x /= k;
        if (x % k == 1)
            ++cnt;
    }

    cout << cnt << endl;
    return 0;
}


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

using namespace std;
typedef long long int lli;

lli n, A, B;

int main()
{
	scanf("%lld %lld %lld",&n,&A,&B);

	if( A > B )
	{
		printf("0\n");
		return 0;
	}

	if( n == 1 )
	{
		if( A == B ) printf("1\n");
		else printf("0\n");
		
		return 0;
	}

	lli mn = (n - 1)*A + B;
	lli mx = A + (n - 1)*B;

	printf("%lld\n",mx - mn + 1);
}

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

struct UnionFind{
    vector<int> parent;
    vector<ll> dist;
    UnionFind(int x = 1){
        parent.clear(); parent.resize(x,-1);
        dist.clear(); dist.resize(x,0);
    }
    int find(int x){
        if(parent[x]<0)return x;
        int r = find(parent[x]);
        dist[x]+=dist[ parent[x] ];
        return parent[x]=r;    
    }
    ll depth(int x) { find(x); return dist[x]; }

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

    int size(int x) { return -parent[find(x)]; }

    void unite(int x,int y,ll k=0){
        k+=depth(y);
        k-=depth(x);
        k*=-1;
        x=find(x);
        y=find(y);
        if(x==y)return;
        if(size(x)<size(y)) { swap(x,y); k *= -1;}
        parent[x]+=parent[y];
        parent[y]=x;
        dist[y]=k;
    }
};


int main(){
    int n,q; cin >> n >> q;
    UnionFind T(n);
    for(int i=0;i<q;i++){
        int type,x,y;
        scanf("%d %d %d",&type,&x,&y);
        if(type==0){
            int a;
            scanf("%d",&a);
            T.unite(x,y,a);
        }
        else{
            if(!T.same(x,y)) printf("?\n");
            else printf("%lld\n",T.depth(x)-T.depth(y));
        }
    }
    return 0;
}




Measured memory_bytes: 3852
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    Cin(string, s, t);
    For(i, n){
        cout << s[i] << t[i];
    }
    Cout();
}


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

int main() {
	int N;
	cin >> N;
	string ans = "APPROVED";
	int A;
	for (int i = 0; i < N; i++) {
		cin >> A;
		if (A % 2 == 0) {
			if (!(A % 3 == 0 || A % 5 == 0)) ans = "DENIED";
		}
	}
	cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		int k1 = sc.nextInt();
		for(int tmp = 0; tmp<k1; tmp++) {
			int a1 = sc.nextInt();
			list.add(a1);
		}
		for(int tmp1 = 1; tmp1<n ;tmp1++) {
			List<Integer> compareList = new ArrayList<Integer>();
			int kn = sc.nextInt();
			for(int tmp2 = 0; tmp2<kn ; tmp2++) {
				int a = sc.nextInt();
				compareList.add(a);
			}
			List<Integer> removeList = new ArrayList<Integer>();
			for(int tmp3=0; tmp3< list.size() ; tmp3++) {
				 if(!compareList.contains(list.get(tmp3))){
					 removeList.add(tmp3);
				 }
			}
			Collections.sort(removeList, Collections.reverseOrder());
			for(int tmp4=0; tmp4 < removeList.size(); tmp4++) {
				int index = removeList.get(tmp4);
				list.remove(index);
			}
		}
		System.out.println(list.size());
	}
}

Measured memory_bytes: 23260
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
typedef long long ll;

int main() {
	fast;
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < 3; i++) {
		int ct = 0;
		while (i < 3 && s[i] == 'R') {
			ct++;
			i++;
		}
		ans = max(ans, ct);
	}
	cout << ans;
	return 0;
}



















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

int main(void){
    int n, k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i,n) cin >> h[i];
    sort(all(h));
    ll sum = 0;
    rep(i, n-k) sum += h[i];
    cout << sum << endl;
    return 0;
}


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

int main()
{
	int N, K, S;
	scanf("%d %d %d", &N, &K, &S);

	int i;
	for (i = 1; i <= K; i++) printf("%d ", S);
	for (; i <= N; i++) printf("%d ", S % 1000000000 + 1);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)

int main() {
	string S;
	string T="abc";
	cin >> S;
	int i;
	rep(i, 3) {
		T[i] = S[i];
	}
	cout << T;
	return 0;
}

Measured memory_bytes: 3628
from sys import stdin

n,m = map(int,stdin.readline().rstrip().split())
c = []
a_list = []

def main():
    for i in range(m):
        a,b = map(int,stdin.readline().rstrip().split())
        a_list.append(a)
        c.append(sum(1 << j-1 for j in list(map(int,stdin.readline().rstrip().split()))))

    inf = 10**10
    dp = [inf]*(1 << n)
    dp[0] = 0

    for i in range(1 << n):
        for A,C in zip(a_list,c):
            dp[C|i] = min(dp[C|i],dp[i]+A)

    if dp[-1] == inf:
        print(-1)
    else:
        print(dp[-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define ALL(x) x.begin(), x.end()
#define INF (1001000000)
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i:c)
#define EXIST(cs,v) (find(ALL(cs),(v))!=cs.end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define UNIQ(c) (c).erase(unique((c).begin(),(c).end()), (c).end());
#define P(p) cout<<(p)<<endl;

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

    int n, i;
    cin >> n >> i;

    P(n+1-i);

    return 0;
}


Measured memory_bytes: 256
#!/bin/bash
read A B C D

export A
export B
export C
export D

while true;
do
        # takahashi turn
        if [ $((${C}-${B})) -le 0 ]; then
                echo Yes
                break
        fi
        C=`echo $((${C}-${B}))`

        # aoki turn
        if [ $((${A}-${D})) -le 0 ]; then
                echo No
                break
        fi
        A=`echo $((${A}-${D}))`

done

Measured memory_bytes: 7376
#include <iostream>

int main(void)
{
	using namespace std;
	char c;
	int sum = 0;
	while(cin.get(c))
	{
		if(c != '\n')
		{
			sum += c - '0' ;
		}
		else if(sum == 0)
		{
			break;
		}
		else
		{
			cout << sum << endl;
			sum = 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e1+10;
string s;
int a[N];
int main()
{
    cin>>s;
    ll ans=s.length();
    ans=(ans+1)*ans/2+1;
    for(int i=0;i<s.length();i++)
    ans-=++a[s[i]-'a'];
    cout<<ans;
    return 0;
}


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

#define endl '\n'
#define int long long

const int N = 110, W = 1e5+9;
int cache[N][W], items[N][2], n, w;

int dp(int id, int wt) {
	if(id == n+1 or wt == 0)
		return 0;
	int &ans = cache[id][wt];
	if(ans != -1) 
		return ans;
	if(wt - items[id][0] >= 0)
		ans = max(dp(id + 1, wt), items[id][1] + dp(id+1, wt - items[id][0]));
	else 
		ans = dp(id+1, wt);
	return ans;
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	memset(cache, -1, sizeof cache);
	cin >> n >> w;
	for(int i = 1; i <= n; i ++) {
		for(int j = 0; j < 2; j ++) {
			cin >> items[i][j];
		}
	}
	cout << dp(1,w) << endl;

	return 0;
}

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

template<class T> inline bool chmax(T& a, T b)
{
	if (a < b){
		a = b;
		return true;
	}
	return false;
}
int N, W;
long long dp[110][100010];
int main()
{
	cin >> N >> W;
	int weight[N], value[N];
	for (int i = 0; i < N; i++) cin >> weight[i] >> value[i];
	
	for (int i = 0; i < N; i++){
		for (int sum_w = 0; sum_w <= W; sum_w++){
			if (sum_w - weight[i] >= 0){
				chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
			}

			chmax(dp[i+1][sum_w], dp[i][sum_w]);
		}
	}

	cout << dp[N][W] << endl;


}


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


int main() {
    vector<int> v(3);
    for(int i = 0 ; i < 3; i++){
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    int r = 10*v[2] + v[1] + v[0];
    cout << r;
    cout << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] team = new int[n];
		int[] result = new int[n];
		int ateam = 0, bteam = 0, apoint = 0, bpoint = 0, i = 0, j = 0;
		for(i = 0; i < n * (n - 1) / 2; i++){
			ateam = scan.nextInt();
			bteam = scan.nextInt();
			apoint = scan.nextInt();
			bpoint = scan.nextInt();
			if(apoint > bpoint){
				team[ateam - 1] += 3;
			} else if(bpoint > apoint){
				team[bteam - 1] += 3;
			} else if(apoint == bpoint){
				team[ateam - 1]++;
				team[bteam - 1]++;
			}
		}
		scan.close();
		for(i = 0; i < n; i++){
			result[i] = 1;
			for(j = 0; j < n; j++){
				if(team[i] < team[j]){
					result[i]++;
				}
			}
		}
		for(i = 0; i < n; i++){
			System.out.println(result[i]);
		}
	}
}

Measured memory_bytes: 41968
import java.util.*;
public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int l = sc.nextInt();
		String[] a = new String[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.next();
			
		}
		Arrays.sort(a);
		for(int j = 0; j < n; j++) {
			System.out.print(a[j]);
			
		}
  	}
}


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

int dp[100010];
int h[100010];

int INF = 2e9 + 17;

void solve()
{
  int n, k; cin >> n >> k;
  for (int i = 0; i < n; i++)
  {
    cin >> h[i];
  }
  for (int i = 0; i < n; i++)
  {
    dp[i] = INF;
  }
  
  dp[0] = 0;
  
  for (int i = 0; i < n - 1; i++)
  {
    for (int j = 1; j <= k; j++)
    {
      if (i + j == n) break;
      dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
    }
  }
  
  cout << dp[n - 1] << endl;
}

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
typedef long long ll;
using namespace std;
int main(void){
    // Your code here!
    int n;ll m;cin>>n>>m;
    map<ll,int> mp;
    ll res=0;
    vector<ll> b(n+1,0);
    rep(i,n){
        ll a;cin>>a;
        b[i+1]=b[i]+a;
        ll buf=b[i+1]%m;
        if(buf==0)mp[0]++;
        res+=mp[(buf==0)? 0:buf];
        if(buf!=0)mp[buf]++;
    }
    cout<<res<<endl;
}


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

using namespace std;

int main() {
  long long X, Y;
  cin >> X >> Y;
  int ans = 0;
  while (X <= Y) {
    X *= 2;
    ans++;
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    vector<int> p(n);
    for(int i=0; i<n; ++i){cin >> p[i];}
    int mi = INT32_MAX;
    int cnt = 0;
    for(int i=0; i<n; ++i){
        mi = min(p[i], mi);
        if(mi>=p[i]){cnt++;}
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,a;
	cin>>n;
	int c1=0;
	for(int i=1;i<=n;i++)
	{
	 a=floor(log10(i) + 1);
	 if(a%2!=0)
	 c1++;
	}cout<<c1;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

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

  if(a == b && b == c){
    cout << 1 << endl;
  }else if(a == b || b == c || c == a){
    cout << 2 << endl;
  }else{
    cout << 3 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    
  public static void main(String[] args) {
      
      Scanner sc = new Scanner(System.in);
      
      String S = sc.next();   

   for(int i = 1;i < S.length();i++){      
      String A = S.substring(0,S.length() - i);                  
      if(isEven(A)){
          System.out.println(S.length() - i);
          return;
      }
   }         
            
  } 
  
  private static boolean isEven(String S){      
      String a = S.substring(0,S.length()/2);
      String b = S.substring(S.length()/2);
      if(S.length()%2 == 0 &&a.equals(b)){
          return true;
      }
      return false;
  }
  
}


Measured memory_bytes: 21844
S = input()
ans = 'AC'

if S[0] != 'A':
  ans = 'WA'

if S[2:-1:1].count('C') != 1:
  ans = 'WA'

S = S.replace('A', 'a').replace('C', 'c')

if S.islower() == False:
  ans = 'WA'
  
print(ans)


Measured memory_bytes: 9092
#include<bits/stdc++.h>
using namespace std;
const int MAX=1e6;
long long n,p;
long long poww(long long x,long long y)
{
	long long ans=1;
	for (;y;y>>=1,x=(x*x)) if (y&1) ans=(ans*x);
	return ans;
}
int main(){
	scanf("%lld%lld",&n,&p);
	long long ans=1;
	for (int i=2;i<=MAX;i++) 
     if (p%i==0)
	{
      int sum=0;
      while (p%i==0) {
      	p/=i; sum++;
      }
      ans*=poww(i,(long long)sum/n);
	}
	if (p>1&&n==1) ans*=p; 
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <queue>
#define N 1003

using namespace std;

struct edge{
	int to, nxt;
}e[N * N * 3];

int n, cnt;
int ins[N * N], mp[N][N], fir[N * N], t[N * N];

queue < int > Q;

int id(int ,int);
void add(int ,int);

int main(){
	scanf("%d", &n); int ans = 0;
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j < n; ++j)
			scanf("%d", mp[i] + j);
	for(int i = 1; i <= n; ++i)
		for(int j = 2; j < n; ++j)
			add(id(i, mp[i][j - 1]), id(i, mp[i][j]));
	for(int i = 1; i <= n * n; ++i){
		if(!ins[i]) Q.push(i);
		t[i] = 1;
	}
	while(!Q.empty()){
		int u = Q.front(); Q.pop(); ans = max(ans, t[u]);
		for(int i = fir[u]; i; i = e[i].nxt){
			int v = e[i].to;
			--ins[v];
			if(!ins[v])
				Q.push(v), t[v] = t[u] + 1;
		}
	}
	for(int i = 1; i <= n; ++i) 
		if(ins[i]) ans = -1;
	cout << ans << endl;
	return 0;
}

int id(int x,int y){
	if(x > y) swap(x, y);
	return (x - 1) * n + y;
}

void add(int u,int v){
	e[++cnt] = (edge){v, fir[u]}; fir[u] = cnt; ++ins[v];
	return ;
}


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

class D
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var ws = new int[n].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).OrderBy(x => x[1]).ToArray();

		var ok = true;
		var t = 0;
		foreach (var w in ws) if ((t += w[0]) > w[1]) { ok = false; break; }
		Console.WriteLine(ok ? "Yes" : "No");
	}
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;

int main(){
  int N;
  cin >> N;
  int res = N;
  rep(i,N+1){
    int cc = 0;
    int t = i;//6^k　で引き出す分のお金
    while(t > 0)cc += t%6, t/=6;
    t = N - i;
    while(t > 0)cc += t%9, t/=9;
    if(res>cc)res = cc;
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define f   first
#define s   second
#define pb          push_back
#define mod         1000000007
#define hell        998244353
#define inf         1000000000000000000LL
using namespace std;
ll n,k,m,l;
//ll dp[15][1005];
void solve()
{   
  
string s;
cin>>n;
ll ans=0;
for(ll i=1;i<=n;i++)
{
    if(i%3!=0 && i%5!=0) ans+=i;
}
cout<<ans;




}    
int main()
{  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //cout<<primes.size();
    ll t=1;
    //cin>>t;
    while(t--)
        solve();

}


Measured memory_bytes: 3652
#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 <cmath>
#include <limits>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
using namespace std;
using ll = long long;

int main() {
	int H, W; cin >> H >> W;
	vector<vector<int>> vec(H, vi(W));

	for (int i = 0; i < H; i++) {
		string s; cin >> s;
		for (int j = 0; j < W; j++) {
			if (s[j] == '.') vec[i][j] = 1;
			else vec[i][j] = 0;
		}
	}

	vector<vector<int>> temp1(H, vi(W));
	for (int i = 0; i < H; i++) {
		temp1[i][0] = vec[i][0];
		for (int j = 1; j < W; j++) {
			temp1[i][j] = temp1[i][j - 1] + vec[i][j];
			if (vec[i][j] == 0) temp1[i][j] = 0;
		}
	}

	vector<vector<int>> temp2(H, vi(W));
	for (int i = 0; i < H; i++) {
		temp2[i][W - 1] = vec[i][W - 1];
		for (int j = W - 2; j > -1; j--) {
			temp2[i][j] = temp2[i][j + 1] + vec[i][j];
			if (vec[i][j] == 0) temp2[i][j] = 0;
		}
	}

	vvi temp3(H, vi(W));
	for (int j = 0; j < W; j++) {
		temp3[0][j] = vec[0][j];
		for (int i = 1; i < H; i++) {
			temp3[i][j] = temp3[i - 1][j] + vec[i][j];
			if (vec[i][j] == 0) temp3[i][j] = 0;
		}
	}

	vvi temp4(H, vi(W));
	for (int j = 0; j < W; j++) {
		temp4[H - 1][j] = vec[H - 1][j];
		for (int i = H - 2; i > -1; i--) {
			temp4[i][j] = temp4[i + 1][j] + vec[i][j];
			if (vec[i][j] == 0) temp4[i][j] = 0;
		}
	}


	int ans = 0;
	rep(i, H) rep(j, W) ans = max(ans, temp1[i][j] + temp2[i][j] + temp3[i][j] + temp4[i][j] - 3);

	cout << ans << endl;
}

Measured memory_bytes: 81916
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
bool vis[30];
char s[100005];
int main(){
    while(~scanf("%s",&s)){
        memset(vis,0,sizeof(vis));
        int i;
        for(i=0;s[i];i++){
            vis[s[i]-'a']=1;
        }
        for(i=0;i<26;i++){
            if(vis[i]==0){
                printf("%c\n",i+'a');
                break;
            }
        }
        if(i==26) printf("None\n");
    }
return 0;}


Measured memory_bytes: 384
import java.math.BigInteger;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        BigInteger a = new BigInteger(sc.next());
        BigInteger b = new BigInteger(sc.next());

        switch (a.compareTo(b)) {
            case 0:
                System.out.println("EQUAL");
                break;
            case 1:
                System.out.println("GREATER");
                break;
            default:
                System.out.println("LESS");
                break;
        }
    }
}


Measured memory_bytes: 21972
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    s_arr = []
    for i in range(N):
        _ =     _in[i+1]   # type:str
        s_arr.append(_)
    M = int(_in[N+1])  # type:int
    t_arr = []
    for i in range(M):
        _ =     _in[i+N+2]   # type:str
        t_arr.append(_)    
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = 0
    w_arr = list(set(s_arr))
    for w in w_arr:
        _ = s_arr.count(w)-t_arr.count(w)
        cnt = max(cnt,_)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 38384
#include<stdio.h>

#define H 2000000
#define INFTY 2000000001

void maxHeapify(int*,int);
void buildMaxHeap(int*);
int heapMaximum(int*);
int heapExtractMax(int*);
void maxHeapInsert(int*,int);
void heapIncreaseKey(int*,int,int);


int n=0;

int main(void){
  char com[8];
  int key,Node[H];
  int i;

  while(1){
    scanf(" %s",com);
    if(com[0] == 'i'){
      scanf(" %d",&key);
      maxHeapInsert(Node,key);
    }
    else{
      if(com[1] == 'x'){
	printf("%d\n",heapExtractMax(Node));
      }
      else{
	break;
      }
    }
  }
  
  return 0;
}

void maxHeapify(int *A, int i){
  int l,r,largest,tmp;
  l = 2*i;
  r = 2*i+1;
  
  if(l <= n && A[l] > A[i]) largest = l;
  else largest = i;
  if(r <= n && A[r] > A[largest]) largest = r;

  if(largest != i){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(A,largest);
  }
}

void buildMaxHeap(int *A){
  int i;

  for(i = n/2; i >= 1; i--){
    maxHeapify(A,i);
  }
}

int heapMaximum(int *A){
  return A[1];
}

int heapExtractMax(int *A){
  int max;
  max = A[1];
  A[1] = A[n];
  n--;
  maxHeapify(A,1);
  return max;
}

void maxHeapInsert(int *A, int key){
  n++;
  A[n] = -INFTY;
  heapIncreaseKey(A,n,key);
}

void heapIncreaseKey(int *A, int i, int key){
  int tmp;
  A[i] = key;
  while(i > 1 && A[i/2] < A[i]){
    tmp = A[i];
    A[i] = A[i/2];
    A[i/2] = tmp;
    i = i/2;
  }
}



Measured memory_bytes: 5616
from sys import stdin
from collections import deque
def main():
    #入力
    readline=stdin.readline
    N,M=map(int,readline().split())
    G=[[] for _ in range(N)]
    A=[0]*M
    B=[0]*M
    for i in range(M):
        a,b=map(lambda x:int(x)-1,readline().split())
        A[i]=a
        B[i]=b
        G[a].append(b)
        G[b].append(a)

    count=0
    for a,b in zip(A,B):
        is_searched=[False]*N
        is_searched[0]=True
        d=deque([0])
        while len(d)>=1:
            now=d.popleft()
            for x in G[now]:
                if (now==a and x==b) or (now==b and x==a):
                    continue
                if is_searched[x]==False:
                    d.append(x)
                    is_searched[x]=True

        if False in is_searched:
            count+=1
    
    print(count)
        
if __name__=="__main__":
    main()

Measured memory_bytes: 3316
N= int(input())
A= [int(x) for x in input().split()]
c_2 = 0
c_4 = 0
for i in range(N):
  if A[i]%4==0:
    c_4 += 1
  elif A[i]%2==0 and A[i]%4!=0:
    c_2 += 1
c=N-c_4-c_2
print('Yes' if (c_2==0 and c_4>=c-1) or c_4>=c else'No')


Measured memory_bytes: 14252
s=list(input())
n=len(s)
insert=0
ans=0
for i in range(2**(3)):
    f=(s[0])
    for j in range(3):
        if i&(1<<j):
            f=f+"+"
        else:
            f=f+"-"
        f=f+s[j+1]
      
   
    if eval(f)==7:
        print(f+"=7")
        exit()


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

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

  vector<int> A(N);
  vector<int> ANS;

  if( N % 2 == 1){
    ANS.push_back(0);
    for(int i = 2; i <= N-1; i += 2){
      ANS.push_back(i);
      ANS.push_back(i);
    }
  }else{
    for(int i = 1; i <= N; i+=2){
      ANS.push_back(i);
      ANS.push_back(i);
    }
  }

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

  sort(ANS.begin(),ANS.end());
  sort(A.begin(),A.end());

  // for(int x: A) cout << x << ",";
  // cout << endl;
  // for(int x: ANS) cout << x << ",";
  // cout << endl;

  if(A == ANS){
    if(N%2) N--;
    long long ans = 1;
    for(int i = 0; i < (N)/2; i++){
       ans *= 2;
       ans = ans % (long long)(7+(1e9));
     }
    cout << ans << endl;
  }else{
    cout << "0" << endl;
  }

  return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;

vector<int> vi;

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

    if (abs(c - a) <= d) cout << "Yes" << endl;
    else if (abs(b - a) <= d && abs(c - b) <= d) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
A, B, K = map(int, input().split())
a = []
b = []
 
for i in range(1, A + 1):
    if(A % i == 0):
        a.append(i)
        
for i in range(1, B + 1):
    if(B % i == 0):
        b.append(i)
        
a = set(a)
b = set(b)
 
print(sorted(list(a & b), reverse = True)[K - 1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for (int i = k; i < (int)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pll = pair<ll, ll>;
const ll mod = 1000000007;
const ll inf = 1000000000000;//10の12乗
ll cnt=0;
int n,m;
vector<vector<int>> v(200000);
vector<bool> seen(200000);
void dfs(int k){
    if(!seen[k]){
        seen[k]=true;
    for(auto next:v[k]){
        if(seen[next]) continue;
        dfs(next);
    }
    cnt++;
    }
    
}

int main() {

    cin >> n >> m;
    ll ans=0;
    rep(i,m){
        int x,y;
        cin >> x >> y;
        x--;y--;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    rep(i,n){
        if(seen[i]) continue;
        dfs(i);
        chmax(ans,cnt);
        cnt=0;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 20328
#include<iostream>

using std::cout;
using std::cin;
using std::endl;

int main(){
    int n, x;
    cin >> n >> x;
    int l[100] = {};
    for(int i = 0; i < n; ++i){
        cin >> l[i];
        if(l[i] == 0)break;
    }
    int point[n + 1];
    int count = 0;
    for(int i = 0; i < n + 1; i++){
        if(i == 0){
            point[i] = 0;
        }else{
            point[i] = point[i - 1] + l[i - 1];
        }
        if(point[i] <= x) ++count;
    }
    cout << count;
}




Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int n, m;
  int A[100][100];
  int b[100];

  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j)
      cin >> A[i][j];
  }
  for (int j = 0; j < m; ++j)
    cin >> b[j];

  for (int i = 0; i < n; ++i) {
    int c = 0;
    for (int j = 0; j < m; ++j)
      c += A[i][j] * b[j];
    cout << c << endl;
  }

  return 0;
}

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

class Main {
    static boolean[] visited;
    static int n;
    static int m;
    static int[] a;
    static int[] b;
    static long ans;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        a = new int[m];
        b = new int[m];
        visited = new boolean[n + 1];
        Arrays.fill(visited, false);
        for (int i = 0; i < m; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
        sc.close();
        ans = 0;
        DFS(1);
        System.out.println(ans);
    }

    public static void DFS(int pos) {
        visited[pos] = true;
        boolean comp = true;
        for (int i = 1; i < n + 1; i++) {
            if (!visited[i]) {
                comp = false;
                break;
            }
        }
        if (comp) {
            ans++;
            visited[pos] = false;
            return;
        }
        for (int i = 0; i < m; i++) {
            if (pos == a[i] && !visited[b[i]]) {
                DFS(b[i]);
            }
        }
        for (int i = 0; i < m; i++) {
            if (pos == b[i] && !visited[a[i]]) {
                DFS(a[i]);
            }
        }
        visited[pos] = false;
        return;
    }
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
#define debug(x) cout<<#x<<"::"<<x<<endl;
using namespace std;
typedef long long ll;

void solve()
{
    int n;
    cin>>n;
    ll h[n][3];
    for(int i=0;i<n;i++)
    {
        cin>>h[i][0]>>h[i][1]>>h[i][2];
    }
    for(int i=1;i<n;i++)
    {
        h[i][0]=h[i][0]+max(h[i-1][1],h[i-1][2]);
        h[i][1]=h[i][1]+max(h[i-1][0],h[i-1][2]);
        h[i][2]=h[i][2]+max(h[i-1][0],h[i-1][1]);
    }
    cout<<max(h[n-1][0],max(h[n-1][1],h[n-1][2]));
    

}

int main()
{
    
    int t;
    t=1;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
char Grading(m,f,r){
	int t;
	char grade;
	t=m+f;
	
	if(m==-1||f==-1){
			grade='F';
		}
	else if(t>=80){
		grade='A';
	}
	else if(t>=65){
		grade='B';
	}
	else if(t>=50){
		grade='C';
	}
	else if(t>=30){
		if(r>=50){
			grade='C';
		}
		else{
			grade='D';
		}
	}
	else{
		grade='F';
	}

	return grade;
}


int main(void){

	int m,f,r;
	char grade;
	
	while(1){
		scanf("%d %d %d",&m,&f,&r);
		if(m==-1&&f==-1&&r==-1){
			break;
		}
		grade=Grading(m,f,r);
		printf("%c\n",grade);
	}

	return 0;
}

Measured memory_bytes: 600
def func x, y, a, b, t
    a*t>=x and b*t>=y
end

n=gets.to_i
x, y=0, 0
n.times{|i|
    a, b=gets.split.map &:to_i
    if i==0
        x=a
        y=b
    else
        if a==1 and b==1
            x=x>y ? x : y
            y=x
        else
            t=1<<63
            r=t*2-1
            while t>0
                r-=t if func(x, y, a, b, r-t)
                t>>=1
            end
            x=a*r
            y=b*r
        end
    end
}
puts x+y



Measured memory_bytes: 1788
import java.util.*;
import java.util.stream.Collectors;

public class Main {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }


    // int N = Integer.parseInt(scanner.nextLine());
    // int N = scanner.nextInt(), M = scanner.nextInt();
    // scanner.nextLine();
    // int[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    static void solve(Scanner scanner) {
        int[] XYZK = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        List<Long> a = Arrays.stream(scanner.nextLine().split(" ")).map(Long::parseLong).sorted(Comparator.comparingLong(x -> -x)).collect(Collectors.toList());
        List<Long> b = Arrays.stream(scanner.nextLine().split(" ")).map(Long::parseLong).sorted(Comparator.comparingLong(x -> -x)).collect(Collectors.toList());
        List<Long> c = Arrays.stream(scanner.nextLine().split(" ")).map(Long::parseLong).sorted(Comparator.comparingLong(x -> -x)).collect(Collectors.toList());

        Set<Long> visited = new HashSet<>();
        Queue<long[]> q = new PriorityQueue<>(Comparator.comparingLong(x -> -x[0]));
        q.add(new long[]{a.get(0) + b.get(0) + c.get(0), 0, 0, 0});
        int k = 0;
        while (k < XYZK[3]) {
            long[] top = q.poll();
            if (!visited.add((top[1] << 24) + (top[2] << 12) + top[3])) {
                continue;
            }
            System.out.println(top[0]);
            k++;
            if (top[1] < XYZK[0] - 1) {
                q.add(new long[]{
                        a.get((int) top[1] + 1) + b.get((int) top[2]) + c.get((int) top[3]),
                        top[1] + 1,
                        top[2],
                        top[3]
                });
            }
            if (top[2] < XYZK[1] - 1) {
                q.add(new long[]{
                        a.get((int) top[1]) + b.get((int) top[2] + 1) + c.get((int) top[3]),
                        top[1],
                        top[2] + 1,
                        top[3]
                });
            }
            if (top[3] < XYZK[2] - 1) {
                q.add(new long[]{
                        a.get((int) top[1]) + b.get((int) top[2]) + c.get((int) top[3] + 1),
                        top[1],
                        top[2],
                        top[3] + 1
                });
            }
        }
    }

}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;

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

int main(){
  string N;
  cin >> N;
  REP(i, N.length()){
    N[i] -= '0';
  }
  int ans = 0;
  int sum = 0;
  REP(i, N.length()){
    if(N[i] != 0){
      int x = sum + N[i]-1+ 9*(N.length()-1-i);
      ans = max(ans, x);
    }
    sum+= N[i];
  }
  ans = max(ans, sum);
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let t: Vec<usize> = (0..n).map(|_| read()).collect();
    let m: usize = read();
    let drink: Vec<(usize,usize)> = (0..m).map(|_| (read(),read())).collect();

    for i in drink.iter() {
        let mut ans = 0;
        for (j,k) in t.iter().enumerate() {
            if i.0 == j+1 {
                ans += i.1;
            }else{
                ans += *k;
            }
        }
        //println!("i:{:?} , j:{}", i,j);
        println!("{}", ans);
    }
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main() {
	unsigned long long N, M;
	cin >> N >> M;
	if (N == 1 && M == 1) {
		cout << 1 << endl;
	}
	else if (N == 1) {
		cout << M - 2 << endl;
	}
	else if (M == 1) {
		cout << N - 2 << endl;
	}
	else {
		cout << (N - 2)*(M - 2) << endl;
	}
}

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

using namespace std;
#define lint long long
#define P pair<int, int>

int main() {
    int N, M;
    cin >> N >> M;
    
    const int INF = N + 1;
    
    int A[N + M], B[N + M];
    
    for(int i = 0; i < N - 1 + M; ++i){
        cin >> A[i] >> B[i];
    }
    
    vector<int> g[N + 1];
    int h[N + 1], ans[N + 1];
    
    for(int i = 0; i < N + 1; ++i){
        ans[i] = 0;
        h[i] = 0;
    }
    
    for(int i = 0; i < N - 1 + M; ++i){
        g[A[i]].push_back(B[i]);
        h[B[i]]++;
    }
    
    stack<int> st;
    
    for(int i = 1; i < N + 1; ++i){
        if(h[i] == 0){
            st.push(i);
            break;
        }
    }
    
    while(!st.empty()){
        int a = st.top(); st.pop();
        for(auto e : g[a]){
            h[e]--;
            if(h[e] == 0){
                st.push(e);
                ans[e] = a;
            }
        }
    }
    
    for(int i = 1; i <= N; ++i){
        cout << ans[i] << endl;
    }
    
    
    
}

Measured memory_bytes: 7808
H, W = (int(x) for x in input().split())
S = [input() for _ in range(H)]
ans = [''] * H  
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            ans[i] += '#'
            continue
        bom = 0
        for k in range(3):
            for l in range(3):
                if 0 <= i-1+k < H and 0 <= j-1+l < W:
                    if S[i-1+k][j-1+l] == '#':
                        bom += 1
        ans[i] += str(bom)
for s in ans:
    print(s)
                    


Measured memory_bytes: 9184
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int x,t;
  cin>>x>>t;
  int ans = 0;
  if(x - t >= 0) {
    ans = x - t;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a,b):
  return a*b //gcd(a,b)
A,B,C,D = map(int,input().split())
c = B//C-(A-1)//C
d = B//D-(A-1)//D
LCM = lcm(C,D)
l = B//LCM-(A-1)//LCM
if C==D==1:
    print(0)
else:
    print(B-A+1-c-d+l)

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

//Compiler version g++ 6.3.0

int main()
{
   long long a,b,d=0,i,j;
   cin>>a>>b;
   
   long long c[b];
   
   for(i=0;i<b;i++)
   {
     cin>>c[i];
   }
   
   //for(i=0;i<b;i++)
   //{
    // cout<<c[i]<<" ";
   //}
   
   for(i=0;i<b;i++)
   {
     d+=c[i];
    // cout<<d;
   }
   
   if(d>=a)
   {
     cout<<"Yes";
   }
   else
   {
     cout<<"No";
   }
   return 0;
     
   
}

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

int main(){

  double a,b;
  double c=0;
  double d=0;
  double x=10;
  double y=0;
  double z=0;
  int p,q;

  scanf("%lf",&a);
  scanf("%lf",&b);


  for(int i=0;i<b;i++){
    y=a*pow(x,i);
    c=c+y;
  }

  for(int i=0;i<a;i++){
    z=b*pow(x,i);
    d=d+z;
  }

  if(a<b){
    p=(int)c;
    printf("%d\n",p);
  }else{
    q=(int)d;
    printf("%d\n",q);
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <utility>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    int a,b;
     cin >>a>>b;
	int arr[100007][2];
	for(int i=0;i<a;i++)
        {
		arr[i][0]=arr[i][1]=0;
	    }
	int n;
	string m;
	for(int i=0;i<b;i++)
	{
	 	cin>>n>>m;
	    	if(m=="AC"&&arr[n-1][0]==0)
		     arr[n-1][0]++;
		  else if(m=="WA"&&arr[n-1][0]==0)
		     arr[n-1][1]++;
	}
    int sum=0,ans=0;
     for(int i=0;i<a;i++)
	   {
		 sum+= arr[i][0];
		if(arr[i][0]==1)
			ans+=arr[i][1];
	   }
  
	cout << sum<<" "<<ans;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
    string a, b, s;
    double n, m, k, r, pi = 3.1416, x = 2.0;
    cin>>r;
    printf("%.10f", x* pi * r);
	return 0;
}


Measured memory_bytes: 3808