akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  ll n,k;
  cin>>n>>k;
  ll ans;
  if(k % 2 == 1) {
    ans = (ll)pow(n/k, 3);
  } else {
    ans = (ll)pow(n/k, 3) + (ll)pow((n+k/2)/ k, 3);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n,k = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

k_digit = k.to_s(2).rjust(40, "0")
bits = []
as.each do |a|
  bits << a.to_s(2).rjust(40, "0").chars
end

best = ""

bits.transpose.each.with_index do |bit, i|
  one = bit.count("1")
  if one > n/2
    d = "0"
  else
    d = "1"
  end
  best << d
end

dp = {}
dp[0] = {}
if k_digit[0] == "1" && best[0] == "0"
  dp[0][:smaller] = true
  dp[0][:value] = "0"
elsif k_digit[0] == best[0]
  dp[0][:smaller] = false
  dp[0][:value] = best[0]
else
  dp[0][:smaller] = false
  dp[0][:value] = k_digit[0]
end

k_digit.size.times.with_index(1) do |_,i|
  break if k_digit[i].nil?
  dp[i] = {}
  if dp[i-1][:smaller]
    dp[i][:smaller] = true
    dp[i][:value] = dp[i-1][:value] + best[i]
  else
    if k_digit[i] == "1" && best[i] == "0"
      dp[i][:smaller] = true
      dp[i][:value] = dp[i-1][:value] + best[i]
    elsif k_digit[i] == best[i]
      dp[i][:smaller] = false
      dp[i][:value] = dp[i-1][:value] + best[i]
    else
      dp[i][:smaller] = false
      dp[i][:value] = dp[i-1][:value] + k_digit[i]
    end
  end
end

xor = dp[39][:value].to_i(2)
puts as.reduce(0) {|a,e| a+=xor^e}

Measured memory_bytes: 242440
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scanner=new Scanner(System.in);

		int a=scanner.nextInt();
		int b=scanner.nextInt();
		int c=scanner.nextInt();
		
		int x=scanner.nextInt();
		int y=scanner.nextInt();
		

		int sum=0;
		
		//cのピザ2枚でa1枚、b1枚分。
		if(a+b>2*c) {
			
			//xとyのうち少ないほうに合わせてｃを買い、残りは直接かう？
			//単品よりc*2のほうが安いパターンもくるかもしれない。
			
			sum+=Math.min(x,y)*2*c;
			
			if(x>y) {
				
				int rate=Math.min(a,2*c);
				
				sum+=(x-y)*rate;
			}else if(x<y) {
				int rate=Math.min(b,2*c);
				
				sum+=(y-x)*rate;
				
			}
			
			
			
		}else {
			sum+=a*x+b*y;
		}

		System.out.println(sum);
		
		scanner.close();

	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s;
    cin >> s;
    int n = s.size(), x = 0;
    for(int i = 0; i < n; i++) x += (s[i] - '0');
    if(x % 9 == 0) cout << "Yes";
    else cout << "No";
    
    return 0;
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
int main(){
  int N, M;
  cin >> N;
  map<string, int> A;
  rep(i, N){
    string a;
    cin >> a;
    A[a]++;
  }
  cin >> M;
  rep(i, M){
    string b;
    cin >> b;
    A[b]--;
  }
  int max = -9999;
  for (auto a : A){
        //std::cout << key << " => " << value << "\n";
        if(max < a.second){
          max = a.second;
        }
    }
    if(max >= 0){
      cout << max << endl;
    }else{
      cout << 0 << endl;
    }
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  bitset<4000001> bit = 0;
  bit[0] = 1;
  int s = 0;
  for(int i = 0; i < N; ++i){
    bit |= (bit<<A[i]);
    s += A[i];
  }
  for(int i = (s+1)/2; i <= s; ++i){
    if(bit[i]){
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 1664
N, M = map(int, input().split())
X = list(map(int, input().split()))

if N >= M:
    print(0)

else:
    X.sort()
    D = []
    for i in range(M-1):
        D.append(abs(X[i] - X[i+1]))

    D.sort()
    print(sum(D[0 : M-N]))

Measured memory_bytes: 20640
#include <algorithm>
#include <functional>

#include <map>
#include <string>
#include <iostream>

using namespace std;

map<char, int> cnt(string s){
    map<char, int> list;
    for(int i = 0; i < s.length(); ++i){
        ++list[s[i]];
    }
    return list;
}

signed main(){
    int N;
    cin >> N;
    
    string S;
    cin >> S;
    
    int max = 0;
    
    for(int i = 1; i < N; ++i){
        map<char, int> first = cnt(S.substr(0, i));
        map<char, int> second = cnt(S.substr(i, N - i));
        
        int dup = 0;
        for(char j = 'a'; j <= 'z'; ++j){
            if(first[j] != 0 && second[j] != 0){
                ++dup;
            }
        }
        
        if(dup > max){
            max = dup;
        }
    }
    
    cout << max << endl;
}

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    string s; cin >> s;

    string ans = "";

    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == '0') {
            ans += '0';
        }

        if (s[i] == '1') {
            ans += '1';
        }

        if (s[i] == 'B') {
            if (ans != "") {
                ans.erase(ans.size()-1);
            }
        }
    }

    cout << ans << endl;
}

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

int main()
{
    //freopen("test.in","r",stdin);
    //freopen("test.ok","w",stdout);
    int64_t n,a=0;
    cin >> n;
    /*for (int i=1;i<=n;i++)
    for (int j=1;j<=n;j++)
        {   
            int64_t x=i,y=j,
            z=i,
            t=j;
            while (x>=10)
            x=x/10;
            while (t>=10)
            t=t/10;
            if (x==(y%10)&&t==(z%10)) a++;
        }*/
    int64_t s[20][20];
    memset(s,0,sizeof(s));
    for (int i=1;i<=n;i++)
    {
        int x=i;
        while (x>=10) x=x/10;
        s[x][i%10]++; 
    }
    for (int i=1;i<=9;i++)
    for (int j=1;j<=9;j++)
        a=a+s[i][j]*s[j][i];
    cout << a;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

int t[100000];
signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    ll n, m;
    cin >> n >> m;
    ll res = 0;
    res += min(n, m / 2LL);
    res += (m - res * 2) / 4LL;
    pri(res);

/*/

//*/ break;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define ff first 
#define ss second  
typedef pair<int,int> pp;
bool com(pp x,pp y){
    return x.ff<y.ff;
} 
int N=1e7+9; 
int h,w,a,b,c,d;
vector<string> s(1002);
bool valid(int x,int y){
    if(x>=h||y>=w||x<0||y<0) return 0;
    if(s[x][y]=='#') return 0;
    return 1;
}
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>h>>w;
	cin>>a>>b;
	cin>>c>>d;
	a--,b--,c--,d--;
	for(int i=0;i<h;i++) cin>>s[i];
	deque<pp> q;
	q.push_front({a,b});
	vector<vector<int>> dis(h+1,vector<int> (w+1,N));
	dis[a][b]=0;
	while(!q.empty()){
	    int u=q.front().ff;
	    int v=q.front().ss;
	    q.pop_front();
	    if(u==c&&v==d) break;
	    for(int dx=-2;dx<=2;dx++){
	        for(int dy=-2;dy<=2;dy++){
	            int nu=u+dx;
	            int nv=v+dy;
	            int d=1;
	            if(nu==u&&nv==v) continue;
	            if(!valid(nu,nv)) continue;
	            if((abs(nu-u)==1&&nv==v)||(abs(nv-v)==1&&nu==u)) d=0;
	            if(dis[nu][nv]>dis[u][v]+d){
	                dis[nu][nv]=dis[u][v]+d;
	                if(d) q.push_back({nu,nv});
	                else q.push_front({nu,nv});
	            }
	        }
	    }
	}
	if(dis[c][d]==N) cout<<-1;
	else cout<<dis[c][d];
	return 0; 
	
}


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

class Base {
private:
  int runner;

public:
  Base() : runner(0) {}
  int hit() {
    int point = (runner & 4) >> 2;
    runner <<= 1;
    runner |= 1;
    return point;
  }
  int homerun() {
    int point = 1;
    for (int i = 0; i <3; ++i) {
      point += (runner >> i) & 1;
    }
    runner <<= 3;
    return point;
  }
};

void solve(int n) {
  for (int i = 0; i < n; ++i) {
    int point = 0;
    int out = 0;
    Base base = Base();

    while(out < 3) {
      string s;
      cin >> s;
      if (s == "HIT")          point += base.hit();
      else if (s == "HOMERUN") point += base.homerun();
      else                     out++;
    }
    cout << point << endl;
  }

}

int main() {
  int n;
  cin >> n;
  solve(n);
}


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

int main() {
  string s;
  cin >> s;

  int sum = 0;
  for (int i = 0; i < s.size(); i ++) {
    sum += s.at(i) - '0';
  }

  if (sum == 1) {
    cout << 10 << endl;
  } else {
    cout << sum << endl;
  }
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int l=sc.nextInt();
		DSet ds1 = new DSet(n+1);
		DSet ds2 = new DSet(n+1);
		for(int i=0; i<k; i++) {
			ds1.unite(sc.nextInt(), sc.nextInt());
		}
		for(int i=0; i<l; i++) {
			ds2.unite(sc.nextInt(), sc.nextInt());
		}
		HashMap<Long, Integer> m = new HashMap<>();
		for(int i=1; i<=n; i++) {
			long key = (long)ds1.findSet(i) * (long)n + (long)ds2.findSet(i);
			m.put(key, m.containsKey(key) ? m.get(key)+1 : 1);
		}
		for(int i=1; i<=n; i++) {
			if(i>1)System.out.print(" ");
			long key = (long)ds1.findSet(i) * (long)n + (long)ds2.findSet(i);
			System.out.print(m.get(key));
		}
		System.out.println();
		sc.close();
	}

	class DSet{

		int p[];
		int rank[];
		public DSet(int n) {
			p=new int[n];
			rank=new int[n];
			for(int i=0; i<n; i++) {
				makeSet(i);
			}
		}
		public void makeSet(int x) {
			p[x]=x;
			rank[x]=0;
		}

		public boolean same(int x, int y) {
			return findSet(x) == findSet(y);
		}

		public int findSet(int x) {
			if(p[x]!=x) {
				p[x]=findSet(p[x]);
			}
			return p[x];
		}

		public void link(int x, int y) {
			if(rank[x] < rank[y]) {
				p[x]=y;
			}else {
				p[y]=x;
				if(rank[x]==rank[y]) {
					rank[x]++;
				}
			}
		}
		public void unite(int x, int y) {
			link(findSet(x), findSet(y));
		}
	}
}


