akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int t; cin >> t; cin.ignore(); while(t--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}
 
int main(){
    fast();

/* you get what you work for not what you wish for */
    ll n;
    cin >> n;
    if((ll)n&1){
        ll o = n/2 + 1;
        ld e = n/2;
        cout << SP(6) << 1.0*o/n << endl;
    }
    else{
        cout << SP(6) << 1.0/2 << endl;
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

N = int(raw_input())
A = [int(raw_input()) for i in xrange(N)]

B = sorted(A)
X = set([A[i] for i in xrange(N) if i%2 == 0])
Y = set([B[i] for i in xrange(N) if i%2 == 0])

print len(Y - X)


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

using namespace std;

long long inf=1000000007;

int main(){
	long long n;
	cin>>n;
	vector<int> hoge(n);
	for(int i=0;i<n;i++) cin>>hoge.at(i);
	sort(hoge.begin(),hoge.end());

	long long ans=inf;

	for(int a=hoge.at(0);a<=hoge.at(n-1);a++){
		long long pre=0;
		for(auto b:hoge){
			pre+=pow(a-b,2);
		}
		ans=min(ans,pre);
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
 
using namespace std;
 
int main(int, char**) {
  int n, k;
  cin >> n >> k;
  
  int p[n];
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
  }
  
  long long m = 0;
  for (int i = 0; i < k; ++i) {
    m += p[i];
  }
 
  long long cur_m = m;
  for (int i = k; i < n; ++i) {
	cur_m = cur_m - p[i - k] + p[i]; 
    m = max(m, cur_m);
  }
  
  printf("%.1f\n", (m + k) / 2.0);
 
  return 0;
}

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

int main(){
  ll n;
  cin >> n;
  ll v;
  vector<pair<ll, ll> > odd(MAX + 1); // cnt, num
  vector<pair<ll, ll> > even(MAX + 1); // cnt, num
  // init
  //for ( int i = 0; i <= MAX; i++)odd[i] = even[i] = make_pair(0, i);

  for ( int i = 0; i < n; i++){
    cin >> v;
    if ( i % 2 == 1){
        odd[v].second = v;
        odd[v].first ++;
    } else {
        even[v].second = v;
        even[v].first ++;
    }
  }

  sort(odd.begin(), odd.end(), greater<pair<ll,ll>>());
  sort(even.begin(), even.end(), greater<pair<ll,ll>>());
  if( odd[0].second != even[0].second){
    cout << n - odd[0].first - even[0].first << endl;
  } else {
    cout << min(n - (odd[0].first + even[1].first), n-(odd[1].first + even[0].first))  << endl;
  }

  return 0;
}

Measured memory_bytes: 31488
while 1:
    try:
        n=list(map(int,input().split()))
        card=[1,2,3,4,5,6,7,8,9,10]
        if sum(n[0:2])<11:
            print("YES")
        else:
            card.remove(n[0])
            card.remove(n[1])
            card.remove(n[2])
            margin=20-sum(n[0:2])
            if card[3]<=margin:
                print("YES")
            else:
                print("NO")
    except:break


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

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt(), m = fs.nextInt();
		int left = 0;
		int right = n;
		for(int i=0;i<m;i++) {
			int l = fs.nextInt(), r = fs.nextInt();
			left = Math.max(left, l);
			right = Math.min(right, r);
		}
		int ans = right - left + 1;
		ans = Math.max(ans, 0);
		System.out.println(ans);
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

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

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

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

Measured memory_bytes: 42172
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int s = Integer.parseInt(scan.next());
		List<Integer> list = new ArrayList<>();
		list.add(s);
		int index = 1;
		int a = s;
		while (true) {
			//System.out.println(a);
			index++;
			a = function(a);
			if (list.contains(a)) {
				System.out.println(index);
				return;
			}
			list.add(a);
		}
	}

	private static int function(int n) {
		if (n % 2 == 0) {
			return n / 2;
		} else {
			return 3 * n + 1;
		}
	}
}


Measured memory_bytes: 21844
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;

template <typename T> void read(T &t)
{
	t=0;int f=0;char c=getchar();
	while(!isdigit(c)){f|=c=='-';c=getchar();}
	while(isdigit(c)){t=t*10+c-'0';c=getchar();}
	if(f)t=-t;
}

int R,C,r,c; 

int main()
{
	read(R),read(C),read(r),read(c);
	printf("%d",(R-r)*(C-c));
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int MAXN = 100001;
const int MOD = 1e9 + 7;

string S;
int N;
LL DP[MAXN][4];
const string lol = "ABC ";
LL dp(int pos, int choices){
    LL& ret = DP[pos][choices];
    if (ret == -1){
        ret = 0;
        if (pos == N){
            ret = (int)(choices == 3);
        }
        else{
            ret = ((S[pos] == '?' ? 3LL : 1LL) * dp(pos + 1, choices)) % MOD;
            if (choices < 3 and (S[pos] == '?' or S[pos] == lol[choices])){
                ret = (ret + dp(pos + 1, choices + 1)) % MOD;
            }
        }
    }
    return ret;
}

int main(){
    cin >> S;
    N = S.size();
    memset(DP, -1, sizeof DP);
    cout << dp(0, 0);
    return 0;
}

Measured memory_bytes: 9856
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>
int inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

//メモリ置き場
int n, m;
set<int> dat;
vector<int> dat2;

//inputします
void input() {
    cin >> n >> m;
    ff(i, 0, n) {
        int a;
        cin >> a;
        dat.insert(a);
    }
    int b = dat.size();
    dat2.resize(b);
    ff(i, 0, b) {
        dat2[i] = *rbegin(dat);
        dat.erase(*rbegin(dat));
    }
}

//ライブラリ置き場

//main
int main() {
    input();
    int ans = 0;
    int br = 0;
    for (int i = dat2[0] / 2; i <= m; i += dat2[0]) {
        ff(j, 1, dat2.size()) {
            if (i % dat2[j] != dat2[j] / 2) {
                br++;
                break;
            }
        }
        if (br) {
            br = 0;
            continue;
        }
        ans++;
    }
    cout << ans << endl;
	return 0; 
}

Measured memory_bytes: 5376
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
using namespace std;
typedef long long ll;
const int maxn=1e5+6;
int main()
{
	priority_queue<ll> q;
	ll n,m,sum;
	ll a[maxn];
	memset(a,0,sizeof(a));
	scanf("%lld%lld",&n,&m);
	sum=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		q.push(a[i]);
	}
	if(n==1)
	{
		while(m)
		{
			m--;
			a[1]/=2;
		}
		printf("%lld\n",a[1]);
	}
	else
	{
		while(m--)
		{
			int k=q.top();
			q.pop();
			k/=2;
			q.push(k);
		}
		while(!q.empty())
		{
			sum+=q.top();
			q.pop();
		}
		printf("%lld\n",sum);
	}
	return 0;
}

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

bool graph[100][100];
bool visited[100];
int a[100], b[100];
long long N;
void dfs(int v)
{
    if (visited[v])
    {
        return;
    }
    visited[v] = true;
    for (int i = 1; i <= N; i++)
    {
        if (graph[v][i])
        {
            dfs(i);
        }
    }
    return;
}

int main()
{
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);

    for (int i = 0; i < M; i++)
    {
        cin >> a[i] >> b[i];
        graph[a[i]][b[i]] = true;
        graph[b[i]][a[i]] = true;
    }

    int cnt = 0;
    for (int i = 0; i < M; i++)
    {
        graph[a[i]][b[i]] = false;
        graph[b[i]][a[i]] = false;

        for(int j = 1; j <= N; j++)
        {
            visited[j] = false;
        }
        
        dfs(1);
        bool connected = true;
        for (int j = 1; j <= N; j++)
        {
            if (!visited[j])
            {
                connected = false;
            }
        }

        if (!connected)
        {
            cnt++;
        }
        graph[a[i]][b[i]] = true;
        graph[b[i]][a[i]] = true;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace AtCoder.BeginnersSelections
{
    class Test{

        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int N = int.Parse(str[0]);
            int x = int.Parse(str[1]);

            int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            Array.Sort(a);

            int i = 0;
            for (;i < N;i++)
            {
                x -= a[i];
                if (x < 0)
                {
                    i++;
                    break;
                }
            }
            if (x != 0)
                i--;
            Console.WriteLine(i);
        }
    }
}

Measured memory_bytes: 13396
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	fastio;
	int a,b;
	cin>>a>>b;
	cout<<(a+b-1)/b<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()

#define endl "\n"
#define pb push_back
#define cout_db cout << fixed

#define MOD 1000000007LL
#define PI 3.1415926

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int n; ll a[100000], b[100000];
	vector< tuple<ll, ll, ll> > vec; 
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		vec.pb( make_tuple(a[i]+b[i], a[i], b[i]) );
	}
	sort(ALL(vec), greater< tuple<ll, ll, ll> >());
	ll taka = 0, ao = 0; bool takaturn = 1;
	for (int i = 0; i < n; i++) {
		if(takaturn) taka += get<1>(vec[i]);
		else ao += get<2>(vec[i]);
		takaturn = !takaturn;
	}
	cout << taka - ao << endl;

	return 0;
}

