akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100000

int N;
int table[NUM+1];

int main(){



	int ans = 0,tmp;

	scanf("%d",&N);

	for(int i = 1; i <= N; i++){

		table[i] = 0;
	}

	for(int i = 0; i < N; i++){

		scanf("%d",&tmp);
		if(tmp > N){

			ans += 1; //絶対に揃わないので除去
		}else{

			table[tmp] += 1;
		}
	}

	for(int i = 1; i <= N; i++){

		if(table[i] == 0)continue;

		if(table[i] >= i){

			ans += table[i]-i;

		}else{

			ans += table[i]; //増やせないため
		}
	}

	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 640
N, K = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
ans = ['First', 'Second']

dp = [1]*(K+1)

for i in range(K+1):
    if i < a[0]:
        dp[i] = 1
    else:
        flag = False
        for x in a:
            if i-x >= 0 and dp[i-x]:
                dp[i] = 0
                flag = True
                break

print(ans[dp[-1]])


Measured memory_bytes: 3956
#include <set>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <vector>
#include <tuple>
#include <string>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <limits>
#include <climits>
#include <numeric>
#include <functional>

#define lnd '\n'
// #define reverse(i, n) for(ll i = n-1; i >= 0; --i)
#define from(i, n) for (ll i = 0; i < n; ++i)
#define loop(i, n) for(ll i = 0; i < n; i++)
#define REPN(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(s) (s).begin(), (s).end()
#define rALL(s) (s).rbegin(), (s).rend()
#define sz(s) (int)(s).size()
#define mk make_pair
#define pb push_back
#define sqr(s) ((s) * (s))

using namespace std;

typedef long long ll;
typedef long long int lli;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;

template <class T>
T GCD (T a, T b) {
  if(a == 0) return b;
  return GCD(b%a, a);
}

template <class T>
T LCM(T a, T b){
  return a*b/GCM(a,b);
}

template <class T>
T modpow(T x, T p){
    T res = 1;
    while(p > 0){
        if(p&1) res *= x;
        x *= x;
        p /= 2;
    }
    return res;
}

template <class T>
T modpow(T x, T p, ll mod){
    T res = 1;
    while(p > 0){
        if(p&1) res = (res*x)%mod;
        x = (x*x)%mod;
        p /= 2;
    }
    return res%mod;
}

template <class T>
void print(T a[], ll n){
    for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
    cout << endl;
}

template<class T>
void printc(T c){
    for(auto const& v: c) std::cout << v << ' ';
    cout << endl;
}

struct HASH{
  size_t operator()(const pair<long,long>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

bool pair_sort(const pair<int, int> &p1, const pair<int,int> &p2){
    if(p1.first != p2.first) return p1.first < p2.first;
    else return p1.second < p2.second;
}

const int INF = std::numeric_limits<int>::max();
const ll M_INF = std::numeric_limits<ll>::min();
const ll LL_INF = std::numeric_limits<ll>::max();

void solution();
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solution();
    return 0;
}

ll result[200005] = {0};
void fact(ll n) {
   if (n >= 0) {
      result[0] = 1;
      for (ll i = 1; i <= n; ++i) {
         result[i] = i * result[i - 1];
      }
   }
}

void dfs(ll n, ll m, ll i, vector<ll> &v){
  if(i == n){
  }else{
    for(int k = 1; k <= m; k++){
      v.push_back(k);
      dfs(n, m, i+1, v);
      v.pop_back();
    }
  
  }
}

void solution(){
  ll n, m;
  cin >> n >> m;

  vector<ll> h(n);
  loop(i, n) cin >> h[i];

  vector<ll> edges(n, 0);
  loop(i, m){
    ll u, v;
    cin >> u >> v;
    --u;
    --v;
    edges[u] = max(edges[u], h[v]);
    edges[v] = max(edges[v], h[u]);
  }

  ll ans = 0;
  loop(i, n){
    if(edges[i] == 0 || h[i] > edges[i]){
      ans++;
    }
  }

  cout << ans << endl;
}     



Measured memory_bytes: 4408
#include<bits/stdc++.h>
using namespace std;
/*void mayank()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}*/
#define ll long long
#define inf 1e9
const int mxN = 1e5;
ll a[mxN + 1], b[mxN + 1];
ll solve(vector<ll>ans, int n, int k) {
	vector<ll>dp(n + 1);
	dp[1] = 0;
	for (int i = 2; i <= n; i++) {
		dp[i] = inf;
		for (int j = i - 1; j >= 1 and (i - j) <= k; j--) {
			dp[i] = min(dp[i], abs(ans[i] - ans[j]) + dp[j]);
		}
	}
	return dp[n];// Time Complexity is O(nk)
}
int main()
{
	//mayank();
	ll n, k;
	cin >> n >> k;
	vector<ll>ans(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> ans[i];
	}
	cout << solve(ans, n, k);
	return 0;
}

Measured memory_bytes: 2560
H, W, K = map(int, input().split())
Ass = [list(map(int, input().rstrip())) for _ in range(H)]

def check(Bss):
    L = len(Bss)
    accBs = [0] * L
    numCut = 0
    for i in range(W):
        for j in range(L):
            if Bss[j][i] > K:
                return H*W
            if accBs[j] + Bss[j][i] > K:
                accBs = [0] * L
                numCut += 1
                break
        for j in range(L):
            accBs[j] += Bss[j][i]
    return numCut

ans = H*W
for ptn in range(2**(H-1)):
    Bss = []
    Bs = Ass[0]
    numCut = 0
    for i in range(1, H):
        if (ptn>>(i-1)) & 1:  # 割る
            Bss.append(Bs)
            Bs = Ass[i]
            numCut += 1
        else:  # 割らない
            Bs = [B+A for B, A in zip(Bs, Ass[i])]
    Bss.append(Bs)

    numCut += check(Bss)
    ans = min(ans, numCut)

print(ans)


Measured memory_bytes: 44508
#include<iostream>
#include<string>
#include<memory.h>
using namespace std;
#define MAX 36

void BubbleSort(char c[],int x[],int n);
void SelectionSort(char c[],int x[],char c2[],int x2[],int n);

int main()
{
	int N,n,i;
	char CARD[MAX+1]={0},CARD2[MAX+1]={0};
	int number[MAX],number2[MAX];

	cin >> N ;
	for(i=0;i<N;i++){
		cin >> CARD[i]>>number[i] ;
	}

	n = N;
	memcpy(CARD2,CARD,MAX+1);
	
	for(i=0;i<N;i++){
		number2[i] = number[i];
	}


	//memcpy(number2,number,MAX); ?????????????????????????????????

	BubbleSort(CARD,number,N);
	SelectionSort(CARD,number,CARD2,number2,n);

	return 0;
}





void BubbleSort(char c[],int x[],int n){
	int i,j,tmp,count=0;
	char temp;

	for(i=1;i<n;i++){
		for(j=(n-1);j>(i-1);j--){ //0?????????????´????????????????????????????
			if(x[j] < x[j-1]){
				tmp = x[j] ;
				x[j] = x[j-1] ;
				x[j-1] = tmp ;

				temp = c[j] ;
				c[j] = c[j-1] ;
				c[j-1] = temp ;

				count++;
			}
		}
	}

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

	if(i<(n-1))cout << c[i] << x[i] << ' ' ;
	if(i == (n-1))cout << c[i] << x[i] << endl ;

	}
	
	cout << "Stable" << endl ;
}

void SelectionSort(char c[],int x[],char c2[],int x2[],int n){
	int i,j,k,tmp,count=0,mini,flag=0;
	char temp;

	for(i=0;i<n;i++){
		mini = i ;
		for(j=i;j<n;j++){
			if(x2[j] < x2[mini]){
				if(mini == i) count++;
				mini = j ;
			}

		}

		tmp = x2[i] ;
		x2[i] = x2[mini] ;
		x2[mini] = tmp ;

		temp = c2[i] ;
		c2[i] = c2[mini] ;
		c2[mini] = temp ;

	}

	
	for(k=0;k<n;k++){
		if(x[k]==x2[k]){
			if(c[k]!=c2[k]) flag=1; //????????????????????¨?????????????????¨??????????????°???????????????
		}
	}


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

	if(i<(n-1))cout << c2[i] << x2[i] << ' ' ;
	if(i == (n-1))cout << c2[i] << x2[i] << endl ;

	}
	
	if(flag == 0) cout << "Stable" << endl;
	if(flag == 1) cout << "Not stable" << endl ;
}

