akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    string s;cin >> s;
    deque<char> d;
    for (int i = 0; i < s.length(); i++) {
        d.push_back(s[i]);
    }
    int q;cin >> q;
    int c = 0;
    while(q--){
        int t;cin >> t;
        if(t == 1){
            c ^= 1;
        }
        else{
            int f;
            char cc;cin >> f >> cc;
            if(c){
                if(f == 2) d.push_front(cc);
                else d.push_back(cc);
            }
            else{
                if(f == 1) d.push_front(cc);
                else d.push_back(cc);
            }
        }
    }
    string ans = "";
    while(!d.empty()){
        ans += d.back();
        d.pop_back();
    }
    if(!c) reverse(ALL(ans));
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

constexpr ll MOD = 1000000000 + 7;

std::string K;
int D;
ll dp[10010][120][2];

ll rec(int i, int rem, int flag){
    if(i == K.size()){
        return rem == 0 ? 1 : 0;
    }

    if(dp[i][rem][flag] != -1){
        return dp[i][rem][flag];
    }

    ll res = 0;
    int mx = flag ? 9 : K[i] - '0';
    for(int j=0;j<=mx;++j){
        res = (res + rec(i + 1, (rem + j) % D, flag || (j < mx))) % MOD;
    }

    return dp[i][rem][flag] = res;
}

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

    std::cin >> K >> D;
    
    memset(dp, -1, sizeof(dp));

    ll res = (rec(0, 0, 0) + MOD - 1) % MOD;
    std::cout << res << std::endl;
}


Measured memory_bytes: 19968
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n)]
cd = [list(map(int,input().split())) for _ in range(m)]
ans = [0]*n
for i in range(n):
    count = 10**9
    for j in range(m):
        ch = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        #print("i =",i,"j=",j,"ch =",ch,count)
        if ch < count:
            ans[i] = j+1
            count = ch
    print(ans[i])

