akhauriyash/Code-Regression huggingface dataset:
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	class Edge {
		int from, to, cost, time;

		public Edge(int from, int to, int cost, int time) {
			// TODO 自動生成されたコンストラクター・スタブ
			this.from = from;
			this.to = to;
			this.cost = cost;
			this.time = time;
		}
	}

	int n, m;
	LinkedList<Edge> edges;

	void solve(int p, int q, int r) {
		int INF = Integer.MAX_VALUE;
		int[] d = new int[m + 1]; // 各駅への最短距離
		for (int i = 0; i < d.length; i++)
			d[i] = INF / 2;
		d[p] = 0;
		while (true) {
			boolean update = false;
			for (Edge e : edges) {
				if (d[e.from] != INF
						&& d[e.to] > d[e.from] + (r == 0 ? e.cost : e.time)) {
					d[e.to] = d[e.from] + (r == 0 ? e.cost : e.time);
					update = true;
				}
			}
			if (!update)
				break;
		}
		System.out.println(d[q]);
	}
	
	int[][] warshall_floyd(int r) {
		int INF = Integer.MAX_VALUE / 2;
		int[][] d = new int[m+1][m+1];
		for(int i=0; i < d.length; i++)
			for(int j=0; j < d[0].length; j++)
				d[i][j] = INF;
		for(Edge e : edges)
			d[e.from][e.to] = (r == 0 ? e.cost : e.time);
		
		for(int k=1; k < m+1; k++)
			for(int i=1; i < m+1; i++)
				for(int j=1; j < m+1; j++)
					d[i][j] = Math.min(d[i][j], d[i][k] + d[k][j]);
		
		return d;
	}

	void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			n = scanner.nextInt();
			m = scanner.nextInt();
			if (n == 0 || m == 0)
				break;
			edges = new LinkedList<Edge>();
			for (int i = 0; i < n; i++) {
				int a = scanner.nextInt();
				int b = scanner.nextInt();
				int cost = scanner.nextInt();
				int time = scanner.nextInt();
				edges.add(new Edge(a, b, cost, time));
				edges.add(new Edge(b, a, cost, time));
			}
			int k = scanner.nextInt();
			if (k == 0)
				return;
			int[][][] d = new int[2][][];
			d[0] = warshall_floyd(0);
			d[1] = warshall_floyd(1);
			for (int i = 0; i < k; i++) {
				int p = scanner.nextInt();
				int q = scanner.nextInt();
				int r = scanner.nextInt();
				System.out.println(d[r][p][q]);
			}
		}
	}

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		new Main().run();
	}

}

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

lis = [int(input()) for i in range(N)]

now = 1
Ans = -1
count = 0

for i in range(len(lis)):
	now = lis[now-1]
	count += 1
	if now == 2:
		Ans = count
		break

print(Ans)
		
	
	

Measured memory_bytes: 7084
#include <bits/stdc++.h>
/**
|||||||||||||       |||||     |||||    ||||||||||
||||||||||||||      |||||     |||||  |||||
|||||     |||||     |||||     |||||  |||||
||||||||||||||||    |||||||||||||||    ||||||||||
|||||||||||||||||   |||||||||||||||           |||||
|||||        |||||  |||||     |||||           |||||
|||||         ||||| |||||     |||||    ||||||||||
AHMED;HASSAN;SAEED;
*/

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    int ans=0;
    int t;
    cin>>t;
    ans+=t;
    for(int i=1;i<n-1;i++){
        int pvt=t;
        cin>>t;
        ans+=(min(t,pvt));
    }
    ans+=t;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
s = list(input())
if len(s) % 2 != 0:
    s.pop(-1)

l = len(s) // 2 - 1
while True:
    t = 0
    for i in range(l):
        if s[i] == s[l + i]:
            t += 1
    if t == l:
        print(t * 2)
        exit(0)
    else:
        l -= 1

Measured memory_bytes: 9124
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

int n;
int t[110];
int m, p, x;