Measured memory_bytes: 5876
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif


int n,a[N];
struct {
	void add(int v, int id) {
		if (a[0].y==id) a[0].x=max(a[0].x,v);
		else if (a[1].x<v) a[1] = {v,id};
		if (a[0].x<a[1].x) swap(a[0],a[1]);
	}
	pii ask(int id) {
		if (a[0].y!=id) return a[0];
		return a[1];
	}
	pii a[2] = {{0,0},{0,0}};	
} f,g;

int main() {
	scanf("%d",&n);
	REP(i,1,n) scanf("%d",a+i);
	map<int,int> v;
	REP(i,1,n) if (i&1) ++v[a[i]];
	for (auto t:v) f.add(t.y,t.x);
	v.clear();
	REP(i,1,n) if (~i&1) ++v[a[i]];
	for (auto t:v) g.add(t.y,t.x);
	int ans = n;
	if (f.a[0].y!=g.a[0].y) ans -= f.a[0].x+g.a[0].x;
	else ans -= max(f.a[0].x+g.a[1].x,f.a[1].x+g.a[0].x);
	printf("%d\n",ans);
}








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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
	for (auto i : a) cerr << i << ' ';\
	cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	ll ans = LINF;
	vector<int> a(n);
	forn(i, 0, n) cin >> a[i];
	fore(x, -100, 100) {
		ll s = 0;
		forn(i, 0, n) s += (x - a[i]) * (x - a[i]);
		ans = min(ans, s);
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
import itertools
N = int(input())
S = [input() for i in range(N)]

S0 = list(map(lambda s:s[0],S))
M,A,R,C,H = 0,0,0,0,0

for i in range(len(S0)):
    if S0[i] == 'M':
        M = M + 1
    elif S0[i] == 'A':
        A = A + 1
    elif S0[i] == 'R':
        R = R + 1
    elif S0[i] == 'C':
        C = C + 1
    elif S0[i] == 'H':
        H = H + 1

Num = [M,A,R,C,H]


c = list(itertools.combinations(Num,3));
sum =0
for w in range(len(c)):
    sum = sum +c[w][0]*c[w][1]*c[w][2]
print(sum)


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

using namespace std;
using ll = long long;
#define int ll
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T> using VVV = vector<VV<T>>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n, k;
  cin >> n >> k;

  int ret = 0;
  FOR(i, 1, n+1) {
    int tmp = i % k;
    int tmp2 = (k - tmp) % k;
    if(tmp != tmp2) continue;
    int x = (n - tmp) / k;
    if(tmp != 0) x++;
    ret += x * x; 
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    LL n,a,b,c,d;

    void solve(){
        cin >> n >> a >> b >> c >> d;
        for(int i=0; i<n; ++i){
            LL u = d*i-c*(n-1-i);
            LL l = c*i-d*(n-1-i);
            if(l<=b-a and b-a <=u){
                cout << "YES" << "\n";
                return;
            }
        }
        cout << "NO" << "\n";
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    Problem p;
    p.solve();
    return 0;
}



Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int n;
string s[50];
int t[50];
string x;

int main() {
    fastio();

    cin >> n;
    forn(i, n) cin >> s[i] >> t[i];
    cin >> x;

    int i = find(s, s + n, x) - s;

    cout << accumulate(t + i + 1, t + n, 0) << endl;

    return 0;
}

Measured memory_bytes: 256
function main(input) {
  const num = Number(input.split("\n")[0]);
  let ans = 1n;
  const numbers = input.split("\n")[1].split(" ").map(i => BigInt(i));
  
  if (numbers.includes(0n)) {
    return console.log(0);
  }
  
  for(let i=0; i < num; i++) {
  	ans *= numbers[i];
    if (ans > 10n**18n) {
      break;
    }
  }
  
  if (ans > 10n**18n) {
    console.log(-1);
  } else {
  	console.log(ans + "");
  }
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 44024
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
using namespace std;

int main()
{
    int n, m, k; cin>>n>>m>>k;

    vector<string> a(n);
    vector<vector<int>> v(n, vector<int>(m, -1));
    queue<pair<int, int>> q;

    for(int i=0; i<n; ++i) {
        cin>>a[i];
        if (q.size()) continue;
        for(int j=0; j<m; ++j) {
            if (a[i][j]=='S') {
                q.emplace(i, j);
                v[i][j]=0;
                break;
            }
        }
    }

    int res=1<<30;
    while (q.size()) {
        int r, c;
        tie(r, c)=q.front();
        q.pop();
        res=min({res, r, c, n-1-r, m-1-c});
        if (res==0) break;
        if (v[r][c]==k) continue;

        if (r and a[r-1][c]!='#' and v[r-1][c]<0) {
            q.emplace(r-1, c);
            v[r-1][c]=v[r][c]+1;
        }
        if (c and a[r][c-1]!='#' and v[r][c-1]<0) {
            q.emplace(r, c-1);
            v[r][c-1]=v[r][c]+1;
        }
        if (r<n-1 and a[r+1][c]!='#' and v[r+1][c]<0) {
            q.emplace(r+1, c);
            v[r+1][c]=v[r][c]+1;
        }
        if (c<m-1 and a[r][c+1]!='#' and v[r][c+1]<0) {
            q.emplace(r, c+1);
            v[r][c+1]=v[r][c]+1;
        }
    }
    cout<<(res+k-1)/k+1<<endl;
}



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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

int euclid(int a, int b)
{
    if (a < b)
        euclid(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

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

    cout << (a + b + 2 - 1) / 2 << endl;
}


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

using namespace std;

int main(){
  int a,b;
  char op;

  while(cin>>a>>op>>b && op != '?'){
    if(op == '+'){
      cout<<a+b<<endl;
    }else if(op=='-'){
      cout<<a-b<<endl;
    }else if(op=='*'){
      cout<<a*b<<endl;
    }else{
      cout<<a/b<<endl;
    }
  }
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n; cin >> n;
   vector<ll> ans;
   string x; cin >> x;
   reverse(x.begin(),x.end());
   ll cnt = 0;
   rep(i,n)cnt += (x[i] == '1');
   if (cnt==0){
      rep(i,n)cout << 1 << endl;
      return 0;
   }
   vector<ll> mod2_up, mod2_down;
   mod2_up.push_back(1%(cnt+1));
   if(cnt!=1)mod2_down.push_back(1%(cnt-1));
   rep(i,n-1){
      mod2_up.push_back((mod2_up[i]*2)%(cnt+1));
      if(cnt!=1)mod2_down.push_back((mod2_down[i]*2)%(cnt-1));
   }
   ll modup = 0, moddown = 0;
   rep(i,n){
      if (x[i]=='1'){
         modup += mod2_up[i];
         if(cnt!=1)moddown += mod2_down[i];
         modup %= (cnt+1);
         if(cnt!=1)moddown %= (cnt-1);
      }
   }
   rep(i,n){
      int ansi = 1, newx;
      if (x[i] == '1'){
         if (cnt==1){
            ans.push_back(0);
            continue;
         }
         newx = moddown;
         newx = (newx - mod2_down[i]+(cnt-1))%(cnt-1);
      }
      else{
         newx = modup;
         newx = (newx + mod2_up[i])%(cnt+1);
      }
      while (newx > 0)
      {
         int popcnt = 0;
         for (int i = newx; i > 0; i>>=1)
            popcnt += (i&1);
         newx %= popcnt;
         ansi++;
      }
      ans.push_back(ansi);
   }
   rep(i,n){
      cout << ans[n-i-1] << endl;
   }
}

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

typedef long long int ll;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll i,j,t,k,l,m,n,c,r,d;

	cin >> l >> r >> d;

	m = 0;

	for(i=l;i<=r;i++)
	{
		if(i%d==0)
		{
			m++;
		}
	}

	cout << m << '\n';

	
	

}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;
int gcd(int x,int y){
	return y?gcd(y,x%y):x;
}
int spe[100005];
int gv[100005];
ll F(int H,int W,int K){
	ll ans=0;
	int LIM=2*K+1500,top=0;
	For(i,0,H-1) gv[i]=gcd(W,i);
	For(k,1,H-1) if (gcd(k,W)>=1000) spe[++top]=k;
	For(k,W-W/2,W-1){
		//if (k%100==0) cerr<<k<<endl;
		int B=min(300000/(W-k),H-1),rp=(k*2==W?1:2);
		For(i,1,B){
			ll key1=1ll*i*(W-k)-gcd(k,i),key2=k;
			ll b1=max(0ll,(2*K+1-key1)/key2);
			if (b1>=i) ans-=rp;
			b1=min(b1,1ll*(H-1)); ans+=b1*rp; key1+=(++b1)*key2;
			for (;key1<=LIM&&b1<=H-1;key1+=key2,++b1){
				ll cv=key1-gv[abs(b1-i)]-gcd(W-k,b1);
				if (cv<=2*K-2&&b1!=i) ans+=rp;
			}
			ll arr=1ll*W*i;
			ll cv=arr-W-gcd(k,i)-gcd(W-k,i);
			if (cv<=2*K-2) ans+=rp;
			if (1ll*(W-k)*1000<=2*K+W+2000){
				Rep(p,top,1){
					int b=i-spe[p];
					if (b<b1||b>=H) continue;
					ll arr=1ll*(W-k)*i-gcd(k,i)+1ll*k*b;
					if (arr>2*K+W+1500) break;
					ll cv=arr-gv[abs(i-b)]-gcd(W-k,b);
					//if (i==2501&&spe[p]==2500) cerr<<cv<<' '<<arr<<endl;
					if (cv<=2*K-2&&arr>LIM) ans+=rp;//cerr<<cv<<' '<<arr<<endl;
				}
				For(p,1,top){
					int b=i+spe[p];
					if (b<b1||b>=H) continue;
					ll arr=1ll*(W-k)*i-gcd(k,i)+1ll*k*b;
					if (arr>2*K+W+1500) break;
					ll cv=arr-gv[abs(i-b)]-gcd(W-k,b);
					if (cv<=2*K-2&&arr>LIM) ans+=rp;
				}
			}
		}
	}
	return 2*ans;
}
/*
5000 5000 100000
197045732
100000 100000 100000
*/
int main(){
	int W,H,K;
	scanf("%d%d%d",&W,&H,&K);
	cout<<F(W,H,K)+F(H,W,K)<<endl;
	cerr<<clock()<<endl;
}

Measured memory_bytes: 4136
import java.io.{BufferedReader, InputStreamReader}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val n = in.readLine().toInt
    val s = in.readLine()

    System.out.println(
      s.toCharArray.map { c =>
        String.valueOf(((c - 'A' + n) % 26 + 'A').asInstanceOf[Char])
      }.mkString("")
    )
  }
}


Measured memory_bytes: 27188
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<map>
using namespace std;
#define ll long long
const int maxn=2e5+5;
int h[maxn],sub[maxn],sum[maxn];
map<int,int> sum_num;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>h[i];
        sub[i]=i-h[i];
        sum[i]=i+h[i];
        if(!sum_num.count(sum[i])) sum_num[sum[i]]=0;
        sum_num[sum[i]]++;
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        if(!sum_num.count(sub[i])) continue;
        ans+=(ll)sum_num[sub[i]];
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 15228
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007;



int main() {
    ll N,D,A;
    cin>>N>>D>>A;
    vector<pair<ll,ll>> M(N);
    rep(i,N){
        cin>>M.at(i).first>>M.at(i).second;
        M.at(i).second=(M.at(i).second-1)/A+1;
    }
    sort(M.begin(),M.end());
    ll bomb=0,ans=0;
    queue<P> range;
    rep(i,N){
        while(!range.empty() && range.front().first<M.at(i).first){
            P f=range.front();range.pop();
            bomb-=f.second;
        //cout<<bomb<<endl;
        }
        if(M.at(i).second-bomb>0){
            ans+=M.at(i).second-bomb;
            range.push({M.at(i).first+2*D,M.at(i).second-bomb});
            bomb+=M.at(i).second-bomb;
        }
        //cout<<bomb<<" "<<ans<<endl;
    }
    cout<<ans<<endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string S;
    cin >> S;
    ll ans = 0;
    iter(c, S) ans += c - '0';
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define rep(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define S second
#define F first

using namespace std;

int main(void){
    pair<int, pair<int, int> > y1, y2;
  cin >> y1.F >> y1.S.F >> y1.S.S;
  cin >> y2.F >> y2.S.F >> y2.S.S;

  if ( y1 > y2 ) swap(y1, y2);
  int pp=0;
  if(y1.S<y2.S)pp=1;
  cout <<  y2.F - y1.F + pp<< endl;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a),i##Len_=(b);i<i##Len_;i++)
#define ALL(x) (x).begin(),(x).end()
#define SORT_PAIR_SECOND(x) sort(ALL(x),[](auto& a,auto& b){return a.second<b.second;})
const char* LF = "\n";
namespace{struct _{_(){
    cin.tie(0);
    ios::sync_with_stdio(false);
}}a;}

vector<pll> V;

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

    REP(i, M) {
        ll a, b;
        cin >> a >> b;
        V[i] = make_pair(a, b);
    }
    SORT_PAIR_SECOND(V);

    ll cnt = 0;
    ll bp = 0;

    REP(i, M) {
        ll a = V[i].first;
        ll b = V[i].second;

        if (cnt && a < bp) continue;

        cnt++;
        bp = b;
    }

    cout << cnt << LF;

    return 0;
}


Measured memory_bytes: 1920
n = list(map(int, list(input().strip())))

total = sum(n)

for i in range(len(n)):
    subtotal = 0
    for j in range(i - 1):
        subtotal += n[j]
    subtotal += n[i] - 1
    for k in range(i + 1, len(n)):
        subtotal += 9

    total = max(total, subtotal)

print(total)


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


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner s = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		String turn = s.next();
		Integer tarou = 0;
		Integer hanako = 0;
		for(int i = 0; i < Integer.parseInt(turn); i++){
			String tarou_card = s.next();
			String hanako_card = s.next();
			Integer result = tarou_card.compareTo(hanako_card);
			if(result == 0){
			if(tarou_card.equals(hanako_card)){
				tarou += 1;
				hanako += 1;
			}
			}
			else if(result > 0){
				tarou += 3;
			}
			else{
				hanako += 3;
			}
		}
		s.close();
		System.out.println(tarou + " " + hanako);
	}
}