Measured memory_bytes: 9140
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,k,i;
    cin>>a>>b>>k;
    for(i=min(a,b);i>=1;i--)
    {
        if(a%i==0&&b%i==0)
        {
            k--;
        }
        if(k==0)
        {
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 764
#include <iostream>                                                                                                               
#include <string>                                                                                                                 
using namespace std;                                                                                                              
                                                                                                                                  
char solve(string s) {                                                                                                            
  if (s[0]=='x' && s[s.size()-1]=='x') {                                                                                          
    return 'x';                                                                                                                   
  } else {                                                                                                                        
    return 'o';                                                                                                                   
  }                                                                                                                               
}                                                                                                                                 
                                                                                                                                  
int main (void) {                                                                                                                 
  string s;                                                                                                                       
  cin >> s;                                                                                                                       
  cout << solve(s) << endl;                                                                                                       
}                                   

Measured memory_bytes: 3208
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
int main()
{
  int n;cin >> n;
  vector<vector<ll>> a(n, vector<ll>(n));
  rep(i,n) rep(j,n) cin >> a[i][j];

  vector<ll> cost((1 << n), 0);
  rep1(mask, (1<<n)-1) {
    rep(i, n) {
      rep(j, n) {
	if(i >= j) continue;
	if( ((mask >> i) & 1) && ((mask >> j) & 1) ) cost[mask] += a[i][j];
      }
    }
  }

  const ll inf = 1e+15;
  vector<ll> dp((1 << n), -inf);
  dp[(1<<n) - 1] = 0;
  for(int mask = (1<<n) - 1; mask > 0; --mask) {
    for(int i = mask; i > 0; i = (i-1)&mask) {
      chmax(dp[mask - i], dp[mask] + cost[i]);
    }
  }

  cout << dp[0] << "\n";
  
  return 0;
}


Measured memory_bytes: 1280
#include<stdio.h>
int main()
{
    int n, k, i=1, y;
    scanf("%d %d", &n, &k);
    for(y=1; y<=n; y++){
        if(i*2 < i+k){
            i *= 2;
        }
        else{
            i += k;
        }
    }
    printf("%d", i);
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



ll X, Y;
ll A, B, C;
ll p[maxn], q[maxn], r[maxn];
ll accp[maxn], accr[maxn];

ll best;

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

    cin>>X>>Y;
    cin>>A>>B>>C;
    for (int i=0; i<A; i++) {
	cin>>p[i];
    }
    for (int i=0; i<B; i++) {
	cin>>q[i];
    }
    for (int i=0; i<C; i++) {
	cin>>r[i];
    }

    sort(p,p+A);
    sort(q,q+B);
    sort(r,r+C);
    reverse(p,p+A);
    reverse(q,q+B);
    reverse(r,r+C);
    
    for (int i=0; i<A; i++) {
	accp[i] = p[i];
	if (i) accp[i] += accp[i-1];
    }

    for (int i=0; i<C; i++) {
	accr[i] = r[i];
	if (i) accr[i] += accr[i-1];
    }


    ll green = 0;
    priority_queue<ll,vector<ll>,greater<ll>> qq;//minheap
    for (int i=0; i<B; i++) {
	qq.push(q[i]);
	green += q[i];
    }

    for (int i=min(C, X); i<C; i++) {
	qq.push(r[i]);
	green += r[i];
    }

    while ((int)qq.size() > Y) {
	green -= qq.top();
	qq.pop();
    }

    //watch(green);

    //take k of the original red apples
    for (int k=max(0LL, X-C); k<=X; k++) {
	int take = X-k;
	ll cur = (k>0 ? accp[k-1] : 0) +  (take>0 ? accr[take-1] : 0) + green;

	//cout<<k<<": "<<cur<<endl;
	
	best = max(best, cur);

	if (take>0) {
	    //take-1
	    if (r[take-1] > qq.top()) {
		green -= qq.top();
		qq.pop();
		green += r[take-1];
		qq.push(r[take-1]);
	    }
	}
    }


    cout<<best<<endl;
    return 0;
}


Measured memory_bytes: 15476
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#define __typeof__ decltype
#endif

#define ITER(c)         __typeof__((c).begin())
#define FOREACH(it, c)  for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)        __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n)    for (int i = ((n)-1); i >= 0; --i)
#define ESIZEOF(A)      (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)      (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC     do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)

int main(void){
    CIN_NO_SYNC;
    int d;

    while(cin >> d){
        if(d < 1) break;
        int t = 0;
        for(int i = d; i < 600; i += d){
            t += i*i*d;
        }
        cout << t << endl;
    }
    return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    VI a(n); cin >> a;

    int u = 0, d = n;
    each(i, a) {
        chmax(u, i);
        chmin(d, i);
    }
    int uc = 0, dc = 0;
    each(i, a) {
        if (i == u)++uc;
        if (i == d)++dc;
    }
    if (u == d) {
        if (u == n - 1)cout << "Yes\n";
        else if (u * 2 <= n)cout << "Yes\n";
        else cout << "No\n";
    }
    else if (u - d == 1) {
        if (uc == 1)cout << "No\n";
        else if (dc + 1 <= u && u <= dc + uc / 2)cout << "Yes\n";
        else cout << "No\n";
    }
    else cout << "No\n";
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000

int main(){
  int N, M; cin >> N >> M;
  vector<pair<int64_t, int64_t>> drink(N);
  rep(i,N) cin >> drink.at(i).first >> drink.at(i).second;

  sort(all(drink));
  int64_t bill_sum = 0, hon_sum = 0;
  rep(i,N) {
    hon_sum += drink[i].second;
    bill_sum += drink[i].first*drink[i].second;
    
    if (hon_sum>=M){
      bill_sum -= drink[i].first*(hon_sum - M);
      break;
    }
  }
  
  cout << bill_sum << endl;
  return 0;
}

Measured memory_bytes: 1920
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef vector<bool> Vb;
typedef vector<int> Vi;

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

void init();

int n;
Vi opt, dp;

int main()
{
	init();

	REP(i, n - 1)
		for (int x : opt)
		{
			if (i + x <= n)
				chmin(dp[i + x], dp[i] + 1);
		}
	cout << dp[n] << endl;
}

void init()
{
	cin >> n;
	dp.resize(n + 1);
	REP(i, n + 1)
		dp[i] = i;

	int x = 6;
	while (x <= n)
	{
		opt.PB(x);
		x *= 6;
	}

	x = 9;
	while (x <= n)
	{
		opt.PB(x);
		x *= 9;
	}
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<ll> a(n),b(n);
    ll total_a=0,total_b=0;
    rep(i,0,n){
        cin>>a[i];
        total_a+=a[i];
    }
    rep(i,0,n){
        cin>>b[i];
        total_b+=b[i];
    }
    
    if(total_a < total_b){
        cout<<-1<<endl;
        return 0;
    }
    
    ll x=0;
    int ans=0;
    vector<ll> k(n);
    rep(i,0,n){
        k[i]=a[i]-b[i];
        if(k[i]<0){
            x+=abs(k[i]);
            ans++;
        }
    }
    
    sort(all(k),greater<ll>());
    rep(i,0,n){
        if(x<=0) break;
        x-=k[i];
        ans++;
    }
    
    cout<<ans<<endl;
}



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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int x,y,z,k;
	cin >> x >> y >> z >> k;
	vector<ll> a(x), b(y), c(z);
	FOR(i,0,x)cin >> a[i];
	FOR(i,0,y)cin >> b[i];
	FOR(i,0,z)cin >> c[i];
	priority_queue<ll> ab;
	FOR(i,0,min(k,x))FOR(j,0,min(k,y)){
		ab.push(a[i] + b[j]);
	}
	priority_queue<ll> ans;
	FOR(i,0,min(k,x*y)){
		ll t = ab.top();
		ab.pop();
		FOR(j,0,min(k,z))ans.push(t + c[j]);
	}
	FOR(i,0,k){
		ANS(ans.top());
		ans.pop();
	}
	return 0;
}


Measured memory_bytes: 43112
def mergesort(n_list, left, right):
    if left + 1 < right:
        mid = math.ceil((left + right)/2)
        mergesort(n_list, left, mid)
        mergesort(n_list, mid, right)
        merge(n_list, left, mid, right)

def merge(n_list, left, mid, right):
    global c
    n1 = mid - left
    n2 = right - mid
    l_list = n_list[left:mid]
    r_list = n_list[mid:right]
    l_list.append(10e10)
    r_list.append(10e10)
    i = 0
    j = 0
    for k in range(left, right):
        c += 1
        if l_list[i] < r_list[j]:
            n_list[k] = l_list[i]
            i += 1
        else:
            n_list[k] = r_list[j]
            j += 1

        
        

import math
n = int(input())
n_list = list(map(int, input().split()))
c = 0
mergesort(n_list, 0, n)
print(" ".join(map(str, n_list)))
print(c)


Measured memory_bytes: 70640
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main (){
    int n;cin>>n;vector<int> v(n);rep(i,0,n)cin>>v[i];
    vector<int> vv=v;
    if(prev_permutation(all(v))){
        rep(i,0,v.size()){
            if(i)cout<<" ";
            cout<<v[i];
        }
        cout<<"\n";
    }
    v=vv;
    rep(i,0,v.size()){
        if(i)cout<<" ";
        cout<<v[i];
    }
    cout<<"\n";
    if(next_permutation(all(v))){
        rep(i,0,v.size()){
            if(i)cout<<" ";
            cout<<v[i];
        }
        cout<<"\n";
    }
}



/*
5
105 24 C 1500000000000 white
100 23 C 1500000000000 blue
105 23 A 1480000000000 pink
110 25 B 1500000000000 black
110 20 A 1300000000000 gree
*/



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

int main()
{
	string S;
	cin >> S;
	rep(i,3)
	{
		a[S[i] - 'a']++;
	}
	if (a[0] == 1 && a[1] == 1 && a[2] == 1) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define MP make_pair
#define MEM(i,j) memset(i,j,sizeof i)
#define Tie ios::sync_with_stdio(0),cin.tie(0)
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int n,m,a,b,toa[200001],tob[200001],tmp,cnt;
string s;
vector<int> v[200001];
queue<int> q;
bitset<200001> u;

int main()
{
	cin>>n>>m>>s;
	for(int i=0;i<m;i++)
	{
		cin>>a>>b,a--,b--;
		v[a].push_back(b),v[b].push_back(a);
		if(s[a]=='A')
			toa[b]++;
		else tob[b]++;
		if(s[b]=='A')
			toa[a]++;
		else tob[a]++;
	}
	for(int i=0;i<n;i++)
		if(toa[i]==0||tob[i]==0)
			q.push(i),cnt++,u[i]=1;
	while(!q.empty())
	{
		tmp=q.front(),q.pop();
		for(int i:v[tmp])
		{
			if(s[tmp]=='A')
				toa[i]--;
			else
				tob[i]--;
			if(!u[i]&&(toa[i]==0||tob[i]==0))
				q.push(i),cnt++,u[i]=1;
		}
	}
	if(cnt==n)cout << "No\n";
	else cout << "Yes\n";
}

Measured memory_bytes: 12420
#include <stdio.h>
#include<stdlib.h>

#define SENTINEL 1000000000

//https://qiita.com/hiso/items/5c36f50c7de61fe870a2

int count=0;

void mergeSort(int A[],int left,int right){
  int i,mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}



void merge(int A[],int left,int mid,int right){
  int n1,n2,i,j,k;
  int *L,*R;
  n1=mid-left;
  n2=right-mid;
  L=(int *)malloc(sizeof(int)*(n1+1));
  R=(int *)malloc(sizeof(int)*(n2+1));
  for(i=0;i<=n1-1;i++){
    L[i]=A[left+i];
  }
  for(j=0;j<=n2-1;j++){
    R[j]=A[mid+j];
  }
  L[n1]=SENTINEL;
  R[n2]=SENTINEL;
  i=0;
  j=0;
  for(k=left;k<=right-1;k++){
   if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
      count++;
    }
    else{
      A[k]=R[j];
      j++;
      count++;
    }
  }
  free(L);
  free(R);
}



int main(void){
    int n,i;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    mergeSort(a,0,n);
    int ans = 0;
    for(i=0;i<n;i++){
        if(i%2==0){
            if(n%2==0){
                ans -= a[i];
            }
            else{
                ans += a[i];
            }
        }
        else{
            if(n%2==0){
                ans += a[i];
            }
            else{
                ans -= a[i];
            }
        }
    }

    printf("%d",ans);
    return 0;

}

Measured memory_bytes: 128
//
// Created by Wangzhe on 2019/10/19.
//

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxn = 300 + 10, INF = 0x3f3f;

int d1[maxn][maxn];

int mp[maxn][maxn];

int main() {
    int n,m,l; cin >> n >> m >>l;
//    for (int i = 0; i < n; i++) {
//        for (int j = 0; j < n; j++) {
//            mp[i][j] = i == j ? 0 : INF;
//            d1[i][j] = i == j ? 0 : INF;
//        }
//    }
    memset(mp, INF, sizeof mp);
    memset(d1, INF, sizeof d1);
    for (int i = 0; i < m; i++) {
        int x, y, z; cin >> x >> y >> z;
        x--; y--;
        mp[x][y] = mp[y][x] = min(mp[x][y],z);
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                mp[j][k] = min(mp[j][k], mp[j][i] + mp[i][k]);
            }
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++){
            if (mp[i][j] <= l) {
                d1[i][j] = 1;
            }
        }
        d1[i][i] = 0;
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                d1[j][k] = min(d1[j][k], d1[j][i] + d1[i][k]);
            }
        }
    }

    int q; cin >> q;
    while (q--) {
        int s, t; cin >> s >>t;
        s--; t--;
        cout << ((d1[s][t] > 500) ? -1 : (d1[s][t] - 1)) << endl;
    }

    return 0;
}

