akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define endl enjoy_codeforces
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    int n;std::cin>>n;
    std::vector<int>sieve(55556);
    for(int p=2,i=0;p<=55555;p++){
        if(sieve.at(p))continue;
        if(p%5==1){
            std::cout<<(i?" ":"")<<p;
            if(++i==n){
                std::cout<<'\n';
                return 0;
            }
        }
        for(int i=p*p;i<=55555;i+=p)sieve.at(i)=true;
    }
}


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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

#define pv(a)	{rep(i,a.size())	cout<<a[i]<<" "; cout<<endl;}
#define mark(v)	cout<<"Here--"<<v<<endl;

const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision

   int n ; cin>>n;
   vector<double> p(n);
   rep(i,n) cin>>p[i];
   vector<vector<double>> coins(n+1,vector<double>(n+1,0));
   coins[0][0] = 1;
   repA(i,1,n){
      repA(j,0,i){
         if(j){
            coins[i][j] += p[i-1]*coins[i-1][j-1] ;
         }

         coins[i][j] += (1-p[i-1])*coins[i-1][j];
      }
   }

   double res = 0;
   repA(i,0,n){
      if(i>n-i){
         res+= coins[n][i];
      }
   }
   printf("%.10f\n",res);
    return 0;
}  

Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b;
    cin >>a >> b;
    int d=a/b;
    int r=a%b;
    double f=(double)a/b;
    cout << d <<" " << r << " " << fixed << setprecision(10) << f << endl;
    return 0;
}


Measured memory_bytes: 3292
import collections

n = int(input())
s_list = [
  ''.join(sorted(input())) for _ in range(n)
]

s_list_cnt = collections.Counter(s_list)
total = 0
for cnt in s_list_cnt.values():
  total += cnt * (cnt - 1) / 2
  
print(int(total))

Measured memory_bytes: 19764
import           Control.Monad      (foldM, replicateM)
import           Data.Bits          (popCount, testBit)
import           Data.IntMap.Strict ((!))
import qualified Data.IntMap.Strict as M


main :: IO ()
main = do
  n <- readLn
  ts <- replicateM n readTestimony
  print $ solve n ts

solve :: Int -> [(Int, [(Int, Int)])] -> Int
solve n ts = maximum $ map popCount xs
  where xs = filter (isValid n ts) [0 .. 2^n-1]

isValid :: Int -> [(Int, [(Int, Int)])] -> Int -> Bool
isValid n ts x = validate x $ foldM f m xys'
  where m = M.fromList [(i, Undefined) | i <- [1 .. n]]
        xys' = concat [xys | ((_, xys), i) <- zip ts [0..], testBit x i]

f :: M.IntMap Personality -> (Int, Int) -> Maybe (M.IntMap Personality)
f m (x, y)
  | z == p         = Just m
  | z == Undefined = Just $ M.insert x p m
  | otherwise      = Nothing
  where p = toEnum y
        z = m ! x

data Personality = Unkind | Honest | Undefined
  deriving (Show, Eq, Enum)

validate :: Int -> Maybe (M.IntMap Personality) -> Bool
validate _ Nothing  = False
validate x (Just m) = all (g x) $ M.toList m

g :: Int -> (Int, Personality) -> Bool
g x (i, p) = p == Undefined || p == p'
  where p' = if testBit x (i - 1) then Honest else Unkind

readTestimony :: IO (Int, [(Int, Int)])
readTestimony = do
  a <- readLn
  xys <- replicateM a readInt2
  return (a, xys)

readInt2 :: IO (Int, Int)
readInt2 = do
  [x, y] <- map read . words <$> getLine
  return (x, y)