int main() {
	cin >> n;
	REP(i, n) {
		cin >> t[i];
	}
	cin >> m;
	REP(i, m) {
		int sum = 0;
		cin >> p >> x;
		p--;
		REP(j, n) {
			if (j == p) sum += x;
			else sum += t[j];
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 256
#include <cassert>
#include <map>
#include <iostream>

using namespace std;
long long modexp(int x, long long e, int m) {
    long long ans = 1, p = x % m;
    while (e > 0) {
        if (e % 2 != 0) ans = (ans * p) % m;
        p = (p * p) % m;
        e >>= 1;
    }
    return ans;
}

long long gcd(long long a, long long b) {
    if (a < 0) a = -a;
    if (b < 0) b = -b;
    if (a < b) swap(a, b);
    while (b > 0) { long long t = a; a = b; b = t % b; }
    return a;
}

int main() {
    int n; cin >> n;
    map<pair<long long, long long>, pair<int, int> > mp;
    int z = 0;
    for (int i = 0; i < n; i++) {
        long long a, b; cin >> a >> b;
        if (a == 0 && b == 0) { z++; continue; }
        if (a < 0) { a = -a; b = -b; }
        assert (a >= 0);
        if (a == 0 && b < 0) b = -b;
        bool pos = b > 0;
        if (b <= 0) { long long tmp = a; a = -b; b = tmp; }
        long long g = gcd(a, b);
        a /= g;
        b /= g;
        // cerr << a << " " << b << endl;
        if (pos) mp[{a, b}].first++;
        else mp[{a, b}].second++;
    }
    long long ans = 1;
    const int M = 1000000007;
    for (auto x : mp) {
        int s = x.second.first, t = x.second.second;
        ans = ans * (modexp(2, s, M) + modexp(2, t, M) - 1) % M;
    }
    ans = ((ans + z - 1) % M + M) % M;
    cout << ans << endl;
}


Measured memory_bytes: 16024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		String s = sc.next();
		String t = sc.next();
		String a="";
		for( int i = 0; i < n; i++) {
			a += (char)s.charAt(i);
			a += (char)t.charAt(i);
		}
		System.out.println(a);
	}
}


Measured memory_bytes: 21844
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int M; cin >> M;
    cout << 24+(24-M) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
const ll mx=1e18;
map<ll,ll>mp;
ll a,b,c,d;
ll solve(ll n){
    if(n==1) return d;
    if(n==0) return 0;
    ll l1,l2,l3,r1,r2,r3;
    if(mp.count(n)) return mp[n];
    l1=n/2;
    r1=(n+1)/2;
    l2=n/3;
    r2=(n+2)/3;
    l3=n/5;
    r3=(n+4)/5;
    ll res=1e18;
    if(n<mx/d) res=n*d;
    res=min(res,solve(l1)+(n-l1*2)*d+a);
    res=min(res,solve(r1)+(r1*2-n)*d+a);
    res=min(res,solve(l2)+(n-l2*3)*d+b);
    res=min(res,solve(r2)+(r2*3-n)*d+b);
    res=min(res,solve(l3)+(n-l3*5)*d+c);
    res=min(res,solve(r3)+(r3*5-n)*d+c);
    return mp[n]=res;
}
int main(){
    int t;
    cin>>t;
    while(t--){
       ll n;
       mp.clear();
       cin>>n>>a>>b>>c>>d;
       cout<<solve(n)<<'\n';
    }
}



Measured memory_bytes: 4340
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <iomanip>
using namespace std;
int main ()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n,m;
	scanf("%d%d",&n,&m);
	n*=m;
	if(n%2==0) printf("Even\n");
	else printf("Odd\n");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a, b, c, d;

	scanf("%d%d%d%d", &a, &b, &c, &d);

	if (a + b > c + d)printf("Left\n");
	else if (a + b < c + d)printf("Right\n");
	else printf("Balanced\n");

	return 0;
}

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

vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

