akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll pow(ll x,ll y){
  if(y==0) return 1;
  ll res=pow(x,y/2);
  res*=res;
  res%=mod;
  if(y%2==1) res*=x;
  return res%mod;
}
ll gyaku(ll x){
  return pow(x,mod-2);
}
vector<ll> frac,gfrac;
void set_frac(ll n){
  frac.push_back(1);
  gfrac.push_back(1);
  for(ll i=1;i<=n;i++){
    frac.push_back(frac[i-1]*i%mod);
    gfrac.push_back(gyaku(frac[i]));
  }
}
ll nCr(ll n,ll r){
  ll res=frac[n]*gfrac[r]%mod;
  res*=gfrac[n-r];
  return res%mod;
}

ll solve(vector<ll> vec,ll H,ll W){
  ll res=0;
  ll now_val=W;
  ll ki=1;
  for(ll i=vec.size()-1;i>=0;i--){
    res+=now_val*vec[i];
    res%=mod;

    now_val+=nCr(W+ki,W-1);
    now_val%=mod;
    ki++;
  }
  for(int i=0;i<vec.size();i++){
    res+=vec[i];
    res%=mod;
  }
  return res;
}

int main(){
  ll r1,c1,r2,c2;
  cin>>r1>>c1>>r2>>c2;
  set_frac(r2+c2+100);
  if(r1==r2){
    if(c1==c2) cout<<nCr(r1+c1,r1)<<endl;
    else{
      ll ans=0;
      for(ll i=c1;i<=c2;i++){
        ans+=nCr(i+r1,r1);
        ans%=mod;
      }
      cout<<ans<<endl;
    }
    return 0;
  }
  else if(c1==c2){
    ll ans=0;
    for(ll i=r1;i<=r2;i++){
      ans+=nCr(i+c1,c1);
      ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
  }
  ll H=r2-r1,W=c2-c1;
  ll ans=nCr(r1+c1,r1);

  vector<ll> v1,v2;
  for(int i=r1+1;i<=r2;i++) v1.push_back(nCr(c1+i,c1));
  for(int i=c1+1;i<=c2;i++) v2.push_back(nCr(r1+i,r1));
  ans+=solve(v1,H,W);
  ans%=mod;
  ans+=solve(v2,W,H);
  ans%=mod;
  cout<<ans<<endl;
}


Measured memory_bytes: 55372
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;

int main() {
    long n, a;
    long cnt = 0, cnt2 = 0;
    cin >> n;
    REP(i,n) {
        cin >> a;
        if (a % 4 == 0) {
            cnt++;
        } else if (a % 2 == 1) {
            cnt2++;
        }
    }
    
    if (cnt + cnt2 == n) {
        if (cnt - cnt2 > -2) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        return 0;
    }
    
    if (cnt >= cnt2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
from sys import stdin
data = stdin.readlines()

a = int(data[0])
b = [int(s) for s in data[1].split()]

if 0 in b:
    print(0)
else:
    ans = 1
    for i in range(0,a):
        ans = ans * b[i]
        if ans > 10**18:
            print(-1)
            break
        else:
            continue
    else:
        print(ans)

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

using namespace std;

int B(int N, int K) {
	int cnt = 0;
	if (N == 0)
		return 1;
	while (N) {
		N /= K;
		cnt++;
	}
	return cnt;
}

int main() {
	int N, K;
	cin >> N >> K;
	cout << B(N, K);
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

int main(void) {
  int N, K;
  scanf("%d %d", &N, &K);

  int x[101];
  rep(i, 0, N) scanf("%d", &x[i]);

  int ans = 0;
  rep(i, 0, N) {
    ans += min(x[i], abs(K - x[i])) * 2;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	ll n; cin >> n;
	int chk = 0;
	rep(i, 42) {
		ll k = (ll)1 << i; k--;
		if (k <= n)chk = i;
	}
	n = n - ((ll)1 << chk) + 1;
	vector<int> v;
	rep(i, chk) {
		v.push_back(i + 1);
	}
	rep(i, chk) {
		v.push_back(i + 1);
	}
	int now = chk+1;
	per(i, 42) {
		if (n&((ll)1 << i)) {
			v.insert(v.begin() + i, now); v.push_back(now);
			now++;
		}
	}
	int len = v.size();
	cout << len << endl;
	rep(i, len) {
		if (i > 0)cout << " ";
		cout << v[i];
	}
	cout << endl;
	return 0;
}

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

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

	int h[N];
	int check = 0;
	rep(i, N) {
		cin >> h[i];
		if(h[i] >= K){
			check++;
		}
	}

	cout << check << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <deque>
#include <functional>
#include <initializer_list>
#include <math.h>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <queue>
#include <vector>

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); --(i))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define SORT(A) std::sort((A).begin(), (A).end())
#define ALL(A) (A).begin(), (A).end()
// 座標圧縮 (for vector) : ソートしてから使うのが一般的 ; SORT(A) => COORDINATE_COMPRESSION(A)
#define COORDINATE_COMPRESSION(A) (A).erase(unique((A).begin(),(A).end()),(A).end())

using lli = long long int;
using pii = std::pair<int, int>;

void VintOut(std::vector<int>& A){
    const int n = A.size();
    if(n == 0){putchar('\n'); return;}
    printf("%d", A[0]);
    for(int i = 1; i < n; ++i) printf(" %d", A[i]);
    putchar('\n');
}
void VintOut(std::vector<long long int>& A){
    const int n = A.size();
    if(n == 0){ putchar('\n'); return;}
    printf("%lld", A[0]);
    for(int i = 1; i < n; ++i) printf(" %lld", A[i]);
    putchar('\n');
}

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

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

inline bool bitUP(int state, int k){ return (state >> k) & 1; }
inline bool bitUP(long long int state, int k){ return (state >> k) & 1;}


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

constexpr lli inf = 2e18;
constexpr int N = 16;
constexpr int M = 1 << N;
std::array<std::array<int, N>, N> A;
std::array<lli, M> D;
std::bitset<M> P;


lli solve(int state){
    if(P[state]) return D[state];

    //printf("%d\n", state);
    int t = state;
    for(int t = (state - 1) & state; t > 0; t = (t - 1) & state){
        chmax(D[state], solve(t) + solve(state ^ t));
    }
    P[state] = true;
    return D[state];
}


int main(void){
    int n; scanf("%d", &n);
    REP(i, n) REP(j, n) scanf("%d", &A[i][j]);

    int m = 1 << n;

    REP(state, m){
        for(int x =     0; x < n; ++x) if(bitUP(state, x))
        for(int y = x + 1; y < n; ++y) if(bitUP(state, y))
        D[state] += A[x][y];
    }
    P[0] = true;

    printf("%lld\n", solve(m - 1));









    


    

    
    
    return 0;
}

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

using namespace std;

int main() {
	double a, l, x;
	cout.precision(10);
	while (cin >> a >> l >> x) {
		double area = sqrt(l * l - a * a / 4.0) * a / 2.0 + sqrt((l + x) * (l + x) / 4.0 - l * l / 4.0) * l;
		cout << fixed << area << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
	scanf("%d",&n);
	if(n<=2)return puts("No"),0;
	int tmp=1;while(tmp<<1<=n)tmp<<=1;
	if(tmp==n)return puts("No"),0;
	
	puts("Yes");
	printf("1 2\n");printf("2 3\n");
	printf("3 %d\n",n+1);
	printf("%d %d\n",n+1,n+2);
	printf("%d %d\n",n+2,n+3);
	
	for(int i=4;i<n;i+=2){
		printf("%d %d\n",n+1,i);
		printf("%d %d\n",n+1,i+1);
		printf("%d %d\n",i,i+1+n);
		printf("%d %d\n",i+1,i+n);
	}
	if(n%2==0){
		printf("%d %d\n",tmp,n);
		printf("%d %d\n",n^tmp^1,2*n);
	}
	return 0;
}


Measured memory_bytes: 2816
void main() {
    int[] tmp = readln.split.to!(int[]);
    int n = tmp[0], k = tmp[1];
    int[] l = readln.split.to!(int[]);
    l.sort!"a > b";
    l[0..k].sum.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int flag=0;
    for(int i=1;i<=b;i++){
        if(a*i%b==c){
            cout<<"YES";
            flag=1;
            i=b+1;
        }
    }
    if(flag==0){
        cout<<"NO";
    }
}


Measured memory_bytes: 256
import sys
n = int(input())
l = list(map(int, input().split()))
dp = [sys.maxsize] *n
dp[0] = 0
for i in range(n):
    for j in range(i+1,i+3):
        if(j<n):
            dp[j]=min(dp[j],dp[i]+abs(l[i]-l[j]))
print(dp[n-1])

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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

ll n;
ll xr=0;
ll a[100005];

int main(){
  cin >> n;
  for(int i=0;i<n;++i){
    cin >> a[i];
    xr=(xr ^ a[i]);
  }
  if(xr==0){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <map>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <sstream>
#include <vector>
#include <stack>
#include <utility>
#include <math.h>
using namespace std;

typedef long ll;

int main()
{
	int N, M;

	int K;
	int A[50] = {};

	int tmp = 0;
	int ans = 0;

	cin >> N >> M;

	//N行取得する
	for (int i = 0; i < N; i++)
	{
		//K回ループ
		cin >> K;
		for (int j = 0; j < K; j++)
		{
			cin >> tmp;
			A[tmp]++;
		}
	}

	for (int i = 1; i <= M; i++)
	{
		if (A[i] == N)
		{
			ans++;
		}
//		cout << A[tmp] << endl;
	}

//	printf("\n");
	cout << ans << endl;
}

/*

*/

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int h[n + 1];
    for(int i = 0; i < n; i++) cin >> h[i];
    ll cost[n + 1] = {};
    for(int i = 1; i <= n; i++) cost[i] = INF;
    for(int s = 0; s < n; s++)
    {
        for(int i = 1; i <= k; i++)
        {
            if(s + i >= n) break;
            cost[s + i] = min(cost[s] + abs(h[s] - h[s + i]), cost[s + i]);
        }
    }
    cout << cost[n - 1] << endl;
    return 0;
}



Measured memory_bytes: 1408
s=input()
p=input()
match=False
for i in range(len(s)):
  if s[i]==p[0]:
    if len(p)>1:
      for j in range(1,len(p)):
        if s[(i+j)%len(s)]!=p[j]:
          break
        if j==len(p)-1:
          match=True
    else:
      match=True

if match==True:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 5560
#from collections import deque,defaultdict
from sys import stdin
input = stdin.readline
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

a = inn()
print(a+a*a+a*a*a)


Measured memory_bytes: 61808
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long int a,b;
    cin >> a >> b;
    long long int x = abs(a-b)/2;
    if(abs(a-x)==abs(b-x)) cout << abs(a-x) << endl;
    else if(abs(a+x)==abs(b-x)) cout << abs(a+x) << endl;
    else if(abs(a-x)==abs(b+x)) cout << abs(a-x) << endl;
    else if(abs(a+x)==abs(b+x)) cout << abs(a+x) << endl;
    else puts("IMPOSSIBLE");
    return 0;
}

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

using namespace std;
using P = pair<int, int>;

int N;
vector<P> v;

double clip(double deg) {
    if (deg < 0) deg += 360;
    if (deg >= 360) deg -= 360;
    return deg;
}

bool inside(double mn, double mx, double deg) {
    if (mn <= mx) {
        return mn <= deg && deg <= mx;
    } else {
        return mn <= deg || deg <= mx;
    }
}

double width(double mn, double mx) {
    if (mn <= mx) return mx - mn;
    else return mx - mn + 360;
}

int main(){
    cin >> N;
    for (int i = 0; i < N; ++i) {
        int x, y;
        cin >> x >> y;
        v.push_back(make_pair(x, y));
    }

    for (int i = 0; i < N; ++i) {
        int xi = v[i].first;
        int yi = v[i].second;
        double mintheta = 0;
        double maxtheta = 360;
        bool first = true;
        bool close = false;
        //cout << "vert " << i << " (" << xi << ", " << yi << ")" << endl;
        for (int j = 0; j < N; ++j) {
            if (i == j) continue;
            int xj = v[j].first;
            int yj = v[j].second;
            //cout << "   vert " << j << " (" << xj << ", " << yj << ")" << endl;

            int dx = xj - xi;
            int dy = yj - yi;
            double theta = atan2((double)dy, (double)dx) * 360 / (2 * M_PI);
            double mnt = clip(theta + 90);
            double mxt = clip(theta + 270);

            if (first) {
                mintheta = mnt;
                maxtheta = mxt;
                first = false;
            } else {
                close = true;
                if (inside(mintheta, maxtheta, mnt)) {
                    mintheta = mnt;
                    close = false;
                }
                
                if (inside(mintheta, maxtheta, mxt)) {
                    maxtheta = mxt;
                    close = false;
                }
                if (close) {
                    if (inside(mnt, mxt, mintheta) || inside(mnt, mxt, maxtheta)) close = false;
                }
            }

            //cout << "    min " << mintheta << " max " << maxtheta << endl;
            if (close) break;
        }
        double prob = 0;
        if (close) {
            //cout << "closed" << endl;
        } else {
            prob = width(mintheta, maxtheta) / 360;
            //cout << "min " << mintheta << " max " << maxtheta << endl;
        }
        printf("%.20f\n", prob);
    } 
}

Measured memory_bytes: 888
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append((i, n // i))

    return divisors

def resolve():
    N = int(input())

    divisors = make_divisors(N)
    ans = 1<<60
    for a, b in divisors:
        s_a = len(str(a))
        s_b = len(str(b))
        if s_a <= s_b:
            ans = min(ans, s_b)
        else:
            ans = min(ans, s_a)
    return print(ans)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
char str[105];
bool flag1,flag2;
int main(){
	scanf("%s",str+1);
	for(int i=1;i<=strlen(str+1);i++){
		if(str[i]=='C')flag1=1;
		if(flag1&&str[i]=='F')flag2=1;
	}
	if(flag1&&flag2)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

//ax + by = c
//dx + ey = d

//y = (af-cd)/(ae-bd)
//x = (c-by)/a

int main(void){
double a,b,c,d,e,f;
while(~scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f))
{
printf("%.3f %.3f\n", (c-b*((a*f-c*d)/(a*e-b*d)))/a, ((a*f-c*d)/(a*e-b*d)));
}
return 0;
}

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

int pref[26];

int main() {
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(0);
	string str; cin >> str;
	uint64_t dup = 0;
	pref[str[0] - 'a']++;
	for (int i = 1; i < (int)str.size(); i++) {
		dup += pref[str[i] - 'a'];
		pref[str[i] - 'a']++;
	}
	cout << (uint64_t)str.size() * (str.size() - 1) / 2 - dup + 1 << '\n';
}


Measured memory_bytes: 720
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0LL);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

vector<int> nexta(vector<int>& pre, int m, int k) {
	int t = pre[k];
	if (t != m) {
		pre[k]++;
		return pre;
	}
	if (k == 0) {
		pre[0] = -1;
		return pre;
	}

	nexta(pre, m, k - 1);
	pre[k] = pre[k - 1];
	return pre;
}

int main() {
	int n, m, q;
	cin >> n >> m >> q;
	vector<int> a(q), b(q), c(q), d(q);
	rep(i, q) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--; b[i]--;
	}

	vector<int> v(n);
	rep(i, v.size()) {
		v[i] = 1;
	}

	int ans=0;


	rep(i, q) {
		if (v[b[i]] - v[a[i]] == c[i]) {
			ans += d[i];
		}
	}

	while (1) {
		v = nexta(v, m, n - 1);

		if (v[0] == -1) {
			cout << ans << endl;
			return 0;
		}
		
		int za = 0;
		rep(i, q) {
			if (v[b[i]] - v[a[i]] == c[i]) {
				za += d[i];
			}
		}
		ans = max(ans, za);
	}
}




Measured memory_bytes: 3564
using System;
using System.Linq;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        var inp = Console.ReadLine();
        bool ans = true;
        for (int i = 0; i < inp.Length - 1; i++)
        {
            if (inp[i] == inp[i + 1]) ans = false;
        }
        Console.WriteLine(ans?"Good":"Bad");
    }
}

Measured memory_bytes: 13140
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn exe(s: &str, s_cnt: usize, t: &str, t_cnt: usize, u: &str) -> [usize; 2] {
    if s == u {
        [s_cnt - 1, t_cnt]
    } else {
        [s_cnt, t_cnt - 1]
    }
}

fn main() {
    input! {
        st: [String; 2],
        a: usize,
        b: usize,
        u: String,
    }
    let ans = exe(&st[0], a, &st[1], b, &u);
    println!("{} {}", ans[0], ans[1]);
}

#[test]
fn test() {
    assert_eq!(exe("red", 3, "blue", 4, "red"), [2, 4]);
    assert_eq!(exe("red", 5, "blue", 5, "blue"), [5, 4]);
}


Measured memory_bytes: 4352
/* warshall_floyd.cpp
    ワーシャルフロイド法を用いて、全点間最短路を求める。

    初期化：dis[i][j] = iからjへの距離(辺がなければINF) (i≠j)
            dis[i][i] = 0
            prev[i][j] = i

    負閉路の検出：dis[i][i] < 0 となる i が存在するか

    verified:
        http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_C&lang=ja
*/

#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e17;

void warshall_floyd(vector<vector<long long>> &dis, vector<vector<long long>> &prev) {
    int V = dis.size();
    for (int k = 0; k < V; k++) {
        for (int i = 0; i < V; i++) {
            for (int j = 0; j < V; j++) {
                if (dis[i][k] + dis[k][j] < dis[i][j]) {
                    dis[i][j] = dis[i][k] + dis[k][j];
                    prev[i][j] = prev[k][j];
                }
            }
        }
    }
}
void back_warshall_floyd(vector<vector<long long>> &dis) {
    int V = dis.size();
    for (int k = 0; k < V; k++) {
        for (int i = 0; i < V; i++) {
            for (int j = 0; j < V; j++) {
                if (i != k && k != j && j != i && dis[i][k] + dis[k][j] == dis[i][j]) {
                    dis[i][j] = INF;
                }
            }
        }
    }
}

/* get_path(prev, s, t)
    入力：warshall_floyd で得た prev, スタート s, ゴール t
    出力：s から t への最短路のパス
*/
vector<int> get_path(const vector<vector<long long>> &prev, int s, int t) {
    vector<int> path;
    for (int cur = t; cur != s; cur = prev[s][cur]) {
        path.push_back(cur);
    }
    path.push_back(s);
    reverse(path.begin(), path.end());
    return path;
}

/* is_negative(dis)
    入力：warshall_floyd で得た dis
    出力：負の有向路を含むかどうか
*/
bool is_negative(const vector<vector<long long>> &dis) {
    int V = dis.size();
    for (int i = 0; i < V; i++) {
        if (dis[i][i] < 0) {
            return true;
        }
    }
    return false;
}

template <class T>
void print_2d_vec(const vector<vector<T>> &A) {
    for (int i = 0; i < (int)A.size(); i++) {
        cout << i << ": ";
        for (int j = 0; j < (int)A[i].size(); j++) cout << A[i][j] << " ";
        cout << endl;
    }
}

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

    // initialization
    vector<vector<long long>> dis(N, vector<long long>(N, INF));
    vector<vector<long long>> prev(N);
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            cin >> dis[i][j];
        }
        prev[i] = vector<long long>(N, i);
    }
    vector<vector<long long>> tmp = dis;
    back_warshall_floyd(tmp);
    // print_2d_vec(tmp);

    vector<vector<long long>> res = tmp;
    warshall_floyd(res, prev);
    long long ans = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (dis[i][j] != res[i][j]) {
                cout << -1 << endl;
                return 0;
            }
            if (i < j && tmp[i][j] != INF) {
                ans += tmp[i][j];
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3072
from collections import deque
n,m=map(int,input().split())
graph=[[] for i in range(n)]
sirusi=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    a-=1;b-=1
    graph[a].append(b)
    graph[b].append(a)
D=deque([0])
visited=[False]*n
visited[0]=True
while D:
    v=D.popleft()
    for i in graph[v]:
        if visited[i]:continue
        visited[i]=True
        sirusi[i]=v
        D.append(i)
print("Yes")
for i in range(1,n):
    print(sirusi[i]+1)

Measured memory_bytes: 34756
n = int(input())
a = list(map(int, input().split()))

n2 = 0
n4 = 0

for ai in a:
  if ai % 4 == 2:
    n2 += 1
  if ai % 4 == 0:
    n4 += 1

if n2 == 0 and n4:
  n2 += 1
if n2 + n4 * 2 >= n:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 15020
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int b[110];
int c[110];
int ijk[121000];
int v[121000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%d",b+i);
	for(int i=0;i<a;i++)scanf("%d",c+i);
	priority_queue<pair<int,int> > Q;
	for(int i=0;i<121000;i++)ijk[i]=mod;
	int tm=0;
for(int i=0;i<a;i++)b[i]*=2;
for(int i=0;i<a;i++)c[i]*=2;

	for(int i=0;i<a;i++){
		for(int j=0;j<=b[i];j++){
			Q.push(make_pair(-c[i],tm+j));
			ijk[tm+j]=min(ijk[tm+j],c[i]);
		}
		tm+=b[i];
	}
	Q.push(make_pair(0,0));
	Q.push(make_pair(0,tm));
	ijk[0]=ijk[tm]=0;
	while(Q.size()){
		int cost=-Q.top().first;
		int at=Q.top().second;
		Q.pop();
		if(v[at])continue;
		v[at]=1;

		if(at&&!v[at-1]&&ijk[at-1]>cost+1){
			ijk[at-1]=cost+1;
			Q.push(make_pair(-cost-1,at-1));
		}
		if(at<tm&&!v[at+1]&&ijk[at+1]>cost+1){
			ijk[at+1]=cost+1;
			Q.push(make_pair(-cost-1,at+1));
		}
	}
	//for(int i=0;i<=tm;i++)printf("%d: %d\n",i,ijk[i]);
	
	double ret=0;
	for(int i=0;i<tm;i++){
		ret+=0.25*(ijk[i]+ijk[i+1]);
	}
	ret/=2;
	printf("%.12f\n",ret);
}

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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;


void solve() {
	ll n,m,ans=0;
	cin>>n>>m;
	vector<pll> A(n);
	for(int i=0;i<n;i++) cin>>A[i].fi>>A[i].se;
	sort(all(A));
	for(int i=0;i<n&&m;i++){
		ans+=A[i].fi*min(m,A[i].se);
		m-=min(A[i].se,m);
	}
	cout<<ans<<"\n";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;
//	ll t;cin>>t;while(t--)
	solve();

}


Measured memory_bytes: 1792
/*************************************************************************
  >         File: C.cc
  >       Author: Riho.Yoshioka
  >         Mail: riho.yoshioka@yandex.com
  > Created Time: Sun 21 Aug 2016 08:31:19 PM CST
*************************************************************************/
#include <bits/stdc++.h>

int main() {
  std::ios::sync_with_stdio(0);
  int n;
  std::cin >> n;
  std::vector<int> numbers, a;
  for (int i = 0; i < n; i++) {
    int x;
    std::cin >> x;
    numbers.emplace_back(x);
  }
  a = numbers;
  std::sort(numbers.begin(), numbers.end());
  numbers.resize(std::unique(numbers.begin(), numbers.end()) - numbers.begin());
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int x = std::lower_bound(numbers.begin(), numbers.end(), a[i]) - numbers.begin();
    if (x % 2 != i % 2) ans++;
  }
  assert(ans % 2 == 0);
  std::cerr << ans << std::endl;
  std::cout << ans / 2 << std::endl;
  return 0;
}