Measured memory_bytes: 119728
N = int(input())
A = list(map(int, input().split() ) )

cnt = 0
for i in range(N-1):
    for j in range(N-1, i, -1):
        if A[j] < A[j-1]:
            cnt += 1
            tmp = A[j]
            A[j] = A[j-1]
            A[j-1] = tmp

print(' '.join(map(str, A)) )
print(cnt)


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

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

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

    ll a,b,c,d;
    cin >> a >> b >> c >> d;

    auto f = [&](ll x) {
        return x - x/c - x/d + x/lcm(c,d);
    };  

    cout << f(b) - f(a-1) << endl;
    return 0;
}

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

class Combination{
	private:
		const static long long MOD = 1e9+7;
		const static long long MAX = 510000;
		vector<long long> fact;
		vector<long long> finv;
		vector<long long> inv;
	public:
		Combination() : fact(MAX),finv(MAX),inv(MAX){
			fact[0] = fact[1] = 1;
			finv[0] = finv[1] = 1;
			inv[1] = 1;
			for(int i=2;i<MAX;i++){
				fact[i] = fact[i-1] * i % MOD;
				inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
				finv[i] = finv[i-1] * inv[i] % MOD;
			}
		}

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


#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
long long mod  = 1e9+7;
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n); 
    rep(i,0,n) cin >> a[i];
    sort(all(a));
    Combination comb;
    ll ans = 0;
    rep(i,0,n-k+1){
        ans += a[n-i-1] * comb.nCk(n-i-1,k-1);
        if(ans<0) ans += 100000*mod;
        ans %= mod;
        ans -= a[i] * comb.nCk(n-i-1,k-1);
        if(ans<0) ans += 100000*mod;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 13056
N,A,B,C,D = map(int,input().split(' '))
S = input()

#N,A,B,C,D = 15,1,3,15,13
#S = "...#.#...#.#..."

#N,A,B,C,D = 4,1,2,4,3
#S = "...."

S = "#" + S + "#"
N = N+2

M = max(C,D)

if "##" in S[A:M+1]:
	print('No')
	exit()
if C < D:
	print('Yes')
	exit()

pos = B
while(True):
	if pos == D:
		if S[pos+1] == "#" or S[pos-1] == "#":
			print("No")
			exit()
		else:
			print("Yes")
			exit()
	if pos == D-1:
		if S[pos+2] == "#" and S[pos-1] == "#":
			print("No")
			exit()
		else:
			print("Yes")
			exit()
	loc = S[pos+1:pos+3]
	if loc == "..":
		print('Yes')
		exit()
	if loc == "#.":
		pos += 2
	if loc == ".#":
		if S[pos-1] == ".":
			print('Yes')
			exit()
		pos += 3





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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

const int maxNM = 50 + 5;
char picA[maxNM][maxNM];
char picB[maxNM][maxNM];

signed main() {
  int n, m;
  std::cin >> n >> m;
  REP(i, n) REP(j, n) { cin >> picA[i][j]; }
  REP(i, m) REP(j, m) { cin >> picB[i][j]; }
  REP(i, n) REP(j, n) {
    if (i + 1 > n - (m - 1) || j + 1 > n - (m - 1))
      continue;
    bool ok = true;
    REP(k, m) REP(l, m) {
      if (picA[i + k][j + l] != picB[k][l])
        ok = false;
    }
    if (ok) {
      std::cout << "Yes" << std::endl;
      return 0;
    }
  }
  std::cout << "No" << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
  
  
// Driver program 
int main() 
{ 
    int a, b;
    cin>>a>>b;
    if(b%2)
        cout<<"No";
    else if(b<2*a || b>4*a)
        cout<<"No";
    else
        cout<<"Yes";
} 

Measured memory_bytes: 3596
# ai<=biなので基本的にbiが強い。最強のaiより弱いbiは使う必要がない
# 順番は関係ないので選びぬかれたbiを強いほうか使っていって、倒せなかったら最強のaiをHがなくなるまで使う
n, h = map(int, input().split())
a, b = 0, []
for _ in range(n):
    ai, bi = map(int, input().split())
    a = max(a, ai)
    b.append(bi)
b = list(sorted(b))

l, r = 0, n
while r-l > 0:
    mid = (l + r) // 2
    if b[mid] >= a:
        r = mid
    else:
        l = mid + 1
b = b[r:][::-1]
count = 0
for bi in b:
    h -= bi
    count += 1
    if h <= 0:
        break

if h > 0:
    count += h // a if h % a == 0 else h // a + 1

print(count)


Measured memory_bytes: 58456
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
ll x, y, z, k;
vector<ll> a;
vector<ll> b;
vector<ll> c;
vector<ll> ab;

bool check(ll num){

    ll res = 0;
    for(int i = 0; i < c.size(); i++){
        ll ok = -1;
        ll ng = ab.size();
        while(abs(ok - ng) > 1){
            ll mid = (ok + ng) / 2;
            if(c[i] + ab[mid] > num){
                ok = mid;
            } else {
                ng = mid;
            }
        }
        res += ok + 1;
    }
    //cout << res << endl;
    return res < k;
}

int main(void){
    cin >> x >> y >> z >> k;
    a.resize(x);
    b.resize(y);
    c.resize(z);
    for(int i = 0; i < x; i++) cin >> a[i];
    for(int i = 0; i < y; i++) cin >> b[i];
    for(int i = 0; i < z; i++) cin >> c[i];

    sort(a.begin(), a.end(), greater<ll>());
    sort(b.begin(), b.end(), greater<ll>());
    sort(c.begin(), c.end(), greater<ll>());

    for(int i = 0; i < x; i++){
        for(int j = 0; j < y; j++){
            ab.push_back(a[i] + b[j]);
        }
    }

    sort(ab.begin(), ab.end(), greater<ll>());

    ll ok = INF;
    ll ng = 0;
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if(check(mid)){
            ok = mid;
        } else {
            ng = mid;
        }
        //cout << ok << " " << ng << endl;
    }



    //cout << "ok" << ok << endl;
    vector<ll> ans;
    for(int i = 0; i < z; i++){
        for(int j = 0; j < ab.size(); j++){
            if(ok < ab[j] + c[i]) ans.push_back(ab[j] + c[i]);
            else break;
        } 
    }

    while(ans.size() < k) ans.push_back(ok);

    sort(ans.begin(), ans.end(), greater<ll>());
    for(int i = 0; i < k; i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 10608
# -*- coding: utf-8 -*-

import io
import sys
import math


def solve(n,m,k,a_lst,b_lst):
    #机ごと、読書時間の累積をリストにする。ただし、リスト化はk時間内で読める範囲とする
    aa_lst = make_sum_list(a_lst,k)
    bb_lst = make_sum_list(b_lst,k)
    len_aa = len(aa_lst)
    len_bb = len(bb_lst)

    #A,Bいずれかが一冊も読めないケースを考慮
    if len_aa == 0:   return len_bb
    elif len_bb == 0: return len_aa
    
    #全て読めるケースを考慮
    if aa_lst[-1] + bb_lst[-1] <= k: return len_aa + len_bb 
    
    #A,Bいずれかのみ読むケースを考慮
    max_read = max(len_aa,len_bb)

    #リスト範囲でA+Bの最大値を探索する。2分探索を用いる
    for i in reversed(range(len_aa)):
        limit = k - aa_lst[i]
        read = i + 1
        if read + len_bb + 1 <= max_read:
            #以後 read は増えない
            break

        imax = len_bb-1
        imin = 0
        imid = len_bb // 2
        while True:
            logd(f"imid: {imid}")

            if bb_lst[imid] <= limit:
                #OK。大を調べる
                if imax - imid <= 1:
                    #探査終了
                    if bb_lst[imax] <= limit:
                        read += imax + 1
                    else:
                        read += imid + 1
                    break
                imin = imid
            else:
                #NG。小を調べる
                if imid - imin <= 1:
                    #探査完了
                    if bb_lst[imin] <= limit:
                        read += imin + 1
                    break
                imax = imid
            imid = (imin + imax) // 2
        max_read = max(read,max_read)
    return max_read

def make_sum_list(lst,max):
    sum_lst = []
    sum = 0
    for n in lst:
        sum += n
        if sum > max:
            break
        sum_lst.append(sum)
    return sum_lst

def main():
    n,m,k = map(int, input().split())
    a_lst = list(map(int, input().split()))
    b_lst = list(map(int, input().split()))
    ans = solve(n,m,k,a_lst,b_lst)
    print(ans)

### DEBUG I/O ###
_INPUT = """\
3 4 240
60 90 120
80 150 80 150
"""
_DEBUG = 0

def logd(str):
    if _DEBUG:
        print(f"[deb] {str}")

### MAIN ###
if __name__ == "__main__":
    if _DEBUG:
        sys.stdin = io.StringIO(_INPUT)
        print("!! Debug Mode !!")

    main()


Measured memory_bytes: 41460
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
 
#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
 
using namespace std;

signed main() {
	int N, M;
	cin >> N >> M;

	int base = 100 * (N - M) + 1900 * M;

	double ret = 0;
	REP(i, 1, 1000) {
		double tmp = base * i;
		double p = 1;
		rep(j, i - 1) {
			p *= 1 - 1.0 / pow(2, M);
		}
		p /= pow(2, M);
		ret += tmp * p;
	}

	cout << (int)(ret + 0.5000000001) << endl;

	return 0;
}


Measured memory_bytes: 512
//Never stop chasing!-MdSourav.
#include <bits/stdc++.h>

#define yes            cout<<"YES"<<endl
#define no             cout<<"NO"<<endl
#define sz(x)          x.size()
#define ll                    long long int
#define ls             long int
#define start          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test           int t;cin>>t;while(t--)
#define f(i, a, n)     for(int i=a; i<n;i++)
#define gcd(a,b)7           __gcd(a,b)
#define lcd(a,b)       (a*b)/gcd(a,b)
#define pb             push_back
#define mp(x,y)        make_pair(x,y)
#define rsrt(v)        sort(v.begin(),v.end(),greater<int>())
#define srt(v)         sort(v.begin(),v.end())
#define basrt(a,n)     sort(a,a+n,greater<int>())
#define asrt(a,n)      sort(a,a+n)
#define fact(n)        ll x=1;for(ll i=1;i<=n;i++){x=(x*i);}
#define F              first
#define S              second
#define deb(x)         cout << #x << ": " << x << endl;
#define enter(v,n)     for(ll i=0;i<n;i++){ll x;cin>>x;v.pb(x);}
#define INF 	       1000000007
#define unique(v)      v.erase(unique(v.begin(),v.end()),v.end())
using namespace std;

double pi=3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664 ;
typedef vector<ll> vll ;
typedef vector<int> vii ;

template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    for (const auto &x : v) os << " " << x;
        return os << '}';
}

void solve()
{

    int n;
    cin>>n;
    map<string,int>mp;
    for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		mp[s]++;
	}
	string a="AC";
	string b="WA";
	string c="TLE";
	string d="RE";
	cout << "AC x " << mp[a] << endl;
	cout << "WA x " << mp[b]<<endl;
	cout << "TLE x " << mp[c]<<endl;
	cout << "RE x " << mp[d]<<endl;


}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    ll test_case=1;
    //cin>>test_case ;
    while(test_case--)
	{
		 solve();
	}

	return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int h = sc.nextInt();
        int n = sc.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
            a[i] = sc.nextInt();
        }
        int[][] hw = new int[h][w];
        for (int i = 0; i < n; i++) {
            if(a[i] == 1) {
                for (int j = 0; j < h; j++) {
                    for (int j2 = 0; j2 < x[i]; j2++) {
                        hw[j][j2] = 1;
                    }
                }
            } else if(a[i] == 2) {
                for (int j = 0; j < h; j++) {
                    for (int j2 = x[i]; j2 < w; j2++) {
                        hw[j][j2] = 1;
                    }
                }
            } else if(a[i] == 3) {
                for (int j = 0; j < y[i]; j++) {
                    for (int j2 = 0; j2 < w; j2++) {
                        hw[j][j2] = 1;
                    }
                }
            } else if(a[i] == 4) {
                for (int j = y[i]; j < h; j++) {
                    for (int j2 = 0; j2 < w; j2++) {
                        hw[j][j2] = 1;
                    }
                }
            }
        }
        int ans = 0;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if(hw[i][j] == 0) ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 39208
