akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

int main() {
	int i, j, k;
	long n, x[200001] = { 0 }, x2[200001] = { 0 }, sum = 0;



	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> x[i];
		x2[i] = x[i];
		sum += x[i];
	}

	sort(x2, x2 + 200001, greater<long>());

	/*
	for (i = 0; i < n; i++) {

		cout << "x2->" << x2[i] << endl;
	}
	*/

	int tyu = n / 2 - 1;

	for (i = 0; i < n; i++) {
		long bb = x[i];
		long ans = x2[tyu];
		if (ans == bb) {
			ans = x2[tyu + 1];
		}
		else if(ans < bb){
			ans = x2[tyu + 1];

		}

		cout << ans << endl;

	}








	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 5376
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    String s = sc.next();
    String t = sc.next();
    pw.println(t + s);
  }
}


Measured memory_bytes: 21844
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
#include<iomanip>

using namespace std;
using ll = long long;
int n;
vector<ll> a;
vector<vector<vector<ll>>> memo;

ll recv(int i, int j, int k) {
    if (i == j) return 0;
    if (memo[i][j][k] != -1) return memo[i][j][k];
    ll ans;
    int nk = k == 0 ? 1 : 0;
    if (k == 0) {
        ans = max(
            recv(i + 1, j, nk) + a[i],
            recv(i, j - 1, nk) + a[j - 1]
        );
    } else {
        ans = min(
            recv(i + 1, j, nk) - a[i],
            recv(i, j - 1, nk) - a[j - 1]
        );
    }
    memo[i][j][k] = ans;
    return ans;
}

int main()
{
    cin >> n;
    a.resize(n);
    memo = vector<vector<vector<ll>>>(n + 1, vector<vector<ll>>(n + 1, vector<ll>(2, -1)));
    REP(i, n) {
        cin >> a[i];
    }
    cout << recv(0, n, 0) << endl;

    // REP(i, n + 1) {
    //     REP(j, n + 1) {
    //         cout << setw(5) << memo[i][j][0] << " ";
    //     }
    //     cout << endl;
    // }
    // cout << endl;
    // REP(i, n + 1) {
    //     REP(j, n + 1) {
    //         cout << setw(5) << memo[i][j][1] << " ";
    //     }
    //     cout << endl;
    // }
}


Measured memory_bytes: 493440
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pii pair <int, int>
#define F first
#define S second
#define ll long long
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define M_PI 3.14159265358979323846
const int N = 200005;
const int mod = 1e9 + 7;
int main() {
    io;
    int n, x[N], y[N], imn, imx;
    ll mx = 0, mn = INT_MAX;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i];
        if(x[i] + y[i] > mx){
            mx = x[i] + y[i];
            imx = i;
        }
        if(x[i] + y[i] < mn){
            mn = x[i] + y[i];
            imn = i;
        }
    }
    ll ans1 = abs(x[imn] - x[imx]) + abs(y[imn] - y[imx]);
    mx = 0, mn = INT_MAX;
    for(int i = 0; i < n; i++){
        x[i] *= -1;
        if(x[i] + y[i] > mx){
            mx = x[i] + y[i];
            imx = i;
        }
        if(x[i] + y[i] < mn){
            mn = x[i] + y[i];
            imn = i;
        }
    }
    ll ans2 = abs(x[imn] - x[imx]) + abs(y[imn] - y[imx]);
    cout << max(ans1, ans2);
}


Measured memory_bytes: 5212
#include <bits/stdc++.h>
#define PB push_back
#define FST first
#define SCD second
#define modp 1000000007
#define MODP 1000000
#define EPS 1e-7
#define INF 0x3f3f3f3f
#define MAX2 113
#define MAX3 5013
#define MAX4 10013
#define MAX5 100013
#define MAX6 2000013
#define MAXN 100013
#define MANX MAXN
using namespace std;
typedef long long LL;
typedef unsigned int UI;
const UI tb[32] = {13, 0, 27, 1, 28, 18, 23, 2, 29, 21, 19, 12, 24, 9, 14, 3, 30, 26, 17, 22, 20, 11, 8, 13, 25, 16, 10, 7, 15, 6, 5, 4};
#define LOG(x) tb[(UI(x) * (UI)263572066) >> 27]
typedef pair<int,int> PA;
typedef pair<PA,PA> PF;
typedef pair<double,double> PAf;

int n,m,tot;

struct E
{
    int a, nxt;
    // E(){}
    // E(int x, int y, int z) : a(x), nxt(y), c(z) {}
};

char s[MAX5];


int main()
{
#ifndef ONLINE_JUDGE
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#endif
    int TT = 1;
    // scanf("%d",&TT);
    for (int ci=1;ci<=TT;++ci) {
    // while (scanf("%d", &n)!=EOF) {
        // scanf("%d", &n);
        scanf("%s", s);
        n = strlen(s);
        char k = s[n>>1];
        int i,j, ans = n>>1;
        if (n&1) i = j = (n>>1);
        else i = n>>1, j = n-1>>1;
        while (i<n&&j>=0&&s[i]==k&&s[j]==k) {
            ++ans;
            ++i;
            --j;
        }
        cout<<ans<<endl;
    }
    return 0;
}

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

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