Measured memory_bytes: 1144
#include<iostream>
#include<list>
#include<vector>
#include<string>
#include<cmath>

using namespace std;

int main(){
    string S;
    cin >> S;
	int sSize = S.size();
  
  	char previous = S[0];
  	int countReverse = 0;
  	for (int i = 1; i < sSize; i++){
      if (S[i] != previous){
        countReverse++;
      }
      previous = S[i];
    }
  
    cout << countReverse <<endl;
}


Measured memory_bytes: 512
#include <stdio.h>

int main() {
        int A, B, K;
        int i;
        int lim, ans;

        scanf("%d %d %d", &A, &B, &K);

        if (A < B) {
                A ^= B;
                B ^= A;
                A ^= B;
        }

        if (A / 2 < B) lim = B;
        else lim = A / 2;

        for (i = lim; i > 0; i--) {
                if (A % i == 0 && B % i == 0) K--;
                if (K == 0) {
                        ans = i;
                        break;
                }
        }

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

        return 0;
}


Measured memory_bytes: 128
#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()
{
    int n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n),b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];

    ll t = 0;
    rep(i, m) t += b[i];

    int j = m;
    int ans = 0;
    rep(i, n + 1) {
        while (j > 0 && t > k) {
            --j;
            t -= b[j];
        }
        if (t > k) break;
        ans = max(ans, i + j);
        if (i == n) break;
        t += a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6412
#include<iostream>
#include<math.h>
using namespace std;
int main(){
    int n,a,b;
    int ans;
    cin>>n;
    for(int i=0;i<=n;i++){
        if(floor(i*1.08)==n){cout<<i<<endl;return 0;}
    }
    cout<<":("<<endl;
    return 0;
}


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

bool isPrime(int x){
    if(x<2) return false;
    if(x==2) return true;
    if(x%2==0) return false;
    for(int i=3;i*i<=x;i+=2){
        if(x%i==0) return false;
    }
    return true;
}

int main(void){
    int N,x;
    int cnt=0;
    cin>>N;
    for (int i=0;i<N;i++){
        cin>>x;
        if(isPrime(x)) cnt++;
    }
    cout<<cnt<<endl;
}



Measured memory_bytes: 3112
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <regex>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include<tuple>

using namespace std;
const int MAX = 100001;
const int INF = 1 << 30;

int main() {
	int N, M;
	int a[MAX], b[MAX];
	vector<pair<int, int>> v;

	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i];
		v.push_back(make_pair(a[i], i));
		v.push_back(make_pair(b[i], i));
	}

	sort(v.begin(), v.end());

	int ans = 0;
	int lim = INF;
	bool check[MAX] = { false };

	for (int i = 0; i < v.size(); i++) {
		if (check[v[i].second] == false) {
			check[v[i].second] = true;
			lim = min(lim, b[v[i].second]);
		}
		else if (a[v[i].second] >= lim) {
			ans++;
			lim = b[v[i].second];
		}
	}

	cout << ans + 1<< endl;

	return 0;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
