akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
 
template <class T, class F>
vector<T> cumulative_sum(size_t n, F f) {
    vector<T> acc(n+1);
    repeat (i,n) {
        acc[i+1] = acc[i] + f(i);
    }
    return acc;
}
template <class T, class F>
vector<vector<T> > cumulative_sum(size_t h, size_t w, F f) {
    vector<vector<T> > acc(h+1, vector<T>(w+1));
    repeat (y,h) {
        repeat (x,w) {
            acc[y+1][x+1] = acc[y+1][x] + f(y, x);
            acc[y+1][x] += acc[y][x];
        }
        acc[y+1][w] += acc[y][w];
    }
    return acc;
}
 
int main() {
    int h, w, query; scanf("%d%d%d", &h, &w, &query);
    vector<vector<bool> > f = vectors(h, w, bool());
    repeat (y,h) {
        repeat (x,w) {
            char c; scanf(" %c", &c);
            f[y][x] = c != '0';
        }
    }
    auto g_hr = [&](int y, int x) { return x >= 1 and f[y][x-1] and f[y][x]; };
    auto g_vr = [&](int y, int x) { return y >= 1 and f[y-1][x] and f[y][x]; };
    auto g = [&](int y, int x) { return g_hr(y, x) + g_vr(y, x); };
    vector<vector<int> > acc = cumulative_sum<int>(h, w, [&](int y, int x) { return f[y][x] - g(y, x); });
    vector<vector<int> > hr(h); repeat (y,h) hr[y] = cumulative_sum<int>(w, [&](int x) { return g_vr(y, x); });
    vector<vector<int> > vr(w); repeat (x,w) vr[x] = cumulative_sum<int>(h, [&](int y) { return g_hr(y, x); });
    while (query --) {
        int ly, lx, ry, rx; scanf("%d%d%d%d", &ly, &lx, &ry, &rx); -- ly; -- lx; // [ly, ry) * [lx, rx)
        int result = 0;
        result += acc[ry][rx] - acc[ry][lx] - acc[ly][rx] + acc[ly][lx];
        result += hr[ly][rx] - hr[ly][lx];
        result += vr[lx][ry] - vr[lx][ly];
        printf("%d\n", result);
    }
    return 0;
}

Measured memory_bytes: 49536
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;
bool f(int x) {
  if(x == 7 || x == 5 || x == 3) return true; 
  else return false;
}
int main() {
  int x;
  cin >> x;
  YORN(f(x)); 
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n;
    int a[100];
    int count = 0;
    int inf = 10000000;
    
    std::cin >> n;
    
    for(int i = 0; i < n; i++){
        std::cin >> a[i];
    }
    
    for(int i = 0; i < n-1; i++){
        if(a[i] == a[i+1]){
            count++;
            a[i+1] = inf;
            //inf--;
        }
    }
    
    std::cout << count << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split()))
adj = [[] for _ in range(N)]
for _ in range(M):
	A, B = map(lambda s: int(s)-1, input().split())
	adj[A].append(B)
	adj[B].append(A)

good = 0
for i, h in enumerate(H):
	for j in adj[i]:
		if H[j] >= h:
			break
	else:
		good += 1
print(good)


Measured memory_bytes: 29364
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
    string s;
    cin >> s;

    int memo=0;
    for(int i=0;i<4;i++){
        for (int j=i+1;j<4;j++)
        {
            if(s[i] == s[j])memo++;
        }
        
    }

    if(memo == 2)cout << "Yes\n";
    else cout << "No\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define cases long long test;cin>>test;while(test--)
#define f_io ios::sync_with_stdio(false); cin.tie(0)
#define foi(a,n) for(long long i=a;i<n;i++)
#define foj(a,n) for(long long j=a;j<n;j++)
#define fok(a,n) for(long long k=a;k<n;k++)
#define ll long long
#define MOD 1000000007
#define INF 1000000000
using namespace std;