Measured memory_bytes: 1280
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <bitset>
#include <utility>
#include <assert.h>
using namespace std;
#define rank rankk
#define mp make_pair
#define pb push_back
#define xo(a,b) ((b)&1?(a):0)
#define tm tmp

//#define LL ll
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const int INF=0x3f3f3f3f;
const ll INFF=0x3f3f3f3f3f3f3f3fll;
const int MAX=1e5+10;
//const ll MAXN=2e8;
//const int MAX_N=MAX;
const ll MOD=1e9+7;
//const long double pi=acos(-1.0);
//const double eps=0.00000001;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
inline ll powMM(ll a,ll b,ll M){
    ll ret=1;
    a%=M;
//    b%=M;
    while (b){
        if (b&1) ret=ret*a%M;
        b>>=1;
        a=a*a%M;
    }
    return ret;
}
void open()
{
//    freopen("1009.in","r",stdin);
    freopen("out.txt","w",stdout);
}
int x,y;
int n;
int a[MAX];
int an1,an2;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
    {
        if(a[i]&1)
            ++x;
        else
            ++y;
    }
    an1=an2=1;
    for(int i=1;i<=n;i++)an1*=3;
    for(int i=1;i<=y;i++)
        an2*=2;
    printf("%d\n",an1-an2);
    return 0;
}
/*
5
5 6
1 2 1
2 3 2
2 4 3
3 4 4
3 5 3
4 5 2
*/


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val S = readLine()!!

    var res = 0
    val st = ArrayDeque<Char>()

    for (c in S.toCharArray()) {
        if (st.isNotEmpty() && st.last != c) {
            st.pollLast()
            res += 2
        } else {
            st.addLast(c)
        }
    }

    println(res)
}