int main(){
    long a=0,b=0,k=0,s=0,c=0;
    cin >> a >> b;
    s = (a*a) - (b*b);
    c = (2*a-2*b);
    k = s / c;
    if((s%c) == 0){
        cout << k;
    }
    else {
        cout << "IMPOSSIBLE";
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast_read ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define For(i,a,b) for(int i = a; i <= b;i++)
#define Forr(i,a,b) for(int i = a;i >= b;i--)
#define fi first
#define se second
#define maxn 500005
#define ll long long
#define INF 1e18
#define pii pair<int,int>
using namespace std;

int n;
string s;

int a[maxn];

vector<int> adj[maxn];

int in[maxn],out[maxn];

int main()
{
    fast_read;
    cin >> s;
    n = s.size();
    ll ans = 0;
    For(i,0,n-1)
    {
        if(s[i] == '<')
            adj[i+1].push_back(i+2),in[i+2]++;
        else
            adj[i+2].push_back(i+1),in[i+1]++;
    }
    queue<pair<int,int> > tp;
    For(i,1,n+1) if(in[i] == 0) tp.push({i,0});
    while(!tp.empty())
    {
        int u = tp.front().fi;
        a[u] = tp.front().se;
        //cout << u << ' ' << a[u] << endl;
        tp.pop();
        for(int v : adj[u])
        {
            in[v]--;
            if(in[v] == 0)
                tp.push({v,a[u]+1});
        }
    }
    ans = 0;
    For(i,1,n+1) ans += a[i];
    cout << ans << endl;
}


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

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

vector<int>p(N);
for(int i = 0; i < N; i++){ 
     cin >> p.at(i);
}

sort(p.begin(), p.end());
int ans = 0;
for(int i = 0; i < N; i++){ 
     if(i < N - 1) ans += p.at(i);
     else if(i == N - 1) ans += p.at(i) / 2; 
}

cout << ans << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string sa, sb, sc;
  char ct = 'a';
  cin >> sa >> sb >> sc;
  reverse(sa.begin(), sa.end());
  reverse(sb.begin(), sb.end());
  reverse(sc.begin(), sc.end());
  while (1) {
    if (ct == 'a') {
      if (sa.empty()) {
        cout << 'A';
        return 0;
      }
      ct = sa[sa.size()-1];
      sa.pop_back();
    } else if (ct == 'b') {
      if (sb.empty()) {
        cout << 'B';
        return 0;
      }
      ct = sb[sb.size()-1];
      sb.pop_back();
    } else {
      if (sc.empty()) {
        cout << 'C';
        return 0;
      }
      ct = sc[sc.size()-1];
      sc.pop_back();
    }
  }
  return 0;
}

Measured memory_bytes: 3640
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    minus = 0
    minus_count = 0
    plus_list = []
    for i in range(N):
        diff = A[i] - B[i]
        if diff < 0:
            minus += diff
            minus_count += 1
        else:
            plus_list.append(diff)
    plus_list.sort(reverse=True)
    if minus == 0:
        print(0)
    else:
        ans = 0
        for v in plus_list:
            minus += v
            ans += 1
            if minus >= 0:break
        if minus < 0:
            print(-1)
        else:
            print(ans+minus_count)
if __name__ == "__main__":
    main()

Measured memory_bytes: 73136
//#include <ext/pb_ds/assoc_container.hpp> 
 //#include <ext/pb_ds/tree_policy.hpp>
// #include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power(((((a)%mod)*((a)%mod))%mod),b/2)%mod;
    else return (((a)%mod)*(power(((((a)%mod)*((a)%mod))%mod),b/2)%mod))%mod;
}
inline ll inverse(ll a,ll md) {
  a %= md;
  if (a < 0) a += md;
  ll b = md, u = 0, v = 1;
  while (a) {
    ll t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}
  
  
 //using namespace __gnu_pbds;
 //#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
// mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); for randomized solution
const int ce=1e9+7;
ll fast_mod(ll input)
{
    return input < ce ? input : input%ce;
}
#define pi acos(-1)
bool comp(pair<int,int> p,pair<int,int> p1)
{
    if(p.first!=p1.first)
    {
        return p.first>p1.first;
    }
    else
    {
        return p.first>p1.first;
    }
}
int32_t main()
{
    IOS

    
    int n;
    cin>>n;
    vector<pair<int,int>> v;
    int pre=0,pre1=0;;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        stack<char> s1;
        int c=0,c1=0;
        for(int j=0;j<s.length();j++)
        {
            if(s[j]==')')
            {
                if(int(s1.size())==0)
                {
                    c++;
                }
                else
                {
                    s1.pop();
                }
            }
            else
            {
                s1.push('(');
            }
        }
        while((int)s1.size())
        {
            c1++;
            s1.pop();
        }
        if(c1==0)
        {
            pre1+=c;
            continue;
        }
        if(c==0)
        {
            pre+=c1;
            continue;
        }
        v.push_back({c1-c,c});
    }
    sort(v.begin(),v.end(),comp);
    for(int i=0;i<v.size();i++)
    {
        if(pre<v[i].second)
        {
            cout<<"No"<<endl;
            return 0;
        }
        pre+=v[i].first;
    }   
    if(pre==pre1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

}       
    

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

int main() {
    string S, T;
    cin>>S>>T;
    int cnt=0;

    if(S.at(0)==T.at(0)) cnt++;
    if(S.at(1)==T.at(1)) cnt++;
    if(S.at(2)==T.at(2)) cnt++;

    cout<<cnt<<endl;

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;i++)
#define FORD(i,a,b) for (int i=a;i>=b;i--)
using namespace std;
typedef pair<int,int> pa;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
LL x,y,ans;
int main(){
	cin>>x>>y;
	ans=1;
	x=x*2;
	while (x<=y){
		++ans;
		x*=2;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
a, b, c = map(int, input().split(" "))
max_v = max(a, b, c)
sum_v = a + b + c
cc = 0
if max_v % 2 == sum_v %2:
    cc = (3 * max_v - sum_v) // 2
else :
    cc = (3 * (max_v + 1) - sum_v) // 2

print(cc)

Measured memory_bytes: 9128
import scala.io.StdIn.{readLine, readInt};
object Main {
    def main(args: Array[String]): Unit = {
        readInt;
        val s = readLine.split(" ").map(_.toLong);
        readInt;
        val t = readLine.split(" ").map(_.toLong);
        val ret = t.foldLeft(0) { (cnt, i) => if (binSearch(i, s)) {cnt + 1}else {cnt}};
        println(ret);
    }
    
    def binSearch(target: Long, arr: Array[Long]): Boolean = {
        def go(first: Int, last: Int): Boolean = {
            val pivot = (first + last) / 2;
            if (target == arr(pivot)) true;
            else if (first == last) false;
            else if (target < arr(pivot)) go(first, pivot);
            else go(pivot + 1, last);
        }
        go(0, arr.length - 1);
    }
}


Measured memory_bytes: 77172
use io::*;

fn main() {
    let con =read_string();
    let mut sc =Scanner::new(&con);

    let s: Vec<char> = sc.next::<String>().chars().collect();
    let k:i64 =sc.next();
    let mut ans = '1';
    for i in 0..s.len(){
        if i as i64==k{
            break;
        }
        if s[i as usize] != '1'{
            ans = s[i as usize];
            break;
        }
    }

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

pub mod io {
    use std;
    use std::str::FromStr;
 
    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }
 
    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }
 
        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }
 
        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }
 
        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }
 
    pub fn read_string() -> String {
        use std::io::Read;
 
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }
 
    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}