typedef long long ll;

ll k;
ll a[50];

int main(){
    cin >> k;

    ll m = (k + 49) / 50;
    rep(i, 50){
        a[i] = 49 + m;
    }
    rep(i, m * 50 - k){
        rep(j, 50){
            if(j == i){
                a[j] -= 50;
            }
            else{
                ++a[j];
            }
        }
    }

    cout << 50 << endl;
    rep(i, 50){
        cout << (i ? " " : "") << a[i];
    }
    cout << endl;
    return 0;
}

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

using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

typedef long long LL;
typedef vector<int> VI;

typedef pair<int, int> P;

int main() {
  string s, t;
  cin >> s >> t;
  set<char> sset;
  set<char> tset;
  for (int i = 0; i < s.length(); i++) {
    sset.insert(s[i]);
  }
  for (int i = 0; i < t.length(); i++) {
    tset.insert(t[i]);
  }
  for (auto x : tset) {
    auto it = sset.find(x);
    if (it == sset.end()) {
      cout << -1 << endl;
      return 0;
    }
  }
  unordered_map<char, vector<int>> mp;
  for (int i = 0; i < s.length(); i++) {
    mp[s[i]].push_back(i);
  }
  vector<P> dp(t.length());

  dp[0] = P(1, mp[t[0]][0]);

  for (int i = 1; i < t.length(); i++) {
    P prev = dp[i-1];
    auto it = upper_bound(mp[t[i]].begin(), mp[t[i]].end(), prev.second);
    P next;
    if (it == mp[t[i]].end()) {
      next = P(prev.first+1, mp[t[i]][0]);
    } else {
      next = P(prev.first, *it);
    }
    dp[i] = next;
  }
  P last = dp[t.length()-1];
  cout << (last.first-1)*s.length() + last.second + 1 << endl;
  return 0;
}


Measured memory_bytes: 1852
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long x = sc.nextLong();
    long[] a = new long[N];
    for(int i = 0; i < N; i++) {
      a[i] = sc.nextLong();
    }
    long count = 0;
    for(int i = 0; i < N - 1; i++) {
      if(a[i] + a[i + 1] > x) {
          count += (a[i] + a[i + 1] - x);
        if(a[i] > x) {
          a[i + 1] = 0;
        } else {
          a[i + 1] = (x - a[i]);
        }
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 53112
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Map<Integer, Integer> ele = new HashMap<Integer, Integer>();
		Set<Integer> idx = new HashSet<Integer>();
		int[][] bingo = {{0, 1, 2},{3, 4, 5}, {6, 7, 8}, {0, 3, 6}, {1, 4, 7}, {2, 5, 8}, {0, 4, 8}, {2, 4, 6}};
		boolean bf = false;

		Scanner sc = new Scanner(System.in);

		for(int i = 0; i < 9; i++) {
			ele.put(sc.nextInt(), i);
		}

		int n = sc.nextInt();

		for(int i = 0; i < n; i++) {
			int num = sc.nextInt();
			if(ele.containsKey(num)) idx.add(ele.get(num));
		}

		for(int[] ns : bingo) {
			for(int i = 0; i < ns.length; i++) {
				if(!idx.contains(ns[i])) break;
				if(i == 2) bf = true;
			}
			if(bf) break;
		}

		System.out.println(bf ? "Yes" : "No");
	}
}

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

using namespace std;

int main()
{
    string s;
    int k;
    bool use[10] = {1,1,1,1,1,1,1,1,1,1};
    string ans;
    bool flg = true;

    cin >> s >> k;

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

    for (int i = 0; i <= stoi(s)*10; i++) {
        string t = to_string(stoi(s)+i);
        for (int i = 0; i < t.size(); i++) {
            if (use[t[i]-'0'] == 0) {
                flg = false;
            }
        }
        if (flg) {
            cout << t << endl;
            return (0);
        }
        flg = true;
    }
}


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

using namespace std;

int main() {

    int n, k, q;

    cin >> n >> k >> q;

    vector<int> arr(n, 0);

    int x = 0;

    for (int i = 0; i < q; i++) {
        cin >> x;
        arr[x-1]++;
    }

    for (int i = 0; i < n; i++) {
        if (arr[i] > q - k) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }


    return 0;
    
}

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


//      DEEP