Measured memory_bytes: 20820
import sys
N = int(input())
for h in range(1,3501):
    for n in range(1,3501):
        if 4*n*h > N*n + N*h and (N*n*h) % (4*n*h-N*h-N*n) == 0:
            w =  (N*n*h) // (4*n*h-N*h-N*n)
            print(n,h,w)
            sys.exit()

Measured memory_bytes: 3316
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1000000007;

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(int argc, char const* argv[])
{
	int a,b;
	cin >> a >> b;
	if (a>8 || b>8) {
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
<?php
while(true){
    $hit = 0;
    $blow = 0;
    $que_card = array();
    $ans_card = array();
    $hoge = fgets(STDIN);
    $hoge = explode(' ', $hoge);
    $hoge[1] = str_replace(array("\r\n", "\r", "\n"), '', $hoge[1]);
    if($hoge[0] == 0 && $hoge[1] == 0){
        break;
    }
    for($i=0;$i<4;$i++){
        $que_card[] = substr($hoge[0], $i, 1);
        $ans_card[] = substr($hoge[1], $i, 1);
    }
    for ($i = 0; $i < 4; $i++) {
        if(in_array($ans_card[$i],$que_card)){
            $blow+=1;
        }
        if($que_card[$i] == $ans_card[$i]){
            $blow-=1;
            $hit+=1;
        }
    }
    echo $hit.' '.$blow.PHP_EOL;
}
?>


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

int main(int argc, const char * argv[]) {
    int n;
    int numbers_to_sort[10];
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> numbers_to_sort[i];
    }
    bool flag = true;
    int cache = 0;
    while(flag){
        flag = false;
        for(int j = 0; j < n - 1; j++){
            if(numbers_to_sort[j] > numbers_to_sort[j + 1]){
                cache = numbers_to_sort[j];
                numbers_to_sort[j] = numbers_to_sort[j + 1];
                numbers_to_sort[j + 1] = cache;
                flag = true;
            }
        }
    }
    int longest = numbers_to_sort[n-1];
    int sum = 0;
    for(int i = 0; i < n-1; i++){
        sum += numbers_to_sort[i];
    }
    if(longest >= sum){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <utility>
#include <cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)

template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int s;

int func(int n){
    if(n%2==0){
        return n/2;
    }else{
        return 3*n+1;
    }
}

int main()
{
    int n,l[15]={},sum=0;
    cin>>n;
    rep(i,n)cin>>l[i];
    sort(l,l+n);
    rep(i,n-1)sum+=l[i];
    if(sum>l[n-1]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
using namespace std;
typedef pair<int, int> pii;

struct node { int n, left, right; };

string S[2];
vector<node> V[2];
vector<node> U;
int p;

int num(int s) {
  int n = 0;
  while('0' <= S[s][p] && S[s][p] <= '9') {
    n = n * 10 + (S[s][p] - '0');
    p++;
  }
  return n;
}

int tree(int s) {
  if(S[s][p] == ')') return -1;
  p++;
  int left = tree(s);
  p += 2;
  int n = num(s);
  p += 2;
  int right = tree(s);
  p++;
  int ret = V[s].size();
  V[s].push_back((node) { n, left, right });
  return ret;
}

int dfs(int q1, int q2) {
  int n = V[0][q1].n + V[1][q2].n;
  int left = V[0][q1].left != -1 && V[1][q2].left != -1 ? dfs(V[0][q1].left, V[1][q2].left) : -1;
  int right = V[0][q1].right != -1 && V[1][q2].right != -1 ? dfs(V[0][q1].right, V[1][q2].right) : -1;
  int ret = U.size();
  U.push_back((node) { n, left, right });
  return ret;
}

void ans(int q) {
  if(q == -1) return;
  cout << "(";
  ans(U[q].left);
  cout << ")[" << U[q].n << "](";
  ans(U[q].right);
  cout << ")";
}

int main(void) {
  REP(i, 0, 2) cin >> S[i];
  int root[2];
  REP(i, 0, 2) {
    p = 0;
    root[i] = tree(i);
  }
  int r = dfs(root[0], root[1]);
  ans(r);
  cout << endl;

  return 0;
}

Measured memory_bytes: 3212
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int count1 = 0;
    int count4 = 0;
    for(int i = 0; i<n; i++) {
      int a = sc.nextInt();
      if(a % 2 == 1) {
        count1++;
      }else if(a % 4 == 0) {
        count4++;
      }
    }
    if((n%2 == 1) && (count1 == n/2+1) && (count4 == n/2)) System.out.println("Yes");
    else if(count1 <= count4) System.out.println("Yes");
    else System.out.println("No");
  }
}

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

int main(){
  int X,Y;
  char s[4];
  for(int i=0; i<4; i++) cin>>s[i];
  int a[4];
  for(int i=0; i<4; i++) a[i]=s[i]-'0';
  if(a[0]==a[1] && a[1]==a[2]) cout<<"Yes"<<endl;
  else if(a[1]==a[2] && a[2]==a[3]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
	ll N;
	cin >> N;
	double A;
	ll i;
	double sum=0;
	for(i=0;i<N;i++){
		cin >> A;
		sum+=1/A;
	}
	cout << 1.0/sum;
	return 0;
}


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

int a[100010]={0};

int main()
{
    char t;
    int n=-1;
    while(n++,(t=getchar())!='\n')if(t=='L')a[n]=-1;

    int cnt=0;
    for(int i=0;i<n-1;i++)
    {
        if(a[i]==0&&a[i+1]==0)
            cnt++;
        else if(a[i]==0&&a[i+1]==-1)
            a[i]=cnt+1,cnt=0;
    }
    cnt=0;
    for(int i=n-1;i>0;i--)
    {
        if(a[i]==-1&&a[i-1]==-1)
            cnt++;
        else if(a[i]==-1&&a[i-1]>0)
            a[i]=cnt+1,cnt=0;
    }
    for(int i=0;i<n;i++)
    {
        if(a[i]<=0)printf("0 ");
        else if(a[i+1]>0)
        {
            int num = a[i]+a[i+1];
            if((num&1)==0)printf("%d %d ",num>>1,num>>1);
            else if((a[i]&1)==0)
                printf("%d %d ",num>>1,(num>>1)+1);
            else printf("%d %d ",(num>>1)+1,num>>1);
            i++;
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 768
#include<stdio.h>
#include<string.h>

#define OK 1
#define NIL -1

int array[2000000];
int array_index[2000000];

int main()
{
    int length;
    int answer;
    int max_num = 0;

    scanf("%d", &length);
    answer = 0;

    for (int i = 0; i<length; i++)
    {
        scanf("%d", &array_index[i]);
        if (array_index[i] > max_num)
        {
            max_num = array_index[i];
        }
    }

    for (int i = 1; i<= max_num; i++)
    {
        array[i] = OK;
    }

    for (int i = 0; i<length; i++)
    {
        int j = array_index[i]; 

        while (j <= max_num)
        {
            array[j] += NIL;
            j += array_index[i];
        }
        
    }

    for (int i = 0; i<length; i++)
    {
        if (array[array_index[i]] >= 0)
        {
            answer ++;
        }
    }

    printf("%d", answer);


    return 0;
}

Measured memory_bytes: 6348
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner tan = new Scanner(System.in);
        while(tan.hasNext()){
            int t=tan.nextInt();
            double sum = 0;
            double[] a = new double[t];
            for (int i = 0; i < t; i++) {
                a[i]=tan.nextDouble();
                sum=sum+1/a[i];
            }
            System.out.println(1/sum);
        }
    }
}


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

int main(void){
  int h, w;
  cin >> h >> w;
  char a[h][w], b[h][w];
  for(int i = 0; i < h; i++)
    for(int j = 0; j < w; j++){
      cin >> a[i][j];
      b[i][j] = '.';
    }

  for(int i = 0; i < h; i++){
    for(int j = 0; j < w - 1; j++){
      if(a[i][j] == '#' && a[i][j + 1] == '#'){
	b[i][j] = '#';
	b[i][j + 1] = '#';
      }
    }
  }

  for(int j = 0; j < w; j++){
    for(int i = 0; i < h - 1; i++){
      if(a[i][j] == '#' && a[i + 1][j] == '#'){
	b[i][j] = '#';
	b[i + 1][j] = '#';
      }
    }
  }

  int num = 0;
  for(int i = 0; i < h; i++)
    for(int j = 0; j < w; j++)
      if(a[i][j] == b[i][j]) num++;
  if(num == h * w) cout << "Yes" << endl;
  else cout << "No" << endl;
  /*
  cout << "a" << endl;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cout << a[i][j];
    }
    cout << endl;
  }
  cout << "b" << endl;  
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cout << b[i][j];
    }
    cout << endl;
  }
  */
  return 0;
}


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

int main() {
  int n;
  while(cin >> n){
    int ans = 0;
    for(int a=0;a<=9;a++){
      for(int b=0;b<=9;b++){
	for(int c=0;c<=9;c++){
	  for(int d=0;d<=9;d++){
	    if(a + b + c + d == n){
	      ans++;
	    }
	  }
	}
      }
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 2984
use proconio::input;

fn main() {
    input!(n: usize, a: [usize; n]);
    let mut ret = 0;
    for (i, v) in a.iter().enumerate() {
        if i % 2 == 0 && v % 2 == 1 {
            ret = ret + 1;
        }
    }
    println!("{}", ret);
}


Measured memory_bytes: 2068
//Volume0-0050
import java.util.Scanner;

public class Main {

	private static final String APPLE = "apple",
			                    PEACH = "peach";
	private static       int    index = 0;
	private static       char[] in_line,
	                            out_line;

	public static void main(String[] args) {

        //input
        Scanner sc = new Scanner(System.in);
    	in_line  = sc.nextLine().toCharArray();

    	//calculation
    	out_line = new char[in_line.length];
    	for(index=0;index<in_line.length;index++){
    		if(!check()){out_line[index] = in_line[index];}
    	}

    	//output
    	System.out.println(String.valueOf(out_line));
	}

	private static boolean check(){
		boolean ret = false;
        String fruit_chk     = "N",
               fruit_replace = "N";
        char   p = 'N';

		for(int j=0;j<2;j++){
			if(j == 0){p = 'a'; fruit_chk = APPLE; fruit_replace = PEACH;}
			if(j == 1){p = 'p'; fruit_chk = PEACH; fruit_replace = APPLE;}
			if(in_line[index] == p){
				if(chk(fruit_chk)){
					replace(fruit_replace);
					ret = true;
					break;
				}
			}
		}
		return ret;
	}

	private static boolean chk(String fruit){
		boolean ret = false;
		if(index + 4 < in_line.length){
			if(String.valueOf(in_line,index,5).equals(fruit)){
				ret = true;
			}
		}
		return ret;
	}

	private static void replace(String fruit){

		char[] f = fruit.toCharArray();
		for(int i=0;i<f.length;i++){
			out_line[index] = f[i];
			if(i<f.length-1){index++;};
		}
	}
}

Measured memory_bytes: 17136
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST            ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll              long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define all(a)          (a).begin(),(a).end()
#define clz(a)          __builtin_clz(a) // count leading zeroes
#define ctz(a)          __builtin_ctz(a) // count trailing zeroes
#define popc(a)         __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define rep(i,a,b)      for(ll i=a;i<b;i++)
#define rfor(i,a,b)     for(ll i=a; i>=b; i--)
#define debug(x)        cerr << #x << " = " << x << endl;
#define F               first
#define S               second
#define endl            '\n'
#define SIZE            1000005
#define deci(n)         cout<<fixed<<setprecision(n)
#define ordered_set     tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const ll lul2 = 998244353;
const ll lul = 1000000007;

void mod(ll &x)
{
    if(x>=lul) x-=lul;
    if(x<0) x+=lul;
}

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

ll expo(ll n, ll p)
{
    if(p == 0) return 1;
    ll x = expo((n*n)%lul, p/2)%lul;
    if(p&1) return (x*n)%lul;
    return x;
}
//---------------------------------------------------------------------

ll ans = 0;
vector<ll> occ(100005,0);
void solve()
{
    ll n,k; cin>>n>>k;
    rfor(i,k,1)
    {
        occ[i] = (occ[i] + expo(k/i,n))%lul;
        mod(occ[i]);
        for(ll j=1; j*j<=i; j++)
        {
            if(i%j == 0)
            {
                if(j!=i) occ[j] = (occ[j]-occ[i] + lul)%lul;
                mod(occ[j]);
                if(j!=1 and j!=i/j) occ[i/j] = (occ[i/j] - occ[i] + lul)%lul;
                mod(occ[i/j]);
            }
        }
    }
    rep(i,1,k+1)
    {
        ll x = (occ[i]*i)%lul;
        mod(x);
        ans+=x%lul;
        mod(ans);
    }
    cout<<ans;
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    rep(i,1,t+1){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3908