Measured memory_bytes: 4352
import collections

N = int(input())
A =[]
for i in range(N):
    A.append(input())
    
ans =[]
c = collections.Counter(A)
m = c.most_common()
ma = m[0][1]

for i in range(len(m)):
    if m[i][1] == ma:
        ans.append(m[i][0])
ans.sort()

print("\n".join(ans))

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

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

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

    int N;
    cin >> N;
    vector<int> A(N + 1), B(N);
    REP(i, N + 1) cin >> A[i];
    REP(i, N) cin >> B[i];

    ll result = 0;
    REP(i, N) {
        int d = min(A[i], B[i]);
        A[i] -= d;
        B[i] -= d;
        result += d;
        int e = min(A[i + 1], B[i]);
        A[i + 1] -= e;
        B[i] -= e;
        result += e;
    }
    cout << result << endl;
    return 0;
}



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

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

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

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

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

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    priority_queue<pll> que;
    ll n, m;
    cin >> n >> m;

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

    rep(i, m) {
        ll b, c;
        cin >> b >> c;
        que.push(MP(c, b));
    }

    ll cnt = 0, sum = 0;

    while (!que.empty()) {
        if (cnt == n) break;
        pll p = que.top();
        que.pop();
        if (cnt + p.second > n) {
            sum += p.first * (n - cnt);
            cnt = n;
        } else {
            sum += p.first * p.second;
            cnt += p.second;
        }
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 6256
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,l,r) for(int i=(l);i<(r);i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef long long ll;  //ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<ll, ll> > PS;
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

bool primeNumber(int n){
    if(n < 2) return false;
    else{
        for(int i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
// g++ -std=c++11 prac.cpp 

int main(){
    ll a,b,x=0,y=0,z=0,n,m=0,k,ans=0,h,w,sum=0,Max=-1e9-1,cnt=0,Min=1e9+1;
    string s,t,u;
    bool ok=true;
    cin >> x;
    while(!primeNumber(x)){
        x++;
    }
    cout << x << endl;
    return 0;
}


 

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

int main() {
	long int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  if(!a) cout<<1;
  else if(!b) cout<<2;
  else if(!c) cout<<3;
  else if(!d) cout<<4;
  else if(!e) cout<<5;
	return 0;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
#define maxc 1010
#define inf 0x3f3f3f3f
#define ll long long

int main()
{
    char a[maxc];
    scanf("%s",a);
    getchar();
    int n=strlen(a);
    for(int i=0;i<n;i++){
        if(a[i]=='1')
            printf("9");
        else
            printf("1");
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256