Measured memory_bytes: 34284
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
        k: i32,
        s: i32,
    }
    // x, y, z <= k
    // x + y + z = s
    // x <= y <= z
    if k * 3 < s {
        println!("0");
        return
    }
    let mut x = 0;
    let mut y = 0;
    let mut z = 0;
    let mut cnt = 0;

    for z in (0..k+1).rev() {
        // if z * 3 < s {
        //     break;
        // }

        for y in (0..k+1).rev() {
            x = s - z - y;
            if x < 0 || x > k {
                continue;
            }
            // println!("{} {} {}", x, y, z);
            cnt += 1;
        }
    }
    println!("{}", cnt);
}


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

using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef long int li;

int main()
{
    IOS;
    //freopen("fr1.txt","r",stdin);
    string s1,s2,s;
    int n;
    cin>>n;
    cin>>s1>>s2;
    for(int i=0;i<n;i++){
        s=s+s1[i];
        s=s+s2[i];
    }
    cout<<s<<endl;
    
    
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>

#define ll long long
#define sz 205

using namespace std;

int main()
{
    ll n,x;

    scanf("%lld",&n);

    ll mx=0;
    ll mn=INT_MAX;

    for(ll i=1;i<=n;i++)
    {
        scanf("%lld",&x);

        mx=max(mx, x);
        mn=min(mn, x);
    }

    ll dif=fabs(mx-mn);

    printf("%lld\n",dif);

    return (0);
}




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


#define file "file"
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef complex<double> point;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define DEBUG 0
#define dout if(DEBUG) cout

const int MAXN = 1e5;
const int MAXN2 = 100 + 6;

int a[MAXN];
int c[MAXN2][MAXN2];
int h, w;


void solve(){
    int h, w, n;
    cin >> h >> w >> n;
    for(int i = 0; i < n; i++) scanf("%d", &a[i]);
    int dir = 0;
    int x = 0, y = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < a[i]; j++){
            c[x][y] = i + 1;
            if(dir){
                y--;
                if(y < 0){
                    dir = 0;
                    x++;
                    y = 0;
                }
            }
            else{
                y++;
                if(y == w){
                    dir = 1;
                    x++;
                    y = w - 1;
                }
            }
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            printf("%d ", c[i][j]);
        }
        printf("\n");
    }
}