#include <iostream>
#include <vector>
#include <map>

using namespace std;

main()
{
    string s; cin>>s;
    if(s[2]==s[3] and s[4]==s[5])
    {
        cout << "Yes" << "\n";
    }
    else
    {
        cout << "No" << "\n";
    }
}

Measured memory_bytes: 256
import math

n = int(input())
set = []
i = 1
ans = []

t = n**0.5
if len(str(t)) <=8:
    print(len(str((math.floor(t)))))
else:
    while i*i <= n:
        cc = []
        pre = []
        if n % i == 0:
            pre.append(i)
            cc.append(len(str(i)))
            if i != n // i:
                pre.append(n//i)
                cc.append(len(str(n//i)))
                if cc == []:
                    continue
                else:
                    ans.append(pre)
                    result = abs(cc[0]-cc[1])
                    set.append(result)

        i += 1


    min = set.index(min(set))
    print(len(str((max(ans[min])))))





Measured memory_bytes: 9488
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m,tot,x,y,z,clr[100010],head[100010],vis[100010],nxt[400010],to[400010];
void add_edge(int u,int v){
	nxt[++tot]=head[u];
	to[tot]=v;
	head[u]=tot;
	return;
}
int dfs(int u){
	vis[u]=1;
	int flg=0;
	for(int i=head[u];~i;i=nxt[i]){
		if(!flg)
			flg=2;
		int v=to[i];
		if(vis[v]){
			if(clr[v]!=clr[u]^1)
				flg=1;
			continue;
		}
		clr[v]=clr[u]^1;
		if(dfs(v)==1)
			flg=1;
	}
	return flg;
}
int main(){
	memset(head,-1,sizeof(head));
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		add_edge(u,v);
		add_edge(v,u);
	}
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			int flg=dfs(i);
			if(!flg)
				x++;
			else if(flg==1)
				y++;
			else z++;
		}
	}
	printf("%lld",1ll*x*x+2ll*x*(n-x)+1ll*y*(y+z*2ll)+2ll*z*z);
	return 0;
}

Measured memory_bytes: 6272
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <queue>
#include <assert.h>
#include <cmath>
#include <deque>
#include <set>
#include <unordered_map>
#include <complex>
#include <fstream>
#include <map>
using namespace std;
using ll = long long;
using ld = long double;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin>>n;
	ll d; cin>>d;
	int ans = 0;
	for(int i=0; i<n; i++) {
		ll x, y; cin>>x>>y;
		if(x*x+y*y<=d*d) ans++;
	}
	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 3144
N = int(input())
A = [[int(_) for _ in input().split()] for i in range(2)]
for j in range(N - 1):
  A[0][j + 1] += A[0][j]
  A[1][N - 2 - j] += A[1][N - 1 - j]
B = [A[0][i] + A[1][i] for i in range(N)]
print(max(B))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){return (int)s.size();}
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    ll a,b,n; cin >> a >> b >> n;
    int ans = 0;
    if(1){
        ll x;
        if(n/b == 0) x = n;
        else x = n - n%b - 1;
        ans = floor((a*x)/b) - a*floor(x/b);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
	char s[5];
	int ans = 0;
	scanf("%s",s);
	for(int i = 0; i < 4; i++){
		if(s[i] == '+')
			ans++;
		if(s[i] == '-')
			ans--;
	}
	printf("%d\n",ans);
return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<climits>

using namespace std;
int const inf=INT_MAX;
class Seg_Tree{
    private:
    int n;
    vector<int> node;
    public:
    int process(int left,int right){
        if(left==inf)return right;
        if(right==inf)return left;
        int ans=left;
        if(left>right)ans=right;
        return ans;
    }
    Seg_Tree(vector<int> v){
        int num=1;
        int size=v.size();
        while(num<size){
            num*=2;
        }
        n=num;
        node.resize(2*num-1,inf);
        for(int i=0;i<size;i++)node[i+num-1]=v[i];
        for(int i=n-2;i>=0;i--)node[i]=process(node[i*2+1],node[i*2+2]);
    }
    void update(int x,int val){
        x+=(n-1);
        node[x]=val;
        while(x>0){
            x=(x-1)/2;
            node[x]=process(node[x*2+1],node[x*2+2]);
        }
    }
    int out(int a,int b,int k=0,int l=0,int r=-1){
        if(r<0)r=n;
        if(a>=r||b<=l)return inf;
        if(a<=l&&b>=r)return node[k];
        int vl=out(a,b,k*2+1,l,(l+r)/2);
        int vr=out(a,b,k*2+2,(l+r)/2,r);
        return process(vl,vr);
    }
};

int main(){
    int n,q;
    cin>>n>>q;
    Seg_Tree tree(vector<int>(n,inf));
    vector<int> c(q);
    vector<int> x(q);
    vector<int> y(q);
    for(int i=0;i<q;i++){
        cin>>c[i]>>x[i]>>y[i];
    }
    for(int i=0;i<q;i++){
        if(c[i]==0)tree.update(x[i],y[i]);
        else cout<<tree.out(x[i],y[i]+1)<<endl;
    }
    return 0;
}


Measured memory_bytes: 5048
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
} 
ll dfs(vvl &g,ll v=0, ll par=-1){
    ll ret=0;
    for(auto nv:g[v]){
        if(nv==par)continue;
        ret^=dfs(g,nv,v);
    }
    return ret+1;
}
int main(){
    ll n;cin >> n;
    vvl g(n);
    rep(i,n-1){
        ll a,b;cin >> a >> b;a--;b--;
        g[a].pb(b);g[b].pb(a);
    }
    if(dfs(g)-1){
        cout << "Alice" <<endl;
    }
    else cout << "Bob" <<endl;
}

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

