akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

vector<int64_t> prime_factor(int64_t n){
    vector<int64_t> ret;
    for(int64_t i=2; i*i<=n; i++){
        if(n % i == 0){
            while(n % i == 0) n /= i;
            ret.push_back(i);
        }
    }
    if(n > 1) ret.push_back(n);
    return ret;
}

int main(){
    int64_t N;
    cin >> N;
    int mx = -1;
    for(int64_t i=1; i*i<=N; i++){
        if(N%i == 0){
            mx++;
            if(i < N/i) mx++;
        }
    }

    int mn = prime_factor(N).size();
    cout << mn << " " << mx << endl;
}



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

using namespace std;

int main(){
    int n, K;
    cin >> n >> K;
    vector<pair<long long,long long>> ps(n);
    for(int i=0;i<n;i++){
        cin >> ps[i].first >> ps[i].second;
    }
    sort(ps.begin(), ps.end());

    long long minx = 8000000000000000000;
    for(int i=0;i<n;i++)
        for(int j=i+1;j<n;j++){
            for(int k=0;k<n;k++){
                int kazu = 0;
                for(int l=k;l<n;l++){
                    if(ps[l].second <= max(ps[i].second, ps[j].second) && ps[l].second >= min(ps[i].second, ps[j].second))
                        kazu++;
                    if(kazu >= K){
                        auto ans = (ps[l].first - ps[k].first) * abs(ps[i].second - ps[j].second);
                        if(minx > ans){
                            minx = ans;
                        }
                    }

                }

            }

        }
    cout << minx << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;
const int INF = 1001001001;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> G[n];
    for(int i =0 ; i<m;i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> dist(n, INF);
    vector<int> pre(n, -1);
    queue<int> que;
    dist[0] = 0;
    que.push(0);
    while(!que.empty()){
        int now = que.front();
        que.pop();
        for(int i = 0; i < G[now].size(); i++){
            int next = G[now][i];
            if(dist[next] == INF){
                dist[next] = dist[now] + 1;
                que.push(next);
            }
            if(pre[next] == -1) pre[next] = now;
        }
    }
    cout << "Yes" << endl;
    for(int i = 1; i< n ;i++){
        cout << pre[i]+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 10560
use std::cmp::Ordering;
use std::io::*;
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let mut sc = Scanner::new(cin.lock());

    let a: i32 = sc.next();
    let b: i32 = sc.next();

    let rel = match a.cmp(&b) {
        Ordering::Less => "<",
        Ordering::Equal => "==",
        Ordering::Greater => ">",
    };

    println!("a {} b", rel);
}

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn next<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }
}



Measured memory_bytes: 5028
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define N 200005
#define mod 1000000007
typedef long long int ll;
typedef long int li;

int n,h[N],b[N];
ll dp[N],tree[4*N+4],ans;

void update(int i,int s,int e,int id,ll val) {
    if(s == e) { tree[i] = val;  dp[id] = val; }
    else {
        int mid = (s+e)/2;
        if(s <= id && id <= mid)  update(2*i,s,mid,id,val);
        else update(2*i+1,mid+1,e,id,val);
        tree[i] = max(tree[2*i],tree[2*i+1]);
    }
}

