akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int tmp = in.nextInt() * 100 + in.nextInt() * 10 + in.nextInt();
            out.println(tmp % 4 == 0 ? "YES" : "NO");
        }

    }
}



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

int main() {
    int n; long long k; cin >> n >> k;
    vector<int> v(n), before(n, -1);
    map<int, int> m;
    for (int i = 0; i < n; i++) cin >> v[i];
    // calc before
    for (int i = 0; i <= n; i++) {
        if (before[i] != -1) continue;
        if (m.find(v[i]) != m.end()) {
            before[i] = m[v[i]];
        } 
        m[v[i]] = i;
    }
    for (int i = 0; i <= n; i++) {
        if (before[i] != -1) continue;
        if (m.find(v[i]) != m.end()) {
            before[i] = m[v[i]];
        } 
        m[v[i]] = i;
    }
    long long count_loop = 0;
    int index = n-1;
    while (true) {
        int next_index = before[index];
        if (index <= next_index) count_loop++;
        index = (n + next_index-1) % n;
        if (index == n-1) {
            count_loop++;
            break;
        }
    }
    long long remain = (count_loop - 1) - (k % count_loop - 1);
    remain %= count_loop;
    index = n-1;
    while (remain) {
        int next_index = before[index];
        if (index <= next_index) remain--;
        index = (n + next_index-1) % n;
    }
    vector<int> ans(n+1, -1); map<int, int> mm;
    int ans_index = 1;
    if (index == n-1) index = -1;
    while (true) {
        index++;
        if (index == n) break;
        int c = v[index];
        if (mm[c] == 0) {
            ans[ans_index] = c;
            mm[c] = ans_index;
            ans_index++;
        } else {
            int t = mm[c];
            for (int i = t; i < ans_index; i++) {
                mm[ans[i]] = 0;
                ans[i] = -1;
            }
            ans_index = t;
        }
    }
    for (int i = 1; i < ans_index; i++) {
        if (i == ans_index) break;
        if (i != 1) cout << " ";
        cout << ans[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 22656
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n'; cout << fixed << setprecision(10);

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> b(n, 0);
	rep(i, n - 1) {
		int a;
		cin >> a;
		a--;
		b[a]++;
	}
	rep(i, n)cout << b[i] << endl;
}

Measured memory_bytes: 3996
def bubble_sort(A, N):
    exchange_cnt = 0
    flg = True
   
    while flg:
        flg = False
        for i in range(1, N)[::-1]:
            if A[i - 1] > A[i]:
                A[i], A[i - 1] = A[i - 1], A[i]
                flg = True
                exchange_cnt += 1
    print(" ".join([str(a) for a in A]))
    print(exchange_cnt)

N = int(input().rstrip())
A = [int(num) for num in input().rstrip().split(" ")]
bubble_sort(A, N)


Measured memory_bytes: 5608
#include <stdio.h>
int main(void)
{
    int a, b, i;
    char op;
    for (i = 1; i > 0; i++)
    {
        scanf("%d %c %d", &a, &op, &b);
        if ( op == '+')
        {
            printf("%d\n", a + b);
        }
        else if ( op == '-')
        {
            printf("%d\n", a - b);
        }
        else if ( op == '*')
        {
            printf("%d\n", a * b);
        }
        else if ( op == '/')
        {
            printf("%d\n", a / b);
        }
        else if( op == '?')
        {
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
using ll = long long;
using namespace std;
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 main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    vector<int> A(N);
    for (auto &i : A) {
        cin >> i;
    }

    auto calc = [&](int x) {
        ll ret = 0, sum = 0;
        REP(i, N) {
            sum += A[i];
            if (sum * x <= 0) {
                ret += abs(sum) + 1;
                sum = x;
            }
            x *= -1;
        }
        return ret;
    };

    std::cout << min(calc(1), calc(-1)) << '\n';

    return 0;
}

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

const long long MOD = 2;


// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    // Failed to predict input format
    int N, M;
    cin >> N >> M;
    // conn[i][j]==1のとき電球iはスイッチjにつながる
    vector<vector<int>> conn(M, vector<int>(N, 0)); 
    for(int i=0; i < M; i++){
        int k;
        cin >> k;
        for(int j=0; j < k; j++){
            int s;
            cin >> s;
            conn[i][s-1] = 1;
        }
    }
    vector<int> p(M, 0);
    for(int i=0; i < M; i++){
        int temp;
        cin >> temp;
        p[i] = temp;
    }

    // solve
    int cnt = 0;
    for(int i=0; i < (1 << N); i++){
        // (i>>j)&1でj番スイッチの状態
        bool all_bulbs_ok = true;
        for(int b=0; b < M; b++){
            // b番電球はついてる？
            int sw_total = 0;
            for(int j=0; j < N; j++){
                int sw_j = (i>>j)&1;
                int sw_conn = conn[b][j];
                sw_total += sw_j*sw_conn;
                sw_total %= 2;
            }
            if(sw_total != p[b]){
                all_bulbs_ok = false;
                break;
            }

            // 電球はつてｔる
        }

        if(all_bulbs_ok){
            cnt++;
        }
        

    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int s;
  scanf("%d",&s);
  int t = s % 100;
  int u = (s - t)/100;
  if(t>=1&&t<=12){
    if(u>=1&&u<=12){
      printf("AMBIGUOUS");
    }
    else{
      printf("YYMM");
    }
  }
  else{
    if(u>=1&&u<=12){
      printf("MMYY");
    }
    else{
      printf("NA");
    }
  }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if(a==0){
        cout << 1 << endl;
        return 0;
    }
    if(b==0){
        cout << 2 << endl;
        return 0;
    }
    if(c==0){
        cout << 3 << endl;
        return 0;
    }
    if(d==0){
        cout << 4 << endl;
        return 0;
    }
    if(e==0){
        cout << 5 << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 3636
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 200000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	ll cost;
	edge(int _t, ll _cost) : t(_t)
		, cost(_cost) {
	}
};
bool isPrime(int n) {

	if (n == 1) return false;
	for (ll i = 2; i * i <= n; i++)
	{
		if (n % i == 0) return false;
	}
	return true;
}
int anyDigitSum(int n) {
	int res = 0;
	while (n > 0)
	{
		res += n % 10;
		n /= 10;
	}
	return res;
}

void Solve() {

	string s;
	cin >> s;
	if (s.size() < 4) {
		cout << "No" << endl;
		return;
	}
	string yaki = "YAKI";
	for (size_t i = 0; i < 4; i++)
	{
		if (s[i] != yaki[i]) {
			cout << "No" << endl;
			return;
		}
	}
	cout << "Yes" << endl;
}
int main() {
	Solve();
	return 0;
}



Measured memory_bytes: 256
N, M=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき

AB=[[int(i) for i in input().split()] for j in range(N)]  # 二次元配列入力　二次元マップみたいな入力のとき

AB.sort(key=lambda x: x[0])

money = 0
ct = M
for i in AB:
    money += min(ct, i[1]) * i[0]
    ct = ct - min(ct, i[1])
    if ct == 0:
        break
print(money)


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

main() {
  int N; cin >> N;
  vector<int> A(N); for (int i = 0; i < N; i++) cin >> A[i];
  vector<int> B(N); for (int i = 0; i < N; i++) cin >> B[i];
  vector<int> C(N); for (int i = 0; i < N; i++) cin >> C[i];

  sort(begin(A), end(A));
  sort(begin(C), end(C));
  ll ans = 0;
  for (int b : B) {
    ll lb = lower_bound(begin(A), end(A), b) - begin(A);
    ll ub = upper_bound(begin(C), end(C), b) - begin(C);
    ans += lb * (N - ub);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1408
s = input()
k = int(input())

ss = s + s

if len(set(s))==1:
    print(int((len(s)*k)/2))
else:
    a=0
    prev = "?"
    for v in s:
        if v==prev:
            a += 1
            prev = "?"
        else:
            prev = v

    b=0
    prev = "?"
    for v in ss:
        if v==prev:
            b += 1
            prev = "?"
        else:
            prev = v

    print(a+(b-a)*(k-1))

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

int main()
{
    string s;
    cin>>s;
    long long int len=s.size();
    long long int d,i,j,k,l;
    cin>>d;

    vector<vector<long long int> > dp(d,vector<long long int> (2,0));
    dp[0][1]=1;

    for(i=0;i<len;i++)
    {
        vector<vector<long long int> > temp_dp(d,vector<long long int> (2,0));
        for(j=0;j<d;j++)
        {
            for(k=0;k<2;k++)
            {
                for(l=0;l<10;l++)
                {
                    if(k==1&&l>s[i]-'0')
                        break;
                    temp_dp[(j+l)%d][k&&!(l<s[i]-'0')]=(temp_dp[(j+l)%d][k&&!(l<s[i]-'0')]+dp[j][k])%mod;
                }
            }
        }
        dp=temp_dp;
    }

    cout<<(dp[0][0]+dp[0][1]-1+mod)%mod;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    vector<int> X(m);
    for(int i = 0; i < m; i++)
    {
        cin >> X[i];
    }
    if (m<=1) {
        cout << 0 << endl;
    }
    else {
        vector<int> Y(m-1);
        sort(X.begin(),X.end());
        for(int i = 0; i < m-1; i++)
        {
            Y[i] = X[i+1] - X[i];
        }
        sort(Y.begin(),Y.end());
        ll sum=0;
        for(int i = 0; i < m-n; i++)
        {
            sum += Y[i];
        }
        cout << sum << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>
#include <fstream>

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
//constexpr long long mod = 1000000007LL;
constexpr long long mod = 998244353;
constexpr int MAX = 5000000;


struct mint {
	long long x;
	mint(long long x = 0) :x((x% mod + mod) % mod) {}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};
int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n, k; cin >> n >> k;
	vector<pair<int, int>> vp(k);
	for (int i = 0; i < k; i++) {
		cin >> vp[i].first >> vp[i].second;
	}
	vector<mint> dp(n + 1);
	vector<mint> imos(n + 1);
	dp[0] = 1;
	for (int i = 0; i < n; i++) {
		if (i) imos[i] += imos[i - 1];
		dp[i] += imos[i];
		for (int j = 0; j < k; j++) {
			int l = i + vp[j].first;
			int r = i + vp[j].second + 1;
			if(l < n) imos[l] += dp[i];
			if (r < n) imos[r] -= dp[i];
		}
		//cout << dp[i].x << "\n";
	}
	cout << dp[n - 1].x << "\n";
	return 0;
}


Measured memory_bytes: 6364
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    ll N, M;

    cin >> N >> M;

    vector<int> A(M), B(M), ans(M-1, 0);
    vector<vector<int> > C(N);

    rep(i,M) {
        cin >> A[i] >> B[i];
        C[A[i]-1].push_back(B[i]-1);
        C[B[i]-1].push_back(A[i]-1);
    }

    vector<int> dist(N, -1);
    queue<int> que;

    dist[0] = 0;
    que.push(0);

    while(!que.empty()) {
        int v = que.front();
        que.pop();

        for(int nv:C[v]) {
            if(dist[nv] != -1) continue;
            dist[nv] = v+1;
            que.push(nv);
        }
    }
    vector<int> abc;
    abc = dist;
    sort(abc.begin(), abc.end());
    if(abc[0]==-1) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
        for(int v=1; v<N; v++) {
            cout << dist[v] << endl;
        }
    }

    return 0;
    
}

Measured memory_bytes: 12836
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.Int();
            int M = in.Int();
            int Q = in.Int();
            int[][] map = new int[N + 1][N + 1];
            for (int i = 0; i < M; i++) {
                int L = in.Int();
                int R = in.Int();
                map[L][R]++;
            }
            for (int i = 1; i <= N; i++) {
                for (int j = 0; j < N; j++) {
                    map[i][j + 1] += map[i][j];
                }
            }
            for (int i = 0; i < Q; i++) {
                int p = in.Int();
                int q = in.Int();
                int ans = 0;
                for (int j = p; j <= q; j++) {
                    ans += map[j][q] - map[j][p - 1];
                }
                out.println(ans);
            }
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

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

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

    }
}



Measured memory_bytes: 65024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cstdlib>
#include <typeinfo>

using namespace std;

#define FOR(i,n) for(i=0;i<n;++i)

int i,j;

int main(void){
    
    string r,g,b;
    cin >> r >> g>> b;
    string ans = r+g+b;
    auto a = atoi(ans.c_str());
    if(a%4==0)cout<<"YES";
    else cout<<"NO";
    
    
    
    
    return 0;
    
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int a,b;
    scanf("%d%d",&a,&b);

    if(a==b){
        printf("Draw\n");
    }else if(a==1&&b==13){
        printf("Alice\n");
    }else if(a==13&&b==1){
        printf("Bob\n");
    }else if(a>b){
        printf("Alice\n");
    }else{
        printf("Bob\n");
    }
    return 0;
}

Measured memory_bytes: 1664
#include "bits/stdc++.h"
using namespace std;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define nl '\n'
#define precision(n) setprecision(n)
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;

int main() { _
    map<char, int> m;
    string s; cin >> s;
    for (char c : s) {
        m[c]++;
        if (m[c] > 1) {
            cout << "No" << nl;
            return 0;
        }
    }
    cout << "Yes" << nl;
    return 0;
}


Measured memory_bytes: 764
def main() :
    W, H, x, y, r = [int(i) for i in input().split()]

    if ((x-r)>=0) and ((x+r)<=W) and ((y-r)>=0) and ((y+r)<=H) :
        print("Yes")
    else :
        print("No")

if __name__ == '__main__' :
    main()

Measured memory_bytes: 7784
/************************************************
   Start coding only after you have clear idea. 
*************************************************/

#include <bits/stdc++.h>

#define x first
#define y second
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
const int maxm = 2e3+23;
const int maxn = 2e5+35;
int n,D,x,y,ans;
int main(){
    cin >> n >> D;
    while(n--){
        cin >> x >> y;
        if(1ll*x*x+1ll*y*y <= 1ll*D*D) ans += 1;
    }
    cout << ans << '\n';
    return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    multiset<int> ms;
    while (n--) {
        int d; cin >> d;
        ms.insert(d);
    }
    int m; cin >> m;
    while (m--) {
        int t; cin >> t;
        if (!ms.count(t)) return cout << "NO" << endl, 0;
        ms.erase(ms.find(t));
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 9600
function f()
    S = readline()
    K = parse.(Int, readline())
    out = S[1]
    for s in S
        if (K == 1)
            out = s
            break
        end
        if (s == '1') 
            K -= 1
        else
            out = s
            break
        end
    end
    println(out)
end
f()

Measured memory_bytes: 161040
#include "bits/stdc++.h"
using namespace std;
typedef unsigned long long ll;

int main(){
  int n,m,s,c;
  char ans[3]={'-','-','-'};
  bool ng=false;
  cin>>n>>m;
  for(int i=0;i<m;++i){
    cin>>s>>c;
    if(ans[s-1]!='-' && ans[s-1]!=char(c+48)){
      ng=true;
      continue;
    }
    else
      ans[s-1]=char(c+48);
  }
  if(ng){
    cout<<-1;
  }
  else if(ans[0]=='0'&&n!=1){
    cout<<-1;
  }
  else{
    for(int i=0;i<n;++i){
      if(ans[i]=='-'){
        if(i==0&&n!=1){
          ans[i]='1';
        }
        else{
          ans[i]='0';
        }
      }
      cout<<ans[i];
    }
  }
}

/*
1 0
2 1
3 2
1 49
*/


Measured memory_bytes: 256
def main():
	N = int(input())
	binary_list = [1,2,4,8,16,32,64]
	diff_n2binary = []
	for binary in binary_list:
		if binary <= N:
			diff_n2binary.append(abs(N - binary))
	print(binary_list[ diff_n2binary.index( min( diff_n2binary ) ) ] )

if __name__ == "__main__":
	main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

void solve()
{
    int n;cin>>n;
    cout<<n*n<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}



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

using namespace std;

int main(){
	int m[10];
	
	for(int i=0; i<10; ++i)
		scanf(" %d", &m[i]);
	
	sort(m, m+10, greater<int>());
	
	for(int i=0; i<3; ++i)
		printf("%d\n", m[i]);
		
	return 0;
}

Measured memory_bytes: 1204
<?php
 // 入力を受け取る
 list($N,$D) = sscanf(trim(fgets(STDIN)), "%d %d");
 $c = 0;
 for($i = 0; $i < $N; $i++){
     list($X, $Y) = sscanf(trim(fgets(STDIN)), "%d %d");
     if(sqrt($X**2+$Y**2) <= $D){
         $c++;
     }
 }
 echo($c);
?>

Measured memory_bytes: 16240
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
ll a[100010];
int main(){
    cin>>N;
    for(ll i=0;i<N;i++){
        cin>>a[i];
    }
    sort(a,a+N);
    ll minDiff=INF;
    ll minNum=0;
    for(ll i=0;i<N-1;i++){
        if(abs(a[i]-(a[N-1]+1)/2)<minDiff){
            minDiff=abs(a[i]-(a[N-1]+1)/2);
            minNum=i;
        }
    }
    cout<<a[N-1]<<" "<<a[minNum]<<endl;
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  rep(i, s.size()){
    if(s[i] == '1' ) s[i] = '9';
    else s[i] = '1';
  }
  cout << s << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

int main() {

    int N, M;
    cin >> N;
    vector<string> s(N);
    REP(i, N) cin >> s[i];
    cin >> M;
    vector<string> t(M);
    REP(i, M) cin >> t[i];

    int ans = 0;
    int score = 0;
    string tmp;
    REP(i, N){
        score = 0;
        tmp = s[i];
        REP(j, N) if (tmp == s[j]) score++;
        REP(j, M) if (tmp == t[j]) score--;
        ans = max(ans, score);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
A_start, A_stop, B_start, B_stop = map(int, input().split())
if A_start <= B_start:
    if A_stop <= B_start:
        time = 0
    elif (A_stop > B_start) & (A_stop <= B_stop):
        time = A_stop - B_start
    else:
        time = B_stop - B_start
else:
    if B_stop <= A_start:
        time = 0
    elif (B_stop > A_start) & (B_stop <= A_stop):
        time = B_stop - A_start
    else:
        time = A_stop - A_start
print(time)

Measured memory_bytes: 3064
#include <iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int mod=1e9+7;
const int N=2e5+100;
ll a[N];
int f[5];
bool cmp(int x,int y)
{
    return abs(x)<abs(y);
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++) {
        cin>>a[i];
        if(a[i]>=0) f[1]++;
        else f[2]++;
    }
    int l=1,r=n;
    ll ans=1;
     if(!f[1]&&m%2==1){
        sort(a+1,a+1+n,cmp);
        for(int i=1;i<=m;i++){
            ans=a[i]*ans%mod;
        }
    }
    else {
        sort(a+1,a+1+n,greater<int>());
    while(m>0){
        if(m%2) ans=ans*a[l]%mod,l++,m--;
        else if(m>=2){
           if(a[l]*a[l+1]>=a[r]*a[r-1]){
              ans=ans*a[l]%mod*a[l+1]%mod;
              l+=2;
              m-=2;
           }
           else{
            ans=ans*a[r-1]%mod*a[r]%mod;
            r-=2;
            m-=2;
           }
        }
    }
    }
    cout<<(ans%mod+mod)%mod<<endl;
    return 0;
}



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

int main() {

  int a,b,c,d;
  cin >> a >> b >> c >> d;

  //お互いに何回攻撃すれば倒せるのか、攻撃ターンを整数で求める
  //整数での切り上げ方法：割る数を割る数に足して１を引く
  int x = (c+b-1)/b;
  int y = (a+d-1)/d;

  if (x <= y) cout << "Yes" << endl;
  else cout << "No" << endl;

}

Measured memory_bytes: 3624
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    def com(com_n, com_r):
        return fac[com_n] * inv[com_r] * inv[com_n - com_r] % md

    x, y = map(int, input().split())

    # combinationの準備
    md = 10 ** 9 + 7
    n_max = 10 ** 6
    fac = [1]
    inv = [1] * (n_max + 1)
    k_fac_inv = 1
    for i in range(1, n_max + 1):
        k_fac_inv = k_fac_inv * i % md
        fac.append(k_fac_inv)
    k_fac_inv = pow(k_fac_inv, md - 2, md)
    for i in range(n_max, 1, -1):
        inv[i] = k_fac_inv
        k_fac_inv = k_fac_inv * i % md

    s, t = x + y, x - y
    if s % 3:
        print(0)
        exit()
    step = s // 3
    if (t + step) % 2:
        print(0)
        exit()
    n_plus = (t + step) // 2
    if not 0 <= n_plus <= step:
        print(0)
        exit()
    print(com(step, n_plus))

main()


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

bool zero_check(vector<int> vec) {
  bool a = true;
  int s = vec.size();
  for (int i = 0; i < s-1; i++) {
    if (!vec.at(i) == 0) {
      a = false;
    }
  }
  return a;
}


int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  while(!zero_check(A)) {
    sort(A.begin(), A.end()); //モンスターを雑魚順にする
    int i = 0;
    while(i < N) {
      if (A.at(i) == 0) {
        i++;
      }
      else { //0じゃない最弱を見つける
        int noob = A.at(i);
        for (int j = i+1; j < N; j++) {
          A.at(j) = A.at(j) % noob;
        }
        break;
      }
    }
  }
  cout << A.at(N-1) << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    long long i,j,k,l,m,n,x;
    cin >> x;
    long long p=100;
    l=0;
    while(p<x)
    {
        p+=p/100;
        l++;
    }
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 3648
/*
    Author: Arham_doshi
    @quote "Code like there's no tommorow!"
     ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
    */
    #include <bits/stdc++.h>
     
    #define int         long long
    #define double      long double
    #define pb          push_back
    #define pf          push_front
    #define pii         pair<int,int>
    #define vi          vector<int>
    #define vii         vector<pii>
    #define mi          map<int,int>
    #define mii         map<pii,int>
    #define all(a)      (a).begin(),(a).end()
    #define rall(a)     (a).rbegin(),(a).rend()
    #define x           first
    #define y           second
    #define sz(x)       (int)x.size()
    #define endl        '\n'
    #define hell        998244353
    #define PI          3.141592653589
    #define bs(v,n)     binary_search(all((v)),(n))
    #define lb(v,n)     lower_bound(all((v)),(n))
    #define ub(v,n)     upper_bound(all((v)),(n))
    #define fo(i,l,u)   for(i=l;i<u;i++)
    #define rfo(i,l,u)  for(i=l;i>=u;i--)
    #define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
    #define _init(b)     memset(b,-1,sizeof(b))
    #define _init0(b)     memset(b,0,sizeof(b))
    #define MOD         1000000007
     
     
     
    using namespace std;
     
    int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }  
    bool mod(double a,double b) {return a/b - floor(a/b);}
    int ceil(int n,int k){if(k%n==0){return k/n;}else return (k/n)+1;}
    int occurs(vi v,int n){
    auto it=lb(v,n);auto it1=ub(v,n);int x=it1-it;return x;}
     
    int logb(int base, int x) {
        return (log(x) / log(base));
    }
    
    
//--------------graphs----------------------------------
vector<int> graph[100005];
int vis[100005];
//pairn (black,white)  i is for black ,j is for white
pii dfs (int p,int parent){
    
    int i=0,j=1,x;
   
    for(int a :graph[p]){
        if(a!=parent){
            pii pr=dfs(a,p);
            x=j;
            j=(j*pr.y)%MOD;
            i=((x*pr.x)+(i*(pr.x+pr.y)))%MOD;
        }
        
    }
    return {j,(i+j)%MOD};
}



void cgraph(int q,int n){
    int a,b;
    
    memset(vis,0,sizeof(vis));
    while(q--){
        cin>>a>>b;
        graph[a].pb(b);
        graph[b].pb(a);
    }
    return ;
}

//---------------------------graphs over-------------------
 
     
     
    signed main()
    {
        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
        int i,j,x,t,n,k;
        cin>>n;
        cgraph(n-1,n);
        pii p = dfs(1,-1);
        cout<<(p.x+p.y)%MOD;
        
        
   
        return 0;
    }

Measured memory_bytes: 13440
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>

using namespace std;

#define INF 1000000007
#define LINF 1000000000000000007

typedef long long i64;
typedef pair<i64,i64> P;


int n;
int a[202020];
int ans[202020];

int main(){
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	
	int cnt = 0;
	for(int i = n; i > 0; i--){
		if(a[i] % 2){
			ans[i]++;
			cnt++;
			for(int j = 1; j*j <= i; j++){
				if(i % j == 0){
					a[j]++;
					if(j*j != i) a[i / j]++;
				}
			}
		}
	}
	
	cout << cnt << endl;
	for(int i = 1; i <= n && cnt > 0; i++){
		if(ans[i]){
			cout << i << endl;
			cnt--;
		}
	}
	
	return 0;
}

Measured memory_bytes: 2432
#include "bits/stdc++.h"
using namespace std;
int main(){
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i = 0; i < N; i++)
		cin >> A.at(i);
	
	double sum = 0.0;
	for(int i = 0; i < N; i++){
		sum += (double)1/A.at(i);
	}
	double ans = (double)1/sum;
	
	printf("%lf\n", ans);
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

int main(){
  int A, B, C, D;
  std::cin >> A >> B >> C >> D;
  int time = std::min(B, D) - std::max(A, C);
  if(time < 0) std::cout << 0 << std::endl;
  else std::cout << time << std::endl;
}

Measured memory_bytes: 256
// B

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};

int main(){
  string s,t;
  cin>>s>>t;
  vector <int> a[30];
  for (int i(0);i<s.size();i++){
    a[s[i]-'a'].push_back(i);
  }
  ll ans(0);
  int now_index(-1);
  for (int i(0);i<t.size();i++){
    bool flag = false;
    if (a[t[i]-'a'].size() == 0){
      cout << -1 << endl;
      return 0;
    }
    auto itr = upper_bound(a[t[i]-'a'].begin(),a[t[i]-'a'].end(),now_index);
    if (itr != a[t[i]-'a'].end()){
      flag = true;
      now_index = *itr;
      //cout << now_index << endl;
    }
    //for (int j(0);j<a[t[i]-'a'].size();j++){
    //  int number = a[t[i]-'a'][j];
    //  if (number > now_index){
    //    now_index = number;
  ////      cout << now_index << endl;
    //    flag = true;
    //    break;
    //  }
    //}
    if (flag == false){
      ans += s.size();
      now_index = -1;
      i--;
    }
  }
  ans += now_index+1;
  cout << ans << endl;
}




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

int main() {
    int n,rmin=1000000000,drmax=-1000000000,i,j;
    cin>>n;
    vector<int> r(n);
    cin>>r[0];
    rmin=r[0];
    for(i=1;i<n;i++){
        cin>>r[i];
        if(drmax<r[i]-rmin)drmax=r[i]-rmin;
        if(rmin>r[i])rmin=r[i];
    }
    cout<<drmax<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef pair<ld, ld> pdd;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 4005;
const int M = (int)1e5 + 9;
const int K = 50000;

bool match(char a, char b){ 
  if(a == '?' || b == '?' || a == b) return true;
  return false;
}

bool AB[M];
bool BC[M];
bool AC[M];



int main(){
  fastIO;
  string a, b, c;
  cin >> a >> b >> c;
  int A = a.size();
  int B = b.size();
  int C = c.size();
  for(int i = -N; i <= N ; i ++ ){
    AB[i+K]=true;
    BC[i+K]=true;
    AC[i+K]=true;
  }
  for(int i = 0 ; i < A; i ++ ){
    for(int j = 0 ; j < B; j ++ ){
      if(!match(a[i],b[j])){
        AB[i-j+K]=false;
      }
    }
  }
  for(int i = 0 ; i < A; i ++ ){
    for(int j = 0 ; j < C; j ++ ){
      if(!match(a[i],c[j])){
        AC[i-j+K]=false;
      }
    }
  }
  for(int i = 0 ; i < B; i ++ ){
    for(int j = 0 ; j < C; j ++ ){
      if(!match(b[i],c[j])){
        BC[i-j+K]=false;
      }
    }
  }
  int ans = A + B + C;
  int L,R;
  for(int i = -N; i <= N ; i ++ ){
    for(int j = -N; j <= N ; j ++ ){
      if(!AB[i+K]) continue;
      if(!AC[j+K]) continue;
      if(!BC[j-i+K]) continue;
      L = min({0,i,j});
      R = max({A,i+B,j+C});
      ans = min(ans, R-L);
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
int main(void){
	char s[101];
	int len;

	scanf("%s",s);
	len = strlen(s);
	for(int i=0;i<len;i++){
		s[i] = 'x';
	}
	printf("%s",s);
	return 0;
}

Measured memory_bytes: 128
n,t = [int(_) for _ in input().split()]
a = []
for i in range(n):
    a.append([int(_) for _ in input().split()])
a = sorted(a, key=lambda x: x[0])
dp = [[0]*(t+1) for i in range(n)]
for j in range(t+1):
    c = a[0][0]
    v = a[0][1]
    if j >= c:
        dp[0][j] = v
dp[0][-1] = v
for i in range(1, n):
    for j in range(1, t+1):
        if j == t:
            c = 1
        else:
            c = a[i][0]
        v = a[i][1]
        if j - c < 0:
            dp[i][j] = dp[i - 1][j]
        else:
            dp[i][j] = max(dp[i - 1][j - c] + v, dp[i-1][j])
ans = 0
for i in range(n-1, 0, -1):
    v = a[i][1]
    ans = max(dp[i-1][t-1]+v, ans)
print(ans)

Measured memory_bytes: 117720
#include <iostream>
#include <string>
#include <iomanip>
#include <math.h>

using namespace std;

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

  int N_cpy = N;
  int digit = 0;
  while (N_cpy != 0)
  {
    N_cpy /= 10;
    ++digit;
  }


  int sum = 0;
  for (int i = 1; i < digit; i += 2)
  {
    sum += pow(10.0, i) - pow(10.0, i - 1);
  }
  if (digit % 2 != 0)  sum += N - (pow(10.0, digit - 1) - 1);

  cout << sum << endl;
}

Measured memory_bytes: 256
def popcount(n):
    return str(bin(n)).count('1')
def f(n):
    if n==0:
        return 0
    else:
        return f(n%popcount(n))+1
N=int(input())
X=input()
K=X.count("1")
#k桁目がone,zeroのとき
ONE=0#K-1
ZERO=0#K+1
tmp1=1
tmp0=1
for i in range(N):
    if X[-i-1]=="1":
        if K>1:
            ONE+=tmp1
            ONE%=(K-1)
        ZERO+=tmp0
        ZERO%=(K+1)
    if K>1:
        tmp1*=2
        tmp1%=(K-1)
    tmp0*=2
    tmp0%=(K+1)
for i in range(N):
    nextnumber=-1
    if X[i]=="1":
        if K==1:
            print(0)
            continue
        else:
            nextnumber=(ONE-pow(2,N-i-1,K-1))%(K-1)
    else:
        nextnumber=(ZERO+pow(2,N-i-1,K+1))%(K+1)
    print(f(nextnumber)+1)


Measured memory_bytes: 76052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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 main(){
    int n;
    cin>>n;
    vector<vector<int>> divisor(n+1,vector<int>(105));
    for(int i=2;i<=n;i++){
        int ii=i;
        for(int j=2;j<100;j++){
            while(ii%j==0){
                ii/=j;
                divisor.at(i).at(j)++;
            }
        }
    }
    vector<int> expo(105);
    rep(i,100){
        rep(j,n+1){
            expo.at(i)+=divisor.at(j).at(i);
        }
    }
    vector<int> prime={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
    int ans;
    rep(i,15){
        rep(j,15){
            if(j<=i)continue;
            rep(k,15){
                if(i==k || j==k)continue;
                int a=prime.at(i),b=prime.at(j),c=prime.at(k);
                if(expo.at(a)>=4 && expo.at(b)>=4 && expo.at(c)>=2) ans++;
            }
        }
    }
    rep(i,15){
        int a=prime.at(i);
        if(expo.at(a)>=74) ans++;
        rep(j,15){
            if(i==j) continue;
            int b=prime.at(j);
            if(expo.at(a)>=24 && expo.at(b)>=2) ans++;
            if(expo.at(a)>=14 && expo.at(b)>=4) ans++;
        }
    }
    cout<<ans<<endl;
}

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


int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; ++i) {
    cin >> d[i];
  }
  sort(d.rbegin(), d.rend());
  int result = 1;
  for (int i = 1; i < N; ++i) {
    int last_di = d[i - 1];
    int di = d[i];
    if (di < last_di) {
      ++result;
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]

A_ = sorted(A.copy(), reverse=True)
max_num = [A_[0], A_[1]]

for i in range(N):
    if A[i] != max_num[0]:
        print(max_num[0])
    else:
        print(max_num[1])


Measured memory_bytes: 14856
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
int main(void){
  ll n,m;
  cin>>n>>m;
  vl x(n),y(n),z(n);
  rep(i,n){
    cin>>x[i]>>y[i]>>z[i];
  }
  vll sums(8,vl(n));
  rep(j,8){
    rep(i,n){
      sums[j][i]=(ll)pow(-1,j)*x[i]+(ll)pow(-1,j/2)*y[i]+(ll)pow(-1,j/4)*z[i];
    }
  }
  rep(i,8){
    sort(sums[i].begin(),sums[i].end());

  }
  ll tmp=0;
  ll ans=0;
  rep(j,8){
    tmp=0;
    for(int i=n-1;i>=n-m;i--){
      tmp+=sums[j][i];
    }
    ans=max(ans,tmp);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <stack>
using namespace std;

//vector
stack <int> st;
int solve(string);
int main(){
    string str;
    while(cin>>str){
        if(str=="+"||str=="-"||str=="*"){
            st.push(solve(str));
        }
        else{
            st.push(atoi(str.c_str()));
        }
        if(getchar()=='\n'){
            cout<<st.top()<<endl;
        }
    }

    return 0;
}

int solve(string str){
    int b=st.top();
    st.pop();
    int a=st.top();
    st.pop();
    if(str=="+") return a+b;
    else if(str=="-") return a-b;
    else return a*b;
}


Measured memory_bytes: 3196
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;

// str中にあるcを省いて切り詰めるてdestに入れる
// cがスペースの場合、"1 2 3" -> "123"
void ommit(char* src, char c, char* dest){
	int len = strlen(src);
	memset(dest, 0, len+1);
	char *p = dest;
	for(int i=0; i<len; i++){
		if(src[i] != c){
			*p = src[i];
			p++;
		}
	}
}

LL calcStr(char* src){
	char dest[22] = {0};
	ommit(src, ' ', dest);
	char *p;
	long long ret = 0;
	
	p = strtok(dest, "+");
	ret += atoll(p);
	while(p !=NULL){
		p = strtok(NULL, "+");
		if(p != NULL){
			ret += atoll(p);
		}
	}
	return ret;
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	string s;
	int len;
	cin >> s;
	len = (int)s.size();
	string S;
	for(int i=0; i<s.size(); i++){
		S += s[i];
		S += ' ';
	}

	long long ans = 0;
	for(int b = 0; b < (1<<(len-1)); b++){
		string ws = S;
		for(int i=0; i<len-1; i++){
			if(b & (1<<i)){
				ws[i*2+1] = '+';
			}
		}
		ans += calcStr((char*)ws.c_str());
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n-1);
  rep(i, n-1) cin >> b[i];
  
  a[0] = b[0];
  for(int i = 1; i < n-1; ++i) {
    a[i] = min(b[i-1], b[i]);
  }
  a[n-1] = b[n-2];
  
  int sum = 0;
  rep(i, n) sum += a[i];
  
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var NK = ReadLine().Split().Select(int.Parse).ToArray();
        var N = NK[0];
        var K = NK[1];
        var S = ReadLine();

        var m = S[0];
        var max = 1;
        var c = S[0] == '0' ? 1 : 0;
        var s = 0;
        for (int i = 1; i < N; i++)
        {
            if (m == '1' && S[i] == '0')
            {
                c++;
                if (c > K)
                {
                    if (S[s] == '1') while (S[s] == '1') s++;
                    while (S[s] == '0') s++;
                    if (s > i) i = s;
                    c--;
                }
            }
            max = Math.Max(max, i - s + 1);
            m = S[i];
        }
        WriteLine(max);
    }
}


Measured memory_bytes: 13372
#include <stdio.h>
                                                                                                
  
int main(void){
                                                                                                
   
    int n, a;
   
      
    scanf("%d", &n);
   
    scanf("%d", &a);
   
   
    if( n % 500 <= a ) printf("Yes\n");

    else printf("No\n");
    

    return 0;
                                                          
}

Measured memory_bytes: 128
import fileinput

chr_master = [' ', '\',.!?', 'abcABC', 'defDEF', 'ghiGHI', 'jklJKL', 'mnoMNO', 'pqrsPQRS', 'tuvTUV', 'wxyzWXYZ']

for s in (line.strip() for line in fileinput.input()):
    s += '!'
    prev_c, cnt = 0, 1
    ans = ''
    for c in s:
        if c == prev_c:
            cnt += 1
            continue
        if prev_c == '0':
            if cnt > 1:
                ans += ' ' * (cnt - 1)
        else:
            ans += chr_master[int(prev_c)][cnt - 1]
        prev_c, cnt = c, 1
    print(ans[1:])

Measured memory_bytes: 7536
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int, int>
#define vi vector<int>
#define pb emplace_back
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define x first
#define y second
#define rep(i, j, k) for(i=j; i<k; i++)
#define sep(i, j, k) for(i=j; i>k; i--)
const int N = 2e5+5;
int A[N], inf = 1e9+7;
int n, k, i, j, dp[N], dp2[N];
vi adj[N], g[N];
int dfs(int id, int p){
    dp[id] = 1;
    vi t1(sz(adj[id]), 1);
    for(int i=0; i<sz(adj[id]); i++) if(adj[id][i]!=p) {
        int a = dfs(adj[id][i], id)+1;
        dp[id] = dp[id]*a%inf;
        if(i<sz(adj[id])-1) g[id][i+1] = a;
        if(i) t1[i-1] = t1[i-1]*a%inf;
    }
    for(int i=0; i<sz(adj[id])-1; i++) g[id][i+1] = g[id][i]*g[id][i+1]%inf;
    for(int i=sz(adj[id])-1; i>=0; i--){
        g[id][i] = g[id][i]*t1[i]%inf;
        if(i) t1[i-1] = t1[i-1]*t1[i]%inf;
    } 
    return dp[id];
}
int dfs1(int id, int p){
    for(int i=0; i<sz(adj[id]); i++) if(adj[id][i]!=p){
        dp2[adj[id][i]] = 1+dp2[id]*g[id][i]%inf;
        dfs1(adj[id][i], id);
    }
    dp[id] = dp[id]*dp2[id]%inf;
}
signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int i, j, a, b, ans = 0;
    cin>>n>>inf;
    rep(i, 1, n){
        cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
        g[a].pb(1); g[b].pb(1);
    }
    dfs(1, 0);
    dp2[1]=1;
    dfs1(1, 0);
    rep(i, 1, n+1) cout<<dp[i]<<"\n";
}

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

#define INF (1<<25)
#define MOD (1000000007)

#define FOR(i,a,n) for (int i = a; i < n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); \
    })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = long long;

vector<int> sieve_of_eratosthenes(int n) {
  vector<int> primes(n);
  for (int i = 2; i < n; ++i)
    primes[i] = i;
  for (int i = 2; i*i < n; ++i)
    if (primes[i])
      for (int j = i*i; j < n; j+=i)
        primes[j] = 0;
  return primes;
}

int main() {
  int n; cin >> n;
  vector<int> prime = sieve_of_eratosthenes(n+1);

  ll ans = 1;
  FOR(i,1,n+1) {
    if (prime[i] == 0) continue;
    ll m = n, cnt = 0;
    while(m > 0) {
      m /= i;
      cnt += m;
    }
    ans = ans * (cnt+1) % MOD;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    int ae = e - a;
    if (ae <= k) cout << "Yay!" << endl;
    else cout << ":(" << endl;


    return 0;
}

Measured memory_bytes: 3604