akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define m0(x) memset(x, 0, sizeof(x))
#define MAX_N 55
using namespace std;
int N, M;
vector<bool> seen;
bool visited[55][55];

void dfs(const vector<vector<bool> > &v, int i) {
  seen[i] = true;
  for (int j = 0; j < N; j++) {
    if (!v[i][j]) continue;
    if (seen[j]) continue;
    dfs(v, j);
  }
}

int main() {
  cin >> N >> M;
  vector<vector<bool> > edge(N + 1, vector<bool>(N + 1, 0));
  REP(i, M) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    edge[a][b] = true;
    edge[b][a] = true;
  }

  int ans = 0;
  REP(i, N) {
    REP(j, N) {
      seen.assign(N, false);
      if (!edge[i][j]) continue;
      if (visited[i][j] || visited[j][i]) continue;
      edge[i][j] = edge[j][i] = false;
      dfs(edge, i);
      edge[i][j] = edge[j][i] = true;

      int cnt = 0;
      REP(k, N) if (seen[k]) cnt++;
      if (cnt != N) ans += 1;

      visited[i][j] = visited[j][i] = true;
    }
  }

  cout << ans << endl;
}

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

map<int, int>mp;
vector<P>v;
int main() {
	int p, s;
	while (scanf("%d,%d", &p, &s), p) {
		v.push_back(P(s, p));
	}
	sort(v.begin(), v.end(), greater<>());
	int j = 1; mp[v[0].second] = 1;
	for (int i = 1; i < v.size(); i++) {
		if (v[i].first == v[i - 1].first)mp[v[i].second] = j;
		else mp[v[i].second] = ++j;
	}
	int q; while (cin >> q)cout << mp[q] << endl;
	return 0;
}

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

int main(){
  std::string N;
  std::cin >> N;
  char l = N.back();
  if(l == '3'){
    std::cout << "bon" << std::endl;
  }
  else if(l == '0' or l == '1' or l == '6' or l == '8'){
    std::cout << "pon" << std::endl;
  }
  else{
    std::cout << "hon" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		sc.close();
		int sum=0;
		if(n<10) {//1~10
			sum=n;
		}else if(n<100){//10~100
			sum=9;
		}else if(n<1000){//100~1000
			sum=n-90;
		}else if(n<10000) {//1000~10000
			sum=909;
		}else if(n<100000){//10000~100000
			sum=n-9090;
		}else {
			sum=90909;
		}
		System.out.println(sum);
	}

}


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

void solve(){
    int a[6];
    for (int  i = 1; i < 6; i++)
    {
        /* code */
        cin>>a[i];
        if(a[i]==0)
        {    cout<< i;
            return;}
    }
    

}

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

}

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;
int  a[N];
int dp[N];