int main() {
    long long N;
    cin >> N;
    int ans = 0;
    for(int i = 1; i <= N; i += 2) {
        if(enum_divisors(i).size() == 8) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define maxn 111
int n, x, ans;
int a[maxn];
int main() {
	scanf("%d%d", &n, &x);
	for (int i = 0; i < n; i++) scanf("%d", a + i);
	std::sort(a, a + n);
	for (int i = 0; i < n; i++) {
		if (x >= a[i]) x -= a[i], ans++;
		else break;
	}
	if (x && ans == n) ans--;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define rep1(i,n) for(int i=1; i<(int)n; i++)
#define repa(i,a,n) for(int i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
#define COUT(x) cout<<(x)<<endl
#define YES(x) cout<<(x?"YES":"NO")<<endl
#define Yes(x) cout<<(x?"Yes":"No")<<endl
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a / gcd(a, b)*b;}
//cout << fixed << setprecision(15);
int N, M, K, H, W, L, R, X;
string S, T;

signed main(){
  int r, D, x;
  cin >> r >> D >> x;
  rep(i,10){
    x = r*x - D;
    COUT(x);
  }
  return 0;

}

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

int main()
{
    int A, B;
    cin >> A >> B;

    int tap = 0;
    int sum = 1;
    while (sum < B) {
        tap++;
        sum += A - 1;
    }

    cout << tap << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     9e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define print(a)                cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define SS                      stringstream
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

ll poww(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD) { return powm(a, m-2, m);}

int main()
{
	fastIO
	ll n,r;
	cin>>r>>n;
	cout<<max(n,(n+100*(10-r)));
	return 0;
}


Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception{
		new Main(new Scanner(System.in), System.out, System.err).exec();
	}
	public final Scanner sc;
	public final PrintStream out, err;
	public Main(final Scanner sc, final PrintStream out, final PrintStream err) {
		this.sc = sc;this.out = out;this.err = err;
	}
	static public final long pair(int a, int b) {return (((long)a) << 32) + b;}
	static public final int getPair1(long v) {return (int)(v >> 32);}
	static public final int getPari2(long v) {return (int)(v & 0xFFFFFFFF);}

	static public final long quad(long a, long b, long c, long d) {
		return ((a&0xFFFF)<< 48) + ((b&0xFFFF)<< 32) + ((c&0xFFFF)<< 16) +(d&0xFFFF);}
	static public final int getQuad1(long v) {return (int)( v >> 48          );}
	static public final int getQuad2(long v) {return (int)((v >> 32) & 0xFFFF);}
	static public final int getQuad3(long v) {return (int)((v >> 16) & 0xFFFF);}
	static public final int getQuad4(long v) {return (int)( v        & 0xFFFF);}

	static public final long record(int e, int m, int i) {
		return quad(-1, e, m, i);
	}
	static public final int re(long record) {
		return getQuad2(record);
	}
	static public final int rm(long record) {
		return getQuad3(record);
	}
	static public final int ri(long record) {
		return getQuad4(record);
	}

	//------------------------------------------

	private int p;
	private int[] inv;
	private int[] fact;
	private int[] finv;
	public final int mod(long v) {
		v %= p;
		return (int)(v < 0 ? v+p : v);
	}
	public final int mul(long a, long b) {
		return mod(a*b);
	}
	public final void initFact(double limit, double p) {
		initFact((int)limit, (int)p);
	}
	public final void initFact(int limit, int p) {
		this.p = p;
		this.inv = new int[limit+1];
		this.fact = new int[limit+1];
		this.finv = new int[limit+1];
		fact[1] = finv[1] = inv[0] = inv[1] = 1;
		for(int i=2;i<=limit;i++) {
			int a = p / i;
			int b = p % i;
			inv[i]  = mul(-a, inv[b]);
			fact[i] = mul(fact[i-1], i);
			finv[i] = mul(finv[i-1], inv[i]);
		}
	}
	public final int comb(int m, int n) {
		return mul(mul(fact[m], finv[n]), finv[m-n]);
	}
	//------------------------------------------
	static long lcm (long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return (long)(c/b);
	}

	//------------------------------------------



	public void exec() throws Exception{
		final int N = sc.nextInt();
		final int M = sc.nextInt();
		if(N==M) {
			out.println("Yes");
		}else {
			out.println("No");
		}

	}
}


Measured memory_bytes: 23636
/* winners never quit and quitters never win.
      #swap                                 */
      
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;
const ld PI = 3.141592653589793;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

template <typename T>
void make_unique(vector<T>& vec) {
  sort(all(vec));
  vec.erase(unique(all(vec)), vec.end());
}

#define endl '\n'
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";

#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...);
}

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)