typedef long long ll;
ll k, n, cnt, tmp, ans;
typedef pair<ll, ll> P;
vector<P> v;
bool flag[100010];
priority_queue<ll, vector<ll>, greater<ll>> pq;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> k;
	for(int i=0; i<n; ++i){
		ll s, t;
		cin >> s >> t;
		v.push_back(P(t, s));
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	for(int i=0; i<k; ++i){
		if(!flag[v[i].second]){
			tmp += v[i].first;
			flag[v[i].second] = true;
			++cnt;
		}else{
			tmp += v[i].first;
			pq.push(v[i].first);
		}
	}
	ans = tmp + cnt * cnt;
	for(int i=k; i<n; ++i){
		if(!pq.empty() && !flag[v[i].second]){
			tmp -= pq.top();
			pq.pop();
			tmp += v[i].first;
			flag[v[i].second] = true;
			++cnt;
			ans = max(ans, tmp + cnt * cnt);
		}
	}
	cout << ans << "\n";
}

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

int main(){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll a_c = a/c;
    ll a_d = a/d;
    ll b_c = b/c;
    ll b_d = b/d;
    ll C = b_c - (a-1)/c;
    ll D = b_d - (a-1)/d;
    ll C_D = c/__gcd(c,d)*d;
    ll CD = b/C_D - (a-1)/C_D;
    //cout << C << " " << D << " " << CD << endl;
    ll ans = b-a+1 -C -D +CD;
    cout << ans << endl;
}

