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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

priority_queue<int, vector<int>, greater<int>> red, green;
int uncolor[100005];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int X, Y, A, B, C;
	gi(X),gi(Y),gi(A),gi(B),gi(C);
	rep(i,A){
		int v;gi(v);
		red.push(v); if(red.size() > X) red.pop();
	}
	rep(i,B){
		int v;gi(v);
		green.push(v); if(green.size() > Y) green.pop();
	}
	rep(i,C) gi(uncolor[i]);
	sort(uncolor, uncolor+C, greater<int>());
	rep(i, C) {
		int opt1 = red.top(), opt2 = green.top();
		if(opt1 < opt2) {
			if(uncolor[i] < opt1) continue;
			red.pop(); red.push(uncolor[i]);
		} else {
			if(uncolor[i] < opt2) continue;
			green.pop(); green.push(uncolor[i]);
		}
	}
	ll ans = 0;
	while(!red.empty()) ans += red.top(), red.pop();
	while(!green.empty()) ans += green.top(), green.pop();
	print(ans);
}


Measured memory_bytes: 3960
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int BUF = 81;
const int INF = 1 << 30;

int row, col;
int A[BUF][BUF], B[BUF][BUF];

void read() {
    cin >> row >> col;
    for (int i = 0; i < row; ++i) {
        for (int j = 0; j < col; ++j) {
            cin >> A[i][j];
        }
    }
    for (int i = 0; i < row; ++i) {
        for (int j = 0; j < col; ++j) {
            cin >> B[i][j];
        }
    }
}



// 12800 = 80 * 80 * 2
#define access(r, c, score) dp[r][c][score + 12800]

void dfs(int r, int c, int score, bool dp[BUF][BUF][BUF * 2 * BUF * 2]) {
    bool &ret = access(r, c, score);

    if (ret) return;
    ret = true;
    
    if (r == row - 1 && c == col - 1) return;
    
    static int dr[] = {1, 0};
    static int dc[] = {0, 1};
    for (int i = 0; i < 2; ++i) {
        int nr = r + dr[i];
        int nc = c + dc[i];
        if (nr >= row || nc >= col) continue;
        
        // choose A
        dfs(nr, nc, score + A[nr][nc] - B[nr][nc], dp);
        
        // choose B
        dfs(nr, nc, score + B[nr][nc] - A[nr][nc], dp);
    }
}


void work() {
    // dp[row][col][score] := visited or not
    static bool dp[BUF][BUF][BUF * 2 * BUF * 2];
    memset(dp, 0, sizeof(dp));

    // choose A
    dfs(0, 0, A[0][0] - B[0][0], dp);
    
    // choose B
    dfs(0, 0, B[0][0] - A[0][0], dp);

    int minV = INF;
    for (int i = 0; i < BUF * 2 * BUF * 2; ++i) {
        if (dp[row - 1][col - 1][i])
            minV = min(minV, abs(i - 12800));
    }

    cout << minV << endl;
}


int main() {
    read();
    work();
    return 0;
}


Measured memory_bytes: 168448
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    ll k; cin >> k;
    unordered_set <ll> used;
    ll minimum = 1e18;
    n %= k;
    while(true){
        if(used.find(n) != used.end()){
            break;
        }
        minimum = min(n, minimum);
        used.insert(n);
        n = abs(n-k);
    }
    cout << minimum << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const int maxn = 2e5 + 10;
int n, a[maxn], d[maxn];
ll ans;

int main(){
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i < n; ++i)
		if (a[i] > i || (i && a[i] - a[i - 1] >= 2))
			return cout << "-1\n", 0;
	for (int i = 1; i < n; ++i)
		d[i - a[i]] = max(d[i - a[i]], a[i]);
	for (int i = 0; i < n; ++i)
		ans += d[i];
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;

