akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;
const int LEN = 100000;

struct fastio{
  int it,len;
  char s[LEN + 5];
  fastio(){
    it = len = 0;
  }
  char get(){
    if(it < len) return s[it++];
    it = 0, len = fread(s,1,LEN,stdin);
    return len ? s[it++] : EOF;
  }
  bool notend(){
    char c;
    for(c = get();c == ' ' || c == '\n';c = get());
    if(it) it--;
    return c != EOF;
  }
  void put(char c){
    if(it == LEN) fwrite(s,1,LEN,stdout), it = 0;
    s[it++] = c;
  }
  void flush(){
    fwrite(s,1,it,stdout);
  }
}buff,bufo;
inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline ll getll(){
  char c; ll res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline void putint(int x,char suf){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[15];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline void putll(ll x,char suf){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[25];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline char get_char(){
  char c;
  for(c = buff.get();c == ' ' || c == '\n';c = buff.get());
  return c;
}
#define maxn 100005
#define maxm 200005
#define mp make_pair
typedef pair<int,int> P;
int n,m,d[maxn],col[maxn],c[maxm];
// col = 1: white, 2: black, 0: TBD or abandoned.
// c = 0: TBD.
vector <P> candidate[maxn],chi[maxn];// to,id.
P nxt[maxn];
void paint(int u){
  int par = nxt[u].first;
  if(!col[par]) paint(par);
  col[u] = 3 - col[par];
  c[nxt[u].second] = d[u];
}
int main(){
  n = getint(), m = getint();
  for(int i = 1;i <= n;i++) d[i] = getint();
  for(int i = 1;i <= m;i++){
    int u = getint(), v = getint();
    if(d[v] >= d[u]) candidate[v].push_back(mp(u,i));
    if(d[u] >= d[v]) candidate[u].push_back(mp(v,i));
  }
  for(int i = 1;i <= n;i++){
    if(candidate[i].empty()){
      puts("-1");
      return 0;
    }
    nxt[i] = candidate[i][0];
  }
  for(int i = 1;i <= n;i++){
    int v = nxt[i].first;
    if(nxt[v].first == i){
      col[i] = 1;
      col[v] = 2;
      c[nxt[i].second] = d[i];
    }
  }
  for(int i = 1;i <= n;i++) if(!col[i]) paint(i);
  for(int i = 1;i <= n;i++) printf(col[i] == 1 ? "W" : "B");
  printf("\n");
  for(int i = 1;i <= m;i++) printf("%d\n",c[i] ? c[i] : 1000000000);
  return 0;
}


Measured memory_bytes: 13824
def main():
    A, B = map(int, input().split())
    S = str(input())
    f = 0
    
    for i in range(A):
        if S[i].isnumeric():
            continue
        else:
            print('No')
            return
    
    if S[A] != '-':
        print('No')
        return
    
    for i in range(A+1, A+B+1):
        if S[i].isnumeric():
            continue
        else:
            print('No')
            return
    print('Yes')
    
main()

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


 const int MAX = 1001;
const int MOD = 1000000007;



signed main(){
    int n,w;
    cin>>n>>w;
    int a,b,c[n*1000+1][n+1];
    for(int i=0;i<=n*1000;i++)c[i][0]=MOD;
    c[0][0]=0;
    for(int i=1;i<=n;i++){
        cin>>a>>b;
        for(int j=0;j<=n*1000;j++){
            if(j>=b)c[j][i]=min(c[j][i-1],c[j-b][i-1]+a);
            else c[j][i]=c[j][i-1];
        }
    }
    a=n*1000;
    while(c[a][n]>w)a--;
    cout<<a;


   return 0;
}

Measured memory_bytes: 39680
n,a,b = map(int,input().split())
h = []
for i in range(n):
    h.append(int(input()))

def hantei(c):
    tmp = 0
    for i in range(n):
        tmp += max(0, -(-(h[i] - b * c) // (a-b)))
    if tmp <= c:
        return True
    else:
        return False

l = 0
r = 10**18+10

while r - l > 1:
    c = (l + r) // 2
    tmp = 0
    for i in range(n):
        tmp += max(0, -(-(h[i] - b * c) // (a-b)))
    if hantei(c):
        r = c
    else:
        l = c

if hantei(l):
    print(l)
else:
    print(r)


Measured memory_bytes: 80956
#include <iostream>
#include <algorithm>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i=0; i< (int)(n); i++)
typedef long long ll;

// select top N number from A and Ci x Bi gathered
int main() {
    int N, M, ai, bi, ci;
    cin >> N >> M;
    // cout << endl << "----" << endl;
    vector<int> A;
    vector<pair<int, int>> BC;
    rep(i, N) {
        cin >> ai;
        A.push_back(- ai);
    }
    make_heap(A.begin(), A.end());

    rep(i, M){
        cin >> bi >> ci;
        BC.push_back(make_pair(ci, bi));
    }
    sort(BC.begin(), BC.end(), greater<pair<int,int>>());



    rep(i, M){
        bi = BC[i].second;
        ci = BC[i].first;
        rep (j, bi){
            if (- ci < A.front()) {
                // cout << "ci: " << ci << " front of A is : " << A.front();
                pop_heap(A.begin(), A.end());
    // for (auto& each : A) cout << each << " "; cout << endl;
                A.pop_back();
    // for (auto& each : A) cout << each << " "; cout << endl;

                A.push_back(- ci);
                push_heap(A.begin(), A.end());
            } else {
                break;
            }
        }
    }
    // for (auto& each : A) cout << each << " " << endl;
    ll sum = - accumulate(A.begin(), A.end(), 0LL);
    cout << sum << endl;
}
    // sort(A.begin(), A.end(), greater<int>());

    // int cur_cnt = 0, cur_sum = 0;
    // rep(i, M) {
    //     // check cnt border
    //     if (cur_cnt + change_cnt >= N) {
    //         change_cnt = N - cur_cnt;
    //     }
    //     cur_cnt += change_cnt;
    //     rep(j, change_cnt) {
    //         if (A[])
    //     }



    //     // end
    //     if (cur_cnt == N) {
    //         break;
    //     }
    // }

Measured memory_bytes: 4700
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define rep(i, f, n) for (int i = (f); i < (int)(n); i++)
#define repe(i, f, n) for (int i = (f); i <= (int)(n); i++)
using namespace std;
using ll = long long;
using pint = pair<int, int>;

const int INF = 1001001001;

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

int main() {
  int s;
  cin >> s;
  vector<int> v(1000000, 0);
  int ans = 1;
  while (true) {
    // 4, 2, 1, 4, 2, 1 ... に収束していく
    if (v[s] > 0) {
      cout << ans << endl;
      return 0;
    }
    v[s]++;
    s = f(s);
    ans++;
  }
  return 0;
}


Measured memory_bytes: 7100
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

#define roop(a,b) for(int a=0;a<b;++a)

int main(){
	int n;
	vector<pair <int,int>> a;
	cin >> n;
	a.resize(n);
	roop(i,n){
		int aa;
		cin >> aa;
		a[i].first = aa;
		a[i].second = i+1;
	}
	sort(a.begin(),a.end());
	roop(i,n){
		cout << a[i].second;
		if(i != n-1)cout << " ";
	}
	cout << endl;
}

Measured memory_bytes: 1664
import sys
sys.setrecursionlimit(10 ** 9)

N = int(input())
X = list(input())

lst = [-1] * (4 * N + 10)
lst[0] = 0
lst[1] = 1

def calc(x):
    if lst[x] != -1:
        return lst[x]
    count = 0
    y = x
    while y:
        if y % 2 == 1:
            count += 1
        y //= 2
    lst[x] = calc(x % count) + 1
    return lst[x]



count = X.count('1') #1の数

count1 = count - 1
count2 = count + 1

# print (count)
total1 = 0
total2 = 0

for i in range(N):
    if X[N - 1 - i] == '1':
        if count1 >= 1:
            total1 += pow(2, i, count1)
            total1 %= (count1)

        total2 += pow(2, i, count2)
        total2 %= (count2)
# print ('total', total)

for i in range(N):
    if X[i] == '1':
        if count1 == 0:
            print (0)
            continue
        tmp_total = (total1 - pow(2, N - 1 - i, count1)) % count1
        amari = tmp_total % count1
        ans = calc(amari) + 1
        print (ans)
    else: # 0の時
        tmp_total = (total2 + pow(2, N - 1 - i, count2)) % count2
        amari = tmp_total % (count2)
        ans = calc(amari) + 1
        print (ans)






Measured memory_bytes: 91592
#!/usr/bin/env python3
import os
from sys import stdin, stdout


def solve(tc):
    n = int(stdin.readline().strip())

    res = {
        'AC':0,
        'WA':0,
        'TLE':0,
        'RE':0
    }
    for i in range(n):
        out = stdin.readline().strip()
        res[out] += 1
        
    for k,v in res.items():
        print(k,'x',v)
    


tcs = 1
tc = 1
while tc <= tcs:
    solve(tc)
    tc += 1


Measured memory_bytes: 67972
#include<bits/stdc++.h>
using namespace std;
int n,a[100005],rs,ans;
int main(){
	scanf("%d %d",&n,&a[1]);
	for(int i=2;i<=n;++i){
		scanf("%d",&a[i]);
		if(a[i]>a[i-1]){
			ans=max(ans,rs);
			rs=0;
		}
		else {
			rs++;
		}
	}
	cout<<max(ans,rs);
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<map>
#include <unordered_set>
#include <unordered_map>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e9;
typedef std::pair<int,int> P;

    ll N,K,ans;
int main(){
    std::ios_base::sync_with_stdio(false);
    cin>>N>>K;
    EREP(i,N){
        if(i<=K)continue;
        ans+=N/i*(i-K);
        if(N%i>K-1&&N%i!=0){
            if(K!=0)ans+=N%i-(K-1);
            else ans+=N%i;
        }

        DEB(i)DEB(N/i*(i-K))DEB(N%i)DEB(ans)END
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
S=input()
T=input()
NS=len(S)
NT=len(T)
MAX=0
for i in range(NS-NT+1):
    COUNT=0
    for j in range(NT):
        if S[i+j]==T[j]:
            COUNT+=1
    if COUNT>MAX:
        MAX=COUNT
print(NT-MAX)
        

Measured memory_bytes: 9012
from collections import deque

s  = input()
q = int(input())

#flag=0 でleft, flag=1でrightが先頭
flag = 0
cnt = 0
d  = deque(s)

for _ in range(q):
    lis = list(input().split())
    if lis[0] == "1":
        if flag:
            flag = 0
        else:
            flag = 1
        cnt += 1
    else:
        if lis[1] == '1':
            if flag:
                d.append(lis[2])
            else:
                d.appendleft(lis[2])
        else:
            if flag:
                d.appendleft(lis[2])
            else:
                d.append(lis[2])


d = list(d)
if cnt % 2 != 0:
    d = d[::-1]


print(''.join(d))

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

int A[102];

int main()
{
    ios::sync_with_stdio(0);
    
    int N;
    cin >> N;

    for(int i=1; i<=N; i++)
    {
        cin >> A[i];
        A[i] += A[i-1];
    }

    int ans = 1e9 + 7;

    for(int i=1; i<N; i++)
        ans = min(ans, abs(A[i] - (A[N] - A[i])));

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
const int inf = 1e9+7;

int A[400][400];
vector<int> mincost(10,inf);
vector<bool> v(10);
int c[10][10];

void dfs(int start,int now,int cost){
	int ret = inf;
	if(now==1){
		mincost[start] = min(mincost[start],cost);
		return;
	}
	for(int i=0;i<=9;i++){
		if(i==now)continue;
		if(v[i])continue;
		v[i]=1;
		dfs(start,i,cost + c[now][i]);
		v[i]=0;
	}
	return;
}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H,W;
	cin >> H >> W;
	for(int i=0;i<=9;i++)for(int j=0;j<=9;j++)cin >> c[i][j];
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)cin >> A[i][j];
	mincost[1]=0;
	for(int i=0;i<=9;i++){
		dfs(i,i,0);
	}
	int ans = 0;
	for(int i=0;i<H;i++)for(int j=0;j<W;j++){
		if(A[i][j]>=0){
			ans += mincost[A[i][j]];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<b?(a=b,1):0)
#define chmin(a,b) (a>b?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int a[30];
int b[30];
int dp[31][1<<16];

int main() {
  int n,c;
  while(cin>>n>>c,n||c) {
    REP(i,n) {
      a[i] = 0;
      REP(j,16) {
        int x; cin >> x;
        if (x) a[i] |= 1<<j;
      }
    }
    REP(i,c) {
      b[i] = 0;
      REP(j,16) {
        int x; cin >> x;
        if (x) b[i] |= 1<<j;
      }
    }
    memset(dp,-1,sizeof(dp));
    dp[0][0] = 0;
    int ans = 0;
    REP(i,n) {
      REP(S,1<<16) {
        if (dp[i][S] == -1) continue;
        int T = S|a[i];
        REP(j,c) {
          chmax(dp[i+1][T&(~b[j])], dp[i][S]+__builtin_popcount(T&b[j]));
        }
      }
    }
    REP(S,1<<16) chmax(ans,dp[n][S]);
    cout << ans << endl;
  }
}

Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

// #define int ll
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << '\n'

const int MOD = (int)1e9 + 7;

int calc_height(int Cx, int Cy, int H, int X, int Y) {
    int ans = H - abs(X - Cx) - abs(Y - Cy);

    return ans > 0 ? ans : 0;
}

int guess_height(int Cx, int Cy, int X, int Y, int low_h) {
    return low_h + abs(X - Cx) + abs(Y - Cy);
}


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

    vector<int> Xs(N);
    vector<int> Ys(N);
    vector<int> Hs(N);
    REP(i, N) {
        cin >> Xs.at(i) >> Ys.at(i) >> Hs.at(i);
    }

    int selected_i;
    int selected_h;
    REP(i, N) {
        int h = Hs.at(i);
        if (h > 0) {
            selected_i = i;
            selected_h = h;
        }
    }

    int selected_x = Xs[selected_i];
    int selected_y = Ys[selected_i];

    debug(selected_x);
    debug(selected_y);
    debug(selected_h);

    int cx, cy;
    FORE(cx, 0, 100) {
        FORE(cy, 0, 100) {
            int guessed_h = guess_height(cx, cy, selected_x, selected_y, selected_h);

            bool ok = true;
            REP(i, N) {
                int x = Xs[i];
                int y = Ys[i];
                int h = Hs[i];
                int calced_h = calc_height(cx, cy, guessed_h, x, y);

                if (calced_h != h) {
                  ok = false;
                    break;
                }
            }

            if (ok) {
                cout << cx << " " << cy << " " << guessed_h << endl;
                return 0;
            }




        }
    }


}


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

int solve(int p, const vector<vector<int>> &v) {
    if (v.at(p).size() == 0) return 0;

    int len = (int)v.at(p).size();
    vector<int> res(len);
    for (int i = 0; i < len; i++) {
        res.at(i) = solve(v.at(p).at(i), v);
    }
    sort(res.begin(), res.end());

    int maximum = 0;
    for (int i = 0; i < len; i++) {
        maximum = max(maximum, res.at(i) + len - i);
    }

    return maximum;
}

int main() {
    int n;
    cin >> n;
    vector<vector<int>> v(n);
    for (int i = 0; i < n - 1; i++) {
        int a;
        cin >> a;
        a--;
        v.at(a).push_back(i + 1);
    }

    int ans = solve(0, v);
    cout << ans << endl;
}

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

typedef long long ll;
#define PI 2 * acos (0.0)

ll MOD = 1e9 + 7 ;
ll arr[100005] ;

int main()
{
  ll n ;
  cin >> n ;
  string s, t, ans = "" ;
  cin >> s >> t ;

  for(int i = 0; i < n; i++) {
    ans += s[i] ;
    ans += t[i] ;
  }
  cout << ans << endl ;

}


Measured memory_bytes: 256
def resolve():
    '''
    code here
    '''
    N, T = [int(item) for item in input().split()]
    t_list = [int(item) for item in input().split()]
    time = 0

    for i in range(N):
        if i == 0:
            time = T
        else:
            delta_time = t_list[i] - t_list[i-1]
            time += min(T, delta_time)
            
    print(time)

if __name__ == "__main__":
    resolve()


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

using namespace std;

template <typename T>
using V = vector<T>;

typedef long double ld;
typedef long long ll;

#define FO(i, N) for (int (i) = 0; (i) < (N); ++(i))
#define FOll(i, N) for (ll (i) = 0; (i) < (N); ++(i))
#define READALL(c) for (auto &e : c) { cin >> e; }
#define PRINTALL(c) for (const auto &e : c) { cout << e << "\t"; } cout << "\n";
#define MP(x, y) (make_pair((x), (y)))
#define MT(...) make_tuple(__VA_ARGS__)
#define G(i, x) get<i>(x)
#define ALL(x) begin(x), end(x)

const int MAXN = 2*1e5+10;
int N, M;
set<int> adj_A[MAXN], adj_B[MAXN];
string S;


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N >> M >> S;
	FO(i, M) {
		int u,v;
		cin >> u >> v;
		--u; --v;
		if (S[v] == 'A') adj_A[u].insert(v);
		else adj_B[u].insert(v);
		if (S[u] == 'A') adj_A[v].insert(u);
		else adj_B[v].insert(u);
	}
	queue<int> Q;
	V<int> marked(N);
	FO(i, N) if (adj_A[i].empty() || adj_B[i].empty()) {
		Q.push(i);
		marked[i] = 1;
	}
	while (Q.size()) {
		int curr = Q.front();
		Q.pop();
		for (int c : adj_A[curr]) if (!marked[c]) {
			auto& cadj = (S[curr] == 'A' ? adj_A[c] : adj_B[c]);
			cadj.erase(curr);
			if (cadj.empty()) {
				Q.push(c);
				marked[c] = 1;
			}
		}
		for (int c : adj_B[curr]) if (!marked[c]) {
			auto& cadj = (S[curr] == 'A' ? adj_A[c] : adj_B[c]);
			cadj.erase(curr);
			if (cadj.empty()) {
				Q.push(c);
				marked[c] = 1;
			}
		}
	}
	cout << (accumulate(ALL(marked), 0) == N ? "No" : "Yes") << endl;
}

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

int gcd(int x,int y){
    if(x==0)return y;
    return gcd(y%x,x);
}

int main(){
    int N;cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;++i){
        cin>>a[i];
    }
    vector<int> l(N),r(N);
    for(int i=0;i<N-1;++i){
        l[i+1]=gcd(l[i],a[i]);
    }
    for(int i=N-1;i>=1;--i){
        r[i-1]=gcd(r[i],a[i]);
    }
    int ans=1;
    for(int i=0;i<N;++i){
        ans=max(ans, gcd(l[i],r[i]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;

struct r{
  int num;
  string s;
  int p;

  bool operator<(const r &b) const {
    return s== b.s ? p>b.p : s<b.s;
  }
};

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

  r x[n];
  REP(i, n){
    cin>>x[i].s>>x[i].p;
    x[i].num = i+1;
  }

  sort(x, x+n);

  REP(i, n){
    cout<<x[i].num<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
	string s; cin >> s;
	if (s[s.size() - 1] == 's') s.push_back('e'), s.push_back('s');
	else s.push_back('s');
	cout << s << endl;
	return 0;
}


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

typedef long long ll;
#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define REPM(i,n) for(ll i=(n-1); 0=<i; i--)
#define VI vector<int>
#define VL vector<ll>
#define VD vector<double>
#define VS vector<string>
#define V_SORT_U(x) sort(x.begin(), x.end());
#define V_SORT_D(x) sort(x.begin(), x.end(),greater<int>());
#define V_SUM(x) accumulate(x.begin(), x.end(), 0)
#define STR_TRANS_UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define STR_TRANS_LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);

int main(void){
    ll A,B,C,K;
    cin >> A >> B >> C >> K;
    
    ll max = 0;

    //最大の値はA、B、Cと順番に取っていった値になる

    if( K <= (A+B) )
    {
        if( K <= A)
        {
            max = K;
        }
        else
        {
            max = A;
        }
    }
    else
    {
        max = A - (K-A-B);
    }

    cout << max << endl;

    return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll dp[10005][105][2];
int to_int(char in){
    return (int)(in - '0');
}

int main() {
    //cout.precision(10);
    string K;
    int D;
    cin >> K >> D;
    int n = K.size();
    dp[n][0][1] = 1;
    for(int index = n; index >= 1; index--){
        for(int modulo = 0; modulo < D; modulo++){
            //cout << index << " " << modulo << " " << dp[index][modulo][0] + dp[index][modulo][1] << endl;
            for(int digit = 0; digit < 10; digit++){
                dp[index - 1][(modulo + digit) % D][0] = (dp[index - 1][(modulo + digit ) % D][0] + dp[index][modulo][0]) % mod;
            }
            int now = to_int(K[n - index]);
            //cout << index - 1 << " " << now << endl;
            dp[index - 1][(modulo + now) % D][1] = (dp[index - 1][(modulo + now) % D][1] + dp[index][modulo][1]) % mod;
            for(int digit = 0; digit < now; digit++){
                dp[index - 1][(modulo + digit) % D][0] = (dp[index - 1][(modulo + digit) % D][0] + dp[index][modulo][1]) % mod;
            }
        }
    }
    cout << (dp[0][0][0] + dp[0][0][1] - 1 + mod) % mod << endl;
    return 0;
}


Measured memory_bytes: 16640
x, y, z, o = [int(_) for _ in input().split()]
a = sorted([int(_) for _ in input().split()])[::-1]
b = sorted([int(_) for _ in input().split()])[::-1]
c = sorted([int(_) for _ in input().split()])[::-1]

def isEnough(p):
    cnt = 0
    for i in range(x):
        for j in range(y):
            for k in range(z):
                if a[i]+b[j]+c[k] < p : break
                cnt += 1
                if cnt >= o: return True
    return False

ok, ng = 0, a[0]+b[0]+c[0]
while abs(ok-ng)>1:
    m = (ok+ng)//2
    if isEnough(m):
        ok = m
    else:
        ng = m

l = []
for i in range(x):
    for j in range(y):
        for k in range(z):
            if a[i]+b[j]+c[k] <= ok : break
            l.append(a[i]+b[j]+c[k])
l.sort(reverse=True)
for i in range(o):
    if len(l) > i:
        print(l[i])
    else:
        print(ok)

Measured memory_bytes: 187932
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<algorithm>
using namespace std;
map<int,int>q;
map<int,int>::iterator it;
int main()
{
    char op[3];
    int a,b,c,d,i,j,k,l,n,m,wa,ac;
    while(~scanf("%d%d",&n,&m))
    {
        wa=0;ac=0;
        if(m==0)
        {
            printf("%d %d\n",ac,wa);
        }
        else
        {
            for(i=0;i<m;i++)
            {
                scanf("%d%s",&a,op);
                if(q[a]==-1)
                    continue;
                if(op[0]=='A')
                {
                    wa+=q[a];
                    ac+=1;
                    q[a]=-1;
                    continue;
                }
                q[a]++;
            }
            q.clear();
            printf("%d %d\n",ac,wa);
        }
    }
}


Measured memory_bytes: 4992
import fractions
def lcm(x,y):
    return (x*y)//fractions.gcd(x,y)

a,b,c,d = map(int,input().split())
print((b-a+1)-b//c-b//d+b//lcm(c,d)+(a-1)//d+(a-1)//c-(a-1)//lcm(c,d))

Measured memory_bytes: 5048
def actual(n, m, a_list):
    popular_threshold = sum(a_list) / (4 * m)

    count_can_be_popular = 0

    for vote in a_list:
        if vote >= popular_threshold:
            count_can_be_popular += 1

    if count_can_be_popular >= m:
        return 'Yes'

    return 'No'

n, m = map(int, input().split())
a_list = list(map(int, input().split()))

print(actual(n, m, a_list))

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

#ifndef ONLINE_JUDGE
freopen(cin, "r", stdin);
freopen(cout, "w", stdout);
#endif

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int temp;
	for (int i=1; i<=5; ++i) {
		cin >> temp;
		if (!temp) {
			cout << i << '\n';
			return 0;
		}

	}
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;




int main() 
{

 fast();

  
  ll a;
  cin>>a;
  vec q(a);
  f(i,0,a)
  {
    cin>>q[i];

  }
  sort(all(q));
  ll q1=q[a/2];
  ll q2=q[(a/2)-1];
  cout<<q1-q2;

    




    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

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

int main() {
  int d[3];
  cin >> d[0] >> d[1] >> d[2];
  for (int i=0; i<(1<<3); ++i) {
    int p,q;
    p = q = 0;
    for (int j=0; j<3; ++j) {
      if ((i >> j) & 1) {
        p += d[j];
      } else 
        q += d[j];
    }
    if (p==q){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(a) (a).begin(), (a).end()
#define dump(x) cout << #x << " = " << (x) << endl

using namespace std;
using ll = long long;

int main() {
  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  ll ans = 0ll;
  ll m = a[0];
  for (int i = 1; i < n; ++i) {
    if (m > a[i]) {
      ans += m - a[i];
    } else {
      m = a[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4832
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

// using
using namespace std;

// typedef
typedef long long ll;
typedef unsigned long long ull;

// assert
template <typename T>
void assert_between(T val, T min, T max)
{
    assert(min <= val && val <= max);
}

// math
// 最大公約数(Gratest Common Divisor)を求める.
template <typename T>
T gcd(T a, T b)
{
    assert(a > 0 && b > 0);
    T num1 = max(a, b);
    T num2 = min(a, b);
    T mod = num1 % num2;
    return (mod == 0) ? num2 : gcd(num2, mod);
}

// 最小公倍数(Least Common Multiple)を求める.
template <typename T>
T lcm(T a, T b)
{
    return (a * b) / gcd(a, b);
}

int main()
{
    int N = INT32_MAX;
    int K = INT32_MAX;
    string S = "";

    map<char, char> m = {
        {'A', 'a'},
        {'B', 'b'},
        {'C', 'c'},
    };

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

    scanf("%d %d", &N, &K);
    cin >> S;

    assert(1 <= N && N <= 50);
    assert(1 <= K && K <= N);
    assert(S.length() == (size_t)N);

    auto p =  m.find(S[K - 1]);
    if (p == m.end()) {
        assert(false);
    }
    S[K - 1] = p->second;

    printf("%s\n", S.c_str());
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <type_traits>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    vector<int> sum(n);
    sum[0] = a[0];
    for(int i = 1; i < n; i++) {
        sum[i] = sum[i - 1] + a[i];
    }

    int ans = INF;
    for(int i = 0; i < n - 1; i++) {
        int a = sum[i];
        int b = sum[n - 1] - sum[i];
        int diff = abs(a - b);
        ans = min(ans, diff);
    }

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


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

#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000001

using namespace std;
#define prime 1000000007

const ll N = 300005;

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";

using namespace std;

int ce(int a, int b){
	return (a+b-1)/b;
}

int r, d, x;

int main(){
	scanf("%d %d %d", &r, &d, &x);

	for (int i = 0; i < 10; ++i){
		x = r*x - d;
		printf("%d\n", x);
	}
			
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,c=0;
    cin>>n;
    int a[n],b[n];
    for(int i=1;i<=n;i++)
        {
            cin>>a[i];
            if(a[i]!=i)
            c++;
        }

    if(c>2)
        cout<<"NO";
    else if(c==2||c==0)
        {
            cout<<"YES";
        }
                    return 0;
}


Measured memory_bytes: 256
! 2019.10.27
!
      program answer
      implicit none
      integer :: N
      integer :: M
      integer :: i
      intrinsic mod
!
      read(*,*) N
!
      do i=1,9
        M = mod(N,i)
        if(M == 0 .and. N/i < 10) then
          write(*,*) 'Yes'
          exit
        end if
        if(i == 9) then
          write(*,*) 'No'
        end if
       end do
!
      end program answer


Measured memory_bytes: 256
/* ****TCIITB**** */

#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          long long
#define pb          push_back
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

#define N  100005

int main()
{
    
    io
    
    long double pi=acos(-1);
    ll r;
    cin>>r;
    long double res=(1*r)*(2*pi);
    cout<<fixed<<setprecision(21)<<res;
}


Measured memory_bytes: 3800
A, B = input().split()

if A.count("."):
    A_int, A_float = A.split('.')
    if len(A_float) == 1:
        A_float += '0'
    A = 100 * int(A_int) + int(A_float)
else:
    A = int(A) * 100

if B.count("."):
    B_int, B_float = B.split('.')
    if len(B_float) == 1:
        B_float += '0'
    B = 100 * int(B_int) + int(B_float)
else:
    B = int(B) * 100

result = (A * B) // 10**4

print(result)


Measured memory_bytes: 9196
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n == 0 && m == 0) break;

			LinkedList<Integer> list = new LinkedList<Integer>();
			for(int i=1;i<=n;i++) list.add(i);

			int idx = n;
			while(list.size() != 1){
				idx = (idx + m - 1) % list.size();
				list.remove(idx);
			}

			System.out.println(list.get(0));
		}
	}
}

Measured memory_bytes: 12000
#include "bits/stdc++.h"

using namespace std;
using VI = vector<int>;
using VPI = vector<pair<int, int>>;
using LL = long long;

#define FOR(a,n) for(int i=a;i<n;i++)
#define rFOR(a,n) for(int i=n-1;i>=a;i--)
#define IN(n,a) for(int i=0;i<n;i++) cin>>a[i]
#define pIN(n,t) for(int i=0;i<n;i++){int a,b; cin>>a>>b; t.emplace_back(a,b);}
#define SORT(a) sort(a.begin(), a.end())
#define ALL(a) a.begin(), a.end()

int main()
{
	string s;
	cin >> s;
	
	if (s == "SUN")cout << "7";
	else if (s == "MON")cout << "6";
	else if (s == "TUE")cout << "5";
	else if (s == "WED")cout << "4";
	else if (s == "THU")cout << "3";
	else if (s == "FRI")cout << "2";
	else cout << "1";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
bitset<4000005> dp;
int n;
int a[2005];
int main(){
    scanf("%d",&n);
    ll sum=0;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    dp[0]=1;
    for(int i=1;i<=n;i++)
        dp|=(dp<<a[i]);
    int ans=0;
    for(int i=1;i<=sum;i++)
        if(dp[i] && i>=(sum+1)/2){
            ans=i;
            break;
        }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 5272
from string import ascii_lowercase as alph

def gen_pattern(N, pre=""):
  for c in alph[:ord(max(pre or "\x60"))-0x5f]:
    pattern = pre+c
    if len(pattern) == N:
      yield pattern
    else:
      yield from gen_pattern(N, pattern)

for pattern in gen_pattern(int(input())):
  print(pattern)


Measured memory_bytes: 5016
h,w=map(int,input().split())
cost=[list(map(int,input().split())) for i in range(10)]
for i in range(10):
  for j in range(10):
    for k in range(10):
      cost[j][k]=min(cost[j][k],cost[j][i]+cost[i][k])
ans=0
for i in range(h):
    a=map(int,input().split())
    for j in a:
        if j==-1:continue
        ans+=cost[j][1]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int N = 3001;
const int INF = 1e18 + 239;

int dp[N][N][4];
int a[N][N];

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

	int n, m, k;
	cin >> n >> m >> k;
	for (int t = 0; t < 4; t++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				dp[i][j][t] = -INF;
			}
		}	
	}
	for (int t = 0; t < k; t++) {
		int i, j, v;
		cin >> i >> j >> v;
		i--;
		j--;
		a[i][j] = v;
	}
	dp[0][0][0] = 0;
	dp[0][0][1] = a[0][0];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			for (int t = 0; t < 4; t++) {
				if (i + 1 < n) {
					dp[i + 1][j][1] = max(dp[i + 1][j][1], dp[i][j][t] + a[i + 1][j]);
					dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][t]);
				}
				if (j + 1 < m) {
					if (t + 1 < 4) {
						dp[i][j + 1][t + 1] = max(dp[i][j + 1][ t + 1], dp[i][j][t] + a[i][j + 1]);
					}
					dp[i][j + 1][t] = max(dp[i][j + 1][t], dp[i][j][t]);
				}
			}
		}
	}
	int ans = -INF;
	for (int t = 0; t <= 3; t++) {
		ans = max(ans, dp[n - 1][m - 1][t]);
	}
	cout << ans << '\n';
}

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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int Cost;
struct Edge {
  int src, dst; Cost cost;
  Edge(int s, int d, Cost c) : src(s), dst(d), cost(c) {}
};
typedef vector<Edge>  Edges;
typedef vector<Edges> Graph;
typedef vector<Cost>  Array;
typedef vector<Array> Matrix;

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

struct Status {
  bool b, w;
  Status() : b(false), w(false) {}
};

char a[51][51];
int w, h;

int dfs(int y, int x, Status &s) {
  if (a[y][x] == 'W') {
    s.w = true;
    return 0;
  }
  if (a[y][x] == 'B') {
    s.b = true;
    return 0;
  }

  int count = 1;
  a[y][x] = 'D';
  rep(i, 4) {
    int nx = x + dx[i];
    int ny = y + dy[i];

    if (0 <= nx && nx < w && 0 <= ny && ny < h && a[ny][nx] != 'D') {
      count += dfs(ny, nx, s);
    }
  }

  return count;
}

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  while (cin >> w >> h, w || h) {
    rep(i, h) rep(j, w) cin >> a[i][j];

    int cnt_w = 0;
    int cnt_b = 0;

    rep(i, h) rep(j, w) {
      if (a[i][j] == '.') {
        Status s;
        int count = dfs(i, j, s);
        if (s.w && s.b) continue;
        if (s.w) cnt_w += count;
        if (s.b) cnt_b += count;
      }
    }

    cout << cnt_b << " " << cnt_w << endl;
  }
  return 0; 
}

Measured memory_bytes: 3152
nn = 404040
P = 10**9+7

fa = [1] * (nn+1)
fainv = [1] * (nn+1)
for i in range(nn):
    fa[i+1] = fa[i] * (i+1) % P
fainv[-1] = pow(fa[-1], P-2, P)
for i in range(nn)[::-1]:
    fainv[i] = fainv[i+1] * (i+1) % P

C = lambda a, b: fa[a] * fainv[b] * fainv[a-b] % P if 0 <= b <= a else 0

N, K = map(int, input().split())
if K >= N-1:
    print(C(2*N-1, N))
else:
    s = 0
    for i in range(K+1):
        s = (s + C(N, i) * C(N-1, i)) % P
    print(s)


Measured memory_bytes: 47596
#!/usr/local/bin/python3
# coding: utf-8


hairu = input()
sockets = 0
plugs = 1
ab = hairu.split()

while True:
    if int(ab[1]) == 1:
        print(0)
        break

    sockets += 1
    plugs -= 1
    plugs += int(ab[0])
    if int(ab[1]) <= plugs:
        print(sockets)
        break


Measured memory_bytes: 2940
#include <cstdio>
#include <bitset>
#include <cmath>
#include <complex>
#include <vector>
#include <algorithm>
#include <stack>

#define EPS 1e-6

using namespace std;
typedef complex<double> coor;

double cross(coor a, coor b)
{
  return a.real() * b.imag() - a.imag() * b.real();
}

double dot(coor a, coor b)
{
  return a.real() * b.real() + a.imag() * b.imag();
}

int main()
{
  int n;
  while (scanf(" %d ", &n) == 1) {
    int sum = 0;
    for (int i = n; i < 600; i += n) {
      sum += i * i * n;
    }
    printf("%d\n", sum);
  }
}

Measured memory_bytes: 0
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        while(true){
            int H = input.nextInt();
            int H1 = H - 2;
            int W = input.nextInt();
            int W1 = W - 2;
            if(H == 0 && W == 0){
                break;
            }
            for(int a = 0; a < W; a++){
                System.out.printf("#");
            }
            System.out.printf("\n");
            //第一行目の”＃”
            for(int b = 0; b < H1; b++){
                System.out.printf("#");
                for(int c = 0; c < W1; c++){
                    System.out.printf(".");
                }
                System.out.printf("#\n");
            }


            for(int a = 0;a < W; a++){
                System.out.printf("#");
            }
            //最後行目の”＃”

            System.out.printf("\n");
            System.out.printf("\n");
        }
    }
}


Measured memory_bytes: 59824
#include<bits/stdc++.h>
using namespace std;
int a[10];
int s[10];
int c[10];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>s[i]>>c[i];
	}
	for(int i=0;i<m;i++){
		for(int j=i+1;j<m;j++){
			if(s[i]==s[j]&&c[i]!=c[j]){
				cout<<-1<<endl;
				return 0;
			}
		}
	}
	for(int i=0;i<m;i++){
		a[s[i]-1]=c[i];
	}
	if(n==1&&!a[0]){
		cout<<0<<endl;
		return 0;
	}
	for(int i=0;i<m;i++){
		a[s[i]-1]=c[i];
		if(s[i]==1&&c[i]==0){
			cout<<-1<<endl;
			return 0;
		}
	}
	if(!a[0])a[0]=1;
	for(int i=0;i<n;i++){
		if(!a[i])cout<<0;
		else cout<<a[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

class BOneClue {
public:
	void solve(std::istream& in, std::ostream& out) {
        int k,x;
        in >> k >> x;
        for(int i=x-k+1;i<x+k;i++){
            out <<i << " ";
        }out << endl;
	}
};


int main() {
	BOneClue solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;
using ll = long long;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main()
{
	int n, k, i, s = 1;

	cin >> n >> k;

	for (i = 1; i <= n; i++) {
		if (s < k) {
			s *= 2;
		}
		else {
			s += k;
		}
	}

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 384
def main():
    n,m = map(int, input().split())
    ans = [0] * n
    chg = [0] * n
    flg = 0
    for i in range(m):
        j,k = map(int, input().split())
        if chg[j-1] == 1 and ans[j-1] != k:
            flg = -1
        elif ans[j-1] == 0:
            ans[j-1] = k
            chg[j-1] = 1
    if flg == -1:
        print(flg)
    elif len(ans) >= 2 and ans[0] == 0:
        if chg[0] == 0:
            ans[0] = 1
            if n == 3:
                print(ans[0], ans[1], ans[2], sep="")
            elif n == 2:
                print(ans[0], ans[1], sep="")
        else:
            print(-1)
    else:
        if n == 3:
            print(ans[0],ans[1],ans[2],sep="")
        elif n == 2:
            print(ans[0],ans[1],sep="")
        else:
            print(ans[0])


if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
//==========================head template==========================
const int N=100010;
int rt=2;
char s[N];
int n;
int X[N],Y[N],ind=0;
inline void adde(int x,int y) {
  X[++ind]=x; Y[ind]=y;
}
signed main() {
  scanf("%s",s+1); n=strlen(s+1);
  for(int i=1;i<=n;i++) s[i]-='0';
  if(!s[1] || s[n]) {puts("-1"); return 0;}
  for(int i=1;i<n-i;i++)
    if(s[i]!=s[n-i]) {
      puts("-1"); return 0;
    } else s[n-i]=0;
  adde(1,2);
  for(int i=2;i<n;i++) {
    if(!s[i]) adde(rt,i+1);
    else {
      adde(rt,i+1);
      rt=i+1;
    }
  }
  for(int i=1;i<=ind;i++)
    printf("%d %d\n",X[i],Y[i]);
  return 0;
}



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

int main(){
    int n;
    string s;
    double money,rate=380000.0,ans;
    cin >>n;
    while (n-->0){
        cin >>money>>s;
        if(s=="BTC")ans +=money*rate;
        else ans +=money;
    }
    

    cout <<fixed<<setprecision(10)<< ans <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

ll powmod(ll x, ll n) { // like pow(x, n)
  ll r = 1;
  while (n) {
    if (n & 1) {
      r = r * x % MOD;
    }
    x = x * x % MOD;
    n >>= 1;
  }
  return r;
}

int main(int argc, char** argv) {
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) {
    cin >> A[i];
  }

  deque<int> d;
  rep(i, N) {
    int p = lower_bound(all(d), A[i]) - d.begin();
    if (p == 0) {
      d.push_front(A[i]);
    } else {
      d[p-1] = A[i];
    }
  }
  int ans = d.size();
  cout << ans << endl;
}


Measured memory_bytes: 1408
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
7
2 1
0 0
1 2
2 2
4 2
1 3
3 3

output:
5
0 0
2 1
4 2
3 3
1 3
"""

import sys
from operator import attrgetter

EPS = 1e-9


def cross(a, b):
    return a.real * b.imag - a.imag * b.real


def dot(a, b):
    return a.real * b.real + a.imag * b.imag


def check_ccw(p0, p1, p2):
    a, b = p1 - p0, p2 - p0
    if cross(a, b) > EPS:
        # print('COUNTER_CLOCKWISE')
        flag = 1
    elif cross(a, b) < -1 * EPS:
        # print('CLOCKWISE')
        flag = -1
    elif dot(a, b) < -1 * EPS:
        # print('ONLINE_BACK')
        flag = 2
    elif abs(a) < abs(b):
        # print('ONLINE_FRONT')
        flag = -2
    else:
        # print('ON_SEGMENT')
        flag = 0
    return flag


def convex_check_Andrew(_polygon):
    upper, lower = list(), list()
    _polygon.sort(key=attrgetter('real', 'imag'))

    upper.extend((_polygon[0], _polygon[1]))
    lower.extend((_polygon[-1], _polygon[-2]))

    for i in range(2, points):
        n1 = len(upper)
        while n1 >= 2 and check_ccw(upper[n1 - 2], upper[n1 - 1], _polygon[i]) == 1:
            n1 -= 1
            upper.pop()
        upper.append(_polygon[i])

    for j in range(points - 3, -1, -1):
        n2 = len(lower)
        while n2 >= 2 and check_ccw(lower[n2 - 2], lower[n2 - 1], _polygon[j]) == 1:
            n2 -= 1
            lower.pop()
        lower.append(_polygon[j])

    # change to counter-clockwise inplace
    lower.reverse()
    # find bottom-left of the hull and split the lower part
    lower_min = min(lower, key=attrgetter('imag', 'real'))
    min_index = lower.index(lower_min)
    lower_right = lower[min_index:]
    lower_left = lower[:min_index]

    return lower_right + upper[-2:0:-1] + lower_left


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    points = int(_input[0])
    p_info = map(lambda x: x.split(), _input[1:])

    polygon = [int(x) + int(y) * 1j for x, y in p_info]
    ans = convex_check_Andrew(polygon)
    print(len(ans))
    for ele in ans:
        print(int(ele.real), int(ele.imag))

Measured memory_bytes: 31132
#include <iostream>
#include <algorithm>
#include <vector>

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

int main() {
    int n;
    cin >> n;
    vector<P> ba(n);
    for (int i=0; i<n; i++) {
        int a, b;
        cin >> a >> b;
        ba[i] = P(b, a);
    }

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

    int time = 0;
    for (int i=0; i<n; i++) {
        if (time + ba[i].second > ba[i].first) {
            cout << "No" << endl;
            return 0;
        }

        time += ba[i].second;
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 1792
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for(int i=(a);i<(int)(n);i++)
#define repc(i, a, n) for(int i=(a);i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
int main() {
	ull a, b, x;
	cin >> a >> b >> x;
	ull init = a%x == 0 ? a : x*(a / x + 1);
	cout << (init > b ? 0 : (b - init) / x + 1) << endl;

	return 0;
}





Measured memory_bytes: 384