void solve(int testCase){

    scanf("%d" , &n);

    for(int i = 0 ; i < n ; i ++){
            scanf("%d" , &a[i]);
            dp[i] = 2e9;
    }

    dp[0] = 0;
    for(int i = 0 ; i < n ; i ++){
            if(i > 0)
                dp[i] = min(dp[i] , dp[i-1] + abs(a[i] - a[i-1]));
            if(i > 1)
                dp[i] = min(dp[i] , dp[i-2] + abs(a[i] - a[i-2]));
    }

    printf("%d\n" , dp[n-1]);

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


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

int seiyaku_check(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	
	int a,b,c,d,e;
	cin >> a >> b >>c;
	
	seiyaku_check(a,1,20);
	seiyaku_check(b,1,20);
	seiyaku_check(c,1,20);
	if(b>a)exit(1);
	
	
	e = a-b;
	d = c-e;
	if(d<0)d=0;
	cout << d << endl;

	
	
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, m, sv, tv;
    cin >> n >> m >> sv >> tv;
    sv--;  tv--;
    
    vvpll G1(n);  // G1 : 円のグラフ
    vvpll G2(n);  // G2 : スヌークのグラフ
    rep(i, m) {
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        u--;  v--;
        G1[u].pb(make_pair(v, a));
        G1[v].pb(make_pair(u, a));
        G2[u].pb(make_pair(v, b));
        G2[v].pb(make_pair(u, b));
    }
    
    // ダイクストラ法。計算量はO((V+E)*log(V))
    vl dist1(n, INF);  // dist1[v] : 頂点svから頂点vへの最短距離
    priority_queue<P, vector<P>, greater<P>> prQ1;
    dist1[sv] = 0;
    prQ1.push(make_pair(sv, 0));  // (頂点番号, 頂点svからの最短距離)
    while(!prQ1.empty()) {
        auto p1 = prQ1.top();
        prQ1.pop();
        ll v = p1.first;
        if(dist1[v] < p1.second) {
            continue;
        }
        for(auto p2 : G1[v]) {
            ll u = p2.first;
            ll cost = p2.second;
            if(dist1[u] > dist1[v] + cost) {
                dist1[u] = dist1[v] + cost;
                prQ1.push(make_pair(u, dist1[u]));
            }
        }
    }

    // ダイクストラ法。計算量はO((V+E)*log(V))
    vl dist2(n, INF);  // dist2[v] : 頂点tvから頂点vへの最短距離
    priority_queue<P, vector<P>, greater<P>> prQ2;
    dist2[tv] = 0;
    prQ2.push(make_pair(tv, 0));  // (頂点番号, 頂点tvからの最短距離)
    while(!prQ2.empty()) {
        auto p1 = prQ2.top();
        prQ2.pop();
        ll v = p1.first;
        if(dist2[v] < p1.second) {
            continue;
        }
        for(auto p2 : G2[v]) {
            ll u = p2.first;
            ll cost = p2.second;
            if(dist2[u] > dist2[v] + cost) {
                dist2[u] = dist2[v] + cost;
                prQ2.push(make_pair(u, dist2[u]));
            }
        }
    }

    vl cost(n);
    rep(v, n) {
        cost[v] = dist1[v] + dist2[v];
    }
    for(ll v = n-1; v >= 1; v--) {
        chmin(cost[v-1], cost[v]);
    }

    const ll MONEY = 1e15;
    rep(i, n) {
        out(MONEY - cost[i]);
    }
    
    re0;
}

Measured memory_bytes: 25456
from math import ceil
n,a,b=map(int,input().split())
h=[int(input()) for i in range(n)]
def enough(x):
  cnt=0
  for i in range(n):
    if h[i]-x*b<=0:
      continue
    cnt+=ceil((h[i]-x*b)/(a-b))
  if cnt<=x:
    return True
  else:
    return False
l=0
r=10**9
while r-l>0:
  mid=(r+l)//2
  if enough(mid):
    r=mid
  else:
    l=mid+1
print(r)

Measured memory_bytes: 7088
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;

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

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

signed main(){
	cin>>N;
	int ans=0;
	for(int i=1;i<=N;i++){
		for(int j=1;j<=N;j++){
			for(int k=1;k<=N;k++){
				int G=gcd(i,j);
				G=gcd(G,k);
				ans+=G;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3636
N = int(input())

res = [0] * (N + 1)
for i in range(1, int(N ** (1 / 2)) + 1):
    for j in range(1, int(N ** (1 / 2)) + 1):
        for k in range(1, int(N ** (1 / 2)) + 1):
            n = i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i
            if n > N:
                break
            else:
                res[n] += 1

for r in res[1:]:
    print(r)


Measured memory_bytes: 9396
#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(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

using graph = vector<vector<int>>;

int main() {
        int n, x, y;
        cin >> n >> x >> y;
        --x; --y;

        graph g(n);
        
        g[x].push_back(y);
        g[y].push_back(x);

        REP(i, n-1) {
                g[i].push_back(i + 1);
                g[i + 1].push_back(i);
        }

        auto d = make_v(n, n, -1);

        REP(i, n) {
                vector<int> vis(n, false);
                queue<int> q;

                d[i][i] = 0;
                vis[i] = true;
                q.push(i);

                while (!q.empty()) {
                        int u = q.front();
                        q.pop();
                        for (int v : g[u]) {
                                if (!vis[v]) {
                                        d[i][v] = d[i][u] + 1;
                                        vis[v] = true;
                                        q.push(v);
                                }
                        }
                }
        }

        vector<int> ans(n, 0);
        REP(i, n)REP(j, n) {
                if (i == j) continue;
                ans[d[i][j]]++;
        }

        FOR(i, 1, n) cout << ans[i] / 2 << endl;

        return 0;
}


Measured memory_bytes: 18048
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
//#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i <= n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i <= n; i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

vector<pair<int, char> > v;
vector<int> ans;

void f(string s, int n, int m)
{
    irep(i, m) {
        if(s[v[i].first-1] != v[i].second) {
            return ;
        }
    }
    if(s.size() == n) {
        ans.push_back(stoi(s));
    }
}

int main(void)
{
    int n, m;
    cin >> n >> m;
    
    irep(i, m) {
        char s;
        int t;
        cin >> t >> s;
        v.push_back(make_pair(t, s));
    }
    
    irep(i, 1000) {
        f(to_string(i), n, m);
    }

    sort(ans.begin(), ans.end()); 
    if(ans.empty() == true) {
        cout << -1 << endl;
    } else {
        cout << ans[0] << endl;
    }

    return 0;
}
/** atcoder **/


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

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  int a, b ;
  cin >> a >> b ;
  
  cout <<(a+b)%24 <<endl ;
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N;
	map<long long int, long long int>mp;
	long long int sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> K;
		sum += K;
		mp[K]++;
	}
	cin >> M;
	while (M--) {
		cin >> L >> R;
		sum -= mp[L] * L;
		mp[R] += mp[L];
		sum += mp[L] * R;
		mp[L] = 0;
		cout << sum << endl;
	}
}

Measured memory_bytes: 9524
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main() {
    int N;
    string S;
    cin >> N;
    cin >> S;
    int x = 0;
    int max = 0;
    for(int i = 0; i < N; i++){
        if(S[i] == 'I') x++;
        else if(S[i] == 'D') x--;
        if(max < x) max = x;
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <set>
#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
constexpr int INF = 1 << 30;

using ll = long long;

int main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  char c;
  cin >> c;
  if ('A' <= c && c <= 'Z')
  {
    cout << 'A';
  }
  else
  {
    cout << 'a';
  }
  return 0;
}


Measured memory_bytes: 3592
#coding: utf-8
N = int(input())
h = list(map(int, input().split()))
dp = [float("inf") for _ in range(N)]
dp[0] = 0
for i in range(1, N):
    dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))
print(dp[N-1])

Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std; void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); solve(); }
template <typename Type> void print_collection(Type coll) { cout << "{ "; for (auto e : coll) cout << e << ' '; cout << "}\n"; }
void solve() {
    int a[2];
    cin >> a[0] >> a[1];
    sort(a, a+2);
    int r = a[1];
    a[1]--;
    sort(a, a+2);
    cout << r + a[1] << '\n';
}