int main() {
    #ifdef NASTYA
        assert(freopen("input.txt", "r", stdin)); assert(freopen("output.txt", "w", stdout));
    #else
    // assert(freopen(file".in", "r", stdin)); assert(freopen(file".out", "w", stdout));
    #endif
    int t = 1;
    while(t--) {
        solve();
    }
    return 0;
}


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

main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int now = 0;
    for (int i = 1; i < n; ++i) {
        if (s[i] == s[i - 1]) {
            now++;
        }
    }
    cout << min(now + 2 * k, n - 1);
    return 0;
}


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

int main(){

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

    int n;long long a=0;
    cin>>n;
    do{
        if(n%5&&n%3)a+=n;
        n--;
    }while(n>=0);
    cout<<a<<endl;

    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int r;cin>>r;
  if(r<1200){
    P("ABC");
    return 0;
  }else if(r<2800){
    P("ARC");
    return 0;
  }else{
    P("AGC");
    return 0;
  }
  return 0;
}


Measured memory_bytes: 256
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
lc = 0
arr = []
nn = 0
while l = $stdin.gets do
  if lc == 0
    nn = l.chomp.to_i
  else
    arr << l.chomp
  end
  lc += 1
end

kishu = []
arr.length.times do |i|
  if i == 0
    kishu << arr[i]
    next
  end
  if arr[i-1][-1] != arr[i][0] or kishu.include?(arr[i])
    puts "No"
    exit
  end
  kishu << arr[i]
end

puts "Yes"