int main(){

    int n; cin >> n;

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

    vector<vector<int>> vbit;

    int tempmax = 0;
    for(int i=0; i<n; i++){
        if(tempmax < a[i]){
            tempmax = a[i];
        }
    }

    int maxdigit = 0;
    if(tempmax == 0){
        maxdigit = 1;
    }
    else{
        int temp = tempmax;
        while(temp > 0){
            temp /= 2;
            maxdigit++;
        }
    }
    // cout << "maxdigit " << maxdigit << endl;

    for(int i=0; i<n; i++){
        int temp = a[i];
        vector<int> emptyvector;
        vbit.push_back(emptyvector);

        for(int j=0; j<maxdigit; j++){
            int tempbit = temp%2;
            vbit[i].push_back(tempbit);
            temp /= 2;
        }
    }

    // for(int i=0; i<n; i++){
    //     cout << a[i] << " ";
    //     for(int j=0; j<maxdigit; j++){
    //         cout << vbit[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    bool allzero = true;
    for(int i=0; i<n; i++){
        if(a[i] != 0){
            allzero = false;
            break;
        }
    }



    if(allzero){
        cout << "Yes" << endl;
    }
    else if(n % 3 != 0){
        cout << "No" << endl;
    }
    else{
        bool gooddigits = true;
        for(int j=0; j<maxdigit; j++){
            int temp = 0;
            for(int i=0; i<n; i++){
                temp += vbit[i][j];
            }
            if(temp != n*2/3 && temp != 0){
                gooddigits = false;
                break;
            }
        }
        if(!gooddigits){
            cout << "No" << endl;
        }
        else{
            map<int, int> mp;
            for(int i=0; i<n; i++){
                if(mp.find(a[i]) == mp.end()){
                    mp.insert(make_pair(a[i], 1));
                }
                else{
                    mp[a[i]]++;
                }
            }
            map<int, int>::iterator itr;
            set<int> st;
            for(itr = mp.begin(); itr != mp.end(); itr++){
                pair<int, int> p = *itr;
                // cout << p.first << " " << p.second << endl;
                st.insert(p.second);
            }
            if(mp.size() == 3 && st.size() == 1){
                cout << "Yes" << endl;
            }
            else if(mp.size() == 2 && mp.count(0) != 0){
                cout << "Yes" << endl;
            }
            else{
                cout << "No" << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 17072
/*
Author:
Prob:
Link:
Tag:
Comp:
*/

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ii pair<int,int>
#define iii pair<int, ii>

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ep emplace_back
#define sz(a) (int) a.size()
#define cl(a) a.clear()

#define vi vector<int>
#define vii vector<ii>

#define FOR(x,a,b) for (int x=a;x<=b;x++)
#define FOD(x,a,b) for (int x=a;x>=b;x--)
#define REP(x,a,b) for (int x=a;x<b;x++)
#define RED(x,a,b) for (int x=a;x>b;x--)

const int MAX = 2e5 + 10;
const int MAXN = 1e6 + 10;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double pi = acos(-1.0);
const double eps = 1e-6;

int f[MAX], g[MAX];
int cnt1, cnt2;
iii a[MAX];
int n, m;
ll res = 0;

int getSet1(int u){
	return f[u] == u ? u : getSet1(f[u]);
}

int getSet2(int u){
	return g[u] == u ? u : getSet2(g[u]);
}

int main(){
	// freopen("test.in", "rt", stdin);
	ios::sync_with_stdio(false);

	cin >> n >> m;
	FOR(i,0,n) f[i] = i;
	FOR(i,0,m) g[i] = i;
	REP(i,0,n){
		cin >> a[i].fi;
		a[i].se = mp(0, i);
	}
	REP(i,0,m){
		cin >> a[i+n].fi;
		a[i+n].se = mp(1, i);
	}
	sort(a,a+n+m);
	cnt1 = n+1, cnt2 = m+1;
	REP(i,0,n+m){
		if (a[i].se.fi == 0){
			int u = getSet1(a[i].se.se);
			int v = getSet1(a[i].se.se + 1);
			if (u == v)
				continue;
			f[v] = u;
			res += 1LL*cnt2*a[i].fi;
			cnt1--;
		}
		else{
			int u = getSet2(a[i].se.se);
			int v = getSet2(a[i].se.se + 1);
			if (u == v)
				continue;
			g[v] = u;
			res += 1LL*cnt1*a[i].fi;
			cnt2--;
		}
	}

	cout << res;

	return 0;
}

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

vector<pair<long long, long long> > prime_factorize(long long N) 
{
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) 
    {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) 
        {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main(void)
{
    long long n; cin >> n;
    int tab[100];
    int c = 1;
    int t = 1;
    for (int i = 0; i < 100; i++)
    {
        if (i == t)
        {
            c++;
            t = c * (c + 1) / 2;
        }
        tab[i] = c - 1;
    }

    long long ans = 0;
    const auto &res = prime_factorize(n);
    for (auto p: res)
    {
        ans += tab[p.second];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
#!/usr/bin/env python3
mod = 10**9 + 7
n, m = map(int, input().split())
ok = [True] * (n + 1)
if m > 0:
    a = [int(input()) for _ in range(m)]
    for x in a:
        ok[x] = False
dp = [0] * (n + 1)
dp[0] = 1
for i in range(n + 1):
    if i > 0 and ok[i - 1]:
        dp[i] = (dp[i] + dp[i - 1]) % mod
    if i > 1 and ok[i - 2]:
        dp[i] = (dp[i] + dp[i - 2]) % mod
print(dp[n])


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

const int N = 2 * 100 * 1000 + 10;

int n, q, ans;
string st;
pair <char, int> Spell[N];

void input() {
    cin >> n >> q;
    cin >> st;

    char tmp;
    for (int i = 0; i < q; i++) {
        cin >> Spell[i].first >> tmp;
        if (tmp == 'R')
            Spell[i].second++;
        else
            Spell[i].second--;
    }
    return;
}

bool f(int x) {
    int pnt = 0;
    while (pnt < q && 0 <= x) {
        if (st[x] == Spell[pnt].first)
            x += Spell[pnt].second;
        if (x >= n)
            return false;
        pnt++;
    }

    if (x < 0)
        return true;
    return false;
}

int BinSearch(int l, int r) {
    while (r - l > 1) {
        int mid = (l + r) / 2;
        if (f(mid))
            l = mid;
        else
            r = mid;
    }
    return r;
}

int main() {
    input() ;
    ans += BinSearch(-1, n) ;

    reverse(st.begin(), st.end()) ;
    for (int i = 0; i < q; i++)
        Spell[i].second *= -1;

    ans += BinSearch(-1, n) ;

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


Measured memory_bytes: 2180
import numpy as np
import heapq
n, m = map(int, input().split())
a = np.array(list(map(int, input().split())))
q = list(-a)
heapq.heapify(q)
#print(q)
for _ in range(m):
    temp = heapq.heappop(q)
    temp = -temp
    temp //= 2
    heapq.heappush(q, -temp)
print(-sum(q))

Measured memory_bytes: 23140
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

signed main()
{
  string S;
  cin >> S;
  int N = S.size();

  for (int i = 0; i < N; i++)
  {
    if (i + 1 < N && S.at(i) == S.at(i + 1))
    {
      cout << i + 1 << " " << i + 2 << endl;
      return 0;
    }
    if (i + 2 < N && S.at(i) == S.at(i + 2))
    {
      cout << i + 1 << " " << i + 3 << endl;
      return 0;
    }
  }

  cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 512
import sys
import numpy as np
 
#%% Smart Solution
 
input = sys.stdin.readline
 
H, W = map(int, input().split())
 
status = np.full((H, W), H*W, dtype=int)
for i in range(H):
    for j, c in enumerate(input()):
        if c == "#":
            status[i,j] = 0
 
 
for h in range(1, H):
    status[h, :] = np.minimum(status[h, :], status[h-1, :] + 1)
for h in range(0, H-1)[::-1]:
    status[h, :] = np.minimum(status[h, :], status[h+1, :] + 1)
for w in range(1, W):
    status[:, w] = np.minimum(status[:, w], status[:, w-1] + 1)
for w in range(0, W-1)[::-1]:
    status[:, w] = np.minimum(status[:, w], status[:, w+1] + 1)
 
print(np.max(status))

Measured memory_bytes: 20184
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long 
const int mod = 1e9+7;
const int maxn=1e5+100;
const int maxm=10000+100;
const int inf=0x3f3f3f3f;

int n;
int A[maxn];
int cnt[100000+10];



int main(){
    //freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);
    cin>>n;
    int man1=-1;
    for(int i=1;i<=n;i++){
        cin>>A[i];
        man1=max(man1,A[i]);
        cnt[A[i]]++;
    }    
    int sum=0;
    int kind=0;

    for(int i=1;i<=man1;i++){
        if(cnt[i]) sum+=cnt[i]-1,kind++;
    }
    if(sum%2==1) kind--;
    printf("%d\n",kind);
    return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int n;
int a[2000];

ll dp[2001][2001];
//??????x,??????y?????¶???
ll dfs(int x, int y)
{
    if(dp[x][y]>=0) return dp[x][y];

    ll ret=0;
    //??????1???
    if(x==y) return a[x];
    else
    {
        //a[x]????????¶
        ll add=a[x];
        int nx=(x-1+n)%n;

        //IOI????????????????????§?????????
        if(nx==y) ret=max(ret,add);
        else
        {
            //IOI??????????????§?????????????????¶
            if(a[nx]>a[y])
            {
                int nnx=(nx-1+n)%n;
                ret=max(ret,dfs(nnx,y)+add);
            }
            else
            {
                int ny=(y+1)%n;
                ret=max(ret,dfs(nx,ny)+add);
            }
        }

        //a[y]????????¶
        add=a[y];
        int ny=(y+1)%n;

        //IOI????????????????????§?????????
        if(x==ny) ret=max(ret,add);
        else
        {
            //IOI??????????????§?????????????????¶
            if(a[x]>a[ny])
            {
                nx=(x-1+n)%n;
                ret=max(ret,dfs(nx,ny)+add);
            }
            else
            {
                int nny=(ny+1)%n;
                ret=max(ret,dfs(x,nny)+add);
            }
        }
    }

    //printf("%d,%d ret %lld\n",x,y,ret);
    return dp[x][y]=ret;
}

int main()
{
    cin >>n;
    rep(i,n) cin >>a[i];

    if(n==1)
    {
        cout << a[0] << endl;
        return 0;
    }
    if(n==2)
    {
        cout << max(a[0],a[1]) << endl;
        return 0;
    }

    memset(dp,-1,sizeof(dp));
    ll ans=0;
    //JOI?????????????????±??????i????????????
    rep(i,n)
    {
        int l=(i-1+n)%n, r=(i+1)%n;
        //IOI??????????????§?????????????????¶
        if(a[l]>a[r]) l=(l-1+n)%n;
        else r=(r+1)%n;

        ans=max(ans,dfs(l,r)+a[i]);
    }

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

Measured memory_bytes: 34448
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
#define maxn 101000

int main()
{
	int n;
	scanf("%d",&n);
	if((n/100)*111>=n) printf("%d\n",(n/100)*111);
	else printf("%d\n",(n/100+1)*111);

	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

// UnionFind 構造体 for tree
type UnionFind struct {
	par []int
}

/*コンストラクタ*/
func newUnionFind(N int) *UnionFind {
	u := new(UnionFind)
	u.par = make([]int, N)
	for i := range u.par {
		u.par[i] = -1
	}
	return u
}
func (u UnionFind) root(x int) int {
	if u.par[x] < 0 {
		return x
	}
	u.par[x] = u.root(u.par[x])
	return u.par[x]
}
func (u UnionFind) unite(x int, y int) {
	xr := u.root(x)
	yr := u.root(y)
	if xr == yr {
		return
	}
	u.par[yr] += u.par[xr]
	u.par[xr] = yr
}
func (u UnionFind) same(x, y int) bool {
	if u.root(x) == u.root(y) {
		return true
	}
	return false
}
func (u UnionFind) size(x int) int {
	return -u.par[u.root(x)]
}

var mod int = 1000000007

type pair struct {
	fi int
	se int
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	//予備
	x := iScan()
	y := iScan()
	z := iScan()
	k := iScan()
	a := make([]int, x)
	b := make([]int, y)
	c := make([]int, z)
	var bc []int
	var ac []int
	for i := 0; i < x; i++ {
		a[i] = iScan()
	}
	for i := 0; i < y; i++ {
		b[i] = iScan()
	}
	for i := 0; i < z; i++ {
		c[i] = iScan()
	}
	for i := 0; i < y; i++ {
		for j := 0; j < z; j++ {
			bc = append(bc, b[i]+c[j])
		}
	}
	sort.Slice(bc, func(i int, j int) bool { return bc[i] > bc[j] })
	for i := 0; i < x; i++ {
		for j := 0; j < smaller(3000, len(bc)); j++ {
			ac = append(ac, a[i]+bc[j])
		}
	}
	sort.Slice(ac, func(i int, j int) bool {
		return ac[i] > ac[j]
	})
	for i := 0; i < k; i++ {
		fmt.Println(ac[i])
	}
}


Measured memory_bytes: 105244
#include<iostream>
#include<cmath>
#include<string>
#include<vector>

using namespace std;
#define ll long long 

int  main(){
    int N;
    cin >> N;
    vector<int> c(N);
    vector<int> s(N);
    vector<int> f(N);
    vector<int> a(N,0);
    int t,b;
    int tmp;
    bool flag = true;
    for(int i = 0; i < N-1; i++){
        cin >> c[i] >> s[i] >> f[i];
    }
    for(int i = 0; i < N-1; i++){
        for(int j = 0; j < N; j++){
            if(j <= i){
                if(a[j]< s[i]){
                    a[j] = s[i];
                }else{
                    t = a[j] % f[i];
                    if(t != 0) a[j] = a[j] - t + f[i];
                }
                a[j] += c[i];
            }
        }
    }
    for(int i = 0; i < N; i++) cout << a[i] << endl;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
struct Edge {
	int to;
	T cost;
	Edge() {}
	Edge(int to, T cost) : to(to), cost(cost) {}
	bool operator>(const Edge &r) const { return this->cost > r.cost; }
};

template<class T>
vector<T> Dijkstra(const vector<vector<Edge<T>>> &edges, const int st) {

	const int V = (int)edges.size();
	const T inf = numeric_limits<T>::max() / 2;
	vector<T> cost(V, inf);
	cost[st] = 0;

	vector<T> prev(V, inf);

	priority_queue<Edge<T>, vector<Edge<T>>, greater<Edge<T>>> pq;
	pq.emplace(st, cost[st]);

	while (!pq.empty()) {

		Edge<T> now(pq.top().to, pq.top().cost);
		pq.pop();

		if (cost[now.to] < now.cost) continue;
		for (const Edge<T> &e : edges[now.to]) {
			T tmp_cost = now.cost + e.cost;
			if (cost[e.to] > tmp_cost) {
				cost[e.to] = tmp_cost;
				pq.emplace(e.to, cost[e.to]);
				prev[e.to] = now.to;
			}
		}
	}

	return prev;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<vector<Edge<int>>> edges(N);
	map<pair<int, int>, int> id;
	for (int i = 0; i < N - 1; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		edges[u].emplace_back(v, 1);
		edges[v].emplace_back(u, 1);
		id[minmax(u, v)] = i;
	}

	int M;
	cin >> M;
	vector<int> cond(N - 1);
	for (int i = 0; i < M; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;

		auto prev = Dijkstra(edges, u);

		while (prev[v] < N) {
			cond[id[minmax(v, prev[v])]] += (1 << i);
			v = prev[v];
		}

	}

	vector<lint> dp(1 << M);
	dp[0] = 1;
	for (int i = 0; i < N - 1; i++) {
		for (int j = (1 << M) - 1; j >= 0; j--) {
			dp[j | cond[i]] += dp[j];
		}
	}

	cout << dp[(1 << M) - 1] << "\n";

	return 0;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s, t, p;
	int a, b;
	cin >> s >> t >> a >> b >> p;
	if(p == s) {
		--a;
	}
	if(p == t) {
		--b;
	}
	cout << a << ' ' << b << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
// Dijkstra
template<typename X>
class Graph {
private:
  int n;// 頂点数
  int m;// 辺の数
  vector<vector<pair<int,pair<X,int>>>> edge; // 重み付き有向辺
  vector<vector<vector<X>>> d;// d[i][j] := 頂点iから頂点jの最短距離
  const X inf = 1e+17; // dの初期値
  vector<pair<X,int>> kk;
public:
  Graph(int _n, int _m, vector<int> a, vector<int> b, vector<X> c, vector<int> d) {
    n = _n;
    m = _m;
    edge.resize(n);
    rep(i,m) {
      add_edge(a[i], b[i], c[i], d[i]);
      add_edge(b[i], a[i], c[i], d[i]); // 無向グラフ
    }
  }

  void add_edge(int from, int to, X cost, int money) {
    edge[from].push_back( {to, {cost, money}} );
  }

  void init(vector<X> c, vector<int> d) {
    kk.resize(n);
    rep(i,n) kk[i] = {c[i], d[i]};
  }

  
  void dijkstra(int s, int g) { // 頂点sから全頂点への最短距離を求める
    d.resize(n);
    d[s].resize(n, vector<X>(2501, inf));
    chmin(g, 2500);
    d[s][s][g] = 0;
    priority_queue< pair<X,pair<int,int>>, vector<pair<X,pair<int,int>>>, greater<pair<X,pair<int,int>>> > pq; // 優先キュー {距離, {頂点, 銀貨}} で距離の小さい順に並ぶ 
    pq.push({0, {s, g}});
    while( !pq.empty() ) {
      pair<X,pair<int,int>> p = pq.top(); pq.pop();
      X dist = p.first; // 
      int v = p.second.first; // 頂点
      int gold = p.second.second; // 銀貨
      if( d[s][v][gold] < dist ) continue;
      int to = min(2500, gold + kk[v].second);
      if(d[s][v][to] > d[s][v][gold] + kk[v].first) {
	d[s][v][to] = d[s][v][gold] + kk[v].first;
	pq.push({d[s][v][to], {v, to}});
      }
      for(auto w : edge[v]) {
	int t = w.first; // 頂点wから頂点tに向かう
	X c = w.second.first; // w -> t のコストがc
	if(w.second.second <= gold) {
	  if(d[s][t][gold - w.second.second] > d[s][v][gold] + c) { // 更新されればキューにぶちこむ
	    d[s][t][gold - w.second.second] = d[s][v][gold] + c;
	    pq.push( {d[s][t][gold - w.second.second], {t, gold - w.second.second}} );
	  }
	}
      }
    }
  }

  X get_d(int u, int v) {
    X res = inf;
    rep(i,2501) {
      chmin(res, d[u][v][i]);
    }
    return res;
  }

};


int main()
{
  int n,m,s;cin >> n >> m >> s;
  vector<int> u(m), v(m), a(m), c(n);
  vector<ll> b(m), d(n);
  rep(i,m) {
    cin >> u[i] >> v[i] >> a[i] >> b[i];
    u[i]--; v[i]--;
  }
  rep(i,n) {
    cin >> c[i] >> d[i];
  }

  Graph<ll> gp(n, m, u, v, b, a);
  gp.init(d, c);
  gp.dijkstra(0, s);
  rep1(i,n-1) {
    cout << gp.get_d(0, i) << "\n";
  }
  
  return 0;
}


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

bool sortbyA(pair<int, int> A1,pair<int, int> A2){
  return A1.first < A2.first;
}

int main(){
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> A(N);
  for(int i=0; i<N; i++){
    scanf("%d %d", &A[i].first, &A[i].second);
  }
  sort(A.begin(), A.end(), sortbyA);
  int total_buy=0;
  long long sum_money=0;
  for(int i=0; i<N; i++){
    long buy = min(M-total_buy, A[i].second);
    total_buy += buy;
    sum_money += buy * A[i].first;
    if(total_buy == M){
      break;
    }
  }
  cout << sum_money << endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC092 {
	class ABC092_A {
		static void Main(string[] args) {
			var A = int.Parse(Console.ReadLine());
			var B = int.Parse(Console.ReadLine());
			var C = int.Parse(Console.ReadLine());
			var D = int.Parse(Console.ReadLine());
			var AB = Math.Min(A, B);
			var CD = Math.Min(C, D);
			Console.WriteLine(AB + CD);
		}
	}
}


Measured memory_bytes: 11092
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

//var done []bool = make([]bool, 10)
//var memo []int = make([]int, 10)

var m map[string]int = make(map[string]int)
var mInt map[int]int = make(map[int]int)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	n := nextInt()
	m := nextInt()
	resn := 0
	resm := 0
	if n >= 2 {
		resn = n * (n - 1) / 2
	}
	if m >= 2 {
		resm = m * (m - 1) / 2
	}

	fmt.Fprint(out, resn+resm)
}


Measured memory_bytes: 640
import java.util.*;

public class Main{
    static int N, M;
    static int[][] a; 
    static boolean[] flag;
    static int count = 0;
    static int[][] d;
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        N = sc.nextInt();
        M = sc.nextInt();
        a = new int[2][M];
        d = new int[N][N];
        for(int i = 0; i < M; i++){
            a[0][i] = sc.nextInt();
            a[1][i] = sc.nextInt();
            d[a[0][i]-1][a[1][i]-1] = 1;
            d[a[1][i]-1][a[0][i]-1] = 1;
        }
        sc.close();
        flag = new boolean[N];
        flag[0] = true;
        dfs(1);
        System.out.println(count);
    }
    static void dfs(int pos){
        if(check()) {
            count++;
            return;
        }
        else {
            for(int i = 0; i < N; i++){
                if(d[pos-1][i] == 1 && flag[i] == false){
                    flag[i] = true;
                    dfs(i+1);
                    flag[i] = false;
                }
            }
        }
        return;
    }

    static boolean check(){
        for(int i = 0; i < N; i++){
            if(!(flag[i]))
                return false;
        }
        return true;
    }
}

Measured memory_bytes: 22740
N, T = map(int, input().split())

c = []
t = []

for n in range(N):
	cn, tn = map(int, input().split())
	if tn <= T:
		c.append(cn)
		t.append(tn)

l = list(zip(c, t))
l.sort()

if len(l) == 0:
	print("TLE") 
else:
	print(l[0][0])

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;
void solve(){
  int n, k, x, y; cin >> n >> k >> x >> y;
  if(n > k) cout << k * x + (n - k) * y << endl;
  else cout << n * x << endl;
  return;
}

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


Measured memory_bytes: 256
class Counter < Hash
	def initialize(a=[])
		super
		self.default=0
		a.each{|e|self[e]+=1}
	end
  def most_common(n=nil)
    a=self.sort_by{|k,v|v}.reverse
    a=a[0,n] if n
    a
  end
	def self.[](*a)
		new(a)
	end
end
def Counter(a=[]) Counter.new(a) end
 
n,*v=`dd`.split.map &:to_i
v=v.each_slice(2).to_a
a,b=v.shift.zip(*v).map(&:compact).map{|e|Counter(e).most_common<<[0,0]}
if a[0][0] != b[0][0]
  p n - (a[0][1] + b[0][1])
else
  p [n-(a[1][1]+b[0][1]), n-(a[0][1]+b[1][1])].min
end

Measured memory_bytes: 27140
N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    s, t = map(int, input().split())
    G[s].append(t)

ans = []
V = set()

def dfs(n):
    for e in G[n]:
        if e not in V:
            dfs(e)
    if n not in V:
        ans.append(n)
        V.add(n)


for i in range(N):
    if i not in V:
        if i not in V:
            dfs(i)
            print()

print(*ans[::-1], sep="\n")


Measured memory_bytes: 9472
using System;

namespace AtCoder.Question
{
    public class QuestionC
    {
        public static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);
            var h = int.Parse(input[2]);
            var m = int.Parse(input[3]);

            //c^2 = a^2 + b^2 - 2ab cosA

            var hourAngle = (h * 60 + m) / (double)720;
            var minutesAngle = m / (double)60;

            var angle = Math.Min(Math.Abs(hourAngle - minutesAngle), Math.Abs(minutesAngle - hourAngle)) * Math.PI * 2;


            var c2 = a * a + b * b - 2 * a * b * Math.Cos(angle);
            Console.WriteLine(Math.Sqrt(c2).ToString(""));
        }
    }
}


Measured memory_bytes: 27784
#include <bits/stdc++.h>
#define int long long
#define R(i,a,n) for(int i=a;i<n;i++)
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};
int ddx[]={0,1,1,1,0,-1,-1,-1};
int ddy[]={-1,-1,0,1,1,1,0,-1};
#define pb push_back
signed main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int a[300009]={},b[300009]={};
  r(i,s.size()){
    int d=0;
    if(s[i]=='W')d++;
    a[i+1]=a[i]+d;
  }
  for(int i=s.size()-1;i>=0;i--){
    int d=0;
    if(s[i]=='E')d++;
    b[i-1]=b[i]+d;
  }
  int ans=1e9;
  r(i,s.size()){
    if(i==0)ans=min(ans,b[i]);
    else if(i==s.size()-1)ans=min(ans,a[i]);
    else ans=min(ans,a[i]+b[i]);
  }
  cout<<ans<<endl;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    sort(A.begin(), A.end());
    vector<ll> B(N);
    if(N%2)
    {
        ll center = A[N/2];
        if(center - A[N/2-1] < A[N/2+1] - center)
        {
            B[0] = A[N/2-1];
            B[1] = A[N/2+1];
            for(int i=0, j=N/2+2, k=2; i<N/2-1; i++, j++, k+=2)
            {
                B[k] = A[i];
                B[k+1] = A[j];
            }
            B[N-1] = center;
        }
        else
        {
            B[0] = A[N/2+1];
            B[1] = A[N/2-1];
            for(int i=0, j=N/2+2, k=2; i<N/2-1; i++, j++, k+=2)
            {
                B[k] = A[j];
                B[k+1] = A[i];
            }
            B[N-1] = center;
        }
    }
    else
    {
        for(int i=N/2-1, j=N-1, k=0; i>=0; i--, j--, k+=2)
        {
            B[k] = A[i];
            B[k+1] = A[j];
        }
    }
    
    // for(auto b : B) cout << b << ' ';
    // cout << '\n';

    ll ans = 0;
    for(int i=1; i<N; i++)
    {
        ans += llabs(B[i] - B[i-1]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4792
fn main() {
    let mut ny = String::new();
    std::io::stdin().read_line(&mut ny).expect("read line");
    let mut inputs = ny
        .trim()
        .split_whitespace()
        .map(|n| n.parse::<i32>().expect("n"));
    let n = inputs.next().expect("n");
    let y = inputs.next().expect("y");
    let ans = solve(n, y).unwrap_or((-1, -1, -1));
    println!("{} {} {}", ans.0, ans.1, ans.2);
}

fn solve(n: i32, y: i32) -> Option<(i32, i32, i32)> {
    let delta = y / 1000 - n;
    if 1000 * n > y {
        return None;
    }
    // 9*a + 4*b = delta
    for i in 0..9 {
        if (delta - 4 * i) % 9 == 0 {
            let j = (delta - 4 * i) / 9;
            if j >= 0 && n - i - j >= 0 {
                return Some((j, i, n - i - j));
            }
        }
    }
    None
}


Measured memory_bytes: 2164
N = int(input())
A_list = sorted(list(map(int, input().split())))[::-1]
a_sum = 0
b_sum = 0

for i in range(N):
    if i % 2 == 0:
        a_sum += A_list[i]
    else:
        b_sum += A_list[i]
print(a_sum - b_sum)

Measured memory_bytes: 3064
#abc174 b

import sys,math,collections,itertools
input = sys.stdin.readline

N,D=list(map(int,input().split()))
cnt =0
for i in range(N):
    x,y=list(map(int,input().split()))
    if x**2+y**2<=D**2:
        cnt+=1
print(cnt)


Measured memory_bytes: 9480
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

const long long M = 998244353;

long long gcd(long long x,long long y){
	if(y == 0)return x;
	return gcd(y,x%y);
}

int main(){
	long long N;
	long long a[100010];
	scanf("%lld",&N);
	for(int i = 1 ; i <= N ; i ++){
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+N+1);
	
	long long ret = 1;
	for(int i = 1 ; i <= N ; i ++){
		ret *= gcd(a[i],i-1);
		ret %= M;
	}
	cout << ret << endl;
}


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

void partition(std::vector<int> sequence, int n) {
    int creterion = sequence.at(n-1);
    int i=0;
    for (int j=0; j<sequence.size()-1; j++) {
        if (creterion >= sequence.at(j)) {
            std::swap(sequence.at(i), sequence.at(j));
            i++;
        }
    }
    std::swap(sequence.at(i), sequence.at(n-1));
    
    for (int j=0; j<sequence.size(); j++) {
        std::cout << (j==i ? "[" : "") << sequence.at(j) << (j==i ? "]" : "") << (j+1 == sequence.size() ? "\n" : " ");
    }
}

int main() {
    int n;
    std::cin >> n;
    std::vector<int> sequence(n);
    for (int i=0; i<n; i++) std::cin >> sequence.at(i);

    partition(sequence, n);
    
}


Measured memory_bytes: 3588
#include<iostream>
#include <vector>
#include <math.h>
using namespace std;
int main(){
  int n=0;
  vector<string> s;
  string input;
  cin >> n;
  while(cin >> input) s.push_back(input);
  int AC=0;
  int WA=0;
  int TLE=0;
  int RE=0; 
  for (int i=0; i<n; i++)
  {
    if (s[i]=="AC") AC++;
    else if (s[i]=="WA") WA++;
    else if (s[i]=="TLE") TLE++;
    else RE++;
  }
  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;
  
  return 0;
}

Measured memory_bytes: 6012
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <cctype>
#include <iostream>
#include <set>
#include <string>
#include <queue>
#include <map>
using namespace std;
int size(string x){
	string::size_type size=x.size();
	return size;
}
#define fu(l,k) for(int i=l;i<k;i++)
#define fd(l,k) for(int i=l;i>k;i--)
#define fi first
#define se second
typedef  vector<string> vs;
typedef  vector<int> vi;
double pi(){
	return M_PI;
}
typedef set<int> set_i;
typedef set<string> set_s;
int main(){
	int n;
	long long int ans=1;
	cin>>n;
	fd(n,0){
		ans*=i;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1156
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
int n,k;
ll ans=0,kk;
ll a[100010],sa[100010],sb[100010];
int main(){
	scanf("%d%d",&n,&k);
	int i,j;
	sa[0]=0;sb[0]=0;
	for(i=1;i<=n;++i){
		scanf("%lld",&a[i]);
		if(a[i]>0)  sa[i]=sa[i-1]+a[i];
		else  sa[i]=sa[i-1];
		sb[i]=sb[i-1]+a[i];
	}
	for(i=k;i<=n;++i){
		ll xx=sb[i]-sb[i-k],yy=sa[i-k]+sa[n]-sa[i];
		if(xx>0)  yy+=xx;
		ans=max(ans,yy);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>

int main(void){
	int n;
	int bestP, bestD, p, d1,d2;
	
	while (scanf("%d",&n), n){
		bestD = bestP = 0;
		for (int i=0; i<n; i++){
			scanf("%d %d %d", &p, &d1, &d2);
			if (d1+d2 > bestD){
				bestD = d1+d2;
				bestP = p;
			}
		}
		printf("%d %d\n", bestP, bestD);
	}
	return 0;
}

Measured memory_bytes: 1028
n = int(input())
a = [0] * n
x = [[] for i in range(n)]
y = [[] for i in range(n)]
for i in range(n):
  a[i] = int(input())
  for j in range(a[i]):
    d, e = map(int, input().split())
    d -= 1
    x[i].append(d)
    y[i].append(e)
ans = 0
for i in range(2 ** n):
  s = 0
  flag = True
  for j in range(n):
    if not ((i >> j) & 1):
      continue
    else:
      s += 1
      for xx, yy in zip(x[j], y[j]):
        if ((i >> xx) & 1) != yy:
          flag = False
  if flag:
    ans = max(ans, s)

print(ans)


Measured memory_bytes: 43756
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    int n, m; cin >> n >> m;
    rep(i, m) {
        int x; cin >> x;
        n -= x;
    }
    if (n>=0) cout << n << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main() {
    int N;
    int d[110];
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> d[i];
    }

    set<int> values; // insertするときに重複しない
    for(int i=0; i<N; i++){
        values.insert(d[i]);
    }
    cout << values.size() << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
using ll = long long;

int main() {
    ll n,a,b,c,d,e;
    cin >> n;
    vector<ll> can_p(5);
    bool flag = false;
    for (int i=0;i<5;i++){
        cin >> can_p.at(i);
        if(can_p.at(i)==1) flag =1;
    }
    ll nin = 1e16;
    for(int i=0;i<5;i++){
        nin = min(nin,can_p.at(i));
    }
    if(flag) {
        cout << n+4 << endl;
        return 0;
    }
    cout << n/nin+5 << endl;
    
    return 0;
}

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

int main()
{
 int n,ans;
 cin >> n;
 if(n==100000){
 ans=90909;
 }else if(n>=10000){
 ans=909+n-9999;
 }else if(n>=1000){
 ans=909;
 }else if(n>=100){
 ans=9+n-99;
 }else if(n>=10){
 ans=9;
 }else{
 ans=n;
 }
 cout << ans;
  return 0;
}

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

int main() {
   while (1) {
      string s;
      getline(cin, s);
      if (s == ".") break;

      stack<char> stk;
      bool ok = true;
      int n = s.size();
      for (int i = 0; i < n; i++) {
         if (s[i] == '(') stk.push(s[i]);
         if (s[i] == '[') stk.push(s[i]);
         if (s[i] == ')') {
            if (stk.empty() || stk.top() != '(') {
               ok = false;
               break;
            }
            stk.pop();
         }
         if (s[i] == ']') {
            if (stk.empty() || stk.top() != '[') {
               ok = false;
               break;
            }
            stk.pop();
         }
      }
      if (ok && stk.empty()) {
         puts("yes");
      } else {
         puts("no");
      }
   }
}


Measured memory_bytes: 3148
#include <stdio.h>

unsigned long int fib( int n ){
  unsigned long int list[45] = {1, 1};
  for( int i = 2; i <= n; i++ ) list[ i ] = list[ i - 1 ] + list[ i - 2 ];
  return list[ n ];
}

int main( void ){
  int n;
  scanf("%d", &n );
  printf("%d\n", fib( n ) );
  return 0;
}


Measured memory_bytes: 2132
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
static const ll INF=1000000000000000;
ll dat[400005];
ll n;
void init(ll n_){
  n=1;
while(n<n_)n*=2;
  for(ll i=0;i<2*n-1;i++)
    dat[i]=INF;
}
void update(ll k,ll a){
k+=n-1;
  dat[k]=a;
  while(0<k){
  k=(k-1)/2;
    dat[k]=min(dat[2*k+1],dat[2*k+2]);
  }
      }
ll query(ll a,ll b,ll k,ll l,ll r){
if(b<=l || r<=a)
  return INF;
  else if(a<=l && r<=b)
    return dat[k];
  else{
  ll val=query(a,b, 2*k+1,l,(l+r)/2);
    ll var=query(a,b,2*k+2,(l+r)/2,r);
    return min(val,var);
  }
}
ll N,M;
int main(){
 cin>>N>>M;
  init(N);
  vector<pair<pair<ll,ll>,ll>>A(M);
  for(int i=0;i<M;i++){
    ll l,r,c;cin>>l>>r>>c;l--;r--;
    pair<ll,ll>p(r,l);
    pair<pair<ll,ll>,ll>q(p,c);
    A[i]=q;
     }sort(A.begin(),A.end());
  update(0,0);
  for(int i=0;i<M;i++){
  ll r=A[i].first.first;
    ll l=A[i].first.second;
    ll c=A[i].second;
  ll m=query(l,r,0,0,n);
    if(m==INF)
      continue;
    if(m+c<dat[r+n-1])
      update(r,m+c);
  }if(dat[N-1+n-1]<INF)
  cout<<dat[N-1+n-1]<<endl;
  else
    cout<<-1<<endl;
  
 
     return 0;
}


Measured memory_bytes: 7596
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
char mp[501][501];
int main()
{
	int hang,lie;
	cin>>hang>>lie;
	getchar();
	for(int i=1;i<=hang;i++)
	{
		for(int j=1;j<=lie;j++)
		{
			mp[i][j]=getchar();
		}
		getchar();
	}
	for(int i=1;i<=hang;i++)
	{
		if(i%2==0)
		{
			for(int j=1;j<=lie;j++)
		    {
			    if(j==1)cout<<"#";
			    else
			    {
			    	if(mp[i][j]=='#')cout<<"#";
			    	else cout<<".";
				}
		    }
			cout<<endl;
		}
		else
		{
			for(int j=1;j<=lie;j++)
		    {
			    if(j==lie)cout<<".";
			    else cout<<"#";
		    }
			cout<<endl;
		}
	}
	
	cout<<endl;
	
    for(int i=1;i<=hang;i++)
	{
		if(i%2==1)
		{
			for(int j=1;j<=lie;j++)
		    {
			    if(j==lie)cout<<"#";
			    else
			    {
			    	if(mp[i][j]=='#')cout<<"#";
			    	else cout<<".";
				}
		    }
			cout<<endl;
		}
		else
		{
			for(int j=1;j<=lie;j++)
		    {
			    if(j==1)cout<<".";
			    else cout<<"#";
		    }
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
char G[13]={0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
short X, Y;
int main(){
	scanf("%hd%hd", &X, &Y);
	if(G[X]==G[Y]){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
}


Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>

using namespace std;

int N;
int A[100];

void printA() {
  for (int i=0; i<N; i++) {
    if (i > 0) putchar(' ');
    printf("%d", A[i]);
  }
  putchar('\n');
}

int main() {
  scanf("%d", &N);
  for (int i=0; i<N; i++) scanf("%d", &A[i]);
  int sc = 0;
  for (int i=0; i<N; i++) {
    int minI = i;
    for (int j=i; j<N; j++) {
      if (A[j] < A[minI]) minI = j;
    }
    if (i != minI) {
      swap(A[i], A[minI]);
      sc++;
    }
  }
  printA();
  printf("%d\n", sc);
  return 0;
}

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

int main() {
  int N,c,b,d;
  b = 1;
  c = 0;
  d = 0;
  cin >> N;
  vector<int> botan(N);
  for(int i = 0; i < N; i++) {
   cin >> botan.at(i);
  }
  for(int i = 0; i < N; i++) {
    if(botan.at(b - 1) == 2) {
      d++;
      c++;
      break;
    }
    else {
      c++;
      b = botan.at(b - 1);
    }
  }
  if(d == 0) {
    cout << -1 << endl;
  }
  else {
    cout << c << endl;
  }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;

ll MAX = 2*(1e5);

vector<vector<ll>> V(MAX);
vector<ll> C(MAX, 0);
vector<bool> vis(MAX, false);


int dfs(int x){
    for(auto v : V[x]){
        if(!vis[v]) {
            vis[v] = true;
            C[v] += C[x];
            dfs(v);
        }
    }
    return 0;
}

int main(){
    ll N, Q; cin >> N >> Q;

    for(int i = 0; i < N-1; i++){
        ll a, b; cin >> a >> b; a--; b--;
        V[a].push_back(b);
        V[b].push_back(a);
    }
    for(int i = 0; i < Q; i++){
        ll p, x; cin >> p >> x;
        p--;
        C[p]+=x;
    }
    vis[0] = true;
    dfs(0);
    for(int i = 0; i < N; i++) cout << C[i] << " ";
    cout << endl;




}


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

int main(){
	int i, n;
	cin >> n;
	vector<double> v(n);
	for (i = 0; i < n; i++) cin >> v[i];
	sort(v.begin(), v.end());
	double ans = (v[0] + v[1]) / 2.00;
	for (auto p = v.begin() + 2; p != v.end(); p++){
		ans = (ans + *p) / 2.00;
	}
	cout << setprecision(99) << ans << endl;
	return 0;
}


Measured memory_bytes: 256