Measured memory_bytes: 256
from itertools import combinations
K, S = map(int, input().split())
ans = 0
if K*3 < S:
    print(0)
else:
    for i in range(K+1):
        for j in range(K+1):
            if S-i-j < 0: break
            elif S-i-j <= K: ans += 1
    print(ans)


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

public class Main {
    static final Scanner     sc = new Scanner(System.in);
    static final PrintStream so = System.out;
    static final int M = (int) 1E9 + 7;
    
    public static void main(String[] args) {
        COMinit();
        
        int N = nint();
        int K = nint();
        int s = N-K+1;
        
        for (int i = 1; i <= K; i++) {
            long a = COM(s, i);
            long b = COM(K-1, i-1);
            so.println(((a%M) * (b%M)) % M);
        }
    }
    static final int MAX = 510000;
    static int MOD = 1000000007;
    static long[] fac = new long[MAX], finv = new long[MAX], inv = new long[MAX];

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

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

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nstr();
        return a;
    }

    private static char[][] nsToChars2D(int h, int w) {
        return nsToChars2D(h, w, 0);
    }

    private static char[][] nsToChars2D(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}


Measured memory_bytes: 34388
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 500005;

int n, m, p, i, s1, s2, ok[N], bad[N];
char t[10];

int main() {
scanf("%d %d", &n, &m);
while (m--) {
	scanf("%d %s", &p, t);
	if (t[0] == 'A') ok[p] = 1; else if (!ok[p]) bad[p]++;
}
s1 = s2 = 0;
for (i=1;i<=n;i++) if (ok[i]) {
	s1++;
	s2 += bad[i];
}
printf("%d %d\n", s1, s2);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MAXN 400+5
using namespace std;
typedef long long LL;
LL n,c,mod=1e9+7;
LL a[MAXN],b[MAXN];
LL f[MAXN][MAXN],s[MAXN][MAXN],sum[MAXN][MAXN];
int main()
{
	scanf("%lld%lld",&n,&c);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++) scanf("%lld",&b[i]);
	for(int i=1;i<=400;i++)
	{
		s[i][0]=1;
		for(int j=1;j<=400;j++)
		{
			s[i][j]=s[i][j-1]*i%mod;
		}
	}
	for(int i=1;i<=400;i++)
	{
		for(int j=0;j<=400;j++)
		{
			sum[i][j]=(sum[i-1][j]+s[i][j])%mod;
		}
	}
	f[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=c;j++)
		{
			for(int k=0;k<=j;k++)
			{
				f[i][j]=(f[i][j]+f[i-1][j-k]*((sum[b[i]][k]-sum[a[i]-1][k]+mod))%mod)%mod;
			}
		}
	}
		printf("%lld\n",f[n][c]);
	return 0;
}