Measured memory_bytes: 1788
#!/usr/bin/env pypy3

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(0)
	n, x, y = map(int, sys.stdin.readline().split())
	x -= 1
	y -= 1
	ans = [0]*(n-1)
	for i in range(n):
		for j in range(i+1, n):
			log.print(i, j, ans)
			if i == j:
				continue
			if (i <= x and j <= x) or (y <= i and y <= j):
				ans[abs(i-j)-1] += 1
			elif (i <= x and y <= j):
				ans[x-i + j-y + 1 - 1] += 1
			elif (x < i < y and x < j < y):
				ans[min(abs(i-j), i-x + 1 + y-j)-1] += 1
			elif (i <= x and x < j < y):
				ans[min(abs(i-j), x-i + 1 + y-j)-1] += 1
			elif (x < i < y and y <= j):
				ans[min(abs(i-j), j-y + 1 + i-x)-1] += 1
	for i in range(len(ans)):
		print(ans[i])







main()

Measured memory_bytes: 43996
def resolve():
    s = [i for i in input()]
    t = [i for i in input()]
    flag = False
    if s == t:
        flag = True
        print("Yes")
    else:
        for i in range(len(s)):
            s = [s[-1]] + s[:-1]
            if s == t:
                flag = True
                print("Yes")
    if not flag:
        print("No")
resolve()

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

void solve() {
    ll n, d, a;
    cin >> n >> d >> a;
    vector<ii> v(n);
    fori (i, 0, n) cin >> v[i].first >> v[i].second;
    sort(begin(v), end(v));
    priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;
    ll ans = 0;
    ll to_rem = 0;
    fori (i, 0, n) {
        ll x, h;
        tie(x, h) = v[i];
        while (!pq.empty() && pq.top().first < x) {
            to_rem -= pq.top().second;
            pq.pop();
        }
        h -= a * to_rem;
        if (h > 0) {
            ll need = (h + a - 1) / a;
            pq.emplace(x + 2 * d, need);
            ans += need;
            to_rem += need;
        }
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}



Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b && b==c) cout<<"No"<<endl;
    else if(a==b ||b==c ||a==c) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<functional>
#include<queue>
#include<math.h>
#define INF 999999

using namespace std;