Measured memory_bytes: 1020
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int n;
    ll a[201]; INITA(a, 0, 200, 0);

    cin >> n;
    REP(i, n) { cin >> a[i]; }

    ll res = 0;
    while (true) {
        bool all = true;
        REP(i, n) {
            if (a[i] % 2 == 0) {
                a[i] /= 2;
            } else {
                all = false;
                break;
            }
        }
        if (all) {
            res++;
        } else {
            break;
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
n,m,k=map(int,input().split(" "))
a=list(map(int,input().split(" ")))
# b=list(map(int,input().split(" ")))
b=map(int,input().split(" "))

t=0
i=0
while i<n :
    if t+a[i]>k :
        break
    t+=a[i]
    i+=1

# j=0
# while j<m :
#     if t+b[j]>k :
#         break
#     t+=b[j]
#     j+=1
j=0
for x in b :
    # print("mk1 x=",x)
    if t+x>k :
        break
    t+=x
    j+=1

ans=i+j
while i>0 :
    i-=1
    t-=a[i]
    if t+x>k :
        continue
    else:
        t+=x
        j+=1
    for x in b :
        # print("mk2 x=",x)
        if t+x>k :
            break
        t+=x
        j+=1
    # while j<m and t+b[j]<=k :
    #     t+=b[j]
    #     j+=1
    ans=max(ans,i+j)

print(ans)


Measured memory_bytes: 35916
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
  int n;
  cin>>n;
  string s;
  map<string,int> mp;
  while(n--)
  {
    cin>>s;
    mp[s]++;
  }
  cout<<"AC x "<<mp["AC"]<<"\n";
  cout<<"WA x "<<mp["WA"]<<"\n";
  cout<<"TLE x "<<mp["TLE"]<<"\n";
  cout<<"RE x "<<mp["RE"]<<"\n";
}

Measured memory_bytes: 3640
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    stringstream ss;

    ll right = tx - sx;
    ll up = ty - sy;

    FOR(i, 0, right){
        ss << 'R';
    }
    FOR(i, 0, up){
        ss << 'U';
    }
    FOR(i, 0, right){
        ss << 'L';
    }
    FOR(i, 0, up){
        ss << 'D';
    }

    // lap 2

    ss << "DR";
    FOR(i, 0, right){
        ss << 'R';
    }
    FOR(i, 0, up){
        ss << 'U';
    }
    ss << "UL";

    // return 

    ss << "UL";
    FOR(i, 0, right){
        ss << 'L';
    }
    FOR(i, 0, up){
        ss << 'D';
    }
    ss << "DR";

    p(ss.str());
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;

const int N=305;

int n,m,mod;
int dp[N][N],c[N][N],s[N][N];

void init(int n){
	int i,j;
	c[0][0]=1;
	for (i=1;i<=n;i++){
		c[i][0]=1;
		for (j=1;j<=i;j++) c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
	}
}

int main(){
	int i,j,k;
	scanf("%d%d%d",&n,&m,&mod);
	init(300);
	for (i=0;i<=m;i++) dp[1][i]=1;
	for (i=m;i>=0;i--) s[1][i]=(s[1][i+1]+dp[1][i])%mod;
	for (i=2;i<=n+1;i++){
		for (j=0;j<=m;j++)
			for (k=1;k<i;k++){
				(dp[i][j]+=1ll*dp[i-k][j]*s[k][j+1]%mod*c[i-2][k-1]%mod)%=mod;
			}
		for (j=m;j>=0;j--) s[i][j]=(s[i][j+1]+dp[i][j])%mod;
	}
	printf("%d\n",dp[n+1][0]);
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int a,b,c,d;
   cin >> a >> b >> c >> d;
   int ff = (c+b-1)/b, ss = (a+d-1)/d;
   if(ss>=ff){
      cout << "Yes\n";
   }else{
      cout << "No\n";
   }
   return 0;
} 

Measured memory_bytes: 3652
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, islice
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')

N = INT()
abc = [LIST() for _ in range(N)]

dp = [[0]*3 for _ in range(N+1)]
for i in range(1, N+1):
	for j in range(3):
		dp[i][j] = max(dp[i-1][(j-1)%3]+abc[i-1][(j-1)%3], dp[i-1][(j+1)%3]+abc[i-1][(j+1)%3])
print(max(dp[N]))


Measured memory_bytes: 91480
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long inf = 1LL<<60;

int main(){
    int a,b,c;
    cin >> a >> b >> c;

    if(a==b && b==c){
        cout << 1 << endl;
    }
    else if(a==b || a==c ||b==c){
        cout << 2 << endl;
    }
    else {
        cout << 3 << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))

dp = [0]*N
dp[N-1], dp[N-2] = 0, abs(h[N-1] - h[N-2])
for i in range(N-3,-1,-1):
    dp[i] = min(abs(h[i] - h[i+1]) + dp[i+1], abs(h[i] - h[i+2]) + dp[i+2])
print(dp[0])

Measured memory_bytes: 13928
import java.util.*;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double t =sc.nextDouble(),a=sc.nextDouble();
        double[] h = new double[n];
        int ans = 0;
        for(int i = 0;i<n;i++){
            h[i] = sc.nextDouble();
            if(Math.abs(a-(t-h[i]*6/1000))<Math.abs(a-(t-h[ans]*6/1000))){
                ans = i;
            }
        }
        System.out.println(ans+1);
    }
}


