akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main()
{
    string a;
    long long int i,l;
    cin>>a;
    l=a.length();
    for(i=0; i<l; i++)
    {
        if(a[i]=='?')
        {
            a[i]='D';
        }
    }
    cout<<a<<endl;
    return 0;
}


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

using namespace std;

int v[4];

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


    v[0] = a;
    v[1] = b;
    v[2] = c;


    int zlicz = 0;

    while(v[0] != v[1] || v[1] != v[2] || v[2] != v[0])
    {
        int mini = min(min(v[0], v[1]), v[2]);
        int para = 0;

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


            if(mini == v[i]) para++;


        }

        if(para == 2)
        {

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

                if(mini == v[i]) v[i]+=1;

            }

        }

        if (para < 2 && para > 0)
        {

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

                if(mini == v[i]) v[i]+=2;

            }

        }

        zlicz++;

    }

    cout<<zlicz;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long double EPS = 1e-27;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, b;
    long double d;
    cin >> d >> n >> b;
    vector<int> p(n), h(n);
    for(int i = 0; i < n; i++) cin >> p[i] >> h[i];
    long double ans = 1e27;
    for(int i = 0; i <= b; i++) {
        bool fi = true;
        long double unit = d / (i + 1);
        long double ok = 1e27;
        long double ng = 0;
        for(int _ = 0; _ <= 100; _++) {
            long double mid = (ok + ng) / 2;
            bool clear = true;
            for(int j = 0; j < n; j++) {
                int k = (int)((p[j] + EPS) / unit);
                long double x = abs(p[j] - (k + 0.5) * unit);
                if(fi) {
                    if(j == n - 1) fi = false;
                    //cerr << j << " " << k << " " << x << endl;
                }
                //cerr << (k + 0.5) * unit << endl;
                long double a = (4 * mid / (unit * unit));
                long double H = mid - a * x * x;
                //if(i == 2) cerr << mid << " " << unit << " " << k << " " << x << " " << H << endl;
                if(H <= h[j]) clear = false;
            }
            if(clear) ok = mid;
            else ng = mid;
        }
        long double L = ok;
        long double R = 1e18;
        auto f = [](long double l, long double d) {
            long double vy = sqrt(2 * l);
            long double T = 2 * vy;
            long double vx = d / T;
            return sqrt(vx*vx+vy*vy);
        };
        for(int _ = 0; _ <= 200; _++) {
            long double l = (2*L+R)/3;
            long double r = (L+2*R)/3;
            long double vy = sqrt(2*l);
            long double T = 2 * vy;
            long double vx = d / ((i + 1) * T);
            long double tmpl = sqrt(vx*vx+vy*vy);
            vy = sqrt(2*r);
            T = 2 * vy;
            vx = d / ((i + 1) * T);
            long double tmpr = sqrt(vx*vx+vy*vy);
            //if(i == 2) cerr << l << " " << r << " " << tmpl << " " << tmpr << endl;
            if(tmpl < tmpr) R = r;
            else L = l;
        }
        //cerr << i << " " << ok << " " << L << endl;
        //cerr << i << " " << ok << endl;
        long double vy = sqrt(2 * ok);
        long double T = 2 * vy;
        long double vx = d / ((i + 1) * T);
        //long double tmp = sqrt(vx*vx+vy*vy);
        long double tmp = f(L, d/(i+1));
        //cerr << vx << " " << vy << " " << tmp << " " << T << endl;
        chmin(ans, tmp);
        long double check = 0;
        //check -= pow(unit/2, 2) / (2 * pow(vx, 2));
        //check += (vy / vx) * (unit / 2);
        //cerr << unit << endl;
    }
    cout << fixed << setprecision(50) << ans << endl;
    return 0;
}


Measured memory_bytes: 3324
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

#define iter(i, n) forw(i, 1, n)
#define iter0(i, n) for (int i = 0; i < n; ++i)
#define forw(i, a, b) for (int i = a; i <= b; ++i)

const int g = 5;
const int mod = 924844033;

#define NR 211000
#define MR 811000

vector<int> e[NR];
int n, a[MR], b[MR], sz[NR], fac[NR], inv[NR], N;

int pr(int a, int z) {
	int s = 1;
	while (z > 0) {
		if (z % 2 == 1) s = 1ll * s * a % mod;
		a = 1ll * a * a % mod;
		z /= 2;
	}
	return s;
}

void fft(int *a, int n, int ty) {
	for (int i = n >> 1, j = 1, k; j < n - 1; ++j) {
		if (i > j) swap(a[i], a[j]);
		for (k = n >> 1; k <= i; k >>= 1) i ^= k;
		i ^= k;
	}

	for (int m = 2; m <= n; m <<= 1) {
		int h = m >> 1, wm = pr(g, (mod - 1) / m * (ty == +1 ? 1 : (m - 1)));

		for (int i = 0; i < n; i += m) {
			int w = 1;
			for (int j = i; j < i + h; ++j) {
				int u = a[j], v = 1ll * w * a[j + h] % mod;
				a[j] = (u + v) % mod;
				a[j + h] = (u - v + mod) % mod;
				w = 1ll * w * wm % mod;
			}
		}
	}

	if (ty == -1) {
		int iv = pr(n, mod - 2);
		iter0(i, n) a[i] = 1ll * a[i] * iv % mod;
	}
}