Measured memory_bytes: 4096
//AOJ 0567: Best Pizza
#include<iostream>
#include<algorithm>
using namespace std;
const int MAX_N = 100;
int n, a, b, c, ans, cal = 0, cost = 0, tcal[MAX_N];
int main(){
	cin >> n >> a >> b >> c;
	for (int i = 0; i < n; i++){
		cin >> tcal[i];
	}
	ans = c / a;
	cost = a;
	cal = c;
	sort(tcal, tcal + n);
	for (int i = n - 1; i >= 0; i--){
		if (ans < tcal[i] / b){
			cal += tcal[i];
			cost += b;
			ans = cal / cost;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
 
int main()
{
   int x,a,b;
   scanf("%d%d%d",&x,&a,&b);
   int ans=x-a;
   int i;
   for(i=1;;++i)
   {
     ans-=b;
     if(b>ans)
         break; 
   }
  
  printf("%d",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long gcd(long long a,long long b)
{
    if(b) return gcd(b,a%b);
    return a;
}
int main()
{
    long long a,b,c,d,e,l,r,ans;
    cin>>a>>b>>c>>d;
    ans=b-a+1;e=c*d/gcd(c,d);
    if(a%c==0) l=a/c;
    else l=a/c+1;
    r=b/c;
    if(r>=l) ans-=r-l+1;
    if(a%d==0) l=a/d;
    else l=a/d+1;
    r=b/d;
    if(r>=l) ans-=r-l+1;
    if(a%e==0) l=a/e;
    else l=a/e+1;
    r=b/e;
    if(r>=l) ans+=r-l+1;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(raw_input())
l = map(int, raw_input().split())
ct = Counter(l)
eat = 0
sub = 0
for i in ct.values():
    eat += (i-1) / 2
    sub += (i-1) % 2
eat += (sub+1) / 2
print n - eat * 2


Measured memory_bytes: 16444
#include<iostream>
#include<string>
using namespace std;
int main(){
    int a,b,ans;
    string op;
    cin >> a >> op >> b; 

    if(op=="+"){
        ans = a+b;
    }else{
        ans = a-b;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
int main() {
    int n; cin >> n;
    vector<string> str(n);
    unordered_map<string, ll> um;
    rep(i, n) cin >> str.at(i);
    ll count = 0;
    rep(i, n){
        sort(str.at(i).begin(), str.at(i).end());
        um[str.at(i)] += 1;
        count += (um[str.at(i)] - 1);
    }
    cout << count << endl;
    return 0;
}

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

const int N = 12;
string S[N];
bool seen[N][N];
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};

struct UnionFind{
    vector<int> par;
    UnionFind(int N) : par(N){
        for(int i = 0; i < N; i++){
            par[i] = -1;
        }
    }
    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        else{
            if(par[rx] > par[ry]) swap(rx, ry);
            par[rx] += par[ry];
            par[ry] = rx;
       }
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    void check(){
        for(auto x : par){
            cout << x << " ";
        }
        cout << endl;
    }
};

void dfs(int x, int y, UnionFind &uf){
    seen[x][y] = true;
    for(int i = 0; i < 4; i++){
        int nx, ny;
        nx = dx[i] + x;
        ny = dy[i] + y;
        if(nx < 0 or ny < 0 or nx >= N or ny >= N) continue;
        if(S[nx][ny] == '0' or seen[nx][ny]) continue;
        uf.unite(x * N + y, nx * N + ny);
        dfs(nx, ny, uf);
    }
    return;
}

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

    while(cin >> S[0]){
        UnionFind uf(N * N);
        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                seen[i][j] = false;
                uf.par[i * N + j] = -1;
            }
        }
        for(int i = 1; i < N; i++){
            cin >> S[i];
        }

        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                if(!seen[i][j] and S[i][j] == '1'){
                    dfs(i, j, uf);
                }
            }
        }

        set<int> st;
        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                if(S[i][j] == '1') st.insert(uf.root(i * N + j));
            }
        }

        cout << st.size() << endl;

    }

    return 0;
}