using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fwd(i,a,n) for(int i=a;i<=n;i++)
#define bak(i,a,n) for(int i=a;i>=n;i--)
#define all(v) v.begin(),v.end()
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef set<int> si;
const ll mod = 1e9 + 7;
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}
ull gcd(ull x,ull y){
   if(y==0)return x;
   return gcd(y,x%y);
}
int main(){
    ll n,w;
    cin>>n>>w;
    vll wei(n+1);
    vll val(n+1);
    for(int i=1;i<=n;i++)cin>>wei[i]>>val[i];

    ll dp[n+1][w+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=w;j++){
            if(i==0 || j==0)dp[i][j]=0;
            else{
                dp[i][j]=dp[i-1][j];
                if(j>=wei[i])dp[i][j]=max(dp[i-1][j-wei[i]]+val[i],dp[i][j]);
            }
        }
    }
    cout<<dp[n][w]<<endl;
}



Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> x(5);
  for(int i=0;i<5;i++){
    cin>>x[i];
  }
  for(int i=0;i<5;i++){
    if(x[i]==0){
      cout<<i+1<<endl;
    }
  }
}

Measured memory_bytes: 3572
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		long x=ir.nextLong();
		long y=ir.nextLong();
		out.println(y>2*x?x+(y-2*x)/4:y/2);
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

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

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

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

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 22484
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
  int a,b;
  cin>>a>>b;
  cout<<a-b+1;
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 5e5 + 5;
const int M = (1 << 20) + 5;
const int MOD = 1e9 + 7;

int n, x;
int a[N];
int pref[N], cnt0[N];
int dp2[M], dp20[M];
int cache[N][2];
set<int> pos[M];

int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

int dp(int idx, int cur)
{
	if(idx == n + 1)
		return (cur == 1);
	int &ans = cache[idx][cur];
	if(ans != -1)
		return ans;
	ans = dp(idx + 1, cur);
	if(cur == 0 && pref[idx] == 0)
		ans += dp(idx + 1, cur ^ 1);
	if(cur == 1 && pref[idx] == x)
		ans += dp(idx + 1, cur ^ 1);
	ans %= MOD;
	return ans;
}	

int get(int l, int r)
{
	return cnt0[r] - cnt0[l - 1];
}