void dfs(int x, int fa) {
	sz[x] = 1;
	for (int v : e[x]) if (v != fa) {
		dfs(v, x), sz[x] += sz[v]; ++a[sz[v]];
	}
	++a[n - sz[x]];
}

int binom(int n, int k) { return 1ll * fac[n] * inv[k] % mod * inv[n - k] % mod; }

int main() {
	scanf("%d", &n);
	iter(i, n - 1) {
		int x, y;
		scanf("%d%d", &x, &y);
		e[x].push_back(y), e[y].push_back(x);
	}

	dfs(1, 0);


	for (N = 1; N < 2 * n; N <<= 1);

	fac[0] = inv[0] = 1;
	a[0] = 0;
	iter(i, n) {
		fac[i] = 1ll * fac[i - 1] * i % mod;
		
		inv[i] = pr(fac[i], mod - 2);
	}
	

	


	iter(i, n) a[i] = 1ll * fac[i] * a[i] % mod;
	forw(i, 0, n - 1) {
		b[n - i] = inv[i];
	}

	//printf("%d\n", a[2*n]);

	fft(a, N, 1), fft(b, N, 1);
	iter0(i, N) a[i] = 1ll * a[i] * b[i] % mod;
	fft(a, N, -1);

	iter(i, n) printf("%lld\n", (1ll * n * binom(n, i) % mod + mod - 1ll * a[n + i] * inv[i] % mod) % mod);
	return 0;
}

Measured memory_bytes: 32640
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string S;
	cin >> S;
	int n = (int)(S.length());
	vector<int> dp(n+2);
	int i = 0;
	dp[0] = 0;
	int tmp = 1;
	while (i < n-1){
		// cout << i << endl;
		// for (int j = 0;j < n; j++){
		// 	cout << dp[j] << endl;
		// }
		if (tmp == 1){
			if (S[i] != S[i+1]){
				dp[i+1] = dp[i] +1;
				i ++;
				tmp = 1;
			}
			else {
				dp[i+1] = dp[i];
				dp[i+2] = dp[i] + 1;
				i += 2;
				tmp = 2;
				
			}
		}
		else{
			dp[i+1] = dp[i] +1;
			i ++;
			tmp = 1;
		}

	}
	if (dp[n-1] == 0){
		cout << dp[n-1] << endl;
	}
	else{
		cout << dp[n-1] + 1 << endl;
	}
	return 0;
}

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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===


int ans[510][510];

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

	int N, M, Q;
	cin >> N >> M >> Q;

	memset(ans, 0, sizeof(ans));
	for (int i = 0; i < M; ++i) {
		int L, R;
		cin >> L >> R;
		--L; --R;
		++ans[0][R];
		--ans[L + 1][R];
		--ans[0][N];
		++ans[L + 1][N];
	}
	for (int i = 0; i < N; ++i) {
		for (int j = i; j < N; ++j) {
			ans[i + 1][j] += ans[i][j];
		}
	}
	for (int i = 0; i < N; ++i) {
		for (int j = i; j < N; ++j) {
			ans[i][j + 1] += ans[i][j];
		}
	}

	for (int i = 0; i < Q; ++i) {
		int L, R;
		cin >> L >> R;
		--L; --R;
		cout << ans[L][R] << '\n';
	}

	return 0;
}

Measured memory_bytes: 1920
#include <stdio.h>
int	main()	{
	int n,cnt =0,copy,i =0;
	int data[10] ={0};
	while(scanf("%d",&n) != EOF){
		
		if(n == EOF){
			break;
		}else{
			if(n != 0){
				data[i] = n;
				i++;
			}else{
				i--;
				printf("%d\n",data[i]);
			}
		}
	}
	return	0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <deque>
#define int long long 
#define fast_io ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define rep(i,start,end) for(int i=start;i<end;i++)
#define per(i,start,end) for (int i=end-1;i>=start;i--)
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vs vector<string>
#define all(a) a.begin(),a.end()
#define vp vector<pair<int,int>>
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
const int N = 1e5;
using namespace std;

void solve()
{
	string s, t;
	cin >> s >> t;
	if (s.length() + 1 != t.length())
	{
		cout << "No\n";
		return;
	}
	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] != t[i])
		{
			cout << "No\n";
			return;
		}
	}
	cout << "Yes\n";
	return;
	

}
int32_t main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	fast_io;
	int t;
	//cin >> t;
	t = 1;
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
vector<int>kaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    //if(!kaijo[0])init_fact(2000010);
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}