int main()
{
    f_io;
    ll n;
    cin >> n;
    vector<pair<ll,ll> > arr(n);
    vector<ll> a(n),b(n);
    foi(0,n)
    {
        cin >> arr[i].first >> arr[i].second;
        a[i] = arr[i].first + arr[i].second;
        b[i] = arr[i].first - arr[i].second;
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    ll ans = max(a[n-1]-a[0],b[n-1]-b[0]);
    cout << ans;
    return 0;
}

Measured memory_bytes: 9524
import itertools

N,M = [int(i) for i in input().split(" ")]

even = [i for i in range(10**3) if i % 2 == 0]
odd =  [i for i in range(10**3) if i % 2 != 0]
lst = even[:N]+odd[:M]
count=0
for i in itertools.combinations(lst,2):
    if sum(list(i)) % 2 == 0:
        count+=1
print(count)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>

using namespace std;

int main()
{
  int n;
  cin >> n;
  
  unordered_map<string,bool> map;
  for(int i=0;i<n;i++)
  {
    string s;
    cin >> s;
    map[s] = true;
  }
  
  cout << map.size() << endl;
  
  return 0;
}

Measured memory_bytes: 17732
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

int main(void){
  int r, D, x;
  cin >> r >> D >> x;
  for(int i = 2000; i < 2010; ++i){
    cout << r * x - D << endl;
    x = r * x - D;  
  }
  return 0;
}


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

#define A 1
#define C 2
#define G 3
#define T 4

int n;
int mem[101][5][5][5];
long MOD = 1e9+7;

long dfs(int p, int c3 ,int c2, int c1){
    if(mem[p][c3][c2][c1] != -1) return mem[p][c3][c2][c1];
    if(p == n) return 1;
    long a = 0;
    a += dfs(p+1, c2, c1, A);
    a += dfs(p+1, c2, c1, T);
    if(!(c1 == C && c2 == A))
        a += dfs(p+1, c2, c1, G);
    if(!(c1 == G && c2 == A || c1 == A && c2 == G ||
        c1 == G && c3 == A || c2 == G && c3 == A))
        a += dfs(p+1, c2, c1, C);
    a = a % MOD;
    mem[p][c3][c2][c1] = a;
    return a;
}
int main(){
    memset(mem, -1, sizeof(mem));
    cin >> n;
    cout << dfs(0, 0, 0, 0) << endl;
}

Measured memory_bytes: 256
program main;
var
    a, b, c, d, e : integer;
begin
    readln(a, b, c, d, e);
    if a <> 1
        then writeln('1');
    if b <> 2
        then writeln('2');
    if c <> 3
        then writeln('3');
    if d <> 4
        then writeln('4');    
    if e <> 5
        then writeln('5');
end.


Measured memory_bytes: 1220
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"
#include "string"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)

int main() {
	string s, t, u;
	cin >> s >> t >> u;
	cout << s[0] << t[0] << u[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define int long long
const int N = 500000;
const long long MOD = 1e9 + 7;

int n, k;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    int ans = 0;
    while (n)
    {
        ans++;
        n /= k;
    }
    cout << ans;
}


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

const int MAX_N = 1e5;
int n, m;
int a[MAX_N];

long gcd(long a, long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        a[i] /= 2;
    }
    sort(a, a + n);

    long c = a[n - 1];
    for (int i = n - 2; i >= 0; i--) {
        c = c * a[i] / gcd(c, a[i]);
        if (c > m) {
            printf("0\n");
            return 0;
        }
    }
    for (int i = 0; i < n; i++) {
        if ((c / a[i]) % 2 == 0) {
            printf("0\n");
            return 0;
        }
    }
    printf("%ld\n", (static_cast<long>(m) + c) / 2 / c);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,k,a,ans1,ans2,MOD=1e9+7,bik[200001];
vector<ll> v;
ll f(ll x,ll y){
    if(y==1)return x;
    if(y%2==0)return f(x,y/2)*f(x,y/2)%MOD;
    return f(x,y-1)*x%MOD;
}
ll comb(ll n,ll r){
    return bik[n]*f(bik[r],MOD-2)%MOD*f(bik[n-r],MOD-2)%MOD;
}
int main(void){
    bik[0]=1;
    for(ll i=0;i<200000;i++){
        bik[i+1]=bik[i]*(i+1);
        bik[i+1]%=MOD;
    }
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n-k+1;i++){
        ans1+=comb(n-i-1,k-1)*v[i];
        ans1%=MOD;
    }
    for(int i=n-1;i>=k-1;i--){
        ans2+=comb(i,k-1)*v[i];
        ans2%=MOD;
    }
    ans2-=ans1;
    ans2%=MOD;
    ans2=(ans2+MOD)%MOD;
    cout<<ans2<<endl;
}


Measured memory_bytes: 2936
#include <iostream>
#include <algorithm>
using namespace std;
long long a[1000001];
long long sum,tot=1;
int main(){
	int i,j,k,n;
	cin>>n;
	for(i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+n+1);
	for(i=2;i<=n;i++){
		if(a[i]==a[i-1])tot=(tot+1)%2;
		else{
			sum+=tot;
			tot=1;
		}
	}
	if(tot%2)sum++;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    string S;
    cin >> S;
    bool ans=true;
    if(S[2]!=S[3]) ans=false;
    if(S[4]!=S[5]) ans=false;
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 998244353;
const long long int INF = 1e18;

long long int N,K,res=INF,A[200000];



int main()
{
    cout << fixed << setprecision(18);
    cin>>N>>K;
    for(long long int i = 1; i <= N; i++){
        cin>>A[i];
        
    }
    cout<<(N-1+(K-2))/(K-1)<<endl;
}


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


int main(){
    int N, K; cin >> N >> K;
    string S; cin >> S;
    int ans = 0, r = 0, l = 0, count = 0;
    while (r < N) {
        while (count < K && r < N){
            if (S[r] == '0') {
                count++;
                while (S[r] == '0' && r < N) r++;
                while (S[r] == '1' && r < N) r++;
            }
            else {
                while (S[r] == '1' && r < N) r++;
            }
        }
        ans = max(ans, r - l);
        count--;
        while (S[l] == '1') l++;
        while (S[l] == '0') l++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <cassert>
#include <iostream>
#include <vector>
#include <stack>
#include <unordered_set>
#include <numeric>
#include <iterator>
#include <unordered_map>
#include <array>
#include <map>
#include <cstring>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctgmath>
#include <set>
#include <queue>
#include <fstream>
#include <ostream>
#include <random>
#include <chrono>
using namespace std;

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

	int a, b;
	cin >> a >> b;
	if (a <= 5)
	{
		cout << 0 << "\n";
	}
	else if (a <= 12)
	{
		cout << b / 2 << "\n";
	}
	else
	{
		cout << b << "\n";
	}
}


Measured memory_bytes: 256
n=int(input())

if n==1:
  print(0)
  
else:
  
  def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
  
  l=factorization(n)
  ans=0
  for i in l:
    m=i[1]
    j=1
    while m>=j:
      m-=j
      ans+=1
      j+=1
  print(ans)

Measured memory_bytes: 9396
#include <cstdio>
#include <vector>
using namespace std;
int N, Q, a, b, p, x, ans[200001];
vector<vector<int>> v(200001);
void dfs(int i, int par) {
  for(int k : v[i]) {
    if(k == par) continue;
    ans[k] += ans[i];
    dfs(k, i);
  }
}
int main() {
  scanf("%d %d", &N, &Q);
  for(int i = 1; i < N; i++) {
    scanf("%d %d", &a, &b);
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for(int i = 1; i <= Q; i++) {
    scanf("%d %d", &p, &x);
    ans[p] += x;
  }
  dfs(1, 0);
  for(int i = 1; i <= N; i++) {
    printf("%d ", ans[i]);
  }
}

Measured memory_bytes: 23424
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

h,w,m=MI()
bomb=set()
row=[0]*h
col=[0]*w
for _ in range(m):
    i,j=MI1()
    row[i]+=1
    col[j]+=1
    bomb.add((i,j))
rmx=max(row)
cmx=max(col)
ii=[]
for i in range(h):
    if row[i]==rmx:ii.append(i)
jj=[]
for j in range(w):
    if col[j]==cmx:jj.append(j)
ans=rmx+cmx
for i in ii:
    for j in jj:
        if (i,j) not in bomb:
            print(ans)
            exit()
print(ans-1)


Measured memory_bytes: 166004
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <queue>
#include <tuple>

using namespace std;

#define REP(i, n) for(int i=0;i<(int)n;i++)
#define REPS(i, n) for(int i=1;i<=(int)n;i++)

typedef vector<int> vi;
typedef pair<int, int> pii;

int d[10] = {0, -1, 0, 1, 0, -1, 0, 1, 0, -1};
int w, h, s1, s2, t1, t2;

char ss[100][100];
int encode(int x, int y, int d){
	return x*16*4 + y*4 + d;
}

unsigned char dp[64*16*4][64*16*4];
unsigned char dp2[64*16*4];
int main(){
	for(int t=1;cin >> w >> h, w;t++){
		REP(i, h) cin >> ss[i];
		vector<vi> g(64*16*4, vi(2, -1));
		vector<vector<vi>> invg(64*16*4, vector<vi>(2));
		REP(i, h)REP(j, w)if(ss[i][j] != '#'){
			REP(k, 4)if(ss[i+d[k]][j+d[k+1]] == '.'){
				int dx=j, dy=i;
				while(ss[dy+d[k]][dx+d[k+1]] != '#'){
					dy+=d[k]; dx+=d[k+1];
				}
				if(ss[i][j] == 'K'){
					s1 = encode(dx, dy, k);
					s2 = encode(j, i, k);
				}
				if(ss[i][j] == 'M'){
					t1 = encode(j, i, k^2);
					t2 = encode(dx, dy, k);
				}
			}
			REP(k, 4)REP(l, 2){
				int dx=j, dy=i;
				int dir = (k+1+l*2)%4;
				while(ss[dy+d[dir]][dx+d[dir+1]] != '#'){
					dy+=d[dir]; dx+=d[dir+1];
				}
				int u = encode(j, i, k);
				int v = encode(dx, dy, dir);
				invg[v][!l].push_back(u);
				g[u][l] = v;
			}
		}
		queue<pii> q;
		REPS(i, 3) q.emplace(s1, s2^i);
		int ans = 0;
		while(!q.empty()){
			int u1, u2; tie(u1, u2) = q.front(); q.pop();
			if((u1|3) == (t1|3)) ans = 1;
			if((u1|3)== (t1|3) && u2 == t2){
				ans = 2; break;
			}
			REP(l, 2){
				int v1 = g[u1][l];
				if(u2 == -1 || invg[u2][l].empty()){
					if(dp2[v1] != t){
						dp2[v1] = t;
						q.emplace(v1, -1);
					}
				}else for(int v2 : invg[u2][l]){
					if(dp[v1][v2] != t){
						dp[v1][v2] = t;
						q.emplace(v1, v2);
					}
				}
			}
		}
		if(ans == 0) puts("He cannot bring tea to his master.");
		if(ans == 1) puts("He cannot return to the kitchen.");
		if(ans == 2) puts("He can accomplish his mission.");
	}
	return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

static const ll INF = 1e15;

const ll mod = 1000000007;

bool ok(const char* c, int size) {
	for (int i = 0; i < size / 2; i++) {
		if (c[i] != c[size - 1 - i]) {
			return false;
		}
	}
	return true;
}

int main(void)
{
	double l;
	cin >> l;
	double v = l / 3;
	double s = v * v * v;
	cout << fixed << setprecision(15);
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>

using namespace std;

void solve(long long A, long long B, long long C, long long D, long long E, long long F){
    long long max_water = static_cast<double>(F)/(100+E) + max(A, B);
    long long ret_water = 0;
    long long ret_sugar = 0;
    double now_racio = 0;
    for (int a = 0; a < 30; a++) {
        for (int b = 0; b < 30; b++) {
            if (A*a + B*b > max_water) {
                break;
            }
            long long water = A*a + B*b;
            long long max_sugar = water * E;
            for (int c = 0; c <= static_cast<double>(max_sugar)/C; c++) {
                for (int d = 0; d <= static_cast<double>(max_sugar)/D; d++) {
                    long long sugar = C*c + D*d;
                    if (sugar > max_sugar) {
                        break;
                    }
                    double racio = static_cast<double>(sugar) / (water*100 + sugar);
                    if (racio >= now_racio && sugar + water*100 <= F) {
                        ret_water = water * 100;
                        ret_sugar = sugar;
                        now_racio = racio;
                    }
                }
            }
        }
    }
    std::cout << ret_water + ret_sugar << ' ' << ret_sugar << std::endl;
}

int main(){	
    struct timeval start,end;
    long long span;
    gettimeofday(&start,NULL);

    long long B;
    long long E;
    long long F;
    long long C;
    long long A;
    long long D;
    scanf("%lld",&A);
    scanf("%lld",&B);
    scanf("%lld",&C);
    scanf("%lld",&D);
    scanf("%lld",&E);
    scanf("%lld",&F);
    solve(A, B, C, D, E, F);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>//数据输入输出流
#include <cstring>//字符串操作函数
#include <cstdio>//C的输入输出
#include <cstdlib>//定义杂项函数及内存分配函数
#include <cmath>//C中的数学函数
#include <string>//c++中的string类 他不能用strcpy等c函数去操作
#include <vector>//STL vetor
#include <list>//STL list
#include <map>// STL map
#include <queue>// STL queue
#include <stack>//sTL stack
#include <bitset>//bitset可按位定义串
//比如：bitset <1000> all;定义一个1000位的串
#include <algorithm>//STL各种算法 比如 swap sort merge max min 比较
#include <numeric>//常用数字操作 一般和algorithm搭配使用
#include <functional>//STL定义运算函数（代替运算符）
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef pair<int,int> PII;
#define fi first
#define se second
#define LOCAL
#define zeros(a,n) memset(a,0,(n)*sizeof(a[0]))
const int modn = 998244353;
int mod(int x) { return x<0?x+modn:x<modn?x:x-modn; }
//inv [ i ] = (modn - modn/i)*inv[ modn%i ] %modn;
const int N = 200005;
int fact[N], rev[N];
LL qpow(int a, int b){
    LL sum = 1;
    while(b){
        if(b & 1) sum = sum * a % modn;
        b >>= 1;
        a = 1ll * a * a % modn;
    }
    return sum;
}
LL fac(int a, int b){
    return 1ll * fact[a] * rev[b] % modn * rev[a-b] % modn;
}
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    fact[0] = fact[1] = 1;
    for(int i = 2; i <= n; ++i) fact[i] = 1ll * fact[i-1] * i % modn;
    rev[0] = rev[1] = 1;
    for(int i = 2; i <= n; ++i){
        rev[i] = 1ll * rev[i-1] * qpow(i, modn-2) % modn;
    }
    LL ans = 0;
    for(int i = 0; i <= k; ++i){
        LL res = 1ll * m * qpow(m-1, n-i-1) % modn;
        res = res * fac(n - 1, n - i - 1) % modn;
        //if(i == 0) cout << res << endl;
        ans = ans + res;
        ans %= modn;
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 4728
N = int(input())
A = list(map(int,input().split()))

count = 0
flag = True

while flag:
    c = [0]*N
    for i in range(N):
        c[i] = A[i]//N
        A[i] %= N
    S = sum(c)
    flag = False
    for i in range(N):
        A[i]+=S-c[i]
        if A[i]>=N:
            flag=True
    count += S

print(count)

Measured memory_bytes: 41708
#include <iostream>
#include<bits/stdc++.h>
#define int long long int
using namespace std;

int32_t main() {
   string s;
   cin>>s;
   int l=0;
   int n=s.length();
   int m=(n-1)/2-1;
   int p=(n+3)/2-1;
   int q=n-1;
   int s1=m-l+1;
   int s2=q-p+1;
   int a=0,b=0,c=0;
   for(int i=0;i<n/2;i++)
   {
       if(s[i]!=s[n-i-1])
       {
           a=1;
           break;
       }
   }
   string t1=s.substr(l,s1);
   string t2=s.substr(p,s2);
  // cout<<t1<<" "<<t2<<endl;
   for(int i=0;i<t1.length()/2;i++)
   {
       if(t1[i]!=t1[t1.length()-i-1])
       {
           b=1;
           break;
       }
   }
   for(int i=0;i<t2.length()/2;i++)
   {
       if(t2[i]!=t2[t2.length()-i-1])
       {
           c=1;
           break;
       }
   }
   if(a||b||c)
   cout<<"No"<<endl;
   else cout<<"Yes"<<endl;
    
}

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

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

	int front = 0;
	int back = 0;
	int maximum = 0;
	int cnt = 0;

	// 長さが1の場合
	if(N == 1){
		if(K>0){
			cout << 1 << endl;
			return 0;
		}
		cout << S << endl;
		return 0;
	}
	
	if(S[0] == '0') cnt++;
	for(int i = 1; i < N; i++)
	{
		if(S[i-1] == '1' && S[i] == '0') cnt++;
		back = i;
		if(cnt > K) break;
	}

	// 全部逆立ちできる場合
	if (cnt <= K) {
		cout << N << endl;
		return 0;
	}
	
	
	maximum = back - front;
	while(back < N)
	{
		for(front++; S[front-1] != '0' || S[front] != '1' ; front++);
		for(back++; back < N && (S[back-1] != '1' || S[back] != '0') ; back++);
		maximum = max(maximum, back - front);
	}

	cout << maximum << endl;
	return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N; cin >> N;
	int s = 0;
	repp(i,0,N){
		int a; cin >> a;
		s += a-1;
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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;
}

int di[4] = {0, 1, 0, -1};
int dj[4] = {1, 0, -1, 0};

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> A(H, vector<char>(W));
  rep(i, H) {
    rep(j, W) {
      cin >> A[i][j];
    }
  }

  vector<vector<int>> dist(H, vector<int>(W, INF));

  typedef pair<int, int> P;
  queue<P> q;
  rep(i, H) {
    rep(j, W) {
      if (A[i][j] == '#') {
        q.push(P(i, j));
        dist[i][j] = 0;
      }
    }
  }

  while (!q.empty()) {
    P now = q.front();
    q.pop();

    rep(d, 4) {
      int i = now.fi;
      int j = now.se;
      int ni = i + di[d];
      int nj = j + dj[d];
      if (ni < 0 || ni >= H || nj < 0 || nj >= W || dist[ni][nj] != INF)
        continue;

      dist[ni][nj] = dist[i][j] + 1;
      q.push(P(ni, nj));
    }
  }

  int ans = 0;
  rep(i, H) {
    rep(j, W) {
      chmax(ans, dist[i][j]);
    }
  }
  cout << ans << endl;
}


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

int main() {
	int n;
	cin >> n;
	n%=10;
	if(n==3){
		cout << "bon";
	}else if(n==0 || n==1 || n==6 || n==8){
		cout << "pon";
	}else{
		cout << "hon";
	}
	cout << endl;
	return 0;
}

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

int main(){
  int h, w;
  cin >> h >> w;
  string ans = "";
  rep(i,h) {
    rep(j,w) {
      string s;
      cin >> s;
      if(s == "snuke") {
        ans += 'A' + j; 
        if(i >= 9) ans += '1';
        ans += '0' + ((i+1) % 10);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int x = tx -sx;
    int y = ty -sy;
    cout << 'D';
    rep(i, x+1) cout << 'R';
    rep(i, y+1) cout << 'U';
    cout << 'L' << 'U';
    rep(i, x+1) cout << 'L';
    rep(i, y+1) cout << 'D';
    rep(i, x+1) cout << 'R';
    rep(i, y) cout << 'U';
    rep(i, x) cout << 'L';
    rep(i, y) cout << 'D';
    cout << endl;
    return 0;
}

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

typedef pair<int,int> P;

int n, ans[200005];
P X[200005];

signed main(){
  
  cin>>n;
  
  for(int i=0;i<n;i++){
    cin>>X[i].first;
    X[i].second = i;
  }
  
  sort(X, X+n);
  
  int l = n/2-1, r = n/2;  

  if( X[l].first == X[r].first ){
    
    for(int i=0;i<n;i++) cout<<X[l].first<<endl;
    
  }
  else{
    
    for(int i=0;i<n;i++){
      if( X[i].first <= X[l].first ) ans[X[i].second] = X[r].first;
      else ans[X[i].second] = X[l].first;
    }
    
    for(int i=0;i<n;i++){
      cout<<ans[i]<<endl;
    }
    
  }
  
  return 0;
}


Measured memory_bytes: 6912
i = []

gets.to_i.times do
  a, b = gets.split
  case a
  when 'insert' then i.unshift(b)
  when 'delete'
    c = i.index(b)
    i.delete_at(c) unless c.nil?
  when 'deleteFirst' then i.shift
  when 'deleteLast' then i.pop
  end
end

puts i.join(' ')

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

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define F(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define endl '\n'

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }





void solve() {
	int K;
	cin >> K;
	ll ans = 0;
	F(i, 1, K)
		F(j, 1, K)
			F(k, 1, K)
				ans += __gcd(__gcd(i, j), k);
	cout << ans << endl;
}





int main() {
	ios::sync_with_stdio(false);
	cout << fixed;

#ifdef LOCAL
	double cl = clock();
#endif

	int T = 1;
	while (T--) solve();

#ifdef LOCAL
  cerr << "Time elapsed: " << (clock() - cl) / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}




Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next())	;
		String S = sc.next();
		int x = 0;
		int ans = 0;
		for(int i = 0; i<N; i++){
			if(S.charAt(i)=='D'){
				x--;
			}
			else{
				x++;
				ans = x > ans ? x : ans;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}

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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)


#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////

int main()
{
    FASTIO;

    ll n , k;

    cin >> k >> n;


    if((k*500)>=n)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }





    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll a, b, c;
  std::cin >> a;
  scanf("%lld.%lld", &b, &c);
  ll ans = a*b*100+a*c;
  std::cout << ans/100 << '\n';
  return 0;
}


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

int main(){
  int r, g, b;
  cin >> r >> g >> b;
  int num = 100 * r + 10 * g + b;
  if(num % 4 == 0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n; cin >> n;
	string s1, s2; cin >> s1 >> s2;
	rep(i, n) {
		cout << s1[i] << s2[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
N = 55555
NN = N*5
furui = (0..NN).map {|n| n }
furui[0] = furui[1] = nil
for i in 2..NN
  if furui[i]
    j = i*2
    while j<=NN
      furui[j] = nil
      j+=i
    end
  end
end

primes = furui[0, N+1].compact
primes_end3 = primes.select {|x| x%10==3 }

n = gets.to_i
ps = primes_end3.shuffle[0, n]
puts ps.join ' '


Measured memory_bytes: 4604
fn main() {
    let mut buf = String::new();
    let _ = std::io::stdin().read_line(&mut buf);
    let (b, a) = buf.trim().split_at(2);
    let b = b.parse::<u32>().unwrap();
    let a = a.parse::<u32>().unwrap();
    let b = b < 1 || 12 < b;
    let a = a < 1 || 12 < a;
    if b && a {
        println!("NA");
    } else if !b && a {
        println!("MMYY");
    } else if b && !a {
        println!("YYMM");
    } else {
        println!("AMBIGUOUS");
    }
}


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

def solve():
    x = int(input())

    """
    x点以上になる最小操作回数。初期状態は自由。
    6と5を交互に繰り返すだけで良くない？

    計算量はO(1)
    """

    # 6と5を何回繰り返せばよいか？
    ans = (x//11) * 2
    restX = x%11

    # 上面を6にする
    if restX > 0:
        restX -= 6
        ans += 1

    # 上面を5にする
    if restX > 0:
        ans += 1
    
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<iomanip>
#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP(i,n,0)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 100000000
using namespace std;

int main(){
	int N;
	cin >> N;
	int d[N];

	int i;
	rep(i,N)
		cin >> d[i];
	int count = 0;

	int len = sizeof(d)/sizeof(d[0]);
	sort(d, d+len);
	int *end = unique(d, d+len);
	for(int *p = &d[0]; p != end; p++)
		count++;

	cout << count << endl;

	return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> S(M), C(M);
    for(int i = 0; i < M; i++) cin >> S[i] >> C[i];
    for(int num = 0; num <= 1000; num++){
        string s = to_string(num);
        if(s.size() != N) continue;
        bool ok = true;
        for(int i = 0; i < M; i++){
            if(s[S[i] - 1] != '0' + C[i]) ok = false;
        }
        if(ok){
            cout << s << endl;
            return 0;
        }
    }
    puts("-1");
}


Measured memory_bytes: 3692
#include <iostream>
using ll = long long;
using namespace std;

/* initialize */
auto p = [](int i) -> int {return i/2;};
auto l = [](int i) -> int{return 2 *i;};
auto r = [](int i) -> int{return 2*i+1;};
int H, A[500001];
void maxheapify(int i){
    int largest,temp;
    int le=l(i), ri=r(i);
    if (le <= H && A[le] > A[i]) largest = le;
    else largest = i;
    if (ri <= H && A[ri] > A[largest]) largest = ri;
    if (largest!=i){
        temp = A[i];
        A[i] = A[largest];
        A[largest] = temp;
        maxheapify(largest);
    }
}
/* main */
int main() {
    cin >> H;
    for (int i = 0; i < H; ++i) cin >> A[i+1];
    for (int i = H/2; i >= 1; --i) maxheapify(i);
    for (int i = 0; i < H; ++i) printf(" %d", A[i+1]);
    cout << "\n";
    return 0;
}


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

using namespace std;

const int N = 1e5 + 7;

int n;
int m;
int d[N];
int used[N];
vector<int> g[N];
int main()
{
    cin >> n >> m;
    for(int i = 1; i <= m; i ++){
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    queue<int> q;
    q.push(1);
    memset(d, 63, sizeof d);
    d[1] = 0;
    while(!q.empty()){
        int v = q.front(); q.pop();
        for(auto to: g[v]){
            if(d[to] > d[v] + 1){
                d[to] = d[v] + 1;
                q.push(to);
            }
        }
    }
    cout << "Yes\n";
    for(int i = 2; i <= n; i ++){
        int idx = -1;
        int mn = INT_MAX;
        for(auto x: g[i]){
            if(mn > d[x]){
                mn = d[x];
                idx = x;
            }
        }
        assert(idx > 0);
        cerr << i << " -> ";
        cout << idx << "\n";
    }
}


Measured memory_bytes: 10460
from collections import Counter
 
N = int(input())
D = Counter(list(map(int, input().split())))
M = int(input())
T = Counter(list(map(int, input().split())))
 
ans = 'YES'
for key, value in T.items():
    if value > D[key]:
        ans = 'NO'
        break
    else:
        pass
print(ans)

Measured memory_bytes: 55588
#include <bits/stdc++.h>
#define SZ(v) ((int)((v).size()))
using namespace std;
using ll = long long;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int nbVal, nbQuery;
	cin >> nbVal >> nbQuery;
	vector<ll> queries {nbVal};
	for (int iQuery = 0; iQuery < nbQuery; ++iQuery) {
		ll x; cin >> x;
		while (!queries.empty() && queries.back() >= x) {
			queries.pop_back();
		}
		queries.push_back(x);
	}

	map<ll, ll> tok;
	tok[queries.back()-1]++;

	for (int iQuery = SZ(queries)-1; iQuery > 0; --iQuery) {
		ll before = queries[iQuery-1];
		ll deb = before;
		while (!tok.empty()) {
			auto it = tok.end();
			--it;
			auto [posTok, nbOcc] = *it;
			if (posTok < deb) break;
			ll nbCompl = (posTok-deb)/before;
			tok[deb-1] += nbOcc*(nbCompl+1);
			tok[(posTok-deb)%before] += nbOcc;
			tok.erase(it);
		}	
	}

	for (ll i = queries.front()-1; i >= 1; --i) {
		tok[i-1] += tok[i];
	}
	for (int iVal = 0; iVal < nbVal; ++iVal) {
		cout << tok[iVal] << "\n";
	}
}


Measured memory_bytes: 10340
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let N = readInt()!
var ans = 0
if N < 2 {
    ans = 1
} else if N < 4 {
    ans = 2
} else if N < 8 {
    ans = 4
} else if N < 16 {
    ans = 8
} else if N < 32 {
    ans = 16
} else if N < 64 {
    ans = 32
} else {
    ans = 64
}
print(ans)


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define int long long 
#define ar array
#define f first
#define s  second
#define REP(i,n) for (int i=0;i<(n);i++)
#define wt(x) int x;cin>>x;while(x--)
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
template <typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename T>
using o_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>; 

void  c_p_c(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input1.txt","r",stdin);

  freopen("output1.txt","w",stdout);
#endif
}
const int mod=1000000007;
int power(int a,int b,int mod){
  a=a%mod;
  if(a==0){
    return 1;
  }
  int res=1;
  while(b){
    if(b&1){
      res=(res*a)%mod;
    }
    b>>=1;
    a=(a*a)%mod;
  }
  return res;
}

int  MMI(int p){
  return power(p,mod-2,mod);
}
int32_t main()
{
 c_p_c();
 int n,x,t;
 cin>>n>>x>>t;
 int ans=(n+x-1)/x;
 cout<<t*ans<<"\n";
 
 return 0;  
 
 
}

Measured memory_bytes: 3608
#include <stdio.h>

void merge_sort(long long x[], int n)
{
	static long long y[51] = {};
	if (n <= 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p] < x[q])? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{
	int i, N;
	long long a[51];
	scanf("%d", &N);
	for (i = 0; i < N; i++) scanf("%lld", &(a[i]));
	merge_sort(a, N);
	
	int j, flag = 0;
	long long count = 0, tmp;
	while (1) {
		flag = 0;
		for (i = N - 1; i >= 0; i--) {
			if (a[i] >= N) {
				flag = 1;
				tmp = a[i] / N;
				a[i] %= N;
				count += tmp;
				for (j = 0; j <= N - 1; j++) {
					if (j == i) continue;
					a[j] += tmp;
				}
			}
		}
		if (flag == 0) break;
	}
	
	printf("%lld\n", count);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1736
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
typedef long long int ll;
void swap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
ll asc(const void *a,const void *b){return *(ll*)a-*(ll*)b;}
ll desc(const void *a,const void *b){return *(ll*)b-*(ll*)a;}
ll max(ll x,ll y){return x>y?x:y;}
ll min(ll x,ll y){return x>y?y:x;}

int main(){
    int k,s;
    int x,y,z;
    int cnt=0;
    x=y=z=0;

    scanf("%d %d",&k,&s);

    for(x=0;x<=k;x++){
        for(y=0;y<=k;y++){
            if(0<=s-(x+y)&&s-(x+y)<=k)cnt++;
        }
    }

    printf("%d\n",cnt);
    return 0;
}

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

using namespace std;

int main()
{
  int n, ans = 2;

  scanf("%d", &n);

  while (true)
  {
    ans *= 2;
    if (n == 1)
    {
      ans = 1;
      break;
    }

    if (ans > n)
    {
      ans /= 2;
      break;
    }
  }

  printf("%d", ans);
}

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() {
  int a;
  string s;
  cin >> a >> s;
  if (a >= 3200) cout << s << endl;
  else cout << "red" << endl;
  return 0;
}


Measured memory_bytes: 3604
import heapq

N, M = list(map(int,input().split()))
A = list(map(int,input().split()))
B = [list(map(int,input().split())) for i in range(M)]
B = sorted(B, key = lambda x: x[1])[::-1]

heapq.heapify(A)
cnt = 0
for i in range(M):
    for _ in range(B[i][0]):  heapq.heappush(A, max(heapq.heappop(A), B[i][1]))
    cnt += B[i][0]
    if cnt >= N:  break
print(sum(A))

Measured memory_bytes: 102968
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 main() {
    input!{
        a: i32,
        b: i32,
        c: i32,
        d: i32,
    }
    let mut a = a;
    let mut c = c;
    loop {
        c -= b;
        a -= d;
        if c <= 0 {
            println!("Yes");
            break;
        }
        else if a <= 0 {
            println!("No");
            break;
        }
    }
}


Measured memory_bytes: 2060
#include <cstdio>
#include <iostream>
#include <cmath>
using namespace std;
int n,L;

int main(){
	scanf("%d%d",&n,&L);
	int sum=0,x=1e9;
	for(int i=1;i<=n;i++){
		sum+=L+i-1;
		if(abs(L+i-1)<abs(x))x=L+i-1;
	}
	printf("%d\n",sum-x);
	return 0;
}

Measured memory_bytes: 256