Measured memory_bytes: 28732
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 1; ll z = 0, o = 1;
vl flag, color, D; vector<vpll> path;
int main() {
	cin >> H >> W;
	vll A(H, vl(W, 0));
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			cin >> A[i][j];
		}
	}
	vector<tuple<ll, ll, ll, ll>> Ans;
	for (i = 0; i < H; i++) {
		for (j = 0; j < W-1; j++) {
			if (A[i][j] % 2 == 1) {
				Ans.push_back(make_tuple(i + 1, j + 1, i + 1, j + 2));
				A[i][j]--;
				A[i][j + 1]++;
			}
		}
	}
	for (i = 0; i < H-1; i++) {
		if (A[i][W-1] % 2 == 1) {
			Ans.push_back(make_tuple(i + 1, W, i + 2, W));
			A[i][W-1]--;
			A[i+1][W-1]++;
		}
	}
	cout << Ans.size() << endl;
	for (i = 0; i < Ans.size(); i++) {
		cout << get<0>(Ans[i]) << " " << get<1>(Ans[i]) << " " << get<2>(Ans[i]) << " " << get<3>(Ans[i]) << endl;
	}
}

Measured memory_bytes: 8172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INF 1000000000000 //10^12

int main(){
    ll n,k;
    cin >> n >> k;
    vector<bool> ans(n,false);
    REP(i,k){
        ll d;
        cin >>d;
        REP(j,d){
            ll temp;
            cin >>temp;
            ans[temp-1]=true;

        }

    }
    ll anss=0;
    REP(i,n){
        if(!ans[i])
            anss++;
    }
    cout << anss<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	int L = A + B;
	int R = C + D;

	if (L > R) {
		cout << "Left" << endl;
	}
	else if (L == R) {
		cout << "Balanced" << endl;
	}
	else if (L < R) {
		cout << "Right" << endl;
	}


}


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