int main()
{
	int h[11];

	for (int i = 0; i < 10; i++) {
		cin >> h[i];
	}
	sort(h, h + 10, greater<int>());

	for (int i = 0; i < 3; i++) {
		cout << h[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 3156
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int N;
bool a = false;



int main() {
    cin >> N;
    if ( N% 10 == 7){
        a = true;
    } else if((N/10)%10 == 7){
        a = true;
    } else if((N/100)%10 == 7){
        a = true;
    }
    if ( a){
        cout << "Yes"<<endl;
    } else {
        cout << "No" << endl;
    }
}




Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
# ----------------------------------------------------------------
# ### DEBUG ###
#
# from IPython.core.debugger import Pdb; Pdb().set_trace()
import sys
from math import log2, ceil
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N,K = map(int, lines.pop(0).split(' '))
    res = 0
    for i in range(1,N+1):
        if i > K:
            res += 1/N
        else:
            t = K / i
            c = ceil(log2(t))
            res += 1/N *  (1/2) ** c
    print(res)


#
# main
#

# 1. use list instead of stdin
# 
# contents = '''\
# 3 10
# \
# '''
# lines = contents.split('\n')
# 
# 2. use stdin

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

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

using namespace std;

void rwFile() {
    freopen("INP.inp", "r", stdin);
    freopen("OUT.out", "w", stdout);
}

void solve() {
    int n; cin >> n;
    long double P[n + 1];
    for (int i = 1; i <= n; i++) cin >> P[i];
    long double res[n + 1][n + 1];
    res[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= i; j++) {
            if (j > 0) res[i][j] = res[i - 1][j - 1] * P[i];
            else res[i][j] = 0;
            if (i > j) res[i][j] += res[i - 1][j] * (1 - P[i]);
        }
    }
    
    long double ans = 0;
    for (int i = (n + 1)/2; i <= n; i++) {
        ans += res[n][i];
    }
    cout << fixed << setprecision(10) << ans;
}

int main()
{
    //rwFile();
    solve();
}


Measured memory_bytes: 140928
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  if(N%2 == 0){
    cout << N << endl;
  }else{
    cout << N * 2 << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    private static int a, b;
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        Main ain = new Main();
        Main.a = scan.nextInt();
        Main.b = scan.nextInt();
        if(Main.a < Main.b){
            System.out.println("a < b");
        }
        else if(Main.a > Main.b){
            System.out.println("a > b");
        }
        else{
            System.out.println("a == b");
        }
    }
}




Measured memory_bytes: 26144
from collections import defaultdict, deque
import sys


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


x, a = LI()
print(0 if x < a else 10)


Measured memory_bytes: 3316
#define _USE_MATH_DEFINES
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
#include<climits>
#include<map>
#include<string>
using namespace std;

bool is_prime[ (int)1e6+1 ];

int main(){
	fill_n(is_prime, 1e6+1, true);
	is_prime[0] = is_prime[1] = false;
	for(int i = 2; i <= 1e6; i++){
		if(!is_prime[i]) continue;
		for(int j = 2; i*j <= 1e6; j++) is_prime[i*j] = false;
	}

	int N, X;
	while(cin >> N >> X, N || X){
		int C[30], ans = -1;
		bool dp[ (int)1e6+1 ] = {};
		for(int i = 0; i < N; i++){
			cin >> C[i];
		}
		dp[0] = true;
		for(int j = 0; j < X; j++){
			if(!dp[j]) continue;
			for(int k = 0; k < N; k++){
				if(j + C[k] > X) continue;
				dp[j + C[k]] = true;
				if(is_prime[j + C[k]]) ans = max(ans, j + C[k]);
			}
		}
		if(ans == -1) puts("NA");
		else printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3108
#include<stdio.h>
#define INF 10000000
int min(int,int);
void warshall_floyd(void);

int graph[21][21];
int V;

int main(void){
int i,j,road,a,b,c,d;
int x1,x2,y1,y2;
for(i=0;i<21;i++)
for(j=0;j<21;j++)
graph[i][j]=INF;

scanf("%d",&V);
scanf("%d",&road);
for(i=0;i<road;i++){
scanf("%d,%d,%d,%d",&a,&b,&c,&d);
graph[a][b]=c;
graph[b][a]=d;
}
scanf("%d,%d,%d,%d",&x1,&x2,&y1,&y2);
warshall_floyd();

printf("%d\n",y1-graph[x1][x2]-graph[x2][x1]-y2);

return 0;
}

int min(int x,int y){
return (x>y)?y:x;
}

void warshall_floyd(){
int i,j,k;
for(k=0;k<=V;k++)
for(i=0;i<=V;i++)
for(j=0;j<=V;j++)
graph[i][j]=min(graph[i][j],graph[i][k]+graph[k][j]);
}

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

using namespace std;

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.first <<","<<P.second <<")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int N = 1000005;

int n;
char word[N];
int pot[N];

vector<int> findMarks(int w) {
    if (w == 1) {
        return {1};
    }
    int p = pot[w];
    if ((1 << p) == w) {
        vector<int> ret;
        for (int i = 1; i <= w; i++) {
            ret.push_back(i);
        }
        return ret;
    }
    auto v = findMarks(w - (1 << p));
    auto ret = v;
    for (int x : v) {
        ret.push_back(x + (1 << p));
    }
    return ret;
}

int main(int argc, char* argv[]) {
//     srand(time(0) * atoi(argv[1]));
    
    scanf("%d", &n);
//     n = 2 * (rand() % 10 + 1);
//     n = 20;
    
    pot[1] = 0;
    for (int i = 2; i <= n; i++) {
        pot[i] = pot[i / 2] + 1;
    }
    scanf("%s", &word[1]);
    bool wasOne = false;
    for (int i = 1; i <= n; i++) {
        word[i] -= '0' + 1;
//         word[i] = rand() % 3;
        wasOne |= word[i] == 1;
    }
    
    if (wasOne) {
        for (int i = 1; i <= n; i++) {
            word[i] %= 2;
        }
    }
    
    auto v = findMarks(n);
    int ans = 0;
    for (int x : v) {
        ans ^= word[x];
    }

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


Measured memory_bytes: 6900
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        x: [i64;5],
    }
    for i in 0..5 {
        if x[i] == 0 {
            println!("{}", i + 1);
        }
    }
}


Measured memory_bytes: 2052
/*
 * Problem     : AOJ1174
 * Title       : The Balance of the World (世界の天秤)
 * Author      : mizo0203
 * Copyright   : Your copyright free
 * Description : やるだけ
 */

#include <stdio.h>
#include <memory.h>
#include <algorithm>
using namespace std;

int h, w, c, maxc;
int p[8][8];

bool input() {
  int i, j;

  scanf("%d %d %d", &h, &w, &c);
  if (!h && !w && !c)
    return false;
  for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
      scanf("%d", &p[i][j]);
    }
  }

  return true;
}