ll query(int i, int s, int e, int l, int r) {
    if(r < s or e < l) return 0;
    if(l <= s and e <= r) return tree[i];
    int mid = (s+e)/2;
    return max(query(2*i,s,mid,l,r),query(2*i+1,mid+1,e,l,r));
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    cin>>n;
    for(int i=0;i<n;i++) cin>>h[i];
    for(int i=0;i<n;i++) cin>>b[i];
    
    for(int i=0;i<n;i++) {
        ll max_s = query(1,1,n,1,h[i]-1);
        update(1,1,n,h[i],b[i]+max_s);
    }
    for(int i=1;i<=n;i++) ans = max(ans,dp[i]);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 9600
x,y=map(int,input().split())
ans=0
if x==1:
    ans+=300000
elif x==2:
    ans+=200000
elif x==3:
    ans+=100000
if y==1:
    ans+=300000
elif y==2:
    ans+=200000
elif y==3:
    ans+=100000

if x==1 and y==1:
    ans+=400000
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>pii;
#define sf(x) scanf("%d",&x)
#define sfl(x) scanf("%lld",&x)
#define lli long long int
#define ll64 int64_t
#define pb push_back
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define frr(i,a) for(int i=0;i<a;i++)
#define frl(i,a) for(lli i=0;i<a;i++)
int main()
{
    lli n,x,k;
    cin>>n>>x>>k;
    lli ans=(n/x)*k;
    if(n%x!=0)
    {
        ans+=k;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3616
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define REV(v) reverse(v.begin(),v.end())
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
#define dout(n) cout<<# n<<" = "<<n<<endl;
#define v1out(v) FOR(j,0,v.size()){cout<<v[j]; if(j!=(ll)v.size()-1)cout<<" ";else cout<<endl; }
#define v2out(v) FOR(i,0,v.size())v1out(v[i]);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ld p = 3.141592653;
    ld n;
    cin>>n;
    cout(6)<<p*n*2<<endl;
}

Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int>v(n+1,1e5);
	for(int i=0;i<n-1;i++){
		cin>>v[i+1];
	}
	
	vector<int>a(n);
	for(int i=0;i<n;i++){
		a[i]=min(v[i],v[i+1]);
	}
	
	int sum=0;
	for(int i=0;i<n;i++){
		sum+=a[i];
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD_CONST 1000000007
typedef long long int lli;

const int prime = 2019;
const int fact = 673;

int get_min_rest(int l, int r, int mod);

int main(){
    int l, r;
    cin >> l >> r;
    if(r - l + 1 >= fact){
        cout << 0 << endl;
        return 0;
    }else{
        cout << get_min_rest(l, r, prime) << endl;
        return 0;
    }
}

int get_min_rest(int l, int r, int mod){
    int res = mod;
    for(int i = l; i < r; ++i){
        for(int j = i + 1; j <= r; ++j){
            res = min(res, ((i % mod) * (j % mod) % mod));
        }
    }
    return res;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define FOR(i, start, end) for(ll i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

int main(void) {
    int N;
    cin >> N;
    vector<int> v(N);    
    vector<int> p(N);
    vector<int> q(N);

    REP (i, N) {
        v[i] = i + 1;
    }
    REP (i, N) {
        cin >> p[i];
    }
    REP (i, N) {
        cin >> q[i];
    }

    int a = 0, b = 0, cnt = 1;
    do {
        if (a == 0 && p == v) {
            a = cnt;
        }
        if (b == 0 && q == v) {
            b = cnt;
        }
        cnt++;
    } while (next_permutation(v.begin(), v.end()));

    cout << abs(a - b) << endl;

    return 0;
}

Measured memory_bytes: 256
N,X,D=map(int,input().split())

from collections import defaultdict

A=defaultdict(list)

A[0].append([0,0])

MIN=0
MAX=0

if D==0:
    w=1
else:
    w=D

for i in range(N):
    MIN+=X+D*i
    MAX+=X+D*(N-1-i)

    A[MIN%w].append(sorted([MIN,MAX]))

D=abs(D)
if D==0:
    if X==0:
        D=1
    else:
        D=X
ANS=0

for mod in A:
    B=A[mod]
    B.sort()
    C=[]

    for MIN,MAX in B:
        
        if C==[]:
            C.append((MIN,MAX))
        x,y=C[-1]

        if y>=MIN:
            C[-1]=(x,max(y,MAX))
        else:
            C.append((MIN,MAX))

    for MIN,MAX in C:
        ANS+=(MAX-MIN)//D+1
    
print(ANS)


Measured memory_bytes: 81968
from collections import deque

def slide_min(L:int, li:list):
	deq=deque()
	ret=[]
	for i,x in enumerate(li):
		while deq and deq[-1][1]>x:
			deq.pop()
		deq.append((i,x))
		if deq[0][0]+L==i:
			deq.popleft()
		ret.append(deq[0][1])
	return ret[L-1:]

def main():
	n,l,*a=map(int,open(0).read().split())
	print(*slide_min(l,a))

if __name__=="__main__":
	main()



Measured memory_bytes: 116720
#include <iostream>
#include <string>
#include <math.h>
#include<algorithm>
using namespace std;

int main(){
  int N;
  cin >> N;
  string ans;
  int i=0;
  if(N==0) cout << 0 << endl;
  while(N!=0){
    if(abs(N%2)==0){
     ans+='0'; 
    }else{
     ans+='1'; 
    }
    N-=abs(N%2);
    N/=-2;
    i++;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
return 0;}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
const int MAXN = 55;
int P[MAXN];
int N;

bool valid() {
    for (int i = 1; i <= N; ++i) {
        if (P[i] != i) {
            return false;
        }
    }
    return true;
}

bool solve() {
    if (valid()) {
        return true;
    }
    for (int i = 1; i <= N; ++i) {
        for (int j = i+1; j <= N; ++j) {
            std::swap(P[i], P[j]);
            if (valid()) {
                return true;
            }
            std::swap(P[i], P[j]);
        }
    }
    return false;
}

int main() {
    scanf("%d", &N);
    for (int i = 1; i <= N; ++i) {
        scanf("%d", &P[i]);
    }
    puts(solve() ? "YES" : "NO");
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int M1, D1, M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;

    if (D2 == 1){
        cout << '1' << endl;
    }
    else{
        cout << '0' << endl;
    }
    
    return 0;
}

Measured memory_bytes: 888
import math
n,k = map(int, input().split())
ans = 0
if n>=k:
    ans += 1-k/n
iterate = k if n>k else n
for i in range(1,iterate+1):
    temp = math.log2(k/i)
    temp = int(temp) if temp%1==0 else int(temp)+1
    ans += (1/n)*math.pow(0.5,temp)
print(format(ans, '.20f'))

Measured memory_bytes: 3060
# include "bits/stdc++.h"

using namespace std;

#define endl "\n"
typedef long long int ll;

inline void fastio(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
inline void setPrecision(int n){cout.precision(n);}

//DEBUG
#define dbg(x) cerr<<(#x)<<": "<<x<<endl
#define dbgV(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgS(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<it<<" "; cerr<<endl;
#define dbgM(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;
#define dbg2D(x) cerr<<(#x)<<": \n"; for(auto y: x) { for(auto it: y) cerr<<it<<" "; cerr<<endl; } cerr<<endl;
#define dbgA(x, n) cerr<<(#x)<<": "; for(int i=0;i<n;++i) cerr<<x[i]<<" "; cerr<<endl;
#define dbgVP(x) cerr<<(#x)<<": "; for(auto it: x) cerr<<"["<<it.f<<", "<<it.s<<"] "; cerr<<endl;

ll MOD = 1e9 + 7;

int n;
int a[21][21];

ll done[1<<21];

ll pairs(int state){
    int idx = __builtin_popcount(state);
    if(idx == n) return 1;
    if(done[state] != -1) return done[state];
    ll ans = 0;
    for(int i=0;i<n;++i)
        if(a[idx][i] && !(state&(1<<i)))
            ans = (ans + pairs(state|(1<<i)))%MOD;
    done[state] = ans;
    return ans;
}

int main(){
    fastio;
    cin>>n;
    for(int i=0;i<n;++i)
        for(int j=0;j<n;++j)
            cin>>a[i][j];
    memset(done, -1, sizeof(done));
    cout<<pairs(0);
    return 0;
}


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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    ll n;
    cin>>n;
    vector<int> adj[n+1];
    repA(i,2,n)
    {
        ll val;
        cin>>val;
        adj[val].pb(i);
    }
    repA(i,1,n)
    {
        ll sz=adj[i].size();
        cout<<sz<<'\n';
    }
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


Measured memory_bytes: 14552
S = input()

res = 'Yes'
dic = {}
for s in S:
    if s in dic:
        dic[s] += 1
        
    else:
        dic[s] = 1
        
for d in dic:
    if dic[d] == 2:
        pass
    else:
        res = 'No'
        
print(res)

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

int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    string s; cin >> s;
    if (s == "ABC") cout << "ARC\n";
    else cout << "ABC\n";

    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,vector<ll> > P;
typedef pair<P,ll>Q;
 
vector<ll>g[200010];
ll ans[200010];
ll n;
vector<ll>dp,a;
 
void dfs(int v,int p=-1){
    int index = lower_bound(dp.begin(),dp.end(),a[v])-dp.begin();
    ll old = dp[index];
    dp[index]=a[v];
    ans[v] = (lower_bound(dp.begin(),dp.end(),INF)-dp.begin());
    ans[v]--;
    for(int j=0;j<(ll)g[v].size();j++){
        int next = g[v][j];
        if(next == p)continue;
        dfs(next,v);
    }
    dp[index] = old;
    return;
}
 
int main(void){
  cin>>n;
  dp.assign(n+5,(ll)INF);
  dp[0]=-(ll)INF;
  a.resize(n);
  for(ll i=0;i<n;i++)cin>>a[i];
  for(ll i=0;i<n-1;i++){
    ll u,v;
    cin>>u>>v;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dp[0]=-(ll)INF;
  dfs(0);
  for(int i=0;i<n;i++)cout<<ans[i]<<endl;
  return 0;
}

Measured memory_bytes: 30288
import numpy as np


def main(n, a, x):
    SUM_MAX = max(a, max(x)) * n + 1
    dp = np.zeros(shape=(n + 1, n + 1, SUM_MAX), dtype=int)

    dp[0][0][0] = 1
    for j in range(1, n + 1):
        for k in range(j + 1):
            dp[j][k][0:x[j - 1]] = dp[j - 1][k][0:x[j - 1]]
            if k >= 1:
                dp[j][k][x[j - 1]:] = dp[j - 1][k][x[j - 1]:] + dp[j - 1][k - 1][:SUM_MAX - x[j - 1]]

    patterns = 0
    for k in range(1, n + 1):
        ka = k * a
        patterns += dp[n][k][ka]
    return patterns


if __name__ == '__main__':
    N, A = map(int, input().split())
    X = list(map(int, input().split()))
    print(main(N, A, X))


Measured memory_bytes: 62112
#include <map>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;
#define INF 0x3f3f3f3f



int main()
{
	long long n, m, sum;
	std::ios::sync_with_stdio(false);
	while (cin >> n >> m)
	{
		sum = 0;
		if (2 * n <= m)
		{
			sum += n;
			m -= 2 * n;
			sum += m / 4;
		}
		else if (2 * n > m)
			sum = m / 2;
		cout << sum << endl;
	}

	return 0;
}


Measured memory_bytes: 256
from sys import stdin, stdout

int_in = lambda: int(stdin.readline())
arr_in = lambda: [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for _ in range(rows)]
str_in = lambda: stdin.readline().strip()
out = lambda o: stdout.write("{}\n".format(o))
arr_out = lambda o: out(" ".join(map(str, o)))
bool_out = lambda o: out("YES" if o else "NO")
tests = lambda: range(1, int_in() + 1)
case_out = lambda i, o: out("Case #{}: {}".format(i, o))


# https://atcoder.jp/contests/abc171/tasks/abc171_e
def solve(n, a):
    xor = a[0]
    for item in a[1:]:
        xor ^= item

    return map(lambda x: xor ^ x, a)


if __name__ == "__main__":
    n = int_in()
    a = arr_in()
    arr_out(solve(n, a))

Measured memory_bytes: 116500
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007

using namespace std;

void solve()
{
    int r;
    cin >> r;
    long double circumference;

    circumference = 2 * (M_PI)*r;
    cout << circumference << "";
}

int main()
{
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);

    //int t;
    //cin >> t;

    // while (t--)
    solve();

    return 0;
}

Measured memory_bytes: 3808
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[]) {
  int n,k;
  cin>>n>>k;
  char s[n];
  for(int i=0;i<n;i++){
    cin>>s[i];
  }
  s[k-1]=s[k-1]+0x20;
  for(int i=0;i<n;i++){
    cout<<s[i];
  }
  cout<<endl;
  return 0;
}


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

int main(){
  cout << fixed << setprecision(5);
  int N; cin >> N;
  vector<double> v(N);
  vector<double> v1(N);
  for (int i=0;i<N;i++){
    cin >> v.at(i);
  }
  double sum=0;
  for (int i=0;i<N;i++){
    v1.at(i)=1 / v.at(i);
    sum+=v1.at(i);
  }
  cout << 1/sum << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

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


Measured memory_bytes: 128
// 物极必反

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 5e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 2e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 20, BL = 400;
const double EPS = 1e-9;
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug(){
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

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

    long long n; cin >> n;

    vector<long long> a(n);
    long long d = 1e18 * 1ll, b = 1, g = 1;

    for(long long i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] == 0) g = 0;
    }

    if(!g) return cout << 0, 0;

    for(long long i = 0; i < n; i++){
        if(a[i] <= d / b){
            b *= a[i];
        }
        else {
            return cout << "-1", 0;
        }
    }

    cout << b;

	return 0;
}


Measured memory_bytes: 3988
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cctype>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
#define  rep(i,n) for(int i=0;i<(n);i++)
#define  REP(i,a,n) for(int i=a;i<(n);i++)
#define  rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define  VI	vector<int>
#define	 VS vector<string>
#define  all(a) (a).begin(),(a).end()
#define  debug(x) cout<<#x<<": "<<x<<endl

using namespace std;
typedef long long int ll;
typedef string::const_iterator State;
typedef pair<int,int> P;
class ParseError {};
const ll INF=1LL<<50;
char fi[101][101];
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
double EPS = 1e-14;
const int MAX_V=100;
const int MAX_N=100;
char o[3]={'+','-','*'};
#define md 1000003



int bow[353][353]={0};
double add(double a,double b){
	if(abs(a+b)<EPS*(abs(a)+abs(b)))
	return 0;
	return a+b;
}

/*struct P{
	double x,y;
	P(){}
		P(double x,double y):x(x),y(y){
		}
		P operator + (P p){
			return P(add(x,p.x),add(y,p.y));
		}
		P operator - (P p){
			return P(add(x,-p.x),add(y,-p.y));
		}
		P operator *(double d){
			return P(x*d,y*d);
		}
		double dot(P p){
			return add(x*p.x,y*p.y);
		}
		double det(P p){
			return add(x*p.y,-y*p.x);
		}
};

bool cmp_x(const P& p,const P& q){
	if(p.x!=q.x) return p.x<q.x;
	return p.y<q.y;
}

vector<P> convex_hull(P* ps, int n){
	sort(ps,ps+n,cmp_x);
	int k=0;
	vector<P> 	qs(n*2);
	
	rep(i,n){
		while(k>1&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)
			k--;
		qs[k++]=ps[i];
	}
	for(int i=n-2,t=k;i>=0;i--){
		while(k>t&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0)
		k--;
		qs[k++]=ps[i];
	}
	qs.resize(k-1);
	return qs;
}

int n,m;
vector<double> p;
P ps[101];
*/
//char c[520][520];
long long mod=1000000007;
long long pow(ll i,ll j){
	ll tmp=1;
	while(j){
		if(j%2) tmp=tmp*i%mod;
		i=i*i%mod;
		j/=2;
	}
	return tmp;
}

int expression(State&);
int term(State&);
int factor(State&);
int number(State&);
int expression(State &begin){
	int ret = term(begin);
	
	for(;;){
		if(*begin == '+'){
			begin++;
			ret += term(begin);
		}
		else if(*begin == '-'){
			begin++;
			ret -= term(begin);
		}
		else
			break;
	}
	return ret;
}

int term(State &begin){
	int ret = factor(begin);
	
	for(;;){
		if(*begin=='*'){
			begin++;
			ret *= factor(begin);
		}
		else if(*begin=='/'){
			begin++;
			ret /= factor(begin);
		}
		else
			break;
	}
	return ret;
}

int factor(State &begin){
	int ret;
	if(*begin == '('){
		begin++;
		ret = expression(begin);
		begin++;
	}
	else
	ret = number(begin);
	
	return ret;

}

int number(State &begin){
	int ret =0;
	
	while(isdigit(*begin)){
		ret*=10;
		ret+=*begin - '0';
		begin++;
	}
	return ret;
}



int main(void){
	
	int d,e;
	
	while(cin>>d>>e,d!=0||e!=0){
		
		double ans=1e9;
		for(int i=0;i<=100;i++){
			if(d-i>=0)
			ans=min(ans,abs(sqrt(pow(d-i,2)+pow(i,2))-e));
		}
		printf("%.10f\n",ans);
	}
}

Measured memory_bytes: 3132
#include<stdio.h>
#include<string.h>

int main() {
   int i = 0;
   char S[100];

   scanf("%s", S);

   for(int i = 0; i < strlen(S); i++) {
      S[i] = 'x';
   }

   printf("%s", S);
   return 0;
}



Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll s,t,d,w[100000],c=0,ans=1e11;
  cin>>s>>t>>d;
  for(ll i=0;i<d;i++)cin>>w[i],c-=w[i];
  s-=t;
  for(ll i=0;i<d;i++){
    s+=w[i];
    if(s<=0)ans=min(ans,i+1);
    else if(c>0)ans=min(ans,i+(s+c-1)/c*d+1);
  }
  if(ans==1e11)ans=-1;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3868
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

int main(){
	int x,y,f;
	string str;
	const char *table[] = {"abcde","fghij","klmno","pqrst","uvwxy","z.?! "};
	while(cin >> str){
		string t,tmp;
		f = 1;
		if(str.size() % 2 == 0){
			for(int i = 0;i < str.size();i += 2){
				tmp = str[i];
				x = atoi(tmp.c_str()) - 1;
				tmp = str[i+1];
				y = atoi(tmp.c_str()) - 1;
				if(x > 5 || y > 4 || x < 0 || y < 0){
					cout << "NA" << endl;
					f = 0;
					break;
				}
				if(f) t += table[x][y];
			}
			if(f) cout << t << endl;
		}
		else{
			cout << "NA" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1196
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(Type, ...)  Type __VA_ARGS__; input(__VA_ARGS__)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
inline i64  sigma(i64 n)            { return (n * (n + 1) >> 1); }
inline i64  updiv(i64 a, i64 b)     { return (a + b - 1) / b; }
inline i64  sqr(i64 n)              { return n * n; }
inline string to_string(char c)     { return string(1, c); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}
template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void input() {}
template <class Head, class... Tail>
inline void input(Head &head, Tail&... tail) { cin >> head; input(tail...); }

inline void print() { cout << "\n"; }
template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}

template <typename Func>
struct FixPoint : Func {
    inline constexpr FixPoint(Func &&f) noexcept : Func(forward<Func>(f)) {}

    template <typename... Args>
    inline decltype(auto) operator()(Args &&... args) const {
        return Func::operator()(*this, forward<Args>(args)...);
    }
};

template< typename Func >
inline decltype(auto) makeFixPoint(Func &&f) {
    return FixPoint< Func >{forward< Func >(f)};
}
// }}} End Header

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

    var(int, N);
    vector<pii> ps(N);

    rep(i, N) {
        var(int, x, y);
        ps[i] = pii(x, y);
    }

    sort(all(ps));


    const auto dist = [](pii a, pii b) -> double {
        return sqrt(sqr(a.first - b.first) + sqr(a.second - b.second));
    };

    double sum = 0.0;
    int cnt = 0;
    do {
        rep(i, N-1) {
            sum += dist(ps[i], ps[i+1]);
        }
        ++cnt;
    } while (next_permutation(all(ps)));

    cout << fixed << setprecision(9);
    print(sum / cnt);

    return 0;
}


Measured memory_bytes: 256
#coding:shift_jis
container = list(input().split(' '))
for i in range(len(container)):
    container[i] = int(container[i])
a = container[2] - (container[0] - container[1]) >= 0
b = container[2] - (container[0] - container[1])
if a:
    print(b)

else:
    print(0)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 10000000000000007LL
#define ll long long
using namespace std;
int mi[3010];
signed main(){
	int x,y,z,k;
	cin>>x>>y>>z>>k;
	vector<int> a,b,c;
	for(int i=0;i<x;i++){
		int t;
		cin>>t;
		a.pb(t);
	}
	for(int i=0;i<y;i++){
		int t;
		cin>>t;
		b.pb(t);
	}
	for(int i=0;i<z;i++){
		int t;
		cin>>t;
		c.pb(t);
	}
	vector<int> d;
	for(int i=0;i<x;i++){
		for(int j=0;j<y;j++){
			d.pb(a[i]+b[j]);
		}
	}
	sort( d.begin(), d.end() );
	sort( c.begin(), c.end() );
	reverse( d.begin(), d.end() );
	reverse( c.begin(), c.end() );
	priority_queue< pair<int,int> > que;
	for(int i=0;i<c.size();i++){
		que.push( mp( c[i] + d[ mi[i] ], i ) );
	}
	vector<int> ans;
	for(int i=1;i<=k;i++){
		pair<int,int> cur = que.top(); que.pop();
		ans.pb(cur.first);
		if( mi[ cur.second ] < x*y-1 ){
			mi[ cur.second ] ++;
			que.push( mp( c[ cur.second ] + d[ mi[cur.second] ], cur.second ) );
		}
	}
	for(int i=1;i<=k;i++){
		cout<<ans[i-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 10616
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main() {
	unsigned short *A, *B;

	int C[VMAX + 1];
	int n, i, j;
	scanf("%d", &n);

	A = (unsigned short *)malloc(sizeof(short)*n + 1);
	B = (unsigned short *)malloc(sizeof(short)*n + 1);

	for (i = 0; i <= VMAX; i++)C[i] = 0;

	for (i = 0; i < n; i++) {
		scanf("%hu", &A[i + 1]);
		C[A[i + 1]]++;
	}

	for (i = 1; i <= VMAX; i++)C[i] = C[i] + C[i - 1];

	for (j = 1; j <= n; j++) {
		B[C[A[j]]] = A[j];
		C[A[j]]--;
	}

	for (i = 1; i <= n; i++) {
		if (i > 1)printf(" ");
		printf("%d", B[i]);
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 10580
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int N, K;
    cin>>N>>K;
    vector<int> hs(N);
    rep(i, N) cin>>hs[i];

    vector<int> dp(N);
    int j;
    rep(i, N - 1) {
        dp[i + 1] = dp[i] + abs(hs[i + 1] - hs[i]);
        rep(j, K) {
            if (i - j < 0) continue;
            if (dp[i + 1] > dp[i - j] + abs(hs[i + 1] - hs[i - j])) {
                dp[i + 1] = dp[i - j] + abs(hs[i + 1] - hs[i - j]);
            }
        }
    }
    cout<<dp[N - 1]<<endl;
}

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int n, m, t;
    cin>> n>> m;

    int f[m+1]= {}, k[n];

    for(int i=0; i<n; i++)
    {
        cin>> k[i];
        while (k[i]--)
        {
            cin>> t;
            f[t]++;
        }
    }

    sort (f, f+m+1, greater <int> ());

    int i=0;
    while ( f[i] ==n)
        i++;

    cout << i;
    nl;


    return 0;
}




Measured memory_bytes: 3652
N = int(input())
a = list(map(int, input().split()))
s = []
k = 0
l = 0

for i in range(N):
	if a[i] <= 399:
		s.append('a')
	elif a[i] <= 799:
		s.append('b')
	elif a[i] <= 1199:
		s.append('c')
	elif a[i] <= 1599:
		s.append('d')
	elif a[i] <= 1999:
		s.append('e')
	elif a[i] <= 2399:
		s.append('f')
	elif a[i] <= 2799:
		s.append('g')
	elif a[i] <= 3199:
		s.append('h')
	else:
		k += 1

if s.count("a") != 0:
	l += 1

if s.count("b") != 0:
	l += 1
	
if s.count("c") != 0:
	l += 1

if s.count("d") != 0:
	l += 1

if s.count("e") != 0:
	l += 1
	
if s.count("f") != 0:
	l += 1

if s.count("g") != 0:
	l += 1

if s.count("h") != 0:
	l += 1
	
m = k + l

if l == 0:
	print(1,m)
else:
	print(l,m)

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

mt19937_64 llrand(random_device{}());

#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define cl(x, v) memset((x), (v), sizeof(x))
#define db(x) cerr << #x << " == " << x << endl
#define dbs(x) cerr << x << endl
#define _ << ", " <<
#define gcd(x, y) __gcd((x), (y))

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> plll;
typedef vector<int> vi;
typedef vector<vi> vii;

const ld EPS = 1e-9, PI = acos(-1.);
const ll LINF = 0x3f3f3f3f3f3f3f3f, LMOD = 1011112131415161719ll;
const int INF = 0x3f3f3f3f, MOD = 1e9+7;
const int N = 1e2+5;
const int K = 1e5+5;

int n, c, w[N], v[N], dp[K];

int main () {
    scanf("%d%d", &n, &c);
    for (int i = 1; i <= n; i++) scanf("%d%d", &w[i], &v[i]);

    cl(dp, 63);
    dp[0] = 0;

    for (int i = 1; i <= n; i++) {
        for (int u = K-1; u >= v[i]; u--) {
            dp[u] = min(dp[u], dp[u-v[i]] + w[i]);
        }
    }

    int ans = 0;
    for (int u = 0; u < K; u++) if (dp[u] <= c) ans = max(ans, u);
    printf("%d\n", ans);

    return 0;
}

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

int findSumOfDigits(int N) {
  int sum = 0;
  while (N > 0) {
    sum += N % 10;
    N /= 10;
  }
  return sum;
}

int main() {
  int N;
  cin >> N;
  int sum = findSumOfDigits(N);
  if (N % sum == 0)
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int main(){
    vector< pair<double,double> > v;
    while(true){
	string s,s1,s2;
	cin >> s;
	if(cin.eof()) break;
	int x = -1;
	REP(i,s.size()){
	    if(s[i] == ','){
		s1 = s.substr(x+1,i-x-1);
		s2 = s.substr(i+1,s.size()-i-1);
		break;
	    }
	}
	v.PB( pair<double,double>(stod(s1),stod(s2)) );
    }
    double ans = 0.0;
    REP(i,v.size()-2){
	double a,b,c,z;
	double ax,ay,bx,by,cx,cy;
	ax = v[0].first - v[i+1].first;
	ay = v[0].second - v[i+1].second;
	bx = v[i+1].first - v[i+2].first;
	by = v[i+1].second - v[i+2].second;
	cx = v[i+2].first - v[0].first;
	cy = v[i+2].second - v[0].second;
	a = sqrt(ax*ax + ay*ay);
	b = sqrt(bx*bx + by*by);
	c = sqrt(cx*cx + cy*cy);
	z = (a+b+c)/2.0;
	ans += sqrt(z*(z-a)*(z-b)*(z-c));
    }
    printf("%.6lf\n",ans);
    return 0;
}

Measured memory_bytes: 3188
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int a[101][101], b[101][101];
	long long c[101][101], s;
	int i, j, k;
	int n, m, l;

	scanf("%d%d%d", &n, &m, &l);
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
	}
	for (i = 0; i < m; i++) {
		for (j = 0; j < l; j++) scanf("%d", &b[i][j]);
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < l; j++) {
			s = 0;
			for (k = 0; k < m; k++) {
				s += a[i][k] * b[k][j];
			}
			c[i][j] = s;
		}
	}

	for (i = 0; i < n; i++) {
		printf("%lld", c[i][0]);
		for (j = 1; j < l; j++) printf(" %lld", c[i][j]);
		putchar('\n');
	}
	return 0;
}



Measured memory_bytes: 2104
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

typedef pair<int,int> edge;

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	int result[100010];
	result[1] = 1;
    int num_ball[100010];
    for (int i = 1; i <= n;i++) {
        num_ball[i] = 1;
    }
	vector<edge> edge_list(m+1);
	for(int i = 1; i <= m; i++){
		int x,y;
		scanf("%d%d", &x, &y);
		edge e(x,y);
		edge_list[i] = e;
	}
	for(int i = 1; i <= m; i++){
	    int src = edge_list[i].first;
	    int dst = edge_list[i].second;
        num_ball[src]--;
        num_ball[dst]++;
        if(result[src]) result[dst] = 1;
        if(num_ball[src] == 0) result[src] = 0;
	}
    int sum = 0;
    for (int i=1;i<=n;i++){
        if(result[i]) sum++;
    }
    printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 1792
n = int(input())
k = int(input())
x = list(map(int,input().split()))
#ボールの座標 x[i],i
#Aの座標 x,i
#Bの座標 k,i
ans = 0
for i in range(n):
  tmpA = abs((x[i]))
  tmpB = abs((x[i] - k))
  tmpAnswer = min(tmpA,tmpB)*2
  ans += tmpAnswer
print(ans)

Measured memory_bytes: 3064
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N;string s; cin >> N >> s;
	int a = 0;
	rep(i,N-1) if(s[i] != s[i+1]) a++;
	cout << a+1 << endl;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long X, long long Y, long long Z, long long K, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C){
    VLL memo;
    REP(i, X) {
        REP(j, Y) {
            memo.PB(A[i] + B[j]);
        }
    }

    sort(ALL(memo), greater<LL>());
    VLL memo2;
    REP(i, min((int)K, (int)memo.size())) {
        REP(j, Z) {
            memo2.PB(memo[i] + C[j]);
        }
    }

    sort(ALL(memo2), greater<LL>());
    REP(i, K) {
        cout << memo2[i] << endl;
    }
}

int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    long long Z;
    scanf("%lld",&Z);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(X);
    for(int i = 0 ; i < X ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(Y);
    for(int i = 0 ; i < Y ; i++){
        scanf("%lld",&B[i]);
    }
    std::vector<long long> C(Z);
    for(int i = 0 ; i < Z ; i++){
        scanf("%lld",&C[i]);
    }
    solve(X, Y, Z, K, std::move(A), std::move(B), std::move(C));
    return 0;
}


Measured memory_bytes: 43240
#include<stdio.h>
#include<string.h>

int main(void){
    char str[13];
    char *p;
    int i;
    scanf("%12s*c",str);
    p=str;
    for(i=0;i<4;i++) printf("%c",str[i]);
    printf(" ");
    for(;i<12;i++) printf("%c",str[i]);
    printf("\n");
    return 0;
}


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

using namespace std;
typedef long long int ll;
int main() {
    
    ll n, i, j, dap[10001]={}, k, x, y, z;
    cin>>n;
    for(x=1;x<=100;x++)
    {
        for(y=1;y<=100;y++)
        {
            for(z=1;z<=100;z++)
            {
                if((x*x+y*y+z*z+x*y+y*z+z*x)<=10000)
                {
                    dap[(x*x+y*y+z*z+x*y+y*z+z*x)]++;
                }
            }
        }
    }
    
    
    for(i=1;i<=n;i++)
    {
        printf("%lld\n", dap[i]);
    }
    
    
    return 0;
}

Measured memory_bytes: 3736
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int x, a;

int main(){
  cin >> x >> a;

  if(x < a) cout << 0 << endl;
  else cout << 10 << endl;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int c2i (char c) {
    return c - '0';
}
int main () {
    string s;
    cin >> s;
    int month = c2i(s[5]) * 10 + c2i(s[6]);
    if(month <= 4){
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vec> mat;
int main(){
    int n,k,r,s,p;
    string t;
    cin>>n>>k>>r>>s>>p>>t;
    ll ans=0;
    rep(i,n){
        if(t[i]=='r') ans+=p;
        if(t[i]=='s') ans+=r;
        if(t[i]=='p') ans+=s;
    }
    ll R=0,S=0,P=0,a,b,c,A[3]={0};
    rep(i,k){
        a=0,b=0;
        for(int j=i;j<n;j+=k){
            if(t[j]=='s'){
                if(b==0) a++;
                else A[b]+=a/2,a=1,b=0;
            }
            if(t[j]=='p'){
                if(b==1) a++;
                else A[b]+=a/2,a=1,b=1;
            }
            if(t[j]=='r'){
                if(b==2) a++;
                else A[b]+=a/2,a=1,b=2;
            }
        }
        A[b]+=a/2;
    }
    cout<<ans-A[0]*r-A[1]*s-A[2]*p;
    //cout<<endl<<R<<" "<<S<<" "<<P;
}

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

Measured memory_bytes: 640
#include "bits/stdc++.h"
//#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair <ll, ll > pll;

bool comp(const pll& a, const pll& b) {
	return a.first < b.first;
}
std::vector<int> enum_div(int n)//nの約数を列挙
{
	std::vector<int> ret;
	for (int i = 1; i * i <= n; ++i)
	{
		if (n % i == 0)
		{
			ret.push_back(i);
			if (i != 1 && i * i != n)
			{
				ret.push_back(n / i);
			}
		}
	}
	return ret;
}


template<int N>
int factorial() {
	return factorial<N - 1>() * N;
}
ll nCr(ll n, ll r);//コンビネーション
int permutation(int n, int r);//nPk パーミュテーション
int factorial(int k);//階乗

template<>  /// 特殊化：factorial<N=”1”>だったら，値を返す
int factorial<1>() {
	return 1;
}
int main()
{
	//priority_queue<int> q;
	string s = {};
	ll h = 0, w = 0, k = 0, a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, ans = 0;
	ll x[100005] = {};
	ll y[100005] = {};
	string str[200005] = {};
	//char* ch[200005] = {};
	char* ch1 = {};
	//ll z[302][302] = {};
	//std::vector<string> data;
	//sort(data.begin(), data.end());//昇順ソート

	cin >> a;
	for (int i = 0; i < a; i++)
	{
		cin >> x[i];
	}
	ans = 9999999999999;
	for (int i = 1; i <= 100; i++)
	{
		b = 0;
		for (int k = 0; k < a; k++)
		{
			b += (x[k] - i) * (x[k] - i);
		}
		ans = min(ans, b);
	}


	cout << ans << endl;

	//return 0;

	/*cout << c << endl;
	cout << b << endl;*/
	//cout << fixed << setprecision(10) <<tmp << endl;
	//cout<<factorial<10><<endl;
	return 0;
}
//2つの組の数をソートしたりするやつ
//vector<pair<ll, ll> > hoges(a);
//for (int i = 1; i <= a; i++)
//{
//	cin >> h;
//	hoges[i - 1] = make_pair(h, i);
//}
//sort(hoges.begin(), hoges.end(), comp);
//for (int i = 0; i < a; i++)
//{
//	cout << hoges[i].second << endl;
//}

int permutation(int n, int r) {
	int n_sum, r_sum;
	int i;
	r = n - r;
	n_sum = factorial(n);
	r_sum = factorial(r);
	return n_sum / r_sum;
}

ll nCr(ll n, ll r) {
	ll ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int factorial(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 22;

inline int add(int x,int y)
{
    return (x + y)%MOD;
}

inline int sub(int x,int y)
{
    return (x+MOD-y)%MOD;
}

inline int mul(int x,int y)
{
    return (ll)x*y%MOD;
}

int a[MAX_N][MAX_N];
int dp[MAX_N][(1 << MAX_N)];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n){
        rep(j,n){
            cin >> a[i][j];
        }
    }
    dp[0][(1 << n)-1] = 1;
    rep(i,n){
        rep(j,(1 << n)){
            if(dp[i][j] == 0) continue;
            rep(k,n){
                if(j >> k & 1 & a[i][k]){
                    dp[i+1][j^(1 << k)] = add(dp[i+1][j^(1 << k)],dp[i][j]);
                }
            }
        }
    }
    cout << dp[n][0] << "\n";
    return 0;
}

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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    bool ret = true;
    int n, len;
    cin >> n;

    vector<int> a(n);

    REP(i, n)
    {
        cin >> a[i];
    }

    sort(a.begin(), a.end());
    len = a.size();
    a.erase(unique(a.begin(), a.end()), a.end());

    cout << (len == a.size() ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 1024