signed main(){
    string s,t;
    cin>>s>>t;
    if(t.substr(0,s.size())==s)puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 3632
N = gets.to_i
S = N.times.map{
	gets.to_i(2)
}

T = S.map{|si|
	(0...N).select{|j| (si>>(N-1-j))&1 == 1 }
}
Ds = lambda{|dbase|
	ds, d, q = [nil]*N, 1, [nil]*N
	ds[dbase] = d
	q.clear; q << dbase
	until q.empty?
		q.size.times{
			T[q.shift].each{|j|
				case ds[j]
				when nil
					ds[j] = d+1
					q << j
				when d+1
				when d-1
				else
					raise
				end
			}
		}
		d += 1
	end
	return ds
}
DsMax = lambda{|dbase|
	d, p, q = 0, 0, 1<<(N-1-dbase)
	until p == (1<<N)-1
		d, p, q, r = d+1, p|q, 0, (p^q)&q
		# assert(r != 0)
		until 0 == (s = r&(-r))
			q |= S[N-s.bit_length]
			r -= s
		end
	end
	return d
}
begin
	p [Ds[0].max, (1...N).map{|i| DsMax[i] }.max].max
rescue RuntimeError
	p(-1)
end


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
int main(){
    string a,b;
    cin>>a>>b;
    
    int an=a.size();
    int bn=b.size();
    string ans="EQUAL";
    if(an>bn)ans="GREATER";

    else if(an<bn)ans="LESS";

    else{
        rep(i,an){
            int ap=a[i]-'0';
            int bp=b[i]-'0';
            if(ap>bp){
                ans="GREATER";
                break;
            }
            else if(bp>ap){
                ans="LESS";
                break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 256
func readArrayInt() -> [Int] {
    readLine()!.split(separator: " ").map({Int($0)!})
}

var line = readArrayInt()
let (N, M) = (line[0], line[1])
var peaks: Set<Int> = []
(0..<N).forEach({peaks.insert($0)})
let H = readArrayInt()

for _ in 1...M {
    let pair = readArrayInt()
    let (A, B) = (pair[0] - 1, pair[1] - 1)
    if H[A] < H[B] {
        peaks.remove(A)
    } else if H[A] > H[B] {
        peaks.remove(B)
    } else {
        peaks.remove(B)
        peaks.remove(A)
    }
}
print(peaks.count)


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

int main(){
    int s[3];
    int count=0;
    int co=0;
    for(int i=0; i<3; i++){
        cin >> s[i];
        if(s[i]==5)
        count++;
        if(s[i]==7)
        co++;
    }
    if(count==2 && co==1)
    cout << "YES" << endl;
    else
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#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()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n, d;
	cin >> n >> d;
	int count;
	count = 0;
	vector<vector<int>>	V(n, vector<int>(d));
	rep(i, n)
	{
		rep(j, d)
			cin >> V.at(i).at(j);
	}
	rep(i, n - 1)
	{
		for (int j = i + 1; j < n; j++)
		{
			int sum;
			sum = 0;
			rep(k, d)
				sum += pow(V.at(i).at(k) - V.at(j).at(k), 2);
			if (pow(floor(sqrt(sum)), 2) == sum)
				count++;
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 256
X,Y=map(int,input().split())
if (X+Y)%3!=0:
  print(0)
  exit()
X,Y=X-(X+Y)//3,Y-(X+Y)//3
if X<0 or Y<0:
  print(0)
  exit()

SIZE=10**6+1; MOD=10**9+7 #998244353 #ここを変更する
 
SIZE += 1
inv = [0]*SIZE  # inv[j] = j^{-1} mod MOD
fac = [0]*SIZE  # fac[j] = j! mod MOD
finv = [0]*SIZE # finv[j] = (j!)^{-1} mod MOD
inv[1] = 1
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2,SIZE):
    inv[i] = MOD - (MOD//i)*inv[MOD%i]%MOD
    fac[i] = fac[i-1]*i%MOD
    finv[i]= finv[i-1]*inv[i]%MOD
 
def choose(n,r): # nCk mod MOD の計算
    if 0 <= r <= n:
        return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
    else:
        return 0
 
print(choose(X+Y,X))


Measured memory_bytes: 123764
#include<bits/stdc++.h>
using namespace std;
int main(){
  priority_queue<int> que;
  int a;
  for(int i = 0;i < 10;i++) {
    cin >> a;
    que.push(a);
  }
  for(int i = 0;i < 3;i++){
    printf("%d\n", que.top());
    que.pop();
  }

  return 0;
}



Measured memory_bytes: 3176
import fractions
n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
L = [0] * n
R = [0] * n
for i in range(1, n):
    L[i] = fractions.gcd(a[i - 1], L[i - 1])
    R[n - 1 - i] = fractions.gcd(a[n - i], R[n - i])
for i in range(0, n):
    ans[i] = fractions.gcd(L[i], R[i])
ans.sort()
print(ans[n - 1])

Measured memory_bytes: 16116
#include<stdio.h>
#include<stdint.h>
#include<inttypes.h>
#define PROCESS_MAX 100001
  
typedef struct{
    char          name[11];
    uint_fast32_t time    ;
} s_process;
  
int main(void)
{
    uint_fast32_t n, q, head = 0, tail = 0, process_time = 0;
    s_process process[PROCESS_MAX];
  
    scanf("%"SCNu32" %"SCNu32, &n, &q);
    for(uint_fast32_t i=0; i<n; ++i){
        scanf("%s %"SCNu32, process[i].name, &process[i].time);
    }
    tail = n;
  
    while(head != tail){
        if(process[head].time > q){
            process_time       += q            ;
            process[head].time -= q            ;
            process[tail]       = process[head];
            head = (head+1) % PROCESS_MAX;
            tail = (tail+1) % PROCESS_MAX;
        }else{
            process_time += process[head].time;
            printf("%s %"PRIu32"\n", process[head].name, process_time);
            head = (head+1) % PROCESS_MAX;
        }
    }
  
    return 0;
}



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

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

    auto sum = 0LL;
    for (int a = 1; a <= k; ++a) {
        for (int b = 1; b <= k; ++b) {
            int ab = gcd(a, b);

            for (int c = 1; c <= k; ++c) {
                int abc = gcd(ab, c);
                sum += abc;
            }
        }
    }

    cout << sum;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define st first
#define nd second
using namespace std;
using pii =pair<int,int>;

char s[25][25];
int ch[25][25];
int n,m;
void clr(){
    for(int i = 0;i<=n+1;i++){
        for(int j=0;j<=m+1;j++){
            if(i==0||j==0||i==n+1||j==m+1){
                ch[i][j]=999;
                continue;
            }
            if(s[i][j]=='#') ch[i][j] = 999;
            else ch[i][j]= -1;
        }
    }


}
int bfs(int x,int y){
    clr();
    ch[x][y] = 0;
    int ma = 0;
    queue<pii> q;
    q.push({x,y});
    while(!q.empty()){
        pii p = q.front();
        q.pop();
        int fi = p.st,se=p.nd;
        for(int i = -1;i<=1;i++){
            for(int j =-1;j<=1;j++){
                if(abs(i)==abs(j)) continue;
                if(ch[fi+i][se+j] == -1) {
                    ch[fi+i][se+j] = ch[fi][se]+1;
                    q.push({fi+i,se+j});
                    if(ch[fi+i][se+j] >ma) ma=ch[fi+i][se+j];
                }
            }
        }
    }
    return ma;
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i =1;i<=n;i++){
        scanf("%s",s[i]+1);
    }
    int ma = 0;
    for(int i = 1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i][j]!='#') ma = max(ma,bfs(i,j));
        }
    }
    printf("%d",ma);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define EPS 1e-7
#define INF 1000000000
#define mod 924844033
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,cnt[200005];
vector<int>edge[200005];
int dfs(int v,int u){
	int sum = 1;
	rep(i,edge[v].size()){
		if(edge[v][i]==u) continue;
		int sz = dfs(edge[v][i],v);
		sum += sz;
		cnt[sz]++;
		cnt[n-sz]++;
	}
	return sum;
}
ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
ll F[200005],R[200005];
void make(){
	F[0] = 1;
	for(int i=1;i<200005;i++) F[i] = F[i-1]*i%mod;
	for(int i=0;i<200005;i++) R[i] = modpow(F[i],mod-2);
}
ll C(int a,int b){
	return F[a]*R[b]%mod*R[a-b]%mod;
}
//array size -> 2*n
ll g[16];
int a[(1<<19)],b[(1<<19)],c[(1<<19)];
void mul(int *a,int *b,int *c,int n){
	if (n<=8){
		memset(g,0,sizeof(g));
		rep(i,n)rep(j,n) g[i+j]+=(ll)a[i]*b[j]%mod;
		rep(i,2*n) c[i]=g[i]%mod;
		return;
	}
	int mid = n/2;
	mul(a,b,c,mid); mul(a+mid,b+mid,c+n,mid);
	int x[mid],y[mid],z[n];
	rep(i,mid){
		x[i]=(a[i]+a[i+mid])%mod; y[i]=(b[i]+b[i+mid])%mod;
	}
	mul(x,y,z,mid);
	rep(i,n) z[i]-=c[i]+c[i+n];
	rep(i,n) c[i+mid]=((c[i+mid]+z[i])%mod+mod)%mod;
}
int main(){
	scanf("%d",&n);
	rep(i,n-1){
		int a,b; scanf("%d%d",&a,&b);
		edge[a].pb(b);
		edge[b].pb(a);
	}
	dfs(1,-1);
	make();
	for(int i=0;i<n;i++){
		a[i] = 1LL*cnt[i]*F[i]%mod;
		b[i] = R[n-1-i];
	}
	mul(a,b,c,(1<<18));
	for(int i=1;i<=n;i++){
		ll ans = C(n,i) * n % mod;
		ll cur = 1LL*c[n-1+i]*R[i]%mod;
		printf("%lld\n",(ans-cur+mod)%mod);
	}
}

Measured memory_bytes: 33792
#include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <tuple>
#include <regex>
#include <map>
#include <cstdint>
#include <set>
#include <deque>

using namespace std;
using ull = unsigned long long;
using ll = long long;

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

#define EPS (1e-7)
#define ALL(x) begin(x), end(x)

bool isMonth(const string& s) {
	const int i = stoi(s);
	return (i <= 12) && (i >= 1);
}

bool isYear(const string& s) {
	return true;
}

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

	const string s1 = S.substr(0, 2);
	const string s2 = S.substr(2, 2);

	bool m1 = isMonth(s1);
	bool m2 = isMonth(s2);

	string ans;
	if (m1 && m2) {
		// 両方あり
		ans = "AMBIGUOUS";
	} else if (m1 && !m2) {
		ans = "MMYY";
	} else if (!m1 && m2) {
		ans = "YYMM";
	} else {
		ans = "NA";
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

const size = 1000000

var reader = bufio.NewReaderSize(os.Stdin, size)

func nextLine() string {
	var line, buffer []byte
	isPrefix := true
	var err error
	for isPrefix {
		line, isPrefix, err = reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
	}
	return string(buffer)
}
func nextStringArray() []string {
	return strings.Split(nextLine(), " ")
}
func nextInt() int {
	n, _ := strconv.Atoi(nextLine())
	return n
}
func nextIntArray() []int {
	s := strings.Split(nextLine(), " ")
	n := len(s)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}

func min(i, j int) int {
	if i > j {
		return j
	}
	return i
}

func main() {
	s := nextLine()
	odds := make([]string, (len(s)+1)/2)
	for i := 0; i < len(s); i += 2 {
		odds[i/2] = string(s[i])
	}
	fmt.Println(strings.Join(odds, ""))
}


Measured memory_bytes: 2176
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE p(n); rep(i, n)cin >> p[i];
	int ans = 0;
	rep(i, n - 2) {
		VE tmp;
		tmp.push_back(p[i]); tmp.push_back(p[i + 1]);
		tmp.push_back(p[i + 2]);
		sort(ALL(tmp));
		if (tmp[1] == p[i + 1])ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int c[]=new int[n];
        int v[]=new int[n];
        
        for(int i=0;i<n;i++){
            c[i]=sc.nextInt();
        }
        
        for(int i=0;i<n;i++){
            v[i]=sc.nextInt();
        }
        int ans=0;
        for(int i=0;i<n;i++){
            ans+=(c[i]>v[i])?c[i]-v[i]:0;
        }
        System.out.println(ans);
        
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(ll)>
using namespace std;
#define All(v) (v).begin(),(v).end()
typedef long long ll;
const ll mod = 1000000007;
const ll inf = mod*mod;
const ll d5 = 114514;
const double EPS = 1e-10;
const double INF = 1e+10;
const double PI = acos(-1.0);
int main(){
    int n;
    cin>>n;
    priority_queue<double> Q;
    for(int i=0;i<n;i++){
        double k;
        cin>>k;
        Q.push(-k);
    }
    while(Q.size()!=1){
        double m = Q.top();
        Q.pop();
        double mi=Q.top();
        Q.pop();
        Q.push((m+mi)/2);
    }
    double res=Q.top();
    cout<<setprecision(5)<<-res<<endl;
}

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

#define N 55
#define M 125555
int sz[N], su[N], dp[M], n, v, d, f[N], s[N], tp[N], ct, as;
bool cmp(int i, int j) { return 1.0 * su[i] / sz[i] < 1.0 * su[j] / sz[j]; }

int solve(int s1, int r)
{
	if (s1 < 0)return -1e9;
	int as = 0;
	for (int i = 1; i <= r; i++)
	{
		int tp = s1 / su[s[i]];
		if (tp > d&& sz[s[i]] != n)tp = d;
		s1 -= tp * su[s[i]], as += tp * sz[s[i]];
		if (sz[s[i]] == n || tp < d)return as;
	}
	return as;
}
int main()
{
	scanf("%d%d%d%d", &n, &v, &d, &su[1]); sz[1] = 1;
	for (int i = 2; i <= n; i++)scanf("%d%d", &su[i], &f[i]), sz[i] = 1;
	for (int i = n; i >= 0; i--)
	{
		sz[f[i]] += sz[i];
		if (su[f[i]] + su[i] > 1e9)su[f[i]] = 1e9 + 1;
		else su[f[i]] += su[i];
	}
	for (int i = 1; i <= n; i++)if (su[i] <= 1e9)su[++ct] = su[i], sz[ct] = sz[i], s[ct] = ct;
	sort(s + 1, s + ct + 1, cmp);
	int fg = 125000;
	for (int i = 1; i <= fg; i++)dp[i] = 1e9 + 2;
	as = solve(v, ct);
	for (int i = ct; i >= 1; i--)
	{
		int mx = d;
		if (mx > 50)mx = 50;
		for (int t = 16; t; t >>= 1)
		{
			while (mx >= 2 * t || (mx && t == 1))
			{
				mx -= t;
				int st = t * sz[s[i]], st2 = 1ll * t * su[s[i]] > 1e9 ? 1e9 + 1 : t * su[s[i]];
				if (st > fg || st2 > v)continue;
				for (int j = fg - st; j >= 0; j--)if (dp[j + st] > dp[j] + st2)dp[j + st] = dp[j] + st2;
			}
		}
	}
	d -= 50;
	if (d < 0)d = 0;
	for (int i = 0; i <= fg && v >= dp[i]; i++)as = max(as, i + solve(v - dp[i], ct));
	printf("%d\n", as);
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    if(a*b%2==0){
        cout <<"Even";
    }else{
        cout << "Odd";
    }
}

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

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

int main (void) {
  int N, A, B;
  cin >> N >> A >> B;
  int ans=0;
  int a;
  for (int i=0; i<=N; i++) {
    a=cal(i);
      if ( A<=a && a<=B ){
      ans = ans+ i;
      }
  }
  cout << ans;
}

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

int main()
{   //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout); 
    int n,i=0;
    string s;
    cin>>n;
    cin>>s;
    if(s.size()>n)
    s=s.substr(0,n)+"...";
    cout<<s<<endl;
    return 0;
}

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

#define PI 4*atan(1)
#define INF 1e8

typedef long long ll;

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

int main(){
  int N;
  while(cin >> N, N){
    N = 1000 - N;
    int ans = 0;
    ans += N / 500;
    N %= 500;
    ans += N / 100;
    N %= 100;
    ans += N / 50;
    N %= 50;
    ans += N / 10;
    N %= 10;
    ans += N / 5;
    ans += N %= 5;
    cout << ans << endl;
  }
}

Measured memory_bytes: 3028
import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.function.Function;
import java.util.function.ToIntFunction;

import static java.lang.Integer.parseInt;

public class Main {

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

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = parseInt(in.readLine());

      Point[] reds  = new Point[n];
      Point[] blues = new Point[n];
      String[] lines;
      for(int i=0, x=0, y=0; i<n; i++) {
        lines = in.readLine().split(" ");
        x = parseInt(lines[0]);
        y = parseInt(lines[1]);
        reds[i] = new Point(x, y); 
      }
      for(int i=0, x=0, y=0; i<n; i++) {
        lines = in.readLine().split(" ");
        x = parseInt(lines[0]);
        y = parseInt(lines[1]);
        blues[i] = new Point(x, y); 
      }

      // Arrays.parallelSort(reds, new Comparator<Point>() {
      //   public int compare(Point a, Point b) {
      //     if(a.y == b.y) return 0;
      //     return a.y > b.y ? -1 : 1;  // 昇順
      //   }
      // });
      Arrays.parallelSort(reds, Comparator.comparingInt(p -> -p.y));

      // Arrays.parallelSort(blues, new Comparator<Point>() {
      //   public int compare(Point a, Point b) {
      //     if(a.x == b.x) return 0;
      //     return a.x > b.x ? 1 : -1;  // 降順
      //   }
      // });
      Arrays.parallelSort(blues, Comparator.comparingInt(p -> p.x));

      boolean[] isDone = new boolean[n];

      int ans = 0;
      for(int i=0; i<n; i++) {
        for(int j=0; j<n; j++) {
          if(!isDone[j] && reds[j].x < blues[i].x && reds[j].y < blues[i].y) {
            ans++;
            isDone[j] = true;
            break;
          }
        }
      }

      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 27476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll L,R;
    cin >> L >> R;
    ll ans = 2020;
    for(ll i = L;i <= min(R,L+4038);i++){
        for(ll j = i+1;j <= min(R,L+4038);j++){
            ll a = i*j % 2019;
            ans = min(a,ans);
        }
    }
    cout << ans << endl;

}

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

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    for (int i=0; i<N; i++){
        cin >> d.at(i);
    }
    const int SIZE = 101;
    vector<int> exist(SIZE, 0);
    for (int i=0; i<N; i++){
        exist.at(d.at(i)) = 1;
    }
    int count = 0;
    for (int i=0; i<SIZE; i++){
        count += exist.at(i);
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int a[5],f[5],ans,b=1;
void printf(){
	if(b==1){
	for(int i=1;i<=3;i++){
		printf("%d",a[i]);
		if(f[i]==1) printf("+");
		else printf("-");
	}
	printf("%d=7",a[4]);
	printf("\n");
	b=0;}
}
void solve(int s,int e){
	if(s==e){
		if(ans==7) printf();
	}
	else{
	for(int i=1;i<=2;i++){
		f[s]=i;
		if(f[s]==1) ans+=a[s+1];
		else ans-=a[s+1];
		solve(s+1,e);
		if(f[s]==1) ans-=a[s+1];
		else ans+=a[s+1];
	}}
}
int main(){
	for(int i=1;i<=4;i++){
		scanf("%1d",&a[i]);
	}
	ans=a[1];
	solve(1,4);
	return 0;
} 

Measured memory_bytes: 256
#![allow(clippy::needless_range_loop)]
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::*;
use proconio::input;
use proconio::marker::*;
use std::*;
use cmp::Reverse;
use collections::{BinaryHeap, HashMap};

type Remainder = (Vec<u8>, bool); // Remaining string and bool whether the string is on the left side

fn is_parindrome(bytes: &[u8]) -> bool {
    bytes.iter().eq(bytes.iter().rev())
}

fn main() {
    input! {
        sc: [(Bytes, usize)]
    }

    let mut costs = HashMap::<Remainder, usize>::new();
    let mut queue = BinaryHeap::<(Reverse<usize>, Remainder)>::new();
    for ((s, c), &on_left) in iproduct!(&sc, &[false, true]) {
        let cost = *c;
        costs
            .entry((s.clone(), on_left))
            .and_modify(|cost_prev| *cost_prev = cost.min(*cost_prev))
            .or_insert(cost);
        queue.push((Reverse(cost), (s.clone(), on_left)));
    }

    // Dijkstra on Remainder
    while let Some((Reverse(cost), (orig, on_left))) = queue.pop() {
        let reversed: Vec<_> = orig.iter().rev().copied().collect();
        sc.iter()
            .flat_map(|(dest, cost)| {
                let on_right = !on_left;
                if on_left {
                    if reversed.ends_with(&dest) {
                        return Some((&orig[dest.len()..], true, cost));
                    }
                    if dest.ends_with(&reversed) {
                        return Some((&dest[..dest.len() - orig.len()], false, cost));
                    }
                }
                if on_right {
                    if reversed.starts_with(&dest) {
                        return Some((&orig[..orig.len() - dest.len()], false, cost));
                    }
                    if dest.starts_with(&reversed) {
                        return Some((&dest[orig.len()..], true, cost));
                    }
                }
                None
            })
            .for_each(|(dest, on_left, cost_diff)| {
                let remainder = (dest.into(), on_left);
                let cost_sum = cost + cost_diff;
                if let Some(mut_v) = costs.get_mut(&remainder) {
                    if *mut_v > cost_sum {
                        *mut_v = cost_sum;
                        queue.push((Reverse(cost_sum), remainder.clone()))
                    }
                } else {
                    costs.insert(remainder.clone(), cost_sum);
                    queue.push((Reverse(cost_sum), remainder.clone()))
                }
            });
    }

    let ans = costs
        .iter()
        .filter(|&((remaining, _), _)| is_parindrome(remaining))
        .map(|(_, &cost)| cost as isize)
        .min()
        .unwrap_or(-1);

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


Measured memory_bytes: 2224
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());

		if(n >= 3200) {
			System.out.println(sc.nextLine());
		} else {
			System.out.println("red");
		}

	}
}

Measured memory_bytes: 22732
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll cur=0,h,w,n;cin>>h>>w>>n;
    vector<ll> pos(h+1,w);
    pos[h]=0;
    for(ll i=0;i<n;i++){
        ll x,y;cin>>x>>y;
        x--;y--;
        pos[x]=min(pos[x],y);
    }
    for(ll i=1;i<=h;i++){
        if(pos[i]<=cur)return cout<<i , 0;
        if(pos[i]==cur+1)continue;
        cur++;
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sll set<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
using namespace std;

int main(){
	IOS;
	int q=1,c=1;
	//cin>>q;
	while(q--){
		int n;cin>>n;
		set<string> s;
		for(int i=0;i<n;i++){
			string x;cin>>x;
			s.insert(x);
		}

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

	}
}

Measured memory_bytes: 19252
#include <iostream>
#include <math.h>
#include <set>
#include<vector>
#include<string>
#include <algorithm>
#include<queue>
#include<map>
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define per(i,j,k) for(int i = (int)j;i >= (int)k;i --)
#define F(i,k) for(int i=(int)0;i<(int)k;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
typedef long long ll;
const int maxn = 2e5 + 5;
using namespace std;
ll m,n,k;
vector<int>E[maxn];
ll mk[maxn],sc[maxn];
int vis[maxn];
void dfs(int x,ll now) {
	vis[x] = 1;
	sc[x] = mk[x] + now;
	for (auto t : E[x]) {
		if (vis[t])continue;
		dfs(t, now + mk[x]);
	}
}
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int n;
	cin >> n>>m;
	rep(i, 1, n - 1) {
		int x, y;
		cin >> x >> y;
		E[x].push_back(y); E[y].push_back(x);
	}
	rep(i, 1, m) {
		int x, y;
		cin >> x >> y;
		mk[x] += y;
	}
	dfs(1,0);
	rep(i, 1, n)cout << sc[i] << ' ';
	double ans = 0;
	cin >> n;

}

/*

*/

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

int main() {
    int n;
    scanf("%d", &n);
    map<pair<int,int>, int> cnt;
    for(int i = 0; i < n; ++i) {
        double x;
        cin >> x;
        long long xl = llround(x * 1e9);
        int two = 0, five = 0;
        while(xl % 2 == 0) {
            two++;
            xl /= 2;
        }
        while(xl % 5 == 0) {
            five++;
            xl /= 5;
        }
        ++cnt[{two,five}];
    }
    long long answer = 0;
    for(auto p1 : cnt) {
        for(auto p2 : cnt) {
            if(p1.first.first+p2.first.first >= 18 && p1.first.second+p2.first.second >= 18) {
                if(p1 < p2) {
                    answer += (long long) p1.second * p2.second;
                }
                else if(p1 == p2) {
                    answer += (long long) p1.second * (p1.second - 1) / 2;
                }
            }
        }
    }
    cout << answer << endl;
}


Measured memory_bytes: 3812
//Heaplax
#include<bits/stdc++.h>
#define int long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
int n,p,f[51][2];
main()
{
	re(n),re(p);
	f[0][0]=1;
	for(int i=1,x;i<=n;++i)
	{
		re(x);
		x&=1;
		f[i][0]=f[i-1][0]+f[i-1][x];
		f[i][1]=f[i-1][1]+f[i-1][x^1];
	}
	printf("%lld\n",f[n][p]);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N, M;
    cin >> N >> M;
    priority_queue<int> A;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        A.push(a);
    }
    for (int i = 0; i < M; i++) {
        A.push(A.top()/2);
        A.pop();
    }
    long long S = 0;
    for (int i = 0; i < N; i++) {
        S += A.top();
        A.pop();
    }
    cout << S << endl;
}

Measured memory_bytes: 892
n = int(input())
len_a = [0]*n
x = [0]*n
y = [0]*n
for i in range(n):
    len_a[i]=int(input())
    x[i]=[0]*len_a[i]
    y[i]=[0]*len_a[i]
    for j in range(len_a[i]):
        x[i][j], y[i][j] = map(int,input().split())
ans = 0
for i in range(2**n):
    honest_list = bin(i)[2:].zfill(n)
    honest_all = True
    for j in range(n):
        if honest_list[j]=='1':
            for k in range(len(x[j])):
                if str(y[j][k]) != honest_list[x[j][k]-1]:
                    honest_all = False
                    break
        if honest_all==False:
            break
    if honest_all:
        if ans < str(honest_list).count('1'):
            ans = str(honest_list).count('1')
print(ans)

Measured memory_bytes: 3064
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: u8,
        s: String,
    }

    let s = s.as_bytes().to_vec();
    let mut ans = vec![];

    for c in s {
        let c = c - b'A';
        let c = (c + n) % 26;
        let c = c + b'A';
        ans.push(c);
    }

    dbg!(&ans);
    println!("{}", std::str::from_utf8(&ans).unwrap());
}


Measured memory_bytes: 2204
/*
非負整数L、Rが与えられます。
２つの整数i,jをL<=i<j<=Rを満たすように選びます。
(i*J)mod2019の最小値を求めてください。
 */


import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc=new Scanner(System.in);
    while(sc.hasNext()){
      long L=sc.nextLong();
      long R=sc.nextLong();
      long ans=1000000000;
      if(R-L>=2019){
        System.out.println(0);
      }else{
        for(long i=L;i<R;i++){
          for(long j=i+1;j<=R;j++){
            ans=Math.min(ans,(i*j)%2019);
          }
        }
        System.out.println(ans);
      }
    }
  }
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs, x0) vector<vector<T>> xs(n, vector<T>(m, x0))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    Cins(int, 3*n, a);
    DeSort(a);
    ll ans = 0;
    For(i, n) ans += a[2*i+1];
    Cout(ans);
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define maxn 100020
#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define inf 0x3f3f3f3f
typedef long long ll;
typedef pair<int,int> pr;

ll sumA,sumB,delta;

int a[maxn],b[maxn];
int d[maxn],cnt,n,ans;

int main(){
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",&a[i]);
	rep(i,1,n){
	   	scanf("%d",&b[i]);
		sumA += a[i] , sumB += b[i];
		if ( a[i] >= b[i] ) d[++cnt] = a[i] - b[i];
		else ans++ , delta += b[i] - a[i];
	}
	if ( sumA < sumB ) return puts("-1"),0;
	sort(d + 1,d + cnt + 1);
	repd(i,cnt,1){
		if ( delta <= 0 ) break;
		delta -= d[i];
		ans++;
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 1408
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <math.h>
#include <bitset>
#include <random>
#include <regex>

using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,f,n) for(int i=f;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1};
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class A, class B> inline A updiv(const A a,const B b){ return (a + b - 1) / b; }
template <class A, class B> inline A gcd(const A a,const B b){ return b ? gcd(b,a % b) : a; }
template <class A, class B> inline A lcm(const A a,const B b){ return a / gcd(a,b) * b; }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;

signed main(void){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

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

    string s;
    cin >> s;

    if(s.size() == 1){
        return cout << 1 << '\n', 0;
    }

    int l = 0, cnt = (s.front() == '0' ? 1 : 0), res = 0;
    for(int r = 1; r < n; ++r){
        if(s[r] == '0' && s[r-1] == '1'){
            ++cnt;
        }
        while(cnt > k){
            ++l;
            if(s[l] == '1' && s[l-1] == '0'){
                --cnt;
            }
        }
        if(cnt <= k) chmax(res, r - l + 1);
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <iomanip>

using namespace std;

void B_149()
{
  int N;
  string S, T;
  cin >> N >> S >> T;

  for (int i = 0; i < N; ++i)
  {
    cout << S[i] << T[i];
  }
}

int main()
{
  //C_140();
  //C_141();
  //C_142();
  //C_143();
  //C_144();
  //C_145();
  //C_146();
  //C_147();
  //C_148();
  //C_149();
  //A_149();
  //B_149();
  //A_148();
  B_149();
  return 0;
}

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

using namespace std;

int main()
{
    string s;

    cin >> s;

    if (s == "A") {
        cout << "T" << endl;
    }
    else if (s == "T") {
        cout << "A" << endl;
    }
    else if (s == "C") {
        cout << "G" << endl;
    }
    else {
        cout << "C" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
 
int main(){
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if a <= 9 && b <= 9 {
		fmt.Println(a * b)
	} else {
		fmt.Println(-1)
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1772