ll nxt() {
    ll TemporaryVariable;
    cin >> TemporaryVariable;
    return TemporaryVariable;
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    string s;
    cin>>s;
    rep(a,0,3)
        cout<<s[a];
    cout<<endl;
	printclock;
	return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
char a[100010];
ll mem[100010][2], mod=1e9+7, n;
ll dp(int x, int l)
{
    if(x==n)
    {
        return 1;
    }
    if(mem[x][l]!=-1)
        return mem[x][l];
    ll res=0;
    if(a[x]=='1' || l)
    {
        res=2*dp(x+1, l);
        res+=dp(x+1, 1);
    }
    else
    {
        res=dp(x+1, 0);
    }
    res%=mod;
    mem[x][l]=res;
    return res;
}
int main()
{
    scanf("%s",a);
    ll ans=0;
    n=strlen(a);
    memset(mem, -1, sizeof mem);
    ans=dp(0, 0);
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 6528
#include <iostream>/*{{{*/
#include <bits/stdc++.h>
#define REP(i, x) for(int i = 0; i < (int)(x); i++)
#define REPS(i,x) for(int i = 1; i <= (int)(x); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x,y) memset(x,y,sizeof(x))
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define PB(a) push_back(a)
#define debug(x) cerr << __LINE__ << ": " << #x << " -> " << x << '\n'
#define INF 999999999
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};/*}}}*/

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,x;
  cin>>a>>b>>c>>x;

  int res=0;
  REP(i,a+1){
    REP(j,b+1){
      REP(k,c+1){
        if ((i*500) + (j*100) + (k*50)==x){
          ++res;
        }
      }
    }
  }

  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
m = int(input())

ans = m
flag = False
for _ in range(n):
    a, b = map(int, input().split())
    if flag:
        continue
    m += a - b
    if m < 0:
        flag = True
        continue
    if m > ans:
        ans = m

if not flag:
    print(ans)
else:
    print(0)



Measured memory_bytes: 5612
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#define INF 1000000013
using namespace std;
typedef long long ll;
ll mod=1e9+7;
double dp[310][310][310];

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      for(int k=0;k<=n;k++){
        if(i==0&&j==0&&k==0) continue;
        double x=i+j+k;
        dp[i][j][k]+=(double)n/x;
        if(i!=0) dp[i][j][k]+=dp[i-1][j+1][k]*(double)i/x;
        if(j!=0) dp[i][j][k]+=dp[i][j-1][k+1]*(double)j/x;
        if(k!=0) dp[i][j][k]+=dp[i][j][k-1]*(double)k/x;
      }
    }
  }
  int ic=0,jc=0,kc=0;
  for(int i=0;i<n;i++){
    if(a[i]==3) ic++;
    else if(a[i]==2) jc++;
    else if(a[i]==1) kc++;
  }
  cout << fixed << setprecision(15) << dp[ic][jc][kc] << endl;
}