Measured memory_bytes: 1164
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
		public static void main(String[] args) {
			int a=scan.nextInt();
			int b=scan.nextInt();
			System.out.println((a+b)%2==0?(a+b)/2:"IMPOSSIBLE");
		}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N, ans{}; cin >> N;
  int A[N]; map<int, int>m; set<int> s; for (int &a: A) {cin >> a; ++m[a]; s.insert(a);}
  vector<bool> B(1000001, true); for (int a : s) for (int j{m[a] > 1 ? a : a + a}; j <= 1000000; j += a) B[j] = false;
  for (int a : A) ans += B[a]; cout << ans;}

Measured memory_bytes: 23208
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define mkp make_pair
//#define d double
void solve(){
	ll n,k;
	cin>>n>>k;
	vl a(n),f(n);
	rep(i,0,n) cin>>a[i];
	rep(i,0,n) cin>>f[i];
	RSort(a);
	Sort(f);
	ll mx=0;
	for(int i=0;i<n;i++){
		mx=max(mx,a[i]*f[i]);
	}
	if(k==0) cout<<mx;
	else{
		ll l=0,r=mx;
		ll ans;
		while(l<=r){
			ll mid=l+(r-l)/2;
			ll cnt=0;
			for(int i=0;i<n;i++){
				cnt+=(a[i]-min(a[i],mid/f[i]));
			}
			if(cnt<=k){
				ans=mid;
				r=mid-1;
			}
			else l=mid+1;
		}
		cout<<ans;
	}
	
 
 
}
int32_t main(){
FIO;
int t=1;
//cin>>t;
while(t--){
	solve();
}
}



Measured memory_bytes: 3328
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>

// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std

Jehian Norman Saviero;

// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;

// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")

// MACROS FOR ATTRIBUTE
#define fi first
#define se second

// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))

// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