Measured memory_bytes: 256
let () =
  let rec read () =
    let n = read_int () in
    if n = 0 then ()
    else
      begin
        let x = Array.make 7 0 in
        for i = 0 to n-1 do
          let m = read_int () in
          if m < 10 then x.(0) <- x.(0)+1
          else if m >= 10 && m < 20 then x.(1) <- x.(1)+1
          else if m >= 20 && m < 30 then x.(2) <- x.(2)+1
          else if m >= 30 && m < 40 then x.(3) <- x.(3)+1
          else if m >= 40 && m < 50 then x.(4) <- x.(4)+1
          else if m >= 50 && m < 60 then x.(5) <- x.(5)+1
          else if m >= 60 then x.(6) <- x.(6)+1
        done;
        Array.iter (fun t -> Printf.printf "%d\n" t) x;
        read ()
      end
  in read ()
;;

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

using namespace std;

int p, q, r;

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

    cin >> p >> q >> r;

    cout << min(p + q, min(p + r, q + r));

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ld long double
#define mod 1000000007
#define mod1 mod
#define mod2 100000009
#define show(a) for(int i=0;i<a.size();i++) cout<<a[i & 1]<<" ";
#define fi first
#define se second
#define vi vector<int>
#define vs vector<string>
#define vll vector<ll>
#define pb push_back
#define pi pair<int,int>
#define si set<int>
#define sll set<ll>
#define pll pair<ll, ll>
#define sci(x) scanf("%d",&x)
#define scs(x)  scanf("%s", x)
#define scll(x) scanf("%I64d",&x)
#define all(v) v.begin(),v.end()
#define sot(v) sort(v.begin(), v.end())
#define maxheap priority_queue<int>
#define mp make_pair
#define fast_io() cin.sync_with_stdio(false);cout.sync_with_stdio(false);
#define PI 3.1415926535
#define long_zero 0ll
#define long_one 1ll
 
inline int sbt(int x){return __builtin_popcount(x);}
 
using namespace std;
using namespace __gnu_pbds;
 
#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define deb(...)
#endif
#define N 10003
bool ok;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;
 
inline int mul(int a, int b, int m = mod) { return (a * b) % m; }
inline int add(int a, int b, int m = mod) { return (a + b) % m; }
inline int sub(int a, int b, int m = mod) { return (a - b + m) % m; }
 
int dx[][2] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};
 