void changeColor2(int a[8][8], int x, int y, int b, int c) {

  if (x < 0 || w <= x || y < 0 || h <= y)
    return;
  if (a[y][x] != b)
    return;

  a[y][x] = c;
  changeColor2(a, x + 1, y, b, c);
  changeColor2(a, x, y + 1, b, c);
  changeColor2(a, x - 1, y, b, c);
  changeColor2(a, x, y - 1, b, c);

}

int changeColor3(int a[8][8], int x, int y) {
  int cnt = 0;

  if (x < 0 || w <= x || y < 0 || h <= y)
    return 0;
  if (a[y][x] != c)
    return 0;

  a[y][x] = 0;
  cnt++;

  cnt += changeColor3(a, x + 1, y);
  cnt += changeColor3(a, x, y + 1);
  cnt += changeColor3(a, x - 1, y);
  cnt += changeColor3(a, x, y - 1);

  return cnt;
}

void changeColor1(int a[8][8], int n) {
  int i;
  int tmp[8][8];

  if (n == 4) {
    changeColor2(a, 0, 0, a[0][0], c);
    i = changeColor3(a, 0, 0);
    if (maxc < i)
      maxc = i;
    return;
  }

  memcpy(tmp, a, sizeof(int) * 8 * 8);

  for (i = 1; i <= 6; i++) {
    if (tmp[0][0] == i)
      continue;
    if (i == c && n == 3)
      continue;
    changeColor2(tmp, 0, 0, tmp[0][0], i);

    changeColor1(tmp, n + 1);
    memcpy(tmp, a, sizeof(int) * 8 * 8);
  }
}

int main() {

  while (input()) {
    maxc = 0;
    changeColor1(p, 0);
    printf("%d\n", maxc);
  }

  return 0;
}

Measured memory_bytes: 764
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

ll Pow(ll A, ll B, ll mod){
  if (B == 0) return 1;
  else{
    if (B % 2 == 0){
      return Pow(A * A % mod, B / 2, mod) % mod;
    }else{
      return A * Pow(A * A % mod, B / 2, mod) % mod;
    }
  }
}

ll nCr(ll N, ll C, ll mod){
  ll ans = 1; C = min(C, N - C);
  for (ll i = 1; i <= C; i++){
    ans *= N - i + 1; ans %= mod;
    ans *= Pow(i, mod - 2, mod); ans %= mod;
  }
  return ans;
}

int main(){
  int N, K; cin >> N >> K;
  int P[N];
  for (int i = 0; i < N; i++){
    cin >> P[i];
  }

  double E[N];
  for (int i = 0; i < N; i++){
    E[i] = P[i] + 1; E[i] /= 2;
  }
  
  double ans = 0;
  for (int i = 0; i < K; i++){
    ans += E[i];
  }

  double now = ans;
  for (int i = K; i < N; i++){
    now += E[i] - E[i - K];
    ans = max(ans, now);
  }
  cout << setprecision(16) << ans << endl;
  
  
  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef double db;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ld,ld> pa;
const int N=1e6+5,M=1e7+5,INF=1e9,mod=1e9+7;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
il void gen(){freopen("data.in","w",stdout);}
int n;
int a[4][N];
void die(){puts("No");exit(0);}
int rev[2],b[N],ni[2];
int bit[N];
void add(int x){for(;x<=n;x+=x&(-x))bit[x]^=1;}
int ask(int x){int res=0;for(;x;x-=x&(-x))res^=bit[x];return res;}
int main(){
	read(n);
	rep(i,1,3)rep(j,1,n)read(a[i][j]);
	rep(i,1,n){
		if((a[1][i]-1)/3!=(a[2][i]-1)/3)die();
		if((a[1][i]-1)/3!=(a[3][i]-1)/3)die();
		if(a[2][i]%3!=2)die();
		if(a[2][i]/3%2==i%2)die();
		if(a[1][i]>a[3][i])rev[i&1]^=1;
		b[i]=a[2][i]/3+1;
	}
	int sta=n;if(n&1)sta--;
	for(int i=sta;i>0;i-=2)
		ni[0]^=ask(b[i]),
		add(b[i]);
	sta=n;if(n&1);else sta--;
	clr(bit);
	for(int i=sta;i>0;i-=2)
		ni[1]^=ask(b[i]),
		add(b[i]);
	if(rev[0]!=ni[1]||rev[1]!=ni[0])die();
	puts("Yes");
}

Measured memory_bytes: 14592