ll fun(vll &A, ll k) { 
	ll n = A.size();
	ll count = 0;
	ll i = 0; 
	ll j = n - 1; 
	while (i < j) { 
		if (A[i] * A[j] <= k) { 
			count += (j - i); 
			i++; 
		} 
		else { 
			j--; 
		} 
	} 
	return count; 
}

ll fun(vll &A, vll &B, ll k) { 
	ll n = A.size();
	ll m = B.size();
	ll count = 0;
	ll i = 0;
	ll j = m - 1; 
	while (i < n && j >= 0) { 
		if (A[i] * B[j] <= k) { 
			count += (j + 1); 
			i++; 
		} else { 
			j--; 
		} 
	}
	return count; 
}


int main() {
	ll N, K;
	scll(N), scll(K);
	vll dat(N);
	vll neg, pos;
	ll type[2];
	type[0] = type[1] = 0;
	for (ll i = 0; i < N; ++i) {
		scll(dat[i]);
		++type[dat[i] >= 0];
		if (dat[i] < 0) {
			neg.pb(-dat[i]);
		} else {
			pos.pb(dat[i]);
		}
	}
	VSORT(neg), VSORT(pos);
	ll totNeg = type[0] * type[1];
	ll totNonNeg = N * (N-1) / 2LL - totNeg;
	if (totNeg >= K) {
		K = totNeg - K + 1;
		ll L = 0, R = 1e18;
		ll ans = R;
		while (L <= R) {
			ll mid = (L + R) / 2LL;
			ll eval = fun(neg, pos, mid);
			if (eval >= K) {
				ans = min(ans, mid);
				R = mid - 1;
			} else {
				L = mid + 1;
			} 
		}
		printf("%lld\n", -ans);
	} else {
		K -= totNeg;
		ll L = 0, R = 1e18;
		ll ans = R;
		while (L <= R) {
			ll mid = (L + R) / 2LL;
			if (fun(neg, mid) + fun(pos, mid) >= K) {
				ans = min(ans, mid);
				R = mid - 1;
			} else {
				L = mid + 1;
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 4084
#include<cstdio>

int n;

char query(int pos) {
	printf("%d\n", pos);
	fflush(stdout);
	
	char s[111];
	scanf("%s", s);
	return s[0];
}

int main() {
	scanf("%d", &n);
	
	int l = 0, r = n-1;
	char chl, chr;
	chl = query(l);
	if (chl == 'V') return 0;
	chr = query(r);
	if (chr == 'V') return 0;
	while(l<=r) {
		int mi = (l+r)/2;
		char res = query(mi);
		if (res == 'V') return 0;
		
		if (mi%2 == l%2 && res == chl ||
			mi%2 != l%2 && res != chl) {
			l = mi; chl = res;
		} else {
			r = mi; chr = res;
		}
	}
	
	return 0;
}

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

int main(){
    int A, B;
    cin >> A >> B;
    if(A > 12){
        cout << B << endl;
    }else if(13 > A && A > 5){
        cout << B/2 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
temp_list = []

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            temp = 500*i + 100*j + 50*k
            temp_list.append(temp)

ans = [n==x for n in temp_list].count(True)
print(ans)

Measured memory_bytes: 9428
#if defined(__GNUC__)
#include <bits/stdc++.h>
#define __int32 __int32_t
// __GNUC__
#else
#include "bits/stdc++.h"
#endif
using namespace std;

#define int long long

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); ++(i))
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); ++(i))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(ALL(x), greater<decltype(x)::value_type>())
#define RSORT2(x, T) sort(ALL(x), greater<T>())
#define REVERSE(x) reverce(ALL(x))
#define ACM(x, y) accumulate(ALL(x), y)

#define INT_POW(x, y) [](int a, int b) -> int {int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)
#define INT_POWM(x, y, m) [](int a, int b, int m) -> int {int c = a; REP(i, b - 1){c *= a; c %= m;} return c;}(x, y, m)
#define FCT(x) [](int a) -> int {int r = 1; REP(i, a){r *= i;} return r;}(x)

// デバッグ用
#define PUT_LIST(x, y) std::copy(ALL(x), ostream_iterator<decltype(x)::value_type>(cout, y))

const int kMod = 1e9 + 7;

int curPowMod(int a, int n, int m) {
	if (n == 0) {
		return 1;
	}
	else if (n == 1) {
		return a;
	}
	else if (n == 2) {
		return a * a;
	}
	else {
		int w = curPowMod(a, n / 2, m);
		w = (w * w) % m;
		return (w * ((n % 2) ? a : 1)) % m;
	}
}

itn main() {
	std::ios::sync_with_stdio(false);

	int n, a, b;

	cin >> n >> a >> b;

	if (n == 2) {
		cout << 0;
		return 0;
	}

	int all_mod_pow = curPowMod(2, n, kMod) - 1;

	int sub_ptr, a_ptr, b_ptr;
	sub_ptr = 0;

	int a_tp, a_bt;
	a_tp = n;
	a_bt = a;

	REP2(i, 1, a) {
		a_tp *= n - i;
		a_bt *= a - i;
		a_tp %= kMod;
		a_bt %= kMod;
	}

	int b_tp, b_bt;
	b_tp = n;
	b_bt = b;

	REP2(i, 1, b) {
		b_tp *= n - i;
		b_bt *= b - i;
		b_tp %= kMod;
		b_bt %= kMod;
	}

	a_ptr = (a_tp * curPowMod(a_bt, kMod - 2, kMod)) % kMod;
	b_ptr = (b_tp * curPowMod(b_bt, kMod - 2, kMod)) % kMod;

	sub_ptr = (a_ptr + b_ptr) % kMod;

	if (all_mod_pow < sub_ptr) {
		all_mod_pow += kMod;
	}

	all_mod_pow -= sub_ptr;

	cout << all_mod_pow;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main()
{
    int N;
    cin>>N;

    cout<<(N*800)-((N/15)*200)<<endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
using namespace std;
bool check1(string s){
    if(s[0]=='A'){
        return true;
    }else{
        return false;
    }
}
bool check2(string s){
    int cnt=0;
    for(int i=2;i<s.size()-1;i++){
        if(s[i]=='C'){
            cnt++;
        }
    }
    if(cnt==1){
        return true;
    }else{
        return false;
    }
}
bool check3(string s){
    for(int i=1;i<s.size();i++){
        if(isupper(s[i])&&s[i]!='C'){
            return false;
        }
    }
    return true;
}
int main(void){
    string s;
    cin>>s;
    if(check1(s)&check2(s)&check3(s)){
        cout<<"AC"<<endl;
    }else{
        cout<<"WA"<<endl;
    }
}

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

fee = 0

if A+B<= 2*C:
    fee += (A+B)*min(X,Y)
    if X > Y:
        if A > 2*C:
            fee += 2*C*(X-Y)
        else:
            fee += A*(X-Y)
    elif Y > X:
        if B > 2*C:
            fee += 2*C*(Y-X)
        else:
            fee += B*(Y-X)
else:
    fee =2*C*min(X,Y)
    if X > Y:
        if A > 2*C:
            fee += 2*C*(X-Y)
        else:
            fee += A*(X-Y)
    elif Y > X:
        if B > 2*C:
            fee += 2*C*(Y-X)
        else:
            fee += B*(Y-X)

print(fee)

Measured memory_bytes: 3064
#include<iostream>
#include<utility>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
#define i64 long long int
int n, m, ace[1111], m2;
pair<int,pair<int,int> > ee[2222],ee2[2222];
map<i64,int> Map;
i64 X;
vector<pair<int,int> > e[1111];
int ancestor(int x){
	return x-ace[x]?ace[x]=ancestor(ace[x]):x;
}

int fat[1111],dep[1111],len[1111];
void dfs(int x){
	for(vector<pair<int,int> >::iterator it = e[x].begin(); it != e[x].end(); it++){
		int y = it->first;
		if(y == fat[x])continue;
		fat[y] = x;
		dep[y] = dep[x] + 1;
		len[y] = it->second;
		dfs(y);
	}
}
int calc(int x,int y){
	int res = 0;
	while(dep[x] > dep[y]){
		res = max(res, len[x]);
		x = fat[x];
	}
	while(dep[y] > dep[x]){
		res = max(res, len[y]);
		y = fat[y];
	}
	while(x != y){
		res = max(res, len[x]);
		res = max(res, len[y]);
		x = fat[x];
		y = fat[y];
	}
	return res;
}
#define mod 1000000007
int pw2(int x){
	int r = 1;
	while(x--)
		r = r*2%mod;
	return r;
}
int main(){
	cin >> n >> m >> X;
	for(int i=0; i<m; i++)
		cin >> ee[i].second.first >> ee[i].second.second >> ee[i].first;
	sort(ee,ee+m);
	i64 tot = 0;
	for(int i=1; i<=n; i++)
		ace[i] = i;
	for(int i=0; i<m; i++){
		int xx = ee[i].second.first, yy = ee[i].second.second;
		int xx2 = ancestor(xx);
		int yy2 = ancestor(yy);
		if(xx2 != yy2){
			ace[xx2] = yy2;
			int zz = ee[i].first;
			tot += zz;
			e[xx].push_back(make_pair(yy, zz));
			e[yy].push_back(make_pair(xx, zz));
		}else{
			ee2[m2++] = ee[i];
		}
	}
	for(int i=1; i<=n; i++)
		if(ancestor(i) != ancestor(1)){
			puts("0");
			return 0;
		}
	if(tot > X){
		puts("0");
		return 0;
	}
	dfs(1);
	for(int i=0; i<m2; i++){
		Map[ee2[i].first - calc(ee2[i].second.first, ee2[i].second.second)] ++;
	}
	if(X == tot){
		int w = n-1 + Map[0];
		printf("%d\n",(pw2(m) - pw2(m-w+1)+ mod) % mod);
	}else{
		X -= tot;
		if(Map.count(X)){
			int w = 0;
			for(map<i64,int>::iterator it = Map.begin(); it != Map.end(); it++){
				if(it->first > X)
					w += it->second;
			}
			printf("%d\n",(pw2(w+Map[X]) - pw2(w) + mod)%mod * 2 % mod);
		}else
			puts("0");
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
using Graph=vector<vector<int>>;

int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  int a,r;
  cin>>a;
  r=0;
  r+=a;
  r+=a*a;
  r+=a*a*a;
  cout<<r<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

i64 K;

int main(){
  cin >> K;
  i64 N = 50;
  i64 time = K / N;
  vector<i64> a(N,time + N - 1);
  K %= N;
  for(int c = 0;c < K;c++){
    a[c] += N + 1;
    for(i64 &i : a) i -= 1;
  }

  cout << N << endl;
  for(int i = 0;i < N;i++){
    cout << a[i] << " \n"[i + 1 == N];
  }
}


Measured memory_bytes: 256
/*
#include <iostream>

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
	ll L, R;
	ll mod = 2019;

	cin >> L >> R;

	ll min = 10000;
	for (ll i = L; i <= R; i++) {
		for (ll j = i + 1; j <= R; j++) {
			int m = (i % mod) * (j % mod) % mod;
			if (m < min) {
				min = m;
			}
			if (m == 0) {
				cout << "0" << endl;
				return 0;
			}
		}
	}

	cout << min << endl;

	return 0;
}
*/
#include <iostream>
 
using namespace std;
 
typedef long long ll;
 
int main(int argc, char *argv[])
{
	ll L, R;
	ll mod = 2019;
 
	cin >> L >> R;
 
	for (ll i = L; i <= R; i++) {
		if (i % 2019 == 0) {
			cout << "0" << endl;
			return 0;
		}
	}
 
	ll min = 10000;
	for (ll i = L; i <= R; i++) {
		for (ll j = i + 1; j <= R; j++) {
			ll x = (i % mod) * (j % mod) % mod;
			if (x < min) {
				min = x;
			}
		}
 	}
	cout << min << endl;
 
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashMap<Integer, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			if (map.containsKey(a)) {
				map.put(a, map.get(a) + 1);
			} else {
				map.put(a, 1);
			}
		}
		int total = 0;
		for (int x : map.keySet()) {
			int y = map.get(x);
			if (y >= x) {
				total += y - x;
			} else {
				total += y;
			}
		}
		System.out.println(total);
	}
}


Measured memory_bytes: 63888
use std::io::Read;
const MOD: u64 = 1_000_000_007;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<u64> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut ans: u64 = 0;
    for bit in 0..60 {
        let mut cnt: u64 = 0;
        for i in 0..n {
            if a[i] >> bit & 1 == 1 {
                cnt += 1;
            }
        }
        ans = (ans + (1u64 << bit) % MOD * (n as u64 - cnt) % MOD * cnt % MOD) % MOD;
    }
    println!("{}", ans);
}

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

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split())) + [0]

ans = 0
ex = 0
for i in range(N+1):
    ans += min(A[i], ex)
    A[i] = max(0, A[i]-ex)

    ans += min(A[i], B[i])
    ex = max(0, B[i] - A[i])

print(ans)

Measured memory_bytes: 18476
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
long long n,q,G[200005]; 
vector < long long > v[200005];
void Dfs (int x,int p,long long val) {
	G[x]=val;
	for (int i=0; i<v[x].size(); i++) {
		if (v[x][i]==p) continue;
		Dfs(v[x][i],x,val+G[v[x][i]]);
	}
}
int main() {
	cin>>n>>q;
	
	for (int i=1; i<n; i++) {
		long long a,b;
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	
	for (int i=1; i<=q; i++) {
		long long a,b;
		cin>>a>>b;
		G[a]+=b;
	}
	
	Dfs(1,0,G[1]);
	
	for (int i=1; i<=n; i++) {
		cout<<G[i]<<" ";
	}
	
	return 0;
}

Measured memory_bytes: 27392
import java.util.Scanner;
class Main {
	int m,f,r,x;
	public void suzuki(){
		Scanner sc = new Scanner(System.in);
		m = sc.nextInt();
		f = sc.nextInt();
		r = sc.nextInt();
		x = m + f;
		while(m != -1 || f != -1 || r != -1){
			if(m == -1 || f == -1){
				System.out.println("F");
			}else{
				if(x >= 80){
					System.out.println("A");
				}else if(x >= 65){
					System.out.println("B");
				}else if(x >= 50){
					System.out.println("C");
				}else if(x >= 30){
					if(r >= 50){
						System.out.println("C");
					}else{
						System.out.println("D");
					}
				}else if(x < 30){
					System.out.println("F");
				}
			}
			m = sc.nextInt();
			f = sc.nextInt();
			r = sc.nextInt();
			x = m + f;
		}
	}
	public static void main(String[] args){
		new Main().suzuki();
	}
}

Measured memory_bytes: 19244
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    count4 = 0
    count1 = 0
    for a in A:
        if a % 4 == 0: count4 += 1
        if a % 2 == 1: count1 += 1
    if count4 >= count1:
        return "Yes"
    elif count4 == count1-1 and count4+count1 == N:
        return "Yes"
    return "No"

if __name__ == '__main__':
    print(main())

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

typedef long long ll;
typedef vector<int> vi;

const double PI=acos(-1.0);

ll x; ll gojou[160];
void input()
{
    cin>>x;
}

void solve()
{
    for(ll i=0ll;i<160ll;++i){
        gojou[i]=i*i*i*i*i;
    }
    bool end=false;
    for(int i=0;i<160;++i){
        for(int j=0; j<160;++j){
            if(gojou[i]-gojou[j]==x){
                cout<<i<<" "<<j<<endl;
                end=true;
                break;
            }
            else if(gojou[i]+gojou[j]==x){
                cout<<i<<" -"<<j<<endl;
                end=true;
                break;
            }
        }
        if(end) break;
    }
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main(void){
    int A, N, M, i, P;
    P = 0;
    scanf("%d %d",&N,&M);
    for(i=0;i<M;i++){
        scanf("%d",&A);
        P =P+A;
    }
    A = N - P;
	if(A<0){
      printf("-1");
    }
  else{
    printf("%d",A);
  }
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int>A(N+2);
  for(int i=1;i<=N;i++)
    cin>>A.at(i);
  A.at(0)=0;
  A.at(N+1)=0;
  int sum=0;
  for(int i=0;i<=N;i++)
    sum+=abs(A.at(i)-A.at(i+1));
  for(int i=1;i<=N;i++){
  if(A[i-1]<A[i] && A[i+1]<A[i]){
     int x=sum-2*(A[i]-max(A[i-1],A[i+1]));
                  cout<<x<<endl;
  }else if(A[i]<A[i-1] && A[i]<A[i+1]){
     int x=sum-2*(min(A[i-1],A[i+1])-A[i]);
    cout<<x<<endl;
  }else
        cout<<sum<<endl;
            
  }
    return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

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

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,s2;
  int ans = 0;
  while(cin >> s){
    s2 = "";
    rep(i,s.size()){
      if(s[i] - '0' >= 0 && s[i] -'0'<= 9){
        s2 += s[i];
      }
      else if(s2.size() !=0){
        ans += ston(s2,1);
        s2.clear();
      }
      else{
        s2.clear();
      }
    }
    if(s2.size() != 0){
      ans += ston(s2,1);
    }
  }
  cout << ans<<endl;
  return 0;
}

Measured memory_bytes: 3140
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef long double ld;


int main(){	
	fastio;
	ld a,b;cin>>a>>b;
	cout<<(a*b)/2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int k,s,cnt=0,n;
  cin>>k>>s;
  for(int i=0;i<=k;i++){
    for(int j=0;i+j<=s && j<=k;j++){
      n=s-i-j;
      if(n<=k && i+j+n==s) cnt++;
    }
  }
  cout<<cnt;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (X, t): (i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };

    let ans = std::cmp::max(X - t, 0);

    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007

const ll mod = 1e9 + 7;

ll power(ll a, ll b) { //a^b
	ll res = 1;
	a = a % MOD;
	while (b > 0) {
		if (b & 1) {res = (res * a) % MOD; b--;}
		a = (a * a) % MOD;
		b >>= 1;
	}
	return res;
}

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

vector <string> v(1003);
ll h, w;

bool valid(ll i, ll j) {
	if (i >= h || i < 0)
		return false;
	if (j >= w || j < 0)
		return false;
	if (v[i][j] == '#')
		return false;
	return true;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> h >> w;
	ll a, b, x, y;
	cin >> a >> b;
	cin >> x >> y;
	a--;
	b--;
	x--;
	y--;
	for (ll i = 0; i < h; i++)
		cin >> v[i];

	vector <vl> dp(h, vl (w, 1e9 + 7));
	priority_queue < pair<ll, pair<ll, ll>> > pq;
	dp[a][b] = 0;
	pq.push({0, {a, b}});
	while (!pq.empty()) {
		auto cur = pq.top();
		pq.pop();
		for (ll i = -2; i <= 2; i++) {
			for (ll j = -2; j <= 2; j++) {
				ll newx, newy;
				newx = cur.ss.ff + i;
				newy = cur.ss.ss + j;
				if (!valid(newx, newy))
					continue;
				if (abs(i) + abs(j) == 1) {
					if (dp[newx][newy] > dp[cur.ss.ff][cur.ss.ss]) {
						dp[newx][newy] = dp[cur.ss.ff][cur.ss.ss];
						pq.push({ -dp[cur.ss.ff][cur.ss.ss], {newx, newy}});
					}
				}
				if (abs(i) + abs(j) > 1) {
					if (dp[newx][newy] > dp[cur.ss.ff][cur.ss.ss] + 1) {
						dp[newx][newy] = dp[cur.ss.ff][cur.ss.ss] + 1;
						pq.push({ -dp[cur.ss.ff][cur.ss.ss] - 1, {newx, newy}});
					}
				}
			}
		}
	}
	if (dp[x][y] == 1000000007)
		dp[x][y] = -1;
	cout << dp[x][y] << "\n";

}

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

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

    vector<string> ans(5);
    int N = s.size();
    int cnt = 0;
    rep(i, N) {
        for (int j = i; j < N; ++j) {
            bool ok = true;
            string sub = s.substr(i, j - i + 1);
            rep(k, cnt) if (ans[k] == sub) ok = false;
            if (!ok) continue;
            if (cnt < 5) {
                ans[cnt] = sub;
                sort(ans.begin(), ans.begin() + cnt+1);
                ++cnt;
            } else {
                if (sub < ans[4]) {
                    ans[4] = sub;
                    sort(ans.begin(), ans.end());
                } else
                    j = N;
            }
        }
    }

    cout << ans[K - 1] << endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;


int main(){
  int n; cin>>n;
  vector<pair<pair<string,int>,int>> p(n);
  rep(i,n){
    string s;
    int pp;
    cin>>s>>pp;
    p[i].first.first=s;
    p[i].first.second=-pp;
    p[i].second=i+1;
  }

  sort(p.begin(),p.end());
  rep(i,n)
  cout<<p[i].second<<endl;

  return 0;
}


Measured memory_bytes: 256
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0

if x <= sum(a):
    for i in range(N):
        if x > 0:
            if x >= a[i]:
                ans += 1
            x -= a[i]

        else:
            break
else:
    memo = x - sum(a)
    x -= memo
    a[-1] += memo
    
    for i in range(N):
        if x > 0:
            if x >= a[i]:
                ans += 1
            x -= a[i]

        else:
            break
    

print(ans)

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

int main(){
    int N;cin>>N;
    int P[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
    int L[15];int n;
    for(int i=0;i<15;i++){
        n=N;L[i]=0;
        while(n>0){
            n=n/P[i];
            L[i]+=n;
        }
    }int id[]={74,24,14,4,2};
     int j=0,temp=0;
     while(j<17&&temp<5){
        if(L[j]>=id[temp]){
            j++;
        }else{
            id[temp]=j;
            temp++;
        }
    }int Sum=id[0]+id[1]*(id[4]-1)+id[2]*(id[3]-1)+id[3]*(id[3]-1)*(id[4]-2)/2;
     cout<<Sum<<endl;
}

Measured memory_bytes: 256
use std::io;


fn main() {
    let m = read_one::<usize>();
    println!("{}", 48 - m);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

int main() {
  int N , A ;
  cin >> N >> A  ;
  int kaisu = 0 ;
  int n = N ;
  while(N>=500) {
    N -= 500 ;
    kaisu++ ;
  }
     if(n-500*kaisu>A) cout << "No" << endl;
  else if(n-500*kaisu<=A) cout << "Yes" << endl;
}




Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        s: String
    }

    let time = s.split('/').collect::<Vec<_>>();
    let y: u64 = time[0].parse().unwrap();
    let m: u64 = time[1].parse().unwrap();
    let d: u64 = time[2].parse().unwrap();
    let is_heisei = y < 2019 || y == 2019 && m < 4 || y == 2019 && m == 4 && d <= 30;
    println!("{}", if is_heisei {"Heisei"} else {"TBD"});
}


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

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<vector<int>> s(N,vector<int>(N,-1));
    for (int i=0;i<N;i++){
        cin >> A[i];
        for (int j=0;j<A[i];j++){
            int x, y;
            cin >> x >> y;
            x--;
            s[i][x] = y;
        }
    }
    int ans = 0;
    for (int bit=0;bit<(1<<N);bit++){
        vector<int> status(N);
        for (int i=0;i<N;i++){
            if ((bit >> i) & 1){
                status[i] = 1;
            }
        }
        bool flag = true;
        for (int i=0;i<N;i++){
            if (status[i] > 0){
                for (int j=0;j<N;j++){
                    if (s[i][j] == -1) continue;
                    if (s[i][j] != status[j]) flag = false;
                }
            }
        }
        int sum = 0;
        for (int i=0;i<N;i++) sum += status[i];
        if (flag) ans = max(ans, sum);
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <map>           // sorted map so O(logn)
#include <unordered_map> // O(1)
typedef long long ll;
using namespace std;

int main()
{
    int n;
    cin >> n;
    bool flag = true;
    unordered_map<int, int> mp;
    for (int i = 0; i < n; ++i)
    {
        int x;
        cin >> x;
        mp[x]++;
        if (mp[x] > 1)
        {
            flag = false;
            break;
        }
    }
    if (flag)
    {
        cout << "YES" << endl;
    }
    else
    {

        cout << "NO" << endl;
    }

    return 0;
}

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

int main()
{
int N;
int jishu;
double gailv;
cin>>N;
if(N>=1&&N<=100)
{
if(N%2==1)
{
	jishu=N/2+1;
}else
{
	jishu=N/2;
}
gailv=1.0*jishu/N;
cout<<setiosflags(ios::fixed)<<setprecision(10);
cout<<gailv<<endl;
}



return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef struct node
{
	long long a;
	int b;
	bool operator <(const node &t)const
	{
		return a<t.a;
	}
}NODE,*PNODE;
NODE a[100001];
int main()
{
	int i,n,m;
	long long s=0;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)
		scanf("%d %d",&a[i].a,&a[i].b);
	sort(a,a+n);
	for(i=0;i<n&&m>0;i++)
	{
		s+=a[i].a*min(a[i].b,m);
		m-=a[i].b;
	}
	printf("%lld",s);
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll   long long int
#define T int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define PI 3.141592653589793238462643383
#define pb push_back
#define all(s) s.begin(),s.end()

ll power(ll x, ll y, ll p){  
    ll res = 1;  
  
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
}  

int main (){
    fast;
    
    ll n, m = 1000000007;
    cin>>n;
    
    // for(int i=0;i<n;i++){
    //     ten = (ten*(ll)10)%m;
    //     nine = (nine*(ll)9)%m;
    //     eight = (eight*(ll)8)%m;
    // }
    ll ans=((power(10,n,m)%m + power(8,n,m)%m)%m - ((power(9,n,m))%m + (power(9,n,m))%m)%m + m)%m;

    cout<<ans<<endl;


}

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

using namespace std;
#define ll long long

int main()
{
	ll h;
	cin >> h;
	ll node = 1;
	ll count = 0;
	while (h > 1)
	{
		h /= 2;
		node *= 2;
	}
	
	while (node >= 1)
	{
		count += node;
		node /= 2;
	}
	
	cout << count;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

void koch(int n, double p1_x, double p1_y, double p2_x, double p2_y);

int main()
{
  int n;
  double p1[2], p2[2];

  p1[0] = 0;
  p1[1] = 0;
  p2[0] = 100;
  p2[1] = 0;

  scanf("%d", &n);

  printf("%f %f\n", p1[0], p1[1]);

  koch(n, p1[0], p1[1], p2[0], p2[1]);

  return 0;
}

void koch(int n, double p1_x, double p1_y, double p2_x, double p2_y)
{
  double s[2], t[2], u[2];
  double r3 = sqrt(3.0);

  if (n == 0){
    printf("%f %f\n", p2_x, p2_y);
    return;
  }

  else {
    s[0] = p1_x + (p2_x - p1_x)/3.0;

    s[1] = p1_y + (p2_y - p1_y)/3.0;

    t[0] = p1_x + 2*(p2_x - p1_x)/3.0;

    t[1] = p1_y + 2*(p2_y - p1_y)/3.0;

    u[0] = s[0] + (-s[0] + r3*s[1] + t[0] - r3*t[1])/2.0;

    u[1] = s[1] + (-r3*s[0] - s[1] + r3*t[0] + t[1])/2.0;

    koch(n - 1, p1_x, p1_y, s[0], s[1]);

    koch(n - 1, s[0], s[1], u[0], u[1]);

    koch(n - 1, u[0], u[1], t[0], t[1]);

    koch(n - 1, t[0], t[1], p2_x, p2_y);
  }
}

Measured memory_bytes: 636
#include <iostream>
#include <algorithm>
#include <vector>
#define MAX 100000
#define rep(i,n) for(long long i = 0; i < n; i++)
using namespace std;
using ll = long long;

int solve();
void print(vector<ll> v);
int check(ll);

int n, k;
ll T[MAX];

int main() {
  cin >> n >> k;
  rep(i, n) cin >> T[i];
  ll ans = solve();
  cout << ans << endl;
  return 0;
}

//最大積載量Pのトラックk台で何個の荷物を積めるか
int check(ll P) {
  int i = 0;
  for (int j = 0; j < k; j++) {
    ll s = 0;
    while (s + T[i] <= P) {
      s += T[i];
      i++;
      if (i == n) return n; //もし全荷物積めるならreturn n
    }
  }
  return i;
}

int solve() {
  ll left = 0;
  ll right = 100000 * 10000;
  ll mid;
  while (right - left > 1) {
    mid = (left + right) / 2;
    int v = check(mid); //mid == Pと定めて何個積めるかチェックする
    if (v >= n) right = mid;
    else left = mid;
  }
  return right;
}

void print(vector<ll> v) {
  vector<ll>::iterator it;
  for (it = v.begin(); it != v.end(); it++) cout << *it << " ";
  cout << endl;
}



Measured memory_bytes: 3896
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=200111;
const int inf=1000000007;
const int mod=1000000007;
const double PI = 3.1415926535897932384626433;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

vvl comb(int n) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v;
}

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll gcd(ll x,ll y){
	if(y)return gcd(y,x%y);
	else return x;
}

int keta(ll a){
	int ke=1;
	while(a/=10)ke++;
	return ke;
}

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

ll zyou(ll x,ll n){
	ll y=1;
	rep(i,0,n){
		y*=x;
	}
	return y;
}


int main() {
	int x[5];
	rep(i,0,5)cin>>x[i];
	int ans=0;
	rep(i,0,5){
		if(x[i]==0){
			ans=i+1;
			break;
		}
	}print(ans);



}

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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    long long x,y;
    cin >> x >> y;
    if(x<y){
        swap(a,b);
        swap(x,y);
    }
   
    cout << y*min(a+b,2*c)+(x-y)*min(a,2*c) << endl;

}

Measured memory_bytes: 3616
#include<iostream>
using namespace std;
int main()
{
	int a[100], b;
	cin >> b;
	for (int i = 0; i < b; i++)
	{
		cin >> a[i];
	}

	for (int i = b-1 ; i >= 0 ;i--)
	{
		cout << a[i];
		if (i > 0)
		{
			cout << " ";
		}
	}
	cout << endl;
}

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

int main() {
  int H,W;
  while(1){
    cin >> H >> W;
    if(H==0 && W==0)
      break;
    
    for(int i=1;i<=H;i++){
      for(int j=1;j<=W;j++){
        
        if(j%2==1 && i%2==1 || j%2==0 && i%2==0)
          cout << '#';
        
        if(j%2==1 && i%2==0 || j%2==0 && i%2==1)
          cout << '.';
      }
      
      cout << endl;
        
    }
    
    cout << endl;
  }
}



Measured memory_bytes: 3084