int fastpow(int a, int b) {
    int res = 1;
    while(b > 0) {
        if(b & 1) res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
 
int modinv(int a) {
    return fastpow(a, mod - 2);
}
 
int n, m, res;
 
int32_t main() {
  	fast_io();
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if(a==0)
    	cout<<1<<endl;
    else if(b==0)
    	cout<<2<<endl;
    
    else if(c==0)
    	cout<<3<<endl;
    
    else if(d==0)
    	cout<<4<<endl;
    
    else if(e==0)
    	cout<<5<<endl;
    
    return 0;
 
}

Measured memory_bytes: 3496
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

const i32 mod = 1000000007;

i32 mod_pow (i32 r, i32 n) {
  i32 t = 1;
  i32 s = r;
  while (n > 0) {
    if (n & 1) t = (i64) t * s % mod;
    s = (i64) s * s % mod;
    n >>= 1;
  }
  return t;
}

i32 inv (i32 a) {
  return mod_pow (a, mod - 2);
}

i32 *fact = NULL;
i32 *iFact = NULL;
void init_fact (const i32 n) {
  fact = (i32 *) calloc (n + 1, sizeof (i32));
  fact[0] = 1;
  for (i32 i = 1; i <= n; ++i) {
    fact[i] = (i64) i * fact[i - 1] % mod;
  }
  iFact = (i32 *) calloc (n + 1, sizeof (i32));
  iFact[n] = inv (fact[n]);
  for (i32 i = n - 1; i >= 0; --i) {
    iFact[i] = (i64) (i + 1) * iFact[i + 1] % mod;
  }
}

i32 comb (i32 n, i32 k) {
  if (!(0 <= k && k <= n)) return 0;
  return (i64) fact[n] * iFact[k] % mod * iFact[n - k] % mod;
}

void run (void) {
  i32 n, k;
  scanf ("%" SCNi32 "%" SCNi32, &n, &k);
  init_fact (2 * n);
  for (i32 i = 1; i <= k; ++i) {
    i32 x = k - i;
    i32 y = (n - k) - (i - 1);
    i32 ans = (i64) comb (x + i - 1, i - 1) * comb (y + i, i) % mod;
    printf ("%" PRIi32 "\n", ans);
  }
}

int main (void) {
  run();
  return 0;
}


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

int main() {
  int X;
  cin >> X;
  if(X == 3 || X == 5 || X == 7)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

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

bool isPrime(unsigned int n);

int main(void){
  int n;
  while(cin>>n && n){
    unsigned int count=0;
    if(n==4) count=1;
    for(unsigned int i=3;i<=n/2;i+=2) if(isPrime(i) && isPrime(n-i)) count++;
    cout<<count<<endl;
  }
}

bool isPrime(unsigned int n){
  for(unsigned int i=3;i*i<=n;i+=2) if(n%i==0) return false;
  return true;
}

Measured memory_bytes: 0
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl;
#define NN cout << "No" << endl;
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
class UnionFind{
  private:
    vector<int>par;
  public:
    UnionFind(int n):par(n){
      for(int i = 0; i < n; i++)par[i] = i;
    }
    int root(int x){
      if(par[x] == x)return x;
      return par[x] = root(par[x]);
    }
    void unite(int x,int y){
      int rx = root(x);
      int ry = root(y);
      if(rx == ry)return;
      par[rx] = ry;
    }
    bool same(int x,int y){
      int rx = root(x);
      int ry = root(y);
      return rx == ry;
    }
};
void zip(vector<long long>&v){
  vector<long long>tmp(v.size());
  for(int i = 0; i < v.size(); i++)tmp[i] = v[i];
  sort(tmp.begin(),tmp.end());
  tmp.erase(unique(tmp.begin(),tmp.end()),tmp.end());
  for(int i = 0; i < v.size(); i++){
    v[i] = lower_bound(tmp.begin(),tmp.end(),v[i]) - tmp.begin();
  }
  return;
}
int solve(){
  ll d,n;
  cin >> d >> n;
  int cnt = 0;
  REP(i,1,10000000){
    int tmp = i;
    bool can = true;
    rep(j,d){
      if(tmp % 100 == 0)tmp /= 100;
      else can = false;
    }
    if(tmp % 100 == 0)can = false;
    if(can)cnt++;
    if(cnt == n){
      cout << i << endl;
      return 0;
    }
  }
  return 0; 
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
} 

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

int a, b, c, d;
vector<int> abcd;

string ans;

void dfs(int i, int sum, string op) {
  if (i == 3 && sum == 7) {
    ans = op;
    return;
  }

  if (i == 3) return;

  dfs(i + 1, sum + abcd[i + 1], op + "+");
  dfs(i + 1, sum - abcd[i + 1], op + "-");

  return;
}

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

  string s;
  cin >> s;

  a = s.at(0) - '0';
  b = s.at(1) - '0';
  c = s.at(2) - '0';
  d = s.at(3) - '0';

  abcd = {a, b, c, d};

  dfs(0, a, "");

  cout << a << ans.at(0) << b << ans.at(1) << c << ans.at(2) << d << "=7"
       << endl;

  return 0;
}

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

int main()
{
    long long n,i,j;
    int out[20] = {0};
    scanf("%lld",&n);
    for(i=0;;i++){
        out[i] = n%26;
        if(n>26&&out[i]!=0) n = n/26;
        else if(n>26&&out[i]==0) n = n/26-1;
        else break;
    }
    for(j=i;j>=0;j--){
        if(out[j]==0) printf("z");
        else printf("%c",96+out[j]);
    }
    return 0;
}



Measured memory_bytes: 1660
package main

import (
	. "fmt"
    "math"
)

// func init() { Println("----------------------------------------") }

func main() {
    const L_MAX = 1003

	var q int
	Scanf("%d", &q)
	X := make([]string, 0, 150)
	Y := make([]string, 0, 150)
	for i := 0; i < 2 * q; i++ {
	    var tmp string
	    Scanf("%s", &tmp)

	    if i % 2 == 0 {
	        X = append(X, tmp)
	    } else {
	        Y = append(Y, tmp)
	    }
	}

    for i := 0; i < q; i++ {
        dp := make([][]int, L_MAX)
        for k, _ := range dp {
            dp[k] = make([]int, L_MAX)
        }

        x, y := X[i], Y[i]

        // init
        isXFound := false
        for c := 0; c < len(x); c++ {
            if isXFound || y[0] == x[c] {
                dp[0][c] = 1
                isXFound = true
            }
        }
        isYFound := false
        for r := 0; r < len(y); r++ {
            if isYFound || x[0] == y[r] {
                dp[r][0] = 1
                isYFound = true
            }
        }

        for r := 1; r < len(y); r++ {
            for c := 1; c < len(x); c++ {
                // dp[r][c]
                if x[c] == y[r] {
                    dp[r][c] = int(math.Max(float64(dp[r - 1][c - 1] + 1), float64(dp[r][c])))
                }

                dp[r][c] = int(math.Max(float64(dp[r][c]), math.Max(float64(dp[r - 1][c]), float64(dp[r][c - 1]))))
            }
        }
        Println(dp[len(y) - 1][len(x) - 1])

        // LCSも求めておく
        // ans := ""
        // r, c := len(y) - 1, len(x) - 1
        // for r >= 0 && c >= 0 {
        //     if y[r] == x[c] {
        //         ans = string(x[c]) + ans
        //         r--
        //         c--
        //     } else {
        //         if dp[r - 1][c] > dp[r][c - 1] {
        //             r--
        //         } else {
        //             c--
        //         }
        //     }
        // }
        // Println(ans)
    }
}



Measured memory_bytes: 22236
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>

using namespace std;
pair<int,int> getPos(int id,int H,int W){
    pair<int,int> result;
    result.first = id / W;
    if(id % (2 * W) < W){
        result.second = id % W;
    }else{
        result.second = (W - 1) - id % W;
    }
    return  result;
}
int main() {
    int H;
    int W;
    cin >> H >> W;
    int a[H][W];
    for(int yi = 0; yi < H; yi++){
        for(int xi = 0; xi < W; xi++){
            cin >> a[yi][xi];
        }
    }
    int sum = 0;
    vector<pair<int,int>>resultB(0);
    vector<pair<int,int>>resultA(0);
    for(int i = 0; i < (H * W) - 1; i++){
        pair<int,int> pos = getPos(i,H,W);
        pair<int,int> nextPos = getPos(i + 1,H,W);
        if(a[pos.first][pos.second] % 2 == 1){
            a[nextPos.first][nextPos.second]++;
            sum++;
            resultB.push_back(pos);
            resultA.push_back(nextPos);
        }

    }
    cout << sum << endl;
    for(int i = 0; i < sum; i++){
        cout << resultB[i].first + 1 << " " << resultB[i].second + 1 << " " << resultA[i].first + 1 << " " << resultA[i].second + 1 << endl;
    }
}

Measured memory_bytes: 5228
#include<cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
int m,n,b,c,e,u,w,v;
typedef struct{
int to,w; 
}fhs;
fhs a;
int d[110000];
vector<fhs> mp[111000];
int dfs(int pp)
{
	for(int x=0;x<mp[pp].size();x++)
	{
		if(d[mp[pp][x].to]==-1)
		{
			if(mp[pp][x].w%2==0)
			{
				d[mp[pp][x].to]=d[pp];
				dfs(mp[pp][x].to);
			}
			else
			{
				d[mp[pp][x].to]=1-d[pp];
				dfs(mp[pp][x].to);
			}
			
		}
	}
	
	
}
int main()
{
	memset(d,-1,sizeof(d));
	cin>>m;
	for(int x=0;x<m-1;x++)
	{
		cin>>u>>v>>w;
		a.to=u;
		a.w=w;
		mp[v].push_back(a);
		a.to=v;
		mp[u].push_back(a);
	}
	d[1]=0;
	dfs(1);
	for(int x=1;x<=m;x++)
	{
		cout<<d[x]<<endl;
	}
	
	
	
}
 

Measured memory_bytes: 8704
#include <iostream>
#include <map>
using namespace std;
#define mod 1000000007

long long two (int x) {
  long long ans = 1;
  for (int i = 0; i < x; i++) {
    ans = ans * 2 % mod;  
  }  
  return ans;
}


int main () {
  int n;
  cin >> n;
  map<int, int> A;
  for (int i = 0; i < n; i++) {
    int sub;
    cin >> sub;
    A[sub]++;
  }
  bool ok = true;
  if (n % 2 == 0) {
    for (auto x = A.begin(); x != A.end(); ++x) {
      if (x->first % 2 == 1 &&
          x->first < n      &&
          x->second == 2) {
        // ok   
      }  
      else {
        ok = false;
        break;  
      }
    }
    if (!ok) {
      cout << 0 << endl;  
    }
    else {
      cout << two (n / 2) << endl;  
    }
  }
  else {
    for (auto x = A.begin(); x != A.end(); ++x) {
      if (x->first == 0) {
        if (x->second == 1) {
          // ok  
        }  
        else {
          ok = false;  
        }
      }  
      else {
        if (x->first < n    &&
            x->second == 2  &&
            x->first % 2 == 0) {
          // ok  
        }  
        else {
          ok = false;  
        }
      }
    }
    if (!ok) {
      cout << 0 << endl;  
    }  
    else {
      cout << two((n - 1) / 2) << endl;  
    }
  }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define ALL(x) (x).begin(),(x).end()
#define PB push_back
#define MP make_pair
#define Mod 998244353
#define MOD 1000000007
using namespace std;
using lint = long long;
using vi = vector<lint>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

// cout << fixed << setprecision(12)

int main(){
  lint D; cin >> D;
  vi c(26); // contest 0-25
  for(lint i=0; i<26; i++) cin >> c[i];
  vvi s(D+1, vi(26)); // day 0-D
  for(lint d=1; d<=D; d++){
    for(lint j=0; j<26; j++){
      cin >> s[d][j];
    }
  }
  vi t(D+1); // day 0-D
  for(lint d=1; d<=D; d++){
    cin >> t[d];
    t[d]--;
  }
  
  vi last(26,0);
  
  lint ans = 0;
  
  for(lint d=1; d<=D; d++){
    ans += s[d][t[d]];
    last[t[d]] = d;
    for(lint j=0; j<26; j++){
      ans -= c[j] * (d - last[j]);
    }
    cout << ans << endl;
  }
}
      
      
    
  
  
  
  

Measured memory_bytes: 3716
s = input()
n = len(s)
if n % 2 == 1:
    n += 1
pattern = '01' * ((n + 10) // 2)

ans_a = 0
ans_b = 0
for i, (a, b, ss) in enumerate(zip(pattern[1:], pattern[:-1], s)):
    if ss != a:
        ans_a += 1
    if ss != b:
        ans_b += 1
print(min(ans_a, ans_b))


Measured memory_bytes: 3380
#include <bits/stdc++.h>
 
using namespace std;
namespace kruskal_n {
struct UnionFind {
	int sz;
	vector<int> par;
	UnionFind(int a) : sz(a), par(sz, -1) {}
	int root(int x) { return par[x] < 0 ? x : par[x] = root(par[x]);}
	bool same(int x, int y) { return root(x) == root(y);}
	bool unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (size(x) < size(y)) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}
	int size(int x) { return -par[root(x)];}
	int size() { return sz;}
};
template<class W>
struct Edge {
	using type = Edge<W>;
	int from;
	int to;
	W w;
	template<class... Args> Edge(int f, int t, Args... args) : from(f), to(t), w(args...) {}
	inline bool operator<(const Edge& rhs) const { return w < rhs.w; }
	inline bool operator>(const type& rhs) const { return rhs < *this; }
	inline bool operator>=(const type& rhs) const { return !(*this < rhs); }
	inline bool operator<=(const type& rhs) const { return !(rhs < *this); }
	inline bool operator==(const type& rhs) const { return !(*this < rhs) && !(rhs < *this); }
	inline bool operator!=(const type& rhs) const { return (*this < rhs) || (rhs < *this); }
};
template<class W>
struct Edges : private vector<Edge<W>> {
	using type = vector<Edge<W>>;
	Edges() : type() {}
	Edges(int n) : type() {assert(0 && "Constructor must be empty");}
	template<class... Args> void add_edge(int u, int v, Args... args) {
		(*this).emplace_back(u, v, args...);
	}
	using type::begin; using type::end; using type::rbegin; using type::rend;
	using type::cbegin; using type::cend; using type::crbegin; using type::crend;
	using type::size; using type::operator[]; using type::at; using type::back; using type::front;
	using type::reserve; using type::resize; using type::assign; using type::shrink_to_fit;
	using type::clear; using type::erase; using type::insert; using type::swap; 
	using type::push_back; using type::pop_back; using type::emplace_back; using type::empty;
};
template<class T>
T Kruskal(Edges<T>& e) {
	sort(e.begin(), e.end());
	UnionFind u(e.size());
	T res = 0;
	for (auto &x : e) {
		if (u.unite(x.from, x.to)) res += x.w;
	}
	return res;
}
}
using kruskal_n::Kruskal;
template<class T> using graph = kruskal_n::Edges<T>;

int main() {
    int n; cin >> n;
    graph<long long> g;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int c; cin >> c;
            if (c >= 0) g.add_edge(i, j, c);
        }
    }
    cout << Kruskal(g) << endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main(){
	int n;
	cin >> n;
	ll a,b,sum=0;
	FOR(i,n){
		cin >> a >>b;
		sum+=b-a+1;
	}
	cout << sum;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pll pair<ll,ll>
#define sll set<ll>
#define msll multiset<ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define vpl vector<pll>
#define gll greater<ll>
#define gpl greater<pll>
#define spl set<pll>
#define mspl multiset<pll>
#define lb lower_bound
#define bp __builtin_popcount
#define ub upper_bound
#define prq priority_queue
#define mp make_pair
#define pb push_back
#define mem(x,y) memset(x, y, sizeof x)
#define endl "\n"
#define sz(x) (ll)x.size()
#define sqr(x) x*x
#define rapido ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef long double ld;
ll mx=INT_MAX;
ll mn=INT_MIN;
ll MOD=1e9+7;
const ll maxs=1e7+5;
ll INF = 1e18;
const ll lg=22; 

ll fast(ll base , ll expo){
    ll res = 1;
    while(expo>=1){
        if(expo%2) res *= base;
        base *= base;
        expo /= 2;
    }
    return base;
}

void code_idhr_h(){
    ll N,M,K; cin>>N>>M>>K;
    ll A[N+1], B[M+1]; mem(A , 0); mem(B , 0);
    ll i,j;
    for(i=1; i<=N; i++){
        cin>>A[i];
        A[i] += A[i-1];
    }
    for(i=1; i<=M; i++){
        cin>>B[i];
        B[i] += B[i-1];
    }
    ll ans = 0;
    i = j = 1;
    for(ll i=0; i<=N; i++){
        ll indx = ub(B+1, B+M+1, K - A[i]) - (B+1);
        if(A[i] + B[indx] <= K){
            ans = max(ans , i + indx);
        }
        if(A[i] > K) break;
    }
    cout<<ans;
}

int main(){
    rapido;
    ll T=1; //cin>>T;
    while(T--){
        mx = INT_MIN;
        code_idhr_h();
    }
    return 0;
}

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

int main() {
    int ans = 0;
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++) {
        cin >> a.at(i);
    }

    int next_num = 1;
    for(int i = 0; i < N; i++) {
        if(a.at(i) != next_num) {
            ans += 1;
        } else
            next_num++;
    }
    if(ans == N)
        ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 1024
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        n: i64,
        a: [i64; 5],
    }
    let bottleneck = a.iter().min().unwrap();
    let ans = (n + bottleneck - 1) / bottleneck + 4;
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>


using namespace std;

int main(){

	bool ok = true;
	int N1, N2, N3, N4;
	int x[] = {1, 9, 7, 4};

	cin >> N1 >> N2 >> N3 >> N4;

	for(int i = 0;i < 4; i++){
		if(N1 != x[i] && N2 != x[i] && N3 != x[i] && N4 != x[i]){
			ok = false;
		}
	}

	if(ok == true){
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}


	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

bool check(int i, int j, int h, int w, const vector<string>& field) {
  if (field[i][j] == '.') return true;
  if (i > 0 && field[i - 1][j] == '#') return true;
  if (i < h - 1 && field[i + 1][j] == '#') return true;
  if (j > 0 && field[i][j - 1] == '#') return true;
  if (j < w - 1 && field[i][j + 1] == '#') return true;
  return false;
}

int main() {
  //
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  if (a + b <= 2 * c) {
    cout << a * x + b * y << endl;
  } else {
    if (x >= y) {
      cout << min(2 * c * x, 2 * c * y + a * (x - y)) << endl;
    } else {
      cout << min(2 * c * y, 2 * c * x + b * (y - x)) << endl;
    }
  }
  return 0;
}


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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll HIGHINF = (ll)1e18;
const ll LOWINF = (ll)1e15;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	int X,Y,Z,K; cin >> X >> Y >> Z >> K;
	V<ll> a(X+2),b(Y+2),c(Z+2);
	for(int i = 0; i < X; ++i)  cin >> a[i];
	for(int i = 0; i < Y; ++i)  cin >> b[i];
	for(int i = 0; i < Z; ++i)  cin >> c[i];

	sort(ALL(a),greater<ll>());
	sort(ALL(b),greater<ll>());
	sort(ALL(c),greater<ll>());

	V<ll> cnt;
	for(int i = 0; i < X; ++i){
		for(int j = 0; j < Y; ++j){
			cnt.push_back(a[i]+b[j]);
		}
	}
	sort(ALL(cnt),greater<ll>());
	V<ll> ans;
	for(int i = 0; i < min((int)cnt.size(),K); ++i){
		for(int j = 0; j < Z; ++j){
			ans.push_back(cnt[i]+c[j]);
		}
	}
	sort(ALL(ans),greater<ll>());
	
	for(int i = 0; i < K; ++i) cout << ans[i] << endl;	


	return 0;
}


Measured memory_bytes: 42856
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
using namespace std;
pair<int,int> p[100000];
signed main(){
	int a,b,ans=0;
	cin>>a;
	f(i,a){
		cin>>b;
		p[i].F=b;
		p[i].S=i;
	}
	sort(p,p+a);
	f(i,a){
		if(abs(i-p[i].S)%2) ans++;
	}
	cout<<ans/2<<endl;
	return 0;
}


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

int main(){
string s;cin>>s;
ll sum=0;
for(int i=0;i<s.size();i++){
    sum+=s[i]-'0';
}
if(sum%9==0) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;
}

Measured memory_bytes: 3716
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <functional>
#include <typeinfo>
#include <utility>
#include <tuple>
#include <queue>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define all(arr) (arr).begin(), (arr).end()
#define yn(formula) (formula) ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(formula) (formula) ? (cout << "YES" << endl) : (cout << "NO" << endl)

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pii> vp;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vp> vvp;

constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1ll << 59;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };

/*<ここから>***********************************************************/

template <typename T>
void warshallFloyd(vector<vector<T>> &d) {
	rep(i, d.size()) rep(j, d.size()) rep(k, d.size()) d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

int main()
{
	int H, W;
	cin >> H >> W;
	vvi c(10, vi(10));
	rep(i, 10) rep(j, 10) cin >> c[i][j];
	warshallFloyd(c);

	vvi A(H, vi(W));
	rep(i, H) rep(j, W) cin >> A[i][j];

	int ans = 0;
	rep(i, H) {
		rep(j, W) {
			if (A[i][j] == -1) continue;

			ans += c[A[i][j]][1];
		}
	}

	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, K, T, W, H, M, C;

const int MAX = 5100000;
const ll MOD = 1e9 + 7;

const double PI=3.14159265358979323846;


long long fac[MAX], finv[MAX], inv[MAX];

vector<double> cx, cy, c;
 ll MM = 1e12;

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

std::vector<int> Eratosthenes(int n ){
    std::vector<bool> is_prime( n + 1 );
    for( int i = 0; i <= n; i++ ) is_prime[ i ] = true;
    std::vector<int> P;
    for( int i = 2; i <= n; i++ ){
        if( is_prime[ i ] ){
            for( int j = 2 * i; j <= n; j += i ){
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}

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

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

  
int main(){
    cin >> N;
    cout <<setprecision(12)<< 2*N * PI << "\n";
    return 0; 
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define SORT(c) sort(ALL((c)))
#define debug(x)                 \
    do {                         \
        std::cout << #x << ": "; \
        view(x);                 \
    } while (0)

template <typename T>
void view(T e) {
    std::cout << e << std::endl;
}
template <typename T>
void view(const std::vector<T>& v) {
    for (const auto& e : v) {
        std::cout << e << ", ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>>& vv) {
    for (const auto& v : vv) {
        view(v);
    }
}

double dis(double x, double y) { return sqrt(x * x + y * y); }

int main() {
    ll N;
    double D;
    cin >> N >> D;
    vector<double> X(N), Y(N);
    ll ans = 0;
    rep(i, N) {
        cin >> X[i] >> Y[i];
        if (dis(X[i], Y[i]) <= D + 0.0000000001) {
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6424