Measured memory_bytes: 227584
//============================================================================
// Name        : svdzva.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
using namespace std;
int main() {
	while (true) {
		int n, play1 = 0, play2 = 0, card1[10000], card2[10000];
		cin >> n;
		if (n == 0)
			break;
		for (int i = 0; i < n; i++) {
			cin >> card1[i] >> card2[i];
			if (card1[i] > card2[i]) {
				play1 = play1 + card1[i] + card2[i];
			} else if (card1[i] < card2[i]) {
				play2 = play2 + card2[i] + card1[i];
			} else {
				play1 = play1 + card1[i];
				play2 = play2 + card2[i];
			}
		}
		cout << play1 <<" "<<play2 << endl;
	}
	return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
const int Max_N=1e5;
int N;
char A[Max_N+10]={};
int main(){
	scanf("%d",&N);
	scanf("%s",A+1);
	int Ans=1;
	for(int i=2;i<=N;i++)
	 if(A[i]!=A[i-1]) ++Ans;
	printf("%d\n",N?Ans:0);
	return 0;
}

Measured memory_bytes: 384
g,p,win,lose=0,0,0,0
gets.chomp.chars.each do |c|
    case c
    when "g"
        if(g > p)
            p += 1
            win += 1
        else
            g += 1
        end
    when "p"
        if(g > p)
            p += 1
        else
            lose += 1
            g += 1
        end
    end
end
p (win - lose)

Measured memory_bytes: 6908
#include <iostream>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int S; cin >> S;
  int a = S/100, b = S%100;
  string ans;
  if (1<=a && a<=12){
    if (1<=b && b<=12)
      ans = "AMBIGUOUS";
    else
      ans = "MMYY";
  }else if (1<=b && b<=12)
    ans = "YYMM";
  else
    ans = "NA";
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    
    if(b == 1){
        cout << 0 << endl;
        return 0;
    }
    
    int ans = 0;
    int temp = 0;
    while(temp < b){
        if(temp == 0){
            temp += a;
        }
        else{
            temp += a - 1;
        }
        
        ++ans;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  if(((n-1)&n) === 0)return "No";
  console.log("Yes");
  var ans = ["1 2"];
  ans.push("1 3");
  ans.push("2 "+(n+3));
  ans.push("3 "+(n+2));
  ans.push((n+1)+" "+(n+3));
  for(var i = 4; i < n; i+=2){
    ans.push(1+" "+i);
    ans.push(1+" "+(i+1));
    ans.push((n+i+1)+" "+i);
    ans.push((n+i)+" "+(i+1));
  }
  if(n%2 === 0){
    var t = n-1;
    ans.push(t+" "+n);
    ans.push(((t-1)^n)+" "+n*2);
  }
  return ans.join("\n");
}

Measured memory_bytes: 51788
n,c,k=map(int,input().split())
s=[]
for i in range(n):
    s.append(int(input()))
s.sort()
ans=1
count=0
a=s[0]
for i in range(n):
    if s[i]-a>k:
        a=s[i]
        count=1
        ans+=1
    else:
        count+=1
    if count==c:
        if i!=n-1:
            count=0
            ans+=1
            a=s[i+1]
    #print(a,count,ans)
print(ans)

Measured memory_bytes: 50392
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;



#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll ,ll> pll;
const int maxn = 1e6 + 120;
 



int a ,b ,c ,x ,y ,res;

int main(){FAST;
    cin >> a >> b >> c >> x >> y;
    c *= 2;
    int minx = min(x ,y);
    if(c  <= a + b)
        res += minx * c,    x -= minx ,y -= minx;

    int val = min(a ,c);
        res += val * x;
    val = min(b ,c);
        res += y * val;

    out(res);
   return 0;
}
 












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

int main(int argc, char* argv[]) {
  vector<int> v;
  int hoge;

  cin >> hoge;
  while(hoge != 0){
    v.push_back(hoge);
    cin >> hoge;
  }

  for(int i = 0 ; i < v.size() ; i++){
    cout << "Case " << i+1 << ": " << v.at(i) << endl;
  }


  return 0;
}

Measured memory_bytes: 1320
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import Data.Bool
import Data.Maybe

main :: IO ()
main = do
  [a,b,x] <- readInts
  print . showAnswer $ solve (a,b,x)

type Input  = (Int, Int, Int)
type Output = Bool

solve :: Input -> Output
solve (a,b,x)
  | c < 0 = False
  | otherwise = c < b
  where
    c = x-a

showAnswer :: Output -> Answer
showAnswer = YESNO

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

data Answer
  = YesNo Bool
  | YESNO Bool
  | AB Bool
  | Number Int
  | String String
  | Compare Ordering
  | Compare2 Ordering

instance Show Answer where
  show (YesNo b)    = bool "No" "Yes" b
  show (YESNO b)    = bool "NO" "YES" b
  show (AB b)       = bool "B"  "A" b
  show (Number i)   = show i
  show (String s)   = s
  show (Compare o)  = ordering "<" "=" ">" o
  show (Compare2 o) = ordering "Right" "Balanced" "Left" o

ordering :: a -> a -> a -> Ordering -> a
ordering lt eq gt o = case o of
  LT -> lt
  EQ -> eq
  GT -> gt

Measured memory_bytes: 380
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
	ll N;
	cin >> N;
	map<ll, ll> m;
	string ans = "YES";
	for (ll i = 0; i < N; i++)
	{
		ll temp;
		cin >> temp;
		m[temp]++;
	}
	ll M;
	cin >> M;
	for (ll i = 0; i < M; i++)
	{
		ll temp;
		cin >> temp;
		if (m[temp] == 0) {
			ans = "NO";
			break;
		}
		--m[temp];
	}
	cout << ans;
	return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			char[] s = in.nextString().toCharArray();
			int n = s.length;

			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < n; i++) {
				if (s[i] == '9') {
					sb.append("1");
				} else if (s[i] == '1') {
					sb.append("9");
				}
			}

			out.println(sb.toString());

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

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

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public int[] nextIntArray1Index(int n) {
			int[] res = new int[n + 1];
			for (int i = 0; i < n; i++) {
				res[i + 1] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public long[] nextLongArray1Index(int n) {
			long[] res = new long[n + 1];
			for (int i = 0; i < n; i++) {
				res[i + 1] = nextLong();
			}
			return res;
		}

		public double[] nextDoubleArray(int n) {
			double[] res = new double[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextDouble();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) int(a.size())
const int N=2e5+10;

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,to[N<<1],nxt[N<<1],d[N],ww[N<<1],tt=1,col[N],h[N],m;
bool vis[N];

void adde(int u,int v) {
	to[++tt]=v;nxt[tt]=h[u];h[u]=tt;
	to[++tt]=u;nxt[tt]=h[v];h[v]=tt;
}

void dfs(int u,int c=0) {
	col[u]=c;vis[u]=1;
	for(int i=h[u],v;v=to[i],i;i=nxt[i])
		if(~ww[i]&&!vis[v]) dfs(v,c^1);
}

int main() {
	memset(ww,-1,sizeof(ww));
	cin>>n>>m;
	for(int i=1;i<=n;i++) d[i]=gi();
	for(int i=1,u,v;i<=m;i++) u=gi(),v=gi(),adde(u,v);
	for(int u=1;u<=n;u++) {
		pii mn=mp(2e9,0);int e=0;
		for(int i=h[u],v;v=to[i],i;i=nxt[i])
			if(mp(d[v],v)<mn) mn=mp(d[v],v),e=i>>1;
		if(mn.fi>d[u]) return cout<<-1,0;
		if(e) ww[e<<1]=ww[e<<1|1]=d[u];
	}
	for(int i=1;i<=n;i++) if(!vis[i]) dfs(i);
	for(int i=1;i<=n;i++) putchar(col[i]?'W':'B');
	cout<<'\n';
	for(int i=1;i<=m;i++) {
		if(!~ww[i<<1]) ww[i<<1]=1e9;
		cout<<ww[i<<1]<<'\n';
	}
	return 0;
}


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

#define ll long long

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int x;
    cin >> x;
    
    long long ans = 0;
    ans += (x / 500) * 1000;
    x %= 500;
    
    ans += (x / 5) * 5;
    
    cout << ans << "\n";
    
    return 0;
}

// scanf("%d %d", &a, &b)
// printf("%d %d", 123, 456);

// getline(cin, s)
// while (cin >> x) {...} - read unknown data

// vector. vector[i],
// set. insert(), contains == set.find(x) != set.end(), size_t size() or count(x) 
// map. contains == count(x) ?


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <vector>
#include <utility>

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

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

template<typename T> void swap(T &x, T &y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T &a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T &a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, k;
std::vector<int> vec[100000];
std::pair<int, int> range[100000];
bool has_val[100000];

void prod(int x, int y) {
	auto & xp = range[x];
	auto   yp = range[y];
	if(has_val[x] && has_val[y] && (xp.first - yp.first) % 2 == 0) { xp = std::make_pair(2, 0); return; }
	if(has_val[y]) {
		has_val[x] = true;
		xp = std::make_pair( max(xp.first, yp.first - 1), min(xp.second, yp.second + 1) );
	}
}

void dfs(int node, int pre) {
	if(pre != -1) { prod(node, pre); }
	for(auto && i : vec[node]) {
		if(i != pre) {
			dfs(i, node);
			prod(node, i);
		}
	}
}

int main() {
	scanf("%d", &n);
	inc(i, n - 1) {
		int a, b;
		scanf("%d%d", &a, &b);
		a--; b--;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	scanf("%d", &k);
	inc(i, n) { range[i] = std::make_pair(-2000000, 3000000); }
	inc(j, k) {
		int v, p;
		scanf("%d%d", &v, &p);
		v--;
		range[v] = std::make_pair(p, p);
		has_val[v] = true;
	}
	
	dfs(0, -1);
	dfs(0, -1); // 念のためもう一回
	
	bool flag = true;
	inc(i, n) {
		if(range[i].first > range[i].second) { flag = false; break; }
	}
	
	printf("%s\n", flag ? "Yes" : "No");
	if(flag) { inc(i, n) { printf("%d\n", range[i].first); } }
	
	return 0;
}


Measured memory_bytes: 11904
h, w = map(int, input().split())
a = []
for i in range(h):
    a.append(list(input()))
for i in range(h - 1, -1, -1):
    if a[i] == ["."] * w:
        del a[i]
for i in range(w - 1, -1, -1):
    if [a[j][i] for j in range(len(a))] == ["."] * len(a):
        for j in range(len(a)):
            del a[j][i]
for i in range(len(a)):
    print("".join(a[i]))

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    public static int n, m, q;
    public static int[][] arr;
    public static int max;
    static void solve(InputReader in, PrintWriter out){
        n = in.ni();
        m = in.ni();
        q = in.ni();
        max = 0;
        arr = new int[q][4];
        for (int i = 0; i < q; i++) arr[i] = in.ni(4);
        int[] a = new int[n];
        for (int i = 1; i <= m; i++) {
            a[0] = i;
            dfs(a, 1);
        }
        out.println(max);
    }
    public static void dfs(int[] a, int sum){
        if(sum==n){
            int res = 0;
            for (int i = 0; i < q; i++) {
                if(a[arr[i][1]-1]-a[arr[i][0]-1]==arr[i][2]) res += arr[i][3];
            }
            max = Math.max(max, res);
        }else{
            int[] b;
            for (int i = a[sum-1]; i <= m; i++) {
                b = Arrays.copyOf(a, n);
                b[sum] = i;
                dfs(b, sum+1);
            }
        }
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 44172
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    string str;
    cin >> str;
    int cnt = 0;
    rep(i,n-2){
        if(str[i] == 'A' && str[i+1] == 'B' && str[i+2] == 'C'){
            cnt++;
        }
    }

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

Measured memory_bytes: 256
matrix = [0]*3
for i in range(3):
    matrix[i] = [int(j) for j in input().split()]
for a1 in range(101):
    for b1 in range(101):
        a2 = matrix[1][0]-b1
        a3 = matrix[2][0]-b1
        b2 = matrix[0][1]-a1
        b3 = matrix[0][2]-a1
        if matrix[1][1]==a2+b2 and matrix[1][2]==a2+b3 and matrix[2][1]== a3+b2 and matrix[2][2] == a3+b3:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

using Data = pair<LL,vector<int>>;
int main(){
    vector<LL> N(3);    // A,B,Cのイテレータ
    int K;
    rep(i,3)cin >> N[i];cin >> K;
    vector<vector<LL>> v(3);        // A,B,Cの入力
    rep(iter,3){
        v[iter].resize(N[iter]);            // resize
        rep(i,N[iter])cin >> v[iter][i];    // 入力
        sort(rall(v[iter]));                // 入力されたデータを降順にソート
    }
    priority_queue<Data> que;               // 和と現在のA,B,Cのindex
    set<Data> se;                           // 順序付き集合
    que.push(Data(v[0][0] + v[1][0] + v[2][0],vector<int>({0,0,0})));   // answer  の初期値というか、最大値、先頭
    rep(k,K){
        auto c = que.top();que.pop();
        cout << c.first << endl;

        // 次の三候補
        rep(iter,3){
            if(c.second[iter] + 1 < N[iter]){   // A,B,Cのうち、一つの順番を遅らせている。  この時、iter＋１が存在するかどうかを判定している。
                LL sum = c.first - v[iter][c.second[iter]] + v[iter][c.second[iter] + 1];   // c.firstはこの時前回の和 から　選んだイテレータの（つまりABCのいずれか）値を引いて、1つ進めたものを足してる。
                auto num = c.second; num[iter]++;      //　indexリストを更新
                auto d = Data(sum,num);                //  計算結果をData型にしている。

                // すでにpushされたもの以外
                if(!se.count(d)) se.insert(d),que.push(d);      //  順序も全く同じものが混入する恐れがあるので、一応チェックしてから追加している。
            }
        }
    }
}

// count(値) は、順序付集合に含まれる指定値の数を返す。set は重複を許さないので、0 または 1 を返す。 
// 処理時間は O(log N) である。

// 順序付集合にデータを追加するときは insert(値) を使用する。 
// 値は、ソートされた位置に挿入される。 
// なので、push_back(値) や push_front(値) は無い。挿入する位置を指定するのは無意味だからだ。

// けんちょんさんのコードそのまま

Measured memory_bytes: 1408
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int T = sc.nextInt();
		int[] a = new int[T];
		for(int i=0; i<T; i++)
			a[i] = sc.nextInt();
		
		Arrays.sort(a);
		
		System.out.println(Math.max(a[T-1]-(K-a[T-1])-1,0));
		
		sc.close();
	}
}


Measured memory_bytes: 9808
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();

		int cnt = 0;
		for (int i=0; i<=A; i++) {
			for (int j=0; j<=B; j++) {
				for (int k=0; k<=C; k++) {
					int cal = ((500 * i) + (100 * j) + (50 * k));
					if ( cal == X ) cnt++;
				}
			}
		}

		System.out.println(cnt);

	}

}


Measured memory_bytes: 23892
import sys

def main():
  input = sys.stdin.readline
  N, M = map(int, input().split())
  ppp = []
  ppm = []
  pmp = []
  pmm = []
  mpp = []
  mpm = []
  mmp = []
  mmm = []
  for _ in range(N):
    x, y, z = map(int, input().split())
    ppp.append(x+y+z)
    ppm.append(x+y-z)
    pmp.append(x-y+z)
    pmm.append(x-y-z)
    mpp.append(-x+y+z)
    mpm.append(-x+y-z)
    mmp.append(-x-y+z)
    mmm.append(-x-y-z)
  ppp = sorted(ppp, key=lambda x:-x)
  ppm = sorted(ppm, key=lambda x:-x)
  pmp = sorted(pmp, key=lambda x:-x)
  pmm = sorted(pmm, key=lambda x:-x)
  mpp = sorted(mpp, key=lambda x:-x)
  mpm = sorted(mpm, key=lambda x:-x)
  mmp = sorted(mmp, key=lambda x:-x)
  mmm = sorted(mmm, key=lambda x:-x)

  ans = max(sum(ppp[:M]), sum(ppm[:M]), sum(pmp[:M]), sum(pmm[:M]),
            sum(mpp[:M]), sum(mpm[:M]), sum(mmp[:M]), sum(mmm[:M]))
  print(ans)


if __name__ == '__main__':
  main()


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

#if __has_include(<local.h>)
#include <local.h>
#endif

using namespace std;

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())
#define ALL(x) (x).begin(),(x).end()

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define IPOW(x,y) LL(pow(x,y))

//Debug
#ifdef LOCAL_H
#define TEST cout << "OK\n"
#define DEBUG(a) a
#else
#define TEST
#define DEBUG(a)
#endif

#ifdef LOCAL_H
[[maybe_unused]]
#endif
const double PI = M_PI;
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const int INF = int(999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const long long MOD = int(1000000007);

//Settings
#ifdef LOCAL_H
const bool DO_BENCHMARK = true;
#endif
const int DOUBLE_ACCURACY = 15;

#ifndef LOCAL_H
    const bool DO_BENCHMARK = false;
#endif

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    void solve();
    if(DO_BENCHMARK){
        clock_t clock_start = clock();
        solve();
        clock_t clock_end = clock();
        const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
        cout << "\n" << time << "[ms]\n";
    }
    else solve();
}

/************************************************************************************************************************************************/

void solve(){
    int N;
    cin >> N;
    vector<int> vec (N);
    for(int i = 0;i < N;i++){
        cin >> vec[i];
        if(vec[i] % 2 == 0){
            if(vec[i] % 3 != 0 && vec[i] % 5 != 0){
                cout << "DENIED" << endl;
                ED;
            }
        }
    }
    cout << "APPROVED" << endl;

}


Measured memory_bytes: 256