Measured memory_bytes: 3200
#include<stdio.h>

int main(void)
{
	int H, W, i, j;
	while(1)
	{
		scanf("%d %d", &H, &W);
		if(H==0||W==0)
		{
			break;
		}
		for(i=1; i<=H; i++)
		{
			for(j=1; j<=W; j++)
			{
				if(i==1||i==H)
				{
					printf("#");
				}
				else if(j==1||j==W)
				{
					printf("#");
				}
				else
				{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}


Measured memory_bytes: 2496
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using ll=long long;
using namespace std;
const auto mod=1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
 

  string s,ans="No"; cin >> s;
  if(s[2]==s[3] && s[4]==s[5]) ans="Yes";
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>

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

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

int main()
{
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); i++)
	{
		if ((i+1) % 2 == 0)
		{
			if (s[i] == 'R')
			{
				cout << "No";
				return 0;
			}
		}
		else
		{
			if (s[i] == 'L')
			{
				cout << "No";
				return 0;
			}
		}
	}
	cout << "Yes";
}


Measured memory_bytes: 31488
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  double n;
  while (cin >> n) {
    if (n == 0) return 0;
    vector<double> v(n);
    double sum = 0;
    for (int i = 0; i < n; i++) {
      cin >> v.at(i);
      sum += v.at(i);
    }

    double ave = sum / n;
    double tmp = 0;
    for (int i = 0; i < n; i++) {
      tmp += v.at(i) * v.at(i) - 2 * v.at(i) * ave + ave * ave;
    }
    double a = sqrt(tmp / n);

    cout << fixed << setprecision(8) << a << endl;

  }


}



Measured memory_bytes: 3280
a, op, b = map(str, input().split())
while op != "?":
    if op == "+":
        print(int(a) + int(b))
    elif op == "-":
        print(int(a) - int(b))
    elif op == "*":
        print(int(a) * int(b))
    elif op == "/":
        print(int(a) // int(b))
    a, op, b = map(str, input().split())


Measured memory_bytes: 5592
import fractions

A,B,C,D = map(int, input().split())

E = (C*D)//fractions.gcd(C,D)

B_count = B-((B//C)+(B//D)-(B//E))
A_count = (A-1)-(((A-1)//C)+((A-1)//D)-((A-1)//E))

print(B_count-A_count)

Measured memory_bytes: 5048
#pragma GCC optimize (2)
#include<bits/stdc++.h>
using namespace std;
const int N=100000+5;
int a[N];
inline int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
    return x*f;
}

int main()
{
	int n=read();
	for (int i=1; i<=n; i++) a[i]=read();
	sort(a+1, a+n+1, greater<int>());
	for (int i=1; i<=n; i++) if (i+1>a[i+1])
	{
		int ans=0;
		for (int j=i+1; a[j]==i; j++) ans^=1;
		ans|=((a[i]-i)&1);
		if (ans) puts("First"); else puts("Second");
		return 0;
	}
	return 0;
}


Measured memory_bytes: 640