int main() {
    int N, A[100], result = 0;
    cin >> N;;

    for (int i = 0; i < N; i++) cin >> A[i];

    for (int i = 0; i < N; i++) {
        int max = 0;
        int maxj = 0;
        for (int j = 0; j < N; j++) {
            if (A[j] >= max) {
                max = A[j];
                maxj = j;
            }
        }
        if (i%2 == 0) result += max;
        else result -= max;
        A[maxj] = 0;

    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define REPA(x, v) for(auto&& x:v)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(v.rbegin(),v.rend())
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

struct union_find {
    vector<int> parent; //親の番号を格納する。親だった場合は-(その集合のサイズ)
    union_find(int N) {
        parent = vector<int>(N, -1); //parentの値を-1にする(すべてバラバラ)
     }
    int root(int A) { //Aがどのグループに属しているか調べる
        if (parent[A] < 0) return A;
        return parent[A] = root(parent[A]);
    }
    int size(int A) { //自分のいるグループの頂点数を調べる
        return -parent[root(A)];//親をとってきたい
    }
    bool connect(int A, int B) { //AとBをくっ付ける．すでにつながっていた場合false
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) return false; //すでにくっついてるからくっ付けない
        if (size(A) < size(B)) swap(A, B); //大小が逆だったらひっくり返しちゃう。
        parent[A] += parent[B]; //Aのサイズを更新する
        parent[B] = A; //Bの親をAに変更する
        return true;
    }
};

int main(void)
{
    int N,M;
    cin >> N >> M;
    union_find uf(N);
    REP(i, M){
        int a,b;
        cin >> a >> b;
        uf.connect(a-1, b-1);
    }

    int ans = 0;
    REP(i, N){
        chmax(ans, uf.size(i));
    }
    pr(ans);
}

Measured memory_bytes: 4044
A, B, C, X, Y = map(int, input().split())

if A + B <= 2 * C:
    print(A * X + B * Y)
else:
    if X <= Y:
        ans = 2 * C * X + min(B, 2 * C) * (Y - X)
    else:
        ans = 2 * C * Y + min(A, 2 * C) * (X - Y)
    print(ans)


Measured memory_bytes: 2940
// Last Change: 04/27/2019 21:03:15.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

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

  ll ans = T / A;
  ans *= B;
  cout << ans << endl;

  //NS::LoopUntilZeroInpput();
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<ll,int> P;
typedef pair<ll,P> PP;

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

int n,m,c;
int limit[100000];
vector<int> ball[100000];
vector<int> BALL;

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

	cin>>n>>m>>c;
	REP(i,c) cin>>limit[i];
	REP(i,n) {
		int color,value;
		cin>>color>>value;
		color--;
		ball[color].pb(value);
	}
	REP(i,c) {
		sort(ALL(ball[i]),greater<int>());
		REP(j,min((int)ball[i].size(),limit[i])) BALL.pb(ball[i][j]);
	}
	sort(ALL(BALL),greater<int>());
	int ans=0;
	REP(i,m) ans+=BALL[i];
	cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 7900
import numpy as np
from functools import *

import sys
sys.setrecursionlimit(100000)



def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


def acinput():
    return list(map(int, input().split(" ")))


X,N=acinput()
if N>0:
    #print(X,N)
    p=sorted(acinput())
else:
    print(X)
    sys.exit()

res=0
res_v=2000
for i in range(0,102):
    #print(i,res,res_v)
    
    d=abs(X-i)
    if res_v>=d and not (i in p):
        if i<X:
            res_v=d
            res=i
        elif d<res_v:
            res_v=d
            res=i
        
print(res)        
#print(res_v)



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

using namespace std;

int main(void){
    int N;
    cin>>N;
    vector<long long> H(N);
    for(int i=0;i<N;i++){
        cin>>H[i];
    }
    int count=0;
    int ans=0;
    for(int i=0;i<N-1;i++){
        if(H[i]>=H[i+1]) count++;
        else{
            count=0;
        }
        ans=max(ans,count);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
// https://atcoder.jp/contests/abc085/tasks/abc085_c
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int main()
{
    int N, Y;
    cin >> N >> Y;
    int yen[3] = {10000, 5000, 1000};
    int ans[3];
    int cnt = 0;
    bool ok = false;
    for (int i = 0; i <= N; ++i)
    {
        for (int j = 0; j <= N; ++j)
        {
            int k = N - i - j;
            if (k < 0) continue;
            int m = yen[0] * i + yen[1] * j + yen[2] * k;
            if (m == Y)
            {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}


Measured memory_bytes: 3592
/* mamba mentality */
#include "bits/stdc++.h"
using namespace std;
typedef long double ld;
#define int long long
typedef pair<int,int> pii;
#define RAGE ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(i=0; i <n; i++)
#define repv(i,k,n) for(int i=k; i<=n; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define endl '\n'
#define deb(x) cout<<#x<<" = "<<x<<endl
#define gcd __gcd
#define inf LLONG_MAX
#define minf LLONG_MIN 
const int mod = (int)(1e9+7);

int power(int x,int n)
{   
    if(n==0)    return 1;
    if(n==1)    return x%mod;
    if(n%2==0)  {   int y = power(x,n/2)%mod;return (y*y)%mod;}
    if(n&1)     {   int y = power(x,n-1);return (x%mod * y%mod)%mod;}
    return 0;
}
bool is_power_2(int n)  { return log2(n)==floor(log2(n));}
bool is_prime(int n){for(int i=2; i*i<=n; i++)if(n%i==0)return 0; return 1;}

int dx[]    =  { 1 ,  0,  -1,  0,  -1, -1, 1,  1};
int dy[]    =  { 0 ,  1,   0, -1,  -1,  1, 1, -1};
char dir[]  =  {'D','R','U','L'};

const int maxn =100005;

/* ------------------------------------------------------- */



void solve()
{
    int n,i,j,k,m;
    cin>>n;
    int ar[n];
    m=0;
    rep(i,n)
        cin>>ar[i];
    sort(ar,ar+n);
    m += ar[n-1];
    int e = 2 , cnt = n-2;
    for(i=n-2; i>=0 && cnt; )
    {
        if(e)
            m += ar[i] , e-- ,cnt--;
        else
            e=2 , i--;
    }
    cout<<m;
}  
signed main()
{
    RAGE;   
    int t=1;
    //  cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 5268
// Last Change: 04/21/2019 23:31:10.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

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

  ll cost = 1e5, c, t;
  for (ll i = 0; i < N; ++i) {
    cin >> c >> t;
    if (t <= T) {
      cost = min(cost, c);
    }
  }

  if (cost == 1e5) {
    cout << "TLE" << endl;
  } else {
    cout << cost << endl;
  }

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 888
class _Node {
  constructor(key, parent = null, left = null, right = null) {
    this.key = key;
    this.parent = parent;
    this.left = left;
    this.right = right;
  }

  getChildrenNumber() {return Number(this.left !== null) + Number(this.right !== null);}

  isLeftChild() {
    if (this.parent === null) return null;
    return this.parent.left === this;
  }

  getLeftOrRight() {return this.isLeftChild() ? 'left' : 'right';}

  getSuccessor() {
    let n;
    if (this.right !== null) {
      n = this.right;
      while (n.left !== null) n = n.left;
    } else {
      n = this.parent;
      while (!n.isLeftChild && n.parent != null) n = n.parent;
    }
    return n;
  }
}

class BinaryTree {
  constructor() {
    this.root = null;
  }

  static get Node() { return _Node; }

  insert(key) {
    if (this.root === null) {
      this.root = new BinaryTree.Node(key);
      return;
    }
    let x = this.root, y;
    let newNode = new BinaryTree.Node(key);
    while (x !== null) {
      y = x;
      x = x[key < x.key ? 'left' : 'right'];
    }
    newNode.parent = y;
    y[key < y.key ? 'left' : 'right'] = newNode;
  }

  find(key) {
    const innerFunc = (n) => {
      if (n === null || n.key === key) return n;
      return innerFunc(n[key < n.key ? 'left' : 'right']);
    };
    return innerFunc(this.root);
  }

  delete(key) {
    const n = this.find(key);
    let leftOrRight = n.getLeftOrRight();
    switch (n.getChildrenNumber()) {
    case 0:
      n.parent[leftOrRight] = null;
      break;
    case 1:
      n.parent[leftOrRight] = n.left || n.right;
      n.parent[leftOrRight].parent = n.parent;
      break;
    default:
      let skey = n.getSuccessor().key;
      this.delete(skey);
      n.key = skey;
    }
  }

  printByIneorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      innerFunc(n.left);
      str += ` ${n.key}`;
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  printByPreorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      str += ` ${n.key}`;
      innerFunc(n.left);
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  print() {
    this.printByIneorder();
    this.printByPreorder();
  }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());

  const tree = new BinaryTree();
  lines.forEach(function(cmd) {
    switch (cmd.charAt(0)) {
    case 'i': tree.insert(Number(cmd.split(' ')[1])); break;
    case 'f': console.log(tree.find(Number(cmd.split(' ')[1])) ? 'yes' : 'no'); break;
    case 'd': tree.delete(Number(cmd.split(' ')[1])); break;
    default: tree.print();
    }
  });
})();



Measured memory_bytes: 202900
# ARC 061 A

def resolve():
  n, m = map(int, input().split())

  arr = [0] * (n+1)

  for i in range(m):
    a, b = map(int, input().split())
    arr[a] += 1
    arr[b] += 1

  for i in range(1, n+1):
    print(arr[i])


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>

using namespace std;

typedef long long ll;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) REP(i,0,b)
#define maxn 100

int f(){
	int ans=0;
	return ans;
}

int main(){
	string a,b,c;
	while(cin>>a>>b>>c){
		char x,y,z;
		x=toupper(a[0]);
		y=toupper(b[0]);
		z=toupper(c[0]);
		cout<<x<<y<<z<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
function main(lines) {
    const n = lines.split('\n')[0]
    const An = lines.split('\n')[1].split(' ').map(Number)
    
    let swap = 0
    //範囲を狭めていく
    for(let i=0; i<n-1; i++){
        let minElement = i;
        for(let j=i; j<n; j++){
            // <=にすると、同一の最小値がいくつもあるときに不具合
            // 左から一番小さな値を検索
            if(An[j] < An[minElement]){
                minElement = j;
            }
        }
        let tmp = An[i]
        An[i] = An[minElement]
        An[minElement] = tmp
        if(i!= minElement){
            swap++
        }
    }
    console.log(An.join(' '))
    console.log(swap)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));




Measured memory_bytes: 15412
#include<stdio.h>
int max(int a, int b) {
  if (a >= b) return a;
  else return b;
}
int main() {
  int small[5][2] = {{0, 0}, {1, 0}, {-1, 0}, {0, 1}, {0, -1}};
  int medium[9][2] = {{1, 1}, {1, 0}, {1, -1}, {0, 1}, {0, 0}, {0, -1}, {-1, 1}, {-1, 0}, {-1, -1}};
  int big[13][2] = {{1, 1}, {1, 0}, {1, -1}, {0, 1}, {0, 0}, {0, -1}, {-1, 1}, {-1, 0}, {-1, -1}, {2, 0}, {-2, 0}, {0, 2}, {0, -2}};
  int paper[10][10];
  int i, j, x, y, X, Y, n, kosuu, noudo;
  for (i = 0; i < 10; i ++) for (j = 0; j < 10; j ++) paper[i][j] = 0;
  kosuu = 0; noudo = 0;
  while(scanf("%d,%d,%d", &x, &y, &n) != EOF) {
    if (n == 1) {
      for (i = 0; i < 5; i ++) {
	X = x + small[i][0]; Y = y + small[i][1];
	if (0 <= X && X < 10 && 0 <= Y && Y < 10) paper[X][Y] ++;
      }
    } else if (n == 2) {
      for (i = 0; i < 9; i ++) {
	X = x + medium[i][0]; Y = y + medium[i][1];
	if (0 <= X && X < 10 && 0 <= Y && Y < 10) paper[X][Y] ++;
      }
    } else if (n == 3) {
      for (i = 0; i < 13; i ++) {
	X = x + big[i][0]; Y = y + big[i][1];
	if (0 <= X && X < 10 && 0 <= Y && Y < 10) paper[X][Y] ++;
      }
    }
  }
  for(i = 0; i < 10; i ++) for (j = 0; j < 10; j ++) {
    kosuu += !paper[i][j]; noudo = max(noudo, paper[i][j]);
  }
  printf("%d\n%d\n", kosuu, noudo);
  return 0;
}

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

int main()
{
    int n;
    cin >> n;
    string s[n];
    int ans = 0;
    int a = 0;
    int b = 0;
    int c = 0;
    int t = -1;
    for(int i=0;i<n;i++){
        cin >> s[i];
        for(int j=0;j<10;j++){
            if((int)s[i].find("AB",j) != -1 && (int)s[i].find("AB",j) != t){
                ans++;
                t = (int)s[i].find("AB",j);
            }
        }

        t = -1;

        if(s[i].front() == 'B' && s[i].back() == 'A'){
            c++;
        }
        else if(s[i].front() == 'B'){
            b++;
        }
        else if(s[i].back() == 'A'){
            a++; 
        }
    }

    if(a == 0 && b == 0){
        if(c != 0)
        ans = ans + c - 1;
    }
    else
    {
        ans = ans + min(a,b) + c;
    }
    cout << ans << endl;

    return 0;
}

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

int coin[] = {500,100,50,10,5,1};

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

    int n;
    while(cin >> n){
        if(!n) break;

        int m = 1000 - n;
        int ans = 0;

        rep(i,6){
            ans += m/coin[i];
            m = m%coin[i];
        }

        cout << ans << endl;
    }

    return 0;
}


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

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> a(m);
    for(int i = 0; i < m; i++) cin >> a[i];
    sort(a.begin(),a.end());
    vector<int> b(m-1);
    for(int i = 0; i < m-1; i++) b[i]=a[i+1]-a[i];
    sort(b.begin(),b.end());
    ll ans =0;

    if(n>=m){
        cout << 0 << endl;
    }
    else{
        for(int i = 0; i < m-n; i++) {
            ans += b[i];
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 4032
import sys
read = sys.stdin.buffer.read
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')
import math


def main():
	
	k=II()
	
	ans=0
	
	li=[0]*(k+1)
	
	for a in range(1,k+1):
		for b in range(1,k+1):
			li[math.gcd(a,b)]+=1
	
	for i in range(1,k+1):
		for c in range(1,k+1):
			ans+=li[i]*math.gcd(i,c)
				
	
	print(ans)





	
if __name__ == "__main__":
	main()


Measured memory_bytes: 9176
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    int c;
    rep(i, N-2){
        if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') {
            c++;
        }
    }
    cout << c << endl;
}


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int a, b, m;
    cin >> a >> b >> m;
    vector<Int> as(a), bs(b);
    for (Int i = 0; i < a; i++) {
        cin >> as[i];
    }
    for (Int i = 0; i < b; i++) {
        cin >> bs[i];
    }
    vector<Int> x(m), y(m), c(m);
    for (Int i = 0; i < m; i++) {
        cin >> x[i] >> y[i] >> c[i];
        x[i]--;
        y[i]--;
    }
    Int mi = INF;
    for (Int i = 0; i < m; i++) {
        mi = min(mi, as[x[i]] + bs[y[i]] - c[i]);
    }
    sort(all(as));
    sort(all(bs));
    mi = min(mi, as.front() + bs.front());
    dump(mi);
    return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define rep(i , n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    ll N, K, b, v[100001]{};
    cin >> N >> K;
    while (cin >> N >> b) {
        v[N] += b;
    }
    N = 0;
    while (K > 0){
        K -= v[++N];
    }
    cout << N << endl;
}


Measured memory_bytes: 4372
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int dp[1001][1001];
  int n,W;
  int v[1000],w[1000];
  int num=0;
  char c;
  int cnt=0;
  while(1){
    cin>> W;
    if(W==0) break;
    cin>> n;
    cnt++;
    for(int i=0;i<=n;i++){
      for(int j=0;j<=W;j++){
	dp[i][j]=0;
      }
    }
    for(int i=1;i<=n;i++){
      scanf("%d,%d",&v[i],&w[i]);
    }

    for(int i=1;i<=n;i++){
      for(int j=1;j<=W;j++){
	if(j<w[i]){
	  dp[i][j]=dp[i-1][j];
	} else {
	  dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
	}
      }
    }

    int ansv=0,answ=0;
    for(int i=1;i<=W;i++){
      if(ansv<dp[n][i]){
	ansv=dp[n][i]; answ=i;
      }
    }
    printf("Case %d:\n%d\n%d\n",cnt,ansv,answ);
  }
}

Measured memory_bytes: 5152
//078 B - ISU 2017/11/11
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int x , y , z; cin >> x >> y >> z;
    int min;
    int i;
    for(i=1;;++i){
        if(x-y*i-(z*(i+1))>=0) continue;
        else {--i; break;}
    }
    cout << i << endl;
}

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD =   1000000007;

/// Lib
///

int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int a, b; cin >> a >> b;
    int lo = min(a, b);
    int hi = max(a, b);
    if( (hi+lo) % 2 != 0){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    int ans = (hi + lo) / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
const int MAX_N = 1000000;
int n;
int num[MAX_N];
int ans=0;

int main(){

    for (int i = 2; i < MAX_N; i++){
        num[i] = 1;
    }
    for (int i = 2; i < MAX_N; i++){
        if (num[i] == 0) continue;
        for (int j = 2; i*j < MAX_N; j++){
            num[i*j] = 0;
        }
    }

    while(scanf("%d",&n) != -1){
        ans = 0;
        for(int i = 0; i < n+1; i++){
            if(num[i] == 1){
            ans++;
        }
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 4928
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = a*b;

		if(d >= c) {
			System.out.println(c);
		}else {
			System.out.println(d);
		}
	}
}

Measured memory_bytes: 21844
#include<stdio.h>

int main(){

int n,i,x=0;
scanf("%d",&n);


while(n>5){
    if(n>=500){
        i=n/500;
        x+=(i*1000);
        n-=(i*500);

    }
    else if( n>=5)
    {
        i=n/5;
        x+=(i*5);
        n-=(i*5);
    }




}


printf("%d",x);




}


Measured memory_bytes: 128
#include <iostream>
#include <queue>
#include <cstdlib>
#define MAX 10001
using namespace std;
typedef long long lld;
int main(void) {
    priority_queue<lld> que;
    lld n, m, x[MAX], y[MAX], z[MAX], ans=0, sum;
    cin >> n >> m;
    for(int i=0; i<n; i++)
        cin >> x[i] >> y[i] >> z[i];
    
    int sx[8] = { 1, 1, 1, 1, -1, -1, -1, -1 };
    int sy[8] = { 1, 1, -1, -1, 1, 1, -1, -1 };
    int sz[8] = { 1, -1, 1, -1, 1, -1, 1, -1 };
    
    
    for(int i=0; i<8; i++) {
        priority_queue<lld> empty;
        swap(que, empty);
        sum = 0;
        for(int j=0; j<n; j++)
            que.push(sx[i]*x[j] + sy[i]*y[j] + sz[i]*z[j]);
        
        for(int j=0; j<m; j++) {
            sum += que.top();
            que.pop();
        }

        ans = ans>=sum ? ans : sum;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) 998244353;
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << setiosflags(ios::fixed);
    ll n, m;
    cin >> n >> m;
    priority_queue<ll> que;

    rep(i, n) {
        ll a;
        cin >> a;
        que.push(a);
    }

    rep(i, m) {
        ll q = que.top();
        que.pop();
        que.push(q / 2);
    }

    ll sum = 0;
    while (!que.empty()) {
        sum += que.top();
        que.pop();
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1400
A,B,C,X = int(input()),int(input()),int(input()),int(input())
n = 0
for i in range(0,A+1):
    for j in range(0,B+1):
        for k in range(0,C+1):
            if 500*i+100*j+50*k == X:
                n=n+1
print(n)

Measured memory_bytes: 2940
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use proconio::*;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let s: String = read!();
    let t: String = read!();
    let s = s.chars().collect_vec();
    let t = t.chars().collect_vec();

    for i in (0..s.len()).rev() {
        if check(&s[i..], &t) {
            println!("{}", cross(&s, &t, i));
            return;
        }
    }
    
    println!("UNRESTORABLE");
}

fn check(s: &[char], t: &[char]) -> bool {
    if s.len() < t.len() {
        return false;
    }

    for i in 0..t.len() {
        if s[i] != '?' && s[i] != t[i] {
            return false;
        }
    }

    true
}

fn cross(s: &[char], t: &[char], start: usize) -> String {
    let mut ss = String::new();

    for i in 0..s.len() {
        if i < start {
            ss.push(if s[i] != '?' { s[i] } else { 'a' });
        } else if i < start + t.len() {
            ss.push(t[i - start]);
        } else {
            ss.push(if s[i] != '?' { s[i] } else { 'a' });
        }
    }

    ss
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T> void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T> void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U> bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U> bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T> bool even(T n) { return ! (n & 1); }
template<class T> bool odd(T n) { return n & 1; }
template<class T> ll rup(T a, T b) { return a % b ? a / b + 1 : a / b; }
template<class T> ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T> ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;
ll intpow(ll a, ll n, ll _mod=numeric_limits<ll>::max()) { ll p=1; while (n) { if (n&1) p=p*a%_mod; a=a*a%_mod; n>>=1; } return p; } 
ll modc(ll a, char op, ll b, ll _mod=mod) { a %= _mod; b %= _mod; ll res = 1; switch(op) {
        case '+': res = (a + b) % _mod; break;
        case '-': res = (a - b) % _mod; break;
        case '*': res = a * b % _mod; break;
        case '/': res = modc(a, '*', modc(b, '^', _mod-2, _mod), _mod); break;
        case '^': res = intpow(a, b, _mod); break;
        case 'P': rep(i, a-b+1, a+1) res = modc(res, '*', i, _mod); break;
        case 'C': res = modc(modc(a, 'P', b, _mod), '/', modc(b, 'P', b, _mod)); break; } if (res < 0) res += _mod; return res; }
 
 
int main()
{
        ll N;
        cin >> N;
        vll left(N), right(N);
 
        vector<pll> v(N);
        rep(i, 0, N) {
                ll x, l;
                cin >> x >> l;
                v[i].first = x - l;
                v[i].second = x + l;
        }
 
        sort(all(v), [](auto x, auto y) { return x.second < y.second; });
 
 
        ll tmp = v[0].second;
        ll ans = 0;
        rep(i, 1, N) {
                if (v[i].first < tmp) {
                        ++ans;
 
                } else {
                        tmp = v[i].second;
                }
        }
 
        cout << N - ans << endl;
}

Measured memory_bytes: 6412
s = int(input())

ls_a = [s]

for i in range(10**5):
    if ls_a[i] % 2 == 0:
        ls_a.append(ls_a[i] / 2)
    elif ls_a[i] % 2 == 1:
        ls_a.append(3 * ls_a[i] + 1)

    if ls_a[i+1] in ls_a[:i]:
        print(i+2)
        break

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

char field[300][300];
int ans[300][300];
int main()
{
	int H, W, K,k=1;
	cin >> H >> W >> K;
	pairs(A);
	int col = 0;
	fx(H) {
		fy(W) {
			cin >> field[x][y];
			if (field[x][y]=='#') {
				ans[x][y] = k++;
				col++;
				pb(A, make_pair(x, y));
			}
		}
	}
	sorts(A)
	fx(K) {
		int h = A[x].first - 1, w = A[x].second;
		int color = ans[h+1][w];
		while (h>=0&&ans[h][w]==0) {
			col++;
			ans[h][w] = color;

			h--;
		}
		h = A[x].first + 1;
		while (h < H && ans[h][w] == 0) {

			col++;
			ans[h][w] = color;
			h++;
		}
	}

	if (col != H * W) {
		fy(W) {
			if (ans[0][y]==0) {
				int w=y;
				if (y!=W-1) {
					while (w<W&&ans[0][w]==0) {
						w++;
					}
					if (w>=W) {
						w = y;
						while (w >=0 && ans[0][w] == 0) {
							w--;
						}
					}
					int h = 0;
					fx(H) {
						for (int z = y; z < w;z++) {
							if (ans[x][w]==ans[h][w]) {
								ans[x][z] = ans[h][w];
							}
							else {
								h = x;
								ans[x][z] = ans[h][w];
							}
						}
					}

				}
				else {
					while (ans[0][w] == 0) {
						w--;
					}
					int h = 0;
					fx(H) {
						for (int z = y; z > w; z--) {
							if (ans[x][w] == ans[h][w]) {
								ans[x][z] = ans[h][w];
							}
							else {
								h = x;
								ans[x][z] = ans[h][w];
							}
						}
					}
				}
			}
		}
	}
	fx(H) {
		fy(W) {
			cout << ans[x][y];
			if (y!=W-1) {
				cout << ' ';
			}
		}
		cout << endl;
	}
    return 0;
}



Measured memory_bytes: 2036
s = list(input())
odds = set(s[::2])
easy_odds = {'R', 'U', 'D'}
evens = set(s[1::2])
easy_evens = {'L', 'U', 'D'}
if odds <= easy_odds and evens <= easy_evens:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
a, b, c = MAP()
print("YES" if b-a == c-b else "NO")

Measured memory_bytes: 13784