int32_t main()
{
	IOS;
	memset(cache, -1, sizeof(cache));
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		pref[i] = pref[i - 1] ^ a[i];
		cnt0[i] = cnt0[i - 1] + (pref[i] == 0);
	}
	if(pref[n] > 0)
	{
		x = pref[n];
		int ans = dp(1, 1);
		cout << ans << endl;
	}
	else
	{
		for(int i = 0; i < M; i++)
			dp20[i] = 1;
		dp2[0] = 0;
		map<int, int> prev;
		for(int i = 1; i <= n; i++)
		{
			if(prev.find(pref[i]) == prev.end())
			{
				dp2[pref[i]] = 1;
				prev[pref[i]] = i;
				continue;
			}
			dp20[pref[i]] += get(prev[pref[i]], i) * dp2[pref[i]];
			dp20[pref[i]] %= MOD;
			dp2[pref[i]] += dp20[pref[i]];
			dp2[pref[i]] %= MOD;
			prev[pref[i]] = i;
		}
		int ans = pow(2LL, cnt0[n] - 1, MOD);
		for(int i = 1; i < M; i++)
			ans += dp2[i];
		ans %= MOD;
		ans %= MOD;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 103296
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;

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

int main()
{
	FAST;
	char in[51][51];
	
	int r,c;
	cin >> r >> c;
	for(int i=0 ; i<r ; i++)
		cin >> in[i];

	for(int i=0 ; i<r ; i++)
	{
		for(int j=0 ; j<c ; j++)
		{
			if(in[i][j] == '#')
				cout << "#";
			else
			{
				int count = 0;
				for(int ii=i-1 ; ii<=i+1 ; ii++)
				{
				    for(int jj=j-1 ; jj<=j+1 ; jj++)
				    {
				        if(ii>=0 && ii<r && jj>=0 && jj<c)
				        {
				            if(in[ii][jj] == '#')   count++;
				        }
				    }
				}
				cout << count;
			}
		}
		cout << "\n";
	}
	return 0;
}

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

#define rep(i, n) for(int i=0;i<(int)(n);++i)

using namespace std;

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

void trace(int A[], int N) {
    for (int i = 0; i < N; ++i) {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

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

const unsigned long long INF = 1LL << 60;

////////////////////////////////////////////////////////////

int main() {
    string N;
    cin >> N;
    if (N.find('7') != std::string::npos) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3632
X, K, D = map(int, input().split())

if X - K * D <= 0 <= X + K * D:
    print(min(
        abs((K * D - X) % (2 * D)),
        abs(-(K * D - X) % (2 * D))
    ))
else:
    print(min(
        abs(X - K * D),
        abs(X + K * D)
    ))

Measured memory_bytes: 9080
#include <iostream>
#include <algorithm>

#define ll long long

using namespace std;

int main(){

 ll a[5],n;
 cin>>n;
 for(int i=0;i<5;++i) cin>>a[i];
 
 ll m=0;
 for(int i=0;i<5;++i){
   m=max(m,n/a[i]+1-!(n%a[i]));
 }
 
  cout<<m+4<<endl;

 return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 100000000
#define inf 1e18 
int maxn=1e5;

using namespace std;

signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif
    
    IOS;
    int x;
    cin>>x;
    if(x>=30) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

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

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

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

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

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

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

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

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

Measured memory_bytes: 8212
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

a1, a2, a3 = map(int, readline().split())

print('bust' if a1 + a2 + a3 >= 22 else 'win')


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

vt=va=0
for _ in range(N):
  T,A=map(int,input().split())
  kt=-(-vt//T)
  ka=-(-va//A)
  
  k=max(kt,ka,1)
  vt=k*T
  va=k*A  
  #print(vt,va)
  
print(vt+va)

Measured memory_bytes: 3064
def perpendicular_bisector(p, q):
    x = (q[0] - p[0])
    y = (q[1] - p[1])
    return (2 * x, 2 * y, p[0]**2-q[0]**2+p[1]**2-q[1]**2)


def gauss_jordan_elimination(Array):
    # N???M??????Array
    N = len(Array)
    if N == 0:
        return (True, Array)
    else:
        M = len(Array[0])

    A = []
    for i in range(len(Array)):
        A.append(Array[i][:])

    pivot = 0
    L = min(N, M)
    while pivot < L:
        pivot_v = A[pivot][pivot]
        pivot_row = pivot
        for i in range(pivot + 1, L):
            v = max(A[i][pivot], -A[i][pivot])
            if pivot_v < v:
                pivot_row = i
                pivot_v = v
        if pivot_row > pivot:
            for i in range(M):
                A[pivot][i], A[pivot_row][i] = A[pivot_row][i], A[pivot][i]
        if pivot_v == 0:
            return ('False', A)
        inv_pivot = 1 / A[pivot][pivot]
        A[pivot][pivot] = 1
        for i in range(pivot + 1, M):
            A[pivot][i] *= inv_pivot
        for i in range(N):
            if i == pivot:
                continue
            t = -1 * A[i][pivot]
            A[i][pivot] = 0
            for j in range(pivot + 1, M):
                A[i][j] += t * A[pivot][j]
        pivot += 1
    return ('True', A)

n = int(input())
for _ in range(n):
    x1, y1, x2, y2, x3, y3 = map(float, input().split())
    a = list(perpendicular_bisector((x1, y1), (x2, y2)))
    b = list(perpendicular_bisector((x1, y1), (x3, y3)))
    c = [a, b]
    state, c = gauss_jordan_elimination(c)
    x = -c[0][2]
    y = -c[1][2]
    r = ((x - x1)**2 + (y - y1)**2)**0.5
    print('{0:.3f} {1:.3f} {2:.3f}'.format(round(x, 3), round(y, 3), round(r, 3)))

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

int main() {
	int n,m,x;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> x;
		n -= x;
	}

	if (n < 0)
		cout << -1 << endl;
	else
		cout << n << endl;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL n,a[100010],q,x,y,mp[100010],ans=0;

int main()
{
	cin>>n;
	rep(i,n)
	{
		cin>>a[i];
		mp[a[i]]++;
		ans+=a[i];
	}
	cin>>q;
	while(q--)
	{
		cin>>x>>y;
		ans+=mp[x]*(y-x);
		mp[y]+=mp[x];
		mp[x]=0;
		cout<<ans<<endl;
	}
	return 0;
}

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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;
int main(){
	int x;
	cin >> x;
	if(x <= 599){
		cout << 8 << endl;
	}else if(x <= 799){
		cout << 7 << endl;
	}else if(x <= 999){
		cout << 6 << endl;
	}else if(x <= 1199){
		cout << 5 << endl;
	}else if(x<= 1399){
		cout << 4 << endl;
	}else if(x<= 1599){
		cout << 3 << endl;
	}else if(x <= 1799){
		cout << 2 << endl;
	}else if(x <= 1999){
		cout << 1 << endl;
	}
}


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

typedef long long ll;
typedef unsigned long long ull;

int b[2005];

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,x,y;
	cin>>n>>x>>y;
	int k;
	
	for(int i=1; i<=n; i++)
		for(int j=i+1; j<=n; j++)
		{
			k=min(min(abs(j-i),abs(i-x)+1+abs(j-y)),abs(i-y)+1+abs(j-x));
			b[k]++;
		}
	
	for(int i=1; i<=n-1; i++)
		cout<<b[i]<< endl;
		
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();
		if(x - r >= 0 && y - r >= 0 && x + r <= W && y + r <= H) System.out.println("Yes");
		else System.out.println("No");
		
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().run();
	}

}



Measured memory_bytes: 26268
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ZERO(x) memset(x,0,sizeof(x))
#define MINUS(x) memset(x,-1,sizeof(x))
#define UNIQUE(x) (x).erase(unique(ALL(x)), (x).end())
#define TOUPPER(x) transform(ALL(x), (x).begin(), ::toupper)
#define TOLOWER(x) transform(ALL(x), (x).begin(), ::tolower)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll qp(ll a,ll b){ll ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
ll qp(ll a,ll b,ll mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const int INF = 1e9;
const ll INFL = 1e18;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5;

int main() {
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double a = 2 * M_PI * (H / 12 + M / 60 / 12);
    double b = 2 * M_PI * M / 60;
    double t = abs(a - b);
    double ans = sqrt(A*A + B*B - 2*A*B*cos(t));
    printf("%.11f\n", ans);
    return 0;
}


Measured memory_bytes: 4228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, d;
    cin >> n >> d;
    vector<vector<ll>> x(n, vector<ll>(d));
    rep(i, n) rep(j, d) cin >> x[i][j];
    set<ll> val;
    reps(i, -16001, 16001) val.insert(i * i);
    ll ans = 0;
    rep(i, n) {
        reps(j, i + 1, n) {
            ll tmp = 0;
            rep(k, d) {
                ll dist = abs(x[i][k] - x[j][k]);
                tmp += dist * dist;
            }
            if (val.count(tmp) > 0) {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
from collections import deque

H, W = map(int, input().split())
A = [input() for _ in range(H)]

D = [[0] * W for _ in range(H)]

Q = deque()
Q1 = deque()
for i in range(H):
    for j in range(W):
        if A[i][j] == '#':
            D[i][j] = 1
            Q.append([i, j])

yudlr = [1, -1, 0, 0]
xudlr = [0, 0, -1, 1]

C = 0
while len(Q) > 0:
    C += 1
    while len(Q) > 0:
        Q1.append(Q.pop())
    while len(Q1) > 0:
        q = Q1.popleft()
        y = q[0]
        x = q[1]
        for i in range(4):
            y1 = y + yudlr[i]
            x1 = x + xudlr[i]
            if y1 < 0 or y1 >= H or x1 < 0 or x1 >= W:
                continue
            if D[y1][x1] == 1:
                continue
            D[y1][x1] = 1
            Q.append([y1, x1])

print(C - 1)

Measured memory_bytes: 143752
N, M, K = map(int, input().split())
friends = [0 for _ in range(N)]
blocks = [0 for _ in range(N)]

class Union():
    def __init__(self, N):
        self.Parent = []
        for i in range(N):
            self.Parent.append(-1)

    def root(self, A):
        if(self.Parent[A] < 0):
            return A
        else:
            self.Parent[A] = self.root(self.Parent[A])
            return self.Parent[A]

    def size(self, A):
        return int(-1 * self.Parent[self.root(A)])

    def connect(self, A, B):
        A = self.root(A)
        B = self.root(B)
        if (A == B):
            return False

        if(self.size(A) < self.size(B)):
            A, B = B, A
        self.Parent[A] += self.Parent[B]
        self.Parent[B] = A
        return True

uni = Union(N)
ans = []
for i in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    friends[A] += 1
    friends[B] += 1
    uni.connect(A,B)

for i in range(K):
    C, D = map(int, input().split())
    C -= 1
    D -= 1
    if (uni.root(C) == uni.root(D)):
        blocks[C] += 1
        blocks[D] += 1

for i in range(N):
    ansi = max(0, uni.size(i) - friends[i] - blocks[i] - 1)
    ans.append(str(ansi))

print(" ".join(ans))




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

int main(){
  int A,B;
  cin >> A >> B;
  
  for(int i=1;i<=10000;i++){
    if(int(i*0.08)!=A) continue;
    if(int(i*0.1)!=B) continue;
    cout << i << endl;
    return 0;
  }
  
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
using System;

namespace abc153_c
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int K = int.Parse(input[1]);

            string[] input2 = Console.ReadLine().Split(' ');
            int[] H = new int[N];
            for (int i = 0; i < N; i++)
            {
                H[i] = Convert.ToInt32(input2[i]);
            }

            Array.Sort(H);
            Array.Reverse(H);

            long kougeki = 0;
            for (int j = 0; j < N; j++)
            {
                if (K > 0)
                {
                    H[j] = 0;
                    K -= 1;
                }

                kougeki += H[j];

            }
            Console.WriteLine(kougeki);
            Console.Read();
        }
    }
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  using P = pair<int, int>;
  map<int, vector<P>> range;
  int N, Q; cin >> N >> Q;
  rep(i, N) {
    int s, t, x;
    cin >> s >> t >> x;
    range[x].emplace_back(max(s - x, 0), max(t - x, 0));
  }
  set<int> ds;
  map<int, int> ans;
  rep(i, Q) {
    int d; cin >> d;
    ds.insert(d);
    ans[d] = -1;
  }
  each(r, range) {
    int x = r.first;
    each(v, r.second) {
      auto it = ds.lower_bound(v.first);
      vector<int> er;
      while (it != ds.end()) {
        if (*it >= v.second) break;
        ans[*it] = x;
        ds.erase(it++);
      }
    }
  }
  each(a, ans) {
    cout << a.second << '\n';
  }
}


Measured memory_bytes: 41856
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

int main()
{
	int n; cin >> n;
	vector<int> v(n), c(n), a(n);
	int sum = 0;
	for (int i = 0; i < n; i++) cin >> v[i];
	for (int i = 0; i < n; i++) cin >> c[i];
	for (int i = 0; i < n; i++)
	{
		a[i] = v[i] - c[i];
		if (a[i] > 0) sum += a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	cout << sum << endl;
}	

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <utility>
#include <vector>

int main() {
  int n;
  std::cin >> n;
  std::string s;
  std::vector<int> c1(5, 0);
  for (int ni = 0; ni < n; ++ni) {
    std::cin >> s;
    switch (s[0]) {
      case 'M':
        ++c1[0];
        break;
      case 'A':
        ++c1[1];
        break;
      case 'R':
        ++c1[2];
        break;
      case 'C':
        ++c1[3];
        break;
      case 'H':
        ++c1[4];
        break;
    }
  }
  long long c2[6][4] = {};
  c2[0][0] = 1;
  for (int ni = 0; ni < 5; ++ni) {
    c2[ni + 1][0] = 1;
    for (int ki = 1; ki <= 3; ++ki) {
      c2[ni + 1][ki] = c2[ni][ki] + c2[ni][ki - 1] * c1[ni];
    }
  }
  std::cout << c2[5][3] << std::endl;
  return 0;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, y;
	cin >> n >> y;
	int a = y / 10000;
	int b = y % 10000 / 5000;
	int c = y % 5000 / 1000;
	int r = n - a - b - c;
	if (r >= 0) {
		if (r / 9 + r % 9 <= a) {
			cout << a - r / 9 - r % 9 << " " << b + r % 9 * 2 << " " << c + r / 9 * 10 << endl;
			return 0;
		}
	}
	b = 0;
	c = y % 10000 / 1000;
	r = n - a - b - c;
	if (r >= 0) {
		if (r / 9 + r % 9 <= a) {
			cout << a - r / 9 - r % 9 << " " << b + r % 9 * 2 << " " << c + r / 9 * 10 << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
}


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

template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

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

    int n; cin >>n;
    vector<int> a(n); cin >> a;

    for (int i=n-1; i >= 0; i-=2) {
        cout << a[i] << " ";
    }
    for (int i = n%2; i < n; i+=2) {
        cout << a[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define ll long long
#define dl double
using namespace std;

//***********************************************************************
int MAXNUM = 5e3+5;
vector <int>vis(MAXNUM);
vector<int> pr;
void sieve() {
	pr.push_back(2);
	for(ll i=3;i<MAXNUM;i+=2) if(!vis[i]) {
		pr.push_back(i);
		for(ll j=i*i;j<MAXNUM;j+=2*i) vis[j]=true;
	}
}
//************************************************************************

void solve()
{
    ll n,k;
    cin >> n >> k;
    ll val=n%k;
    val=min(val,abs(val-k));
    cout << val << endl;
 }


int main()
{ 
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	ll t;
	//cin >> t;
	t=1;
	while(t--)
	{
		solve();
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=205,up=128;
int n,m,len,vis[N],b[N];
char s[N],ans[N];
int f(char c)
{
    if(c>='a'&&c<='z') return c-'a';
    if(c>='A'&&c<='Z') return c-'A'+f('z')+1;
    return c-'0'+f('Z')+1;
}
char g(int x)
{
    if(x<26) return 'a'+x;
    if(x<52) return 'A'+x-26;
    return '0'+x-52;
}
int query()
{
    m++;assert(m<=850);
    printf("? %s\n",s+1);
    fflush(stdout);
    int ans;scanf("%d",&ans);
    return ans;
}
vector<int>v;
bool cmp(int x,int y)
{
    for(int i=1;i<=n;i++) s[i]=ans[i];
    s[1+n]=g(x);
    for(int i=2;i<=vis[y]+1;i++)
        s[i+n]=g(y);
    s[vis[y]+2+n]='\0';
    return len-query()==vis[y]+n+1;
}
void msort(int l,int r)
{
    if(l==r) return;
    int m=l+r>>1;
    msort(l,m);msort(m+1,r);
    int i=l,j=m+1,k=l;
    while(i<=m&&j<=r)
        if(cmp(v[i],v[j])) b[k++]=v[i++];
        else b[k++]=v[j++];
    while(i<=m) b[k++]=v[i++];
    while(j<=r) b[k++]=v[j++];
    for(int i=l;i<=r;i++) v[i]=b[i];
}
string ss="Atcod3rIsGreat";
int q(char c)
{
    int ans=0;
    for(int i=0;i<ss.size();i++)
        if(c==ss[i]) ans++;
    return ans;
}
int main()
{
    for(int i=0;i<=61;i++)
    {
        for(int j=1;j<=128;j++) s[j]=g(i);
        s[129]='\0';
        vis[i]=128-query();
        //vis[i]=q(g(i));
        len+=vis[i];
        if(vis[i]) v.push_back(i);
    }
    msort(0,v.size()-1);
    int l=0,r=v.size()-1;
    while(l<=r)
    {
        ans[++n]=g(v[l]);
        vis[v[l]]--;
        if(!vis[v[l]]) l++;
        else if(l!=r)
        {
            int pos=l;
            for(int i=128;i;i>>=1)
                if(pos+i<=r&&cmp(v[pos+i],v[l]))
                pos+=i;
            int x=v[l];
            for(int i=l;i<pos;i++) v[i]=v[i+1];
            v[pos]=x;
        }
    }
    ans[n+1]='\0';
    printf("! %s\n",ans+1);
}
//Atcod3rIsGreat
/*
? ac
13
? cd
12
? ad
13
? eo
13
? orr
11
? err
13
? co
12
? do
13
? drr
11
? arr
13
? ae
13
? stt
13
? tA
13
? GI
13
? I3
13
? A3
12
? t3
12
? s3
13
? sI
13
? sG
12
? cA
13
? ctt
13
? c3
12
? o3
12
? d3
12
? r3
13
? rI
12
? eI
13
? es
13
? eG
13
? AtGt
10
? Atat
10
? Atcod3rer
13
? Atcod3rsr
5
? Atcod3rGr
5
! Atcod3rIsGreat
*/


Measured memory_bytes: 3792
import sys
from heapq import heappush, heappop

x, y, z, k = map(int ,sys.stdin.readline().split())
a, b, c = (sorted(map(int, sys.stdin.readline().split())) for _ in range(3))

def main():
    res = []
    for i in range(x):
        for j in range(y):
            heappush(res, -(a[i] + b[j]))
    
    res2 = []
    for i in range(min(k, x * y)):
        ab = -heappop(res)
        for j in range(z):
            heappush(res2, -(ab + c[j]))
    
    for i in range(k):
        yield -heappop(res2)

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

Measured memory_bytes: 162524
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

int idx[26], dis[26], cnt[26];

void solve(void){
    string S;
    cin >> S;
    int l = S.size();
    rep(l, i) {
        int c = S[i]-'a';
        if (cnt[c]) {
            dis[c] = max(dis[c], i - idx[c] - 1);
        }
        else dis[c] = i;
        idx[c] = i;
        cnt[c]++;
    }
    rep(26, i) if (cnt[i] == l) {
        cout << 0 << endl;
        return;
    }
    int ans = INF;
    rep(26, i) dis[i] = max(dis[i], l - idx[i] - 1);
    rep(26, i) ans = min(dis[i], ans);
    cout << ans << endl;
}

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


Measured memory_bytes: 256
p = []
for i in range(3):
    a = input().rstrip().split(" ")
    p.append(int(a[0]))
    p.append(int(a[1]))
#print(p)

c = []
for i in range(4):
    a = p.count(i + 1)
    c.append(a)
c.sort()

if c == [1, 1, 2, 2]:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    int c[3][3];
    for(int i=0;i<3;i++)for(int j=0;j<3;j++) cin >> c[i][j];

    int a1 = c[0][0], a2 = c[0][1] ,a3 = c[0][2];
    int amax = max (a1 ,max(a2 ,a3));
  	a1 -= amax;
  	a2 -= amax;
  	a3 -= amax;
    int b2 ,b3;
    bool ok1 = false ,ok2 = false;

    while(a1<=c[0][0] && a2<=c[0][1] && a3<=c[0][2] ){
        for(b2=0;b2<100;b2++){
            if(a1+b2 == c[1][0] && a2+b2 == c[1][1] && a3+b2 == c[1][2]){
                ok1 = true;
                break;
            }
        }
        for(b3=0;b3<100;b3++){
            if(a1+b3 == c[2][0] && a2+b3 == c[2][1] && a3+b3 == c[2][2]){
                ok2 = true;
                break;
            }
        }
        a1++;
        a2++;
        a3++;
    }

    if(ok1 && ok2)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

int dp[101][10001]; // i????????§?????????j??????????????§???v
int N, W;

int v[10000];
int w[10000];


using namespace std;

int serch(int i,int cw) {
	if (i >= N) return 0; 
	if (dp[i][cw] != -1) return dp[i][cw];

	if (cw + w[i] > W) return serch(i + 1,cw);
	return dp[i][cw] = 
		max(
			max(serch(i + 1,cw + w[i]) + v[i]
				,serch(i , cw + w[i]) + v[i])
			,serch(i + 1,cw)); 
}


int main() {

	for (int i = 0; i < 100; i++) {
		for(int j = 0; j < 10000; j++) {
			dp[i][j] = -1;
		}
	}

	cin >> N >> W;

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

	cout << serch(0,0) << endl;

	return 0;
}

Measured memory_bytes: 5704
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var n=arr.shift()-0;
var s=arr.shift().split("");
var [a,b]=[0,0];
s.forEach(v=>{
   if("ABCDEFGHIJKLM".includes(v))a+=1
   else if("NOPQRSTUVWXYZ".includes(v))a-=1
   else if("abcdefghijklm".includes(v))b+=1
   else if("nopqrstuvwxyz".includes(v))b-=1
});
str="";
if(a>0)str+="A".repeat(a);
else if(a<0)str+="N".repeat(a*-1);
if(b>0)str+="a".repeat(b);
else if(b<0)str+="n".repeat(b*-1);
console.log(str.length);
console.log(str);



Measured memory_bytes: 20412
use std::cmp::min;
use std::io::stdin;

fn main() {
    let mut is = String::new();
    stdin().read_line(&mut is).ok();
    let mut itr = is.split_whitespace().map(|e| e.parse::<usize>().unwrap());
    let n: usize = itr.next().unwrap();
    let k: usize = min(itr.next().unwrap(), 41);
    is.clear();
    stdin().read_line(&mut is).ok();
    let mut a = is
        .split_whitespace()
        .map(|e| e.parse::<i64>().unwrap())
        .collect::<Vec<i64>>();

    for _ in 0..k {
        let mut b = vec![0; n + 1];
        for i in 0..n {
            let l = i.saturating_sub(a[i] as usize);
            let r = min(i + a[i] as usize + 1, n);
            b[l] += 1;
            b[r] += -1;
        }
        for i in 1..n {
            b[i] += b[i - 1];
        }

        a = b;
        a.pop();
        if a.iter().all(|e| e == &(n as i64)) {
            break;
        }
    }

    let mut flg = false;
    for e in a {
        if flg {
            print!(" ");
        }
        print!("{}", e);
        flg = true;
    }
    println!();
}


Measured memory_bytes: 6360
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Deque<String> deque = new ArrayDeque<String>();
		Map<String, Integer> map = new HashMap<String, Integer>();
		deque.push("01234567");
		map.put(deque.getFirst(), 0);
		int count = 1;
		while (!deque.isEmpty()) {
			int size = deque.size();
			while (size-- > 0) {
				String str = deque.pop();
				for (int i = 0; i < 4; i++) {
					String newStr = slove(str, i);
					if (!newStr.isEmpty() && !map.containsKey(newStr)) {
						map.put(newStr, count);
						deque.offer(newStr);
					}
				}
			}
			count++;
		}
		Scanner scanner = new Scanner(System.in);
		while (scanner.hasNext()) {
			System.out.println(map.get(scanner.nextLine().replace(" ", "")));
		}
	}

	private static String slove(String str, int i) {
		int index = str.indexOf("0");
		StringBuilder builder = new StringBuilder(str);

		switch (i) {
		case 0:
			if (index != 3 && index != 7) {
				String rep = String.valueOf(str.charAt(index + 1));
				return rep(builder, str, rep, index, 1);

			} else {
				return "";
			}
		case 1:
			if (index != 0 && index != 4) {
				String rep = String.valueOf(str.charAt(index - 1));
				return rep(builder, str, rep, index, -1);
			} else {
				return "";
			}
		case 2:
			if (index < 4) {
				String rep = String.valueOf(str.charAt(index + 4));
				return rep(builder, str, rep, index, 4);
			} else {
				return "";
			}
		default:
			if (index > 3) {
				String rep = String.valueOf(str.charAt(index - 4));
				return rep(builder, str, rep, index, -4);
			} else {
				return "";
			}
		}
	}

	private static String rep(StringBuilder builder, String str, String rep,
			int index, int x) {
		return builder.replace(index, index + 1, rep)
				.replace(index + x, index + x + 1, "0").toString();
	}

	private static String rep(String str, String rep) {
		return str.replace("0", "9").replace(rep, "0").replace("9", rep);
	}
}

Measured memory_bytes: 62668
//abc145D
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

long long gya(long long a) { //逆元を求める
  long long m=1000000007, b=m, u=1, v=0, c, t;
  while(b){
    t=a / b; //何これ
    a-=t * b, u-=t * v; //何これ
    c=a, a=b, b=c, c=u, u=v, v=c; //swap
  }
  return (u + m) % m;
}
long long com(long long b, long long d) { //bCd
  int i, mod=1000000007;
  long long ret=1, re2=1;
  for(i=1; i <= d; i++)
    ret=ret * (b - d + i) % mod, re2=re2 * i % mod;
  return ret * gya(re2 % mod) % mod;
}

int main(void) {
  int x, y, tmp, n, m;
  scanf("%d %d", &x, &y);
  if((x + y) % 3 != 0 || x / y > 2 || y / x > 2){
    printf("0");
    return 0;
  }else if(y > x) tmp=x, x=y, y=tmp;

  n=(2 * y - x) / 3, m=(x + y) / 3 - n;
  //printf("%d %d\n",n,m);
  printf("%lld", com(n+m, m));
  return 0;
}

Measured memory_bytes: 128