akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize(2)
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)

const int maxn = 1 << 19;
int mx[maxn << 1], siz;

void init(int n) {
	for (siz = 1; siz < n; siz <<= 1) ;
	memset(mx, 0, sizeof(mx));
}

void upd(int i, int a, int b, int x, int v) {
	if (a + 1 == b) {mx[i] = v; return ;}
	int m = (a + b) >> 1;
	if (x < m) upd(i << 1, a, m, x, v);
	else upd(i << 1 | 1, m, b, x, v);
	mx[i] = max(mx[i << 1], mx[i << 1 | 1]);
}

int qry(int i, int a, int b, int v, vector <int> &vec) {
	if (mx[i] < v) return v;
	if (a + 1 == b) {vec.pb(a); return mx[i];}
	int m = (a + b) >> 1;
	if (v < mx[i << 1]) v = qry(i << 1, a, m, v, vec);
	if (v < mx[i << 1 | 1]) v = qry(i << 1 | 1, m, b, v, vec);
	return v;
}

struct T {
	int val, fix, siz;
	T *ls, *rs;
	T(int v) {val = v; fix = rand(); siz = 1; ls = rs = NULL;}
	void pu() {siz = (ls ? ls->siz : 0) + 1 + (rs ? rs->siz : 0);}
};

void split(T *x, int v, T *&a, T *&b) {
	if (!x) {a = b = NULL; return ;}
	if (x->val <= v) a = x, split(x->rs, v, a->rs, b), a->pu();
	else b = x, split(x->ls, v, a, b->ls), b->pu();
}

T *merge(T *a, T *b) {
	if (!a || !b) return a ? a : b;
	if (a->fix < b->fix) {a->rs = merge(a->rs, b), a->pu(); return a;}
	else {b->ls = merge(a, b->ls), b->pu(); return b;}
}

int mxv(T *x) {return x ? max(mxv(x->rs), x->val) : 0;}
void prt(T *x) {if (x) prt(x->ls), printf("%d ", x->val), prt(x->rs);}

int n, a[maxn];
T *rt[maxn];

int main() {
//	freopen("in", "r", stdin);
	srand(200);
	scanf("%d", &n);
	for (int i = 0; i < n; ++ i) scanf("%d", &a[i]);
	int m = 0;
	for (int i = 0; i < n; ++ i) {
		if (a[i] < a[i - 1]) m ++;
		rt[m] = merge(rt[m], new T(a[i]));
	}
	int n2 = n * 2; init(n2);
	for (int i = 0; i <= m; ++ i) upd(1, 0, n2, i, mxv(rt[i]));
	for (int i = 0; i <= n; ++ i) {
		vector <int> vec;
		qry(1, 0, n2, 0, vec);
		++ m;
		int v = 0;
		for (int j = 0; j < vec.size(); ++ j) {
			T *a, *b;
			split(rt[vec[j]], v, a, b);
			rt[vec[j]] = a;
			upd(1, 0, n2, vec[j], mxv(a));
			v = mxv(b);
			rt[m] = merge(rt[m], b);
		}
		upd(1, 0, n2, m, mxv(rt[m]));
		if (rt[m]->siz == n) {printf("%d\n", i); break;}
//		for (int j = 0; j <= m; ++ j)
//			prt(rt[j]), putchar(' '); puts("");
	}
//	printf("%.3f\n", clock() * 1.0 / CLOCKS_PER_SEC);
	return 0;
}


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

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

  int t[N] = {0}, x[N] = {0}, y[N] = {0};
  for (int i = 0; i < N; i++) cin >> t[i] >> x[i] >> y[i];

  bool feasible = true;
  for (int i = 0; feasible && i < N; i++) {
    if (t[i] < x[i] + y[i]) feasible = false;
    else {
      int dist = x[i] + y[i];
      if (t[i] % 2 != dist % 2) feasible = false;
    }
  }

  cout << (feasible ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 1408
N = int(input())

position_list = []
for _ in range(N):
    asdf = list(map(int, input().split(' ')))
    position_list.append(asdf)
    if asdf[2] >= 1:
        base_position = asdf

def check_position_diff(position1, position2):
    x = position1[0] - position2[0]
    y = position1[1] - position2[1]
    return x, y

for x in range(102):
    for y in range(102):
        diff_x, diff_y = check_position_diff((x,y), (base_position[0], base_position[1]))
        h = max(abs(diff_x) + abs(diff_y) + base_position[2], 0)
        collect = []
        for position in position_list:
            diff_x, diff_y = check_position_diff((x,y), (position[0], position[1]))
            hx = max(h - abs(diff_x) - abs(diff_y),0)
            collect.append(position[2]==hx)
        if all(collect):
            print(x, y, h)
            exit()
        collect=[]

Measured memory_bytes: 3064
import java.util.*;

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

    int n = sc.nextInt();
    int k = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();

    int yen = (Math.min(k, n) * x) + Math.max(n - k, 0) * y;

    System.out.println(yen);

  }
}

Measured memory_bytes: 21460
import sys

"""テンプレ"""

# 高速
input = sys.stdin.readline

# 1行を空白でリストにする(int)
def intline():
    return list(map(int, input().split()))


# 上のstrヴァージョン
def strline():
    return list(map(str, input().split()))


# 1列に並んだ数
def intlines(n):
    return [int(input() for _ in range(n))]


# 上の文字列ヴァージョン
def lines(n):
    return [input() for _ in range(n)]
    

# Union-Find木  http://at274.hatenablog.com/entry/2018/02/02/173000
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)


# 重み付きのUnion-Find木　http://at274.hatenablog.com/entry/2018/02/03/140504
class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        # 根への距離を管理
        self.weight = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 併合
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            # 木の高さが同じだった場合の処理
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]




"""ここからメインコード"""


a, b, _ = intline()
print(a * b // 2)


Measured memory_bytes: 3192
#include<iostream>
#include<string>
using namespace std;
int main(){
	int cnt;
	string str, tmp_str;
	while(cin>>tmp_str){
		str = str + tmp_str;
	}
	string::iterator sp     = str.begin();
	while(sp != str.end()){
		*sp = tolower(*sp);
		sp++;
	}
	for(int i = 'a'; i <= 'z'; i++){
		cnt=0;
		sp = str.begin();
		while(sp != str.end()){
			if(char(i) == *sp){
				cnt++;
			}
			sp++;
		}
		cout << char(i) << " : " << cnt << endl;;
	}
	return 0;
}

Measured memory_bytes: 1200
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    
    if (a == b) System.out.println(c);
    if (b == c) System.out.println(a);
    if (c == a) System.out.println(b);
  }
}


Measured memory_bytes: 35652
import java.util.*;

class Main {
    static int a;
    static int b;

    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      a = sc.nextInt();    
      b = sc.nextInt();    
      if (a<b) {
          System.out.println("a < b");
      } else if (a>b) {
        System.out.println("a > b");
      } else {
        System.out.println("a == b");
      }
    }
}


Measured memory_bytes: 26172
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

    vint p(a), q(b), r(c);
    rep(i, a) cin >> p[i];
    rep(i, b) cin >> q[i];
    rep(i, c) cin >> r[i];
    sort(rall(p));
    sort(rall(q));
    sort(rall(r));

    priority_queue<int, vint, greater<int>> ra, ga;
    rep(i, x) ra.push(p[i]);
    rep(i, y) ga.push(q[i]);

    rep(i, c) {
        int rs = ra.top();
        int gs = ga.top();
        if (rs < gs) {
            if (rs < r[i]) {
                ra.pop();
                ra.push(r[i]);
            }
            else if (gs < r[i]) {
                ga.pop();
                ga.push(r[i]);
            }
        }
        else {
            if (gs < r[i]) {
                ga.pop();
                ga.push(r[i]);
            }
            else if (rs < r[i]) {
                ra.pop();
                ra.push(r[i]);
            }
        }
    }

    ll ans = 0;
    while(!ra.empty()) {
        ans += ra.top();
        ra.pop();
    }
    while(!ga.empty()) {
        ans += ga.top();
        ga.pop();
    }

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

Measured memory_bytes: 2552
#include "bits/stdc++.h"
using namespace std;


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define sec second
#define fir first
#define pb push_back



/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
//const int inf = pow(2, 62);
//const int mod = 1e9 + 7;
const int mod = 100000;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};



/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
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 (b<a) { a=b; return 1; } return 0; }




/* main */



signed main(){

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

    
    vi arr; rep(i,0,3) arr.push_back(input());

    if(count(all(arr), 5) == 2 && count(all(arr), 7) == 1){
        print("YES");
    }else{
        print("NO");
        
    }


    
    



    
    

    







   




    

    

    




    



    



    

 
    
    


    

    
   
    













}






    










    




    










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

#define int long long 

using namespace std;

#define	mod 			1000000007
#define	inf 			1000000000000000
#define infty			1000000000000000000LL
#define	md				998244353
#define	PI				acos(-1.0)

int beki(int wa,int rr){
    if(rr==0) return 1%mod;
    if(rr==1) return wa%mod;
    wa%=mod;
    if(rr%2==1) return ((int)beki(wa,rr-1)*(int)wa)%mod;
    int zx=beki(wa,rr/2);
    return (zx*zx)%mod;
}

void solve()
{
    int n;cin >> n;
    int a=beki(10,n);
    int b=beki(9,n);
    b*=2;
    int c=beki(8,n);
    int ans=(a+mod-b+mod+c)%mod;
    cout << ans << endl;
}

int32_t main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    //int t;cin >> t;while(t--)
    	solve();

    return 0;
}

Measured memory_bytes: 3624
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <cstdlib>
#include <unordered_map>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007 
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> e;
	vector<int> d;
	REP(i, n) {
		int a;
		cin >> a;
		d.push_back(0);
		e.push_back(a);
	}
	int query;
	cin >> query;
	REP(i, query) {
		int a, b, c;
		cin >> a >> b >> c;
		b--;
		if (a == 1) {
			d[b] += c;
		}
		else {
			d[b] -= c;
		}
		if (!(d[b] >= 0 && d[b] <= e[b])) {
			cout << b + 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	return 0;
}


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

const int MOD = 1e9 + 7;

vector<vector <int> > g;

pair <int, int> dfs(int u, int p) {
    int w = 1, b = 1;
    for (auto v : g[u])
	if (v != p) {
	    auto c = dfs(v, u);
	    w = (1LL * w * (0LL + c.first + c.second) % MOD) % MOD;
	    b = (1LL * b * c.first) % MOD;
	}
    return {w, b};
}

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

    int n;
    cin >> n;

    g.resize(n + 1);
    for(int i = 0; i < n - 1; i++) {
		int u, v; cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
    }

    auto ans = dfs(1, 0);
    cout << (0LL + ans.first + ans.second) % MOD << '\n';
    return 0;
}


Measured memory_bytes: 12672
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

const int MAX = 1000010;
const int MOD = 1000000007;

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

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  COMinit();
  I x,y;
  cin >> x >> y;
  I a,b;
  I c,d;
  if (x == y){
    if (x % 3 == 0){
      c = x / 3;
      d = x / 3;
      cout << COM(c+d,d) << endl;
    }else{
      cout << 0 << endl;
    }
  }else{
    a = abs(x - y);
    b = min(y,x) - a;
    if (b % 3 == 0){
      c = a + b / 3;
      d = b / 3;
      cout << COM(c+d,d) << endl;
    }else{
      cout << 0 << endl;
    }
  }
  return 0;
}



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

int main(){
  int d;
  ll g;
  cin>>d>>g;
  ll vec[d][2];
  for(int i=0;i<d;i++){
    cin>>vec[i][0]>>vec[i][1];
  }
  int vecb[d];
  int ans=10000,pr=0,sc=0;
  for(int bit=0;bit<(1<<d);bit++){
    for(int i=0;i<d;i++){
      if(bit&(1<<i)){
        vecb[i]=1;
      }
      else{
        vecb[i]=0;
      }
    }
    pr=0,sc=0;
    for(int i=0;i<d;i++){
      if(vecb[i]==1){
        pr+=vec[i][0];
        sc+=vec[i][0]*(i+1)*100+vec[i][1];
      }
    }
    if(sc>=g){
      ans=min(pr,ans);
      continue;
    }
    for(int i=d-1;i>=0;i--){
      if(vecb[i]==0){
        pr+=min((g-sc+i*100+99)/(i*100+100),vec[i][0]-1);
        sc+=min((g-sc+i*100+99)/(i*100+100),vec[i][0]-1)*(i+1)*100;
      }
      if(sc>=g){
        ans=min(pr,ans);
        break;
      }
    }
  }
  cout<<ans<<endl;
}

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

using namespace std;

inline long digit_sum(long x)
{
	long res = 0;
	while(x)
	{
		res += x % 10;
		x /= 10;
	}
	return res;
}

inline bool check(long x, long y)
{
	return (x * (digit_sum(y)) <= y * digit_sum(x));
}

long best = 1e15;

void solve(void)
{
	vector<long> ans;
	for (long k = 1e11; k > 0; k /= 10)
	{
		for (long i = 10000; i >= 1001; i--)
		{
			long n = k * i - 1;
			if (check(n, best))
			{
				ans.push_back(n);
				best = n;
			}
		}
	}
	for (long n = 999; n >= 1; n--)
	{
		if (check(n, best))
		{
			ans.push_back(n);
			best = n;
		}
	}
	reverse(ans.begin(), ans.end());
	int k;
	cin >> k;
	for (int i = 0; i < k; i++)
	{
		cout << ans[i] << '\n';
	}
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

using namespace std;

int main()

{
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    

       int i,j,n,x,y;
       cin>>n;
        vector<pair<int,int> >  v;
        for(i=0;i<n;i++){
        	cin>>x>>y;
            v.push_back(make_pair(y,x));
        }
        sort(v.begin(),v.end());
        priority_queue<int> pq;
        
        int t=0,ans=0;
        for(i=0;i<v.size();i++){
            
            if(pq.size()==0){
                if(t+v[i].second<=v[i].first){
                    t+=v[i].second;
                    pq.push(v[i].second);
                }
            }else{
                
                if(t+v[i].second<=v[i].first){
                    t+=v[i].second;
                    pq.push(v[i].second);
                }else{
                    
                    int temp = pq.top();
                    if(temp>v[i].second){
                        pq.pop();
                        pq.push(v[i].second);
                        t=t-temp+v[i].second;
                    }
                    
                }
                
                
            }
            int sz=pq.size();
            ans=max(ans,sz);
            
            
        }

        if(ans==n)cout<<"Yes";
        else cout<<"No";

    return 0;
}

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

typedef long long ll;
typedef pair<string,string> P;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n;
    string s;
    map<P,ll> cnt;
    cin >> n >> s;
    for (int i = 0;i < (1<<n);++i) {
        string k1 = "",k2 = "";
        for (int j = 0;j < n;++j) if ((i>>j)&1) k1 += s[j];
        for (int j = n-1;j >= 0;--j) if (((i>>j)&1)^1) k2 += s[j];
        cnt[P(k1,k2)]++;
    }
    ll ans = 0;
    for (int i = 0;i < (1<<n);++i) {
        string k1 = "",k2 = "";
        for (int j = 0;j < n;++j) if ((i>>j)&1) k1 += s[2*n-j-1];
        for (int j = n-1;j >= 0;--j) if (((i>>j)&1)^1) k2 += s[2*n-j-1];
        ans += cnt[P(k1,k2)];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 91904
#B問題
N,X = map(int,input().split())
L = list(map(int,input().split()))
land = [0]
for i in range(N):
    land.append(land[-1]+L[i])
land.sort()
count = 0
for l in land:
    if l <= X:
        count+=1
        
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>

int main() {
    int n;
    std :: cin >> n;
    n--;
    int64_t cnt = 0;
    
    for(int i = 1 ; i <= n ; i++) {
        cnt += floorl((long double)n / (long double) i);
    }

    std :: cout << cnt << '\n';
}

Measured memory_bytes: 3628
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
"""
n = input()
print("ABC"+n)
"""

#B
n = I()
p = [1]
for i in range(n):
    p.append(p[-1]*2)
    if p[-1] > n:
        print(p[-2])
        quit()
#C
"""
def dijkstra():
    d[0] = 0
    q = [[0,0]]
    while q:
        dx, x = heappop(q)
        for y in v[x]:
            if d[y] > dx+1:
                d[y] = dx+1
                heappush(q,[d[y],y])
n,m = LI()
v = [[] for i in range(n)]
for i in range(m):
    a,b = LI()
    a -= 1
    b -= 1
    v[a].append(b)
    v[b].append(a)
d = [float("inf") for i in range(n)]
dijkstra()
if d[n-1] <= 2:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
"""

#D
"""
k = I()
ans = [i+k//50 for i in range(50)]
k %= 50
for i in range(k):
    ans[i] += 51
    for j in range(50):
        ans[j] -= 1
print(50)
print(*ans)
"""

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 38768
R, G, B, n=map(int, input().split())

r=n//R
g=n//G
b=n//B

cnt=0
for i in range(r+1):
    for j in range(g+1):
        tmp = i*R + j*G
        if (n-tmp)%B == 0 and 0 <= (n-tmp)//B <= b:
            cnt+=1


print(cnt)

Measured memory_bytes: 67040
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N; ll T;

void solve() {
	cin >> N >> T;
	ll p = 0;
	ll res = 0;

	rep(i, 0, N) {
		ll t; cin >> t;
		if(i == 0) continue;
		if(t - p >= T) res += T;
		else res += t - p;
		p = t;
	}
	cout << res + T << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main(){
  string s; cin >> s;
  int ans = 0;
  rep(i, s.size()){
    if(i % 2 == 0){
      if(s[i] == 'p') ans--;
    }
    else{
      if(s[i] == 'g') ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3764
#include<stdio.h>

#define N 2501//2501

int main(){
	int n,a,x[50],i,j,k;
	long long dp[50][51][N]={0},ans=0;
	scanf("%d%d",&n,&a);
	for(i=0;i<n;i++)scanf("%d",&x[i]);
	dp[0][0][0]=1;
	dp[0][1][x[0]]=1;
	for(i=1;i<n;i++){
		for(k=1;k<=i+1;k++){
		for(j=0;j<N;j++){
			dp[i][k-1][j]+=dp[i-1][k-1][j];
			if(x[i]<=j)dp[i][k][j]+=dp[i-1][k-1][j-x[i]];
		}
		}
	}
	/*
	for(k=0;k<n;k++){
	for(j=1;j<=n;j++){
	for(i=0;i<N;i++)printf("%lld,",dp[k][j][i]);
		puts("");
		}
		puts("ok");
		}
		*/
	for(i=1;i<=n;i++)ans+=dp[n-1][i][a*i];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 50048
#include "bits/stdc++.h"
using namespace std;

int main() {
	string S;
	cin >> S;
	if (("a" == S) || ("i" == S) || ("u" == S) || ("e" == S) || ("o" == S)) {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}
	return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;


int main()
{
    int x, n, i;
    while(scanf("%d", &x) != EOF)
    {
        n = 0;
        for(i = 1; n < x; i++)
        {
            n += i;
        }
        printf("%d\n", i - 1);
    }
    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/nomura2020/tasks/nomura2020_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

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

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

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

#ifndef TEST
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N;
  cin >> N;

  VL as(N + 1);
  rep(i, N + 1) cin >> as[i];

  VL rev_acc(N + 1);
  repr(i, N + 1) { rev_acc[i] = as[i] + (i < N ? rev_acc[i + 1] : 0); }

  if (N == 0) {
    ll res = as[0] == 1 ? 1 : -1;
    drop(res);
  }

  unless(as[0] == 0) drop(-1);

  ll prev_non_leaf_ct = 1;
  ll res = 1;

  rep1(i, N) {
    ll ma = min(2 * prev_non_leaf_ct, rev_acc[i]);
    unless(as[i] <= ma) drop(-1);

    res += ma;
    prev_non_leaf_ct = ma - as[i];
  }

  cout << res << "\n";
}


Measured memory_bytes: 4744
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "

const int MXN = 3005;
LL dp[MXN][MXN]; // dają sume 
int mod = 998244353; 
LL inv = 998244354 / 2;

int main()
  {
  ios_base::sync_with_stdio(0); 
  int n, s;
  cin >> n >> s;

  LL pot2 = 1;
  dp[0][0] = 1;

  assert(inv * 2 % mod == 1);

  FOR(i, 1, n)
    {
    int a;
    cin >> a;
    FOR(j, 0, s)
      {
      dp[i][j] = dp[i-1][j];
      }
    FOR(j, a, s)
      {
      dp[i][j] += dp[i-1][j-a] * inv % mod;
      dp[i][j] %= mod;
      }
    
    }
  LL res = dp[n][s];
  REP(i, n)res = res * 2 % mod;
  cout << res << endl;
  }


Measured memory_bytes: 74020
#include <bits/stdc++.h>
#include <string.h>
#define rep(i, n) for(int i = 0; i<(n); i++)
using namespace std;
typedef long long ll;
static const int MAX = 200000; 
//pi = 3.14159265358979323846

int main() {

    int n;
    cin >> n;
    int b[MAX];

    rep(i, n - 1) cin >> b[i];

    int a[MAX];
    rep(i, n){
        a[i] = min(b[i], b[i - 1]);
        if(i == 0) a[i] = b[i];
        if(i == n - 1) a[i] = b[i - 1];
    }

 //   rep(i, n) cout << a[i] << "#" ;
    int ans = 0;
    rep(i, n + 1) ans += a[i];
    cout << ans << endl;

}



Measured memory_bytes: 256
def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

s = gets.chomp
ans = 1e20
(s.size-2).times do |i|
  k = s[i,3].to_i
  k = (753 - k).abs
  ans = [k,ans].min
end
p ans

Measured memory_bytes: 1788
import java.util.*;

public class Main{
    public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
   	
    int a = sc.nextInt();
    String s = sc.next();    
  	
    if(a<3200){
    	System.out.println("red");
    }else{
    	System.out.println(s);
    }    
    
    }
}

Measured memory_bytes: 21716
<?php
list($n,$m,$x,$y) = explode(" ",trim(fgets(STDIN)));
$l = explode(" ",trim(fgets(STDIN)));
$r = explode(" ",trim(fgets(STDIN)));
$a = max($l);
$b = min($r);
if($a<$b&&$b>$x){
  $z = $a+1;
  while($z<=$b){
    if($z>$a&&$z<=$y){
      echo "No War";
      exit;
    }
    ++$z;
  }
  if($z>=$b){
    echo "War";
  }
}else{
  echo "War";
}

Measured memory_bytes: 4856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

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

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
#define guard(x) if( not ( x ) ) continue;
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

template<typename T>
struct Maybe {
   T x;
   bool valid;
   Maybe() : valid(false) {}
   Maybe(T x_) : x(x_), valid(true) {}
   operator T() const {
      assert( valid );
      return x;
   }
};

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      std::string ss;
      if( not std::getline(std::cin, ss) ) exit(0);
      puts(ss[0]==ss[2] ? "=" : ss[0] > ss[2] ? ">" : "<");
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
  int N;
  cin >>N;
  
  vector<int> a(N);
  for (int i=0;i<N;i++){
    cin >> a[i];
  }
  
  int suma=0,sumb=0;
  
  sort(a.begin(),a.end());
  
  if (N%2==0){
    for(int i=0;i<N;i += 2){
      sumb += a[i];
      suma += a[i+1];
    }
  }
  else{
    suma += a[0];
     for(int i=1;i<N;i += 2){
      sumb += a[i];
      suma += a[i+1];
    }
    
  }
   cout << suma-sumb << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int inf = 1000000000;


int main(void) {
  int n;
  cin >> n;
  vector<int> m(n);
  vector<int> d(n);
  vector<int> v(n);
  vector<int> s(n);
  vector<int> c(12 * 30, 0);
  for(int i=0; i<n; i++){
    cin >> m[i] >> d[i] >> v[i] >> s[i];
    m[i]--; d[i]--;
    int tmp = m[i] * 30 + d[i];
    for(int j=tmp; j<tmp+v[i]; j++){
      if( j < 0 ) c[(720+j)%360] = max(c[(720+j)%360], s[i]);
      else if( j >= 360 ) c[j%360] = max(c[(j)%360], s[i]);
      else c[j] = max(c[j], s[i]);
    }
    for(int j=1; j<=s[i]; j++){
      if( tmp - j < 0 ) c[(720+tmp-j)%360] = max({0, c[(720+tmp-j)%360], s[i]-j});
      else if( tmp - j >= 360 ) c[(tmp-j)%360] = max({0, c[(tmp-j)%360], s[i]-j});
      else c[tmp-j] = max({0, c[tmp-j], s[i]-j});
    }
    for(int j=0; j<s[i]; j++){
      if( tmp+v[i]+j < 0 ) c[(720+tmp+v[i]+j)%360] = max({0, c[(720+tmp+v[i]+j)%360], s[i]-j-1});
      else if( tmp+v[i]+j >= 360 ) c[(tmp+v[i]+j)%360] = max({0, c[(tmp+v[i]+j)%360], s[i]-j-1});
      else c[tmp+v[i]+j] = max({0, c[tmp+v[i]+j], s[i]-j-1});
    }
  }

  cout << *min_element(c.begin(), c.end()) << endl;


  return 0;
}

// EOF

Measured memory_bytes: 3092
N, M = map(int, input().split())

goal = [0] * (N + 1)
wrong = [0] * (N + 1)
ans = [0, 0]

for i in range(M):
  p, s =  map(str, input().split())
  if goal[int(p)] == 0:
    if s == "AC":
      ans[0] += 1
      ans[1] += wrong[int(p)]
      goal[int(p)] = 1
    else:
      wrong[int(p)] += 1
      
print(ans[0], ans[1])


Measured memory_bytes: 4596
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
const int N=100010;
bool cmp(int a,int b){return a>b;}
int s[N],n;
bool check()
{
	int ind=1,dnd;
	while(s[ind+1]>=ind+1 && ind<n)ind++;
//	printf("ind = %d\n",ind);

	for(dnd=ind;dnd<n && s[dnd+1]==ind;dnd++);

	return ((s[ind]-ind)&1) || ((dnd-ind)&1);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",s+i);
	std::sort(s+1,s+n+1,cmp);
	printf("%s\n",check()?"First":"Second");
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <numeric>
#include <utility>
#include <iomanip>

using namespace std;
using int64 = long long;

struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b, bb;
    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        if (i%2) bb.push_back(a);
        else b.push_back(a);
    }
    if (n%2 == 0) {
        auto tmp = b;
        b = bb;
        bb = tmp;
    }
    for (int i=b.size()-1; i>=0; i--) {
        cout << b[i];
        if (i==0 && bb.size()==0) cout << endl;
        else cout << " ";
    }
    for (int i=0; i<bb.size(); i++) {
        cout << bb[i];
        if (i==bb.size()-1) cout << endl;
        else cout << " ";
    }
}


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

// クエリの範囲を、開始位置でソート
// 開始位置が左端のクエリ(A0,B0)から順に貪欲に求める
// 開始位置が左端のクエリに対応できる範囲で、一番他のクエリを巻き込めるのは
// B0 （のすぐ左）の橋を落とすこと。
// なので、まずはこの A0 を落とす位置 r としてループを進める。
// Bn < r というクエリnが出てきた場合
//	r では現在のクエリnは満たせないので、r = Bn として r の位置を変更する。
//	現在よりも手前のクエリに関しては、Bn > An で、An はソートされているので、
//	その変更をしてもクエリは満たされたまま。
// r <= An というクエリnが出てきた場合
//	r ではこれ以上満たせるクエリが無いってことなので、現在みている An,Bn を
//	新たな左端クエリとして扱って、r = Bn として、落とす橋数をインクリメント


int main() {
  int N,M;
  cin >> N >> M;
  vector< pair<int,int> > ab(M);
  REP(i,M) {
    cin >> ab[i].first >> ab[i].second;
  }
  sort(ab.begin(), ab.end());
  int r = ab[0].second;
  int ans = 1;
  REP(i,M) {
    if ( ab[i].second < r ) { r = ab[i].second; }
    if ( ab[i].first >= r ) { 
      ans++;
      r = ab[i].second;
    }
//    cout << i << " : " << ab[i].first << " "  << ab[i].second << " : " << r << " " << ans << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifdef LOCAL
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#else
#define debug(x) ;
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

ll dp[1010][1010];

int main(){
  int h, w;
  char mass[1010][1010];

  scanf("%d%d", &h, &w);

  for(int i=0;i<h;i++){
    scanf("%s", mass[i]);
  }

  dp[0][0] = 1;

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(i < h-1 && mass[i+1][j] == '.') (dp[i+1][j] += dp[i][j]) %= mod;
      if(j < w-1 && mass[i][j+1] == '.') (dp[i][j+1] += dp[i][j]) %= mod;
    }
  }

  cout << dp[h-1][w-1] << endl;

  return 0;
}


Measured memory_bytes: 9088
/*Arnab's Code
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define vll vector<ll>
#define vii vector<int>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define take(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define takes(a,n,st) for(ll i=st;i<n+st;i++)cin>>a[i]
ll sum(ll a[],ll n,ll s){ for(ll i=0;i<n;i++)s+=a[i]; return s;}
#define mod 1000000009
ll power(ll x, ll y, ll p)  {  
    ll res = 1;  
    x = x % p;   
    if (x == 0) return 0;  
    while (y > 0){  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
ll a[100017];
ll x[100017];
void solve(){
	ll n,i,q,b,c,tot;
	cin>>n;
	for(i=0;i<100017;i++)
		x[i]=0;
	take(a,n);
	for(i=0;i<n;i++){
		x[a[i]]++;
	}
	tot=sum(a,n,0);
	cin>>q;
	for(i=0;i<q;i++){
		cin>>b>>c;
		tot-=(b*x[b]);
		tot+=(c*x[b]);
		x[c]+=x[b];
		x[b]=0;
		cout<<tot<<endl;
	}
//	for(i=0;i<100017;i++){
//		tot+=(i*x[i]);
//	}
//	cout<<tot;
	return;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ll t,T;
//	cin>>T;
	T=1;
	for(t=1;t<=T;t++){
//		cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 5148
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 1000005;
const int mod = 1000000007;

int f[maxn][2];

void pd(int &ret, int val){
  if(ret==-1||ret>val)ret=val;
}

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  string s;
  cin>>s;
  reverse(s.begin(),s.end());
  int n = s.size();
  memset(f,-1,sizeof(f));
  f[0][0] = 0;
  for(int i=0;i<n;i++)
    for(int j=0;j<2;j++){
      if(f[i][j]==-1)continue;
      for(int k=0;k<10;k++){
        int tt = k + j + s[i] - '0';
        pd(f[i+1][tt>=10], f[i][j] + k + tt % 10);
      }
    }
  cout<<min(f[n][0],f[n][1] + 1)<<endl;
  return 0;
}

Measured memory_bytes: 9220
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <math.h>
#include <vector>
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <algorithm>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define N 100010
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair
#define inf 1000000007
#define mod 1000000007
#define pii pair <int, int>
#define all(x) x.begin(), x.end()
#define FOR(i, x, y) for (int i = x; i <= y; i++)
//#define tr(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

//using namespace __gnu_pbds;

using namespace std;

//template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

string s, t;
string ar[100];

int main()
{
	cin >> s >> t;
	int n = s.length();
	int m = t.length();
	
	int in = 0;
	for(int i=0; i < n-m+1; i++) {
		bool ok = 0;
		
		for(int h=0; h < m; h++)
			if(s[i+h] != t[h] && s[i+h] != '?')
				ok = 1;
		
		if(ok == 0) {
			ar[++in] = s;
			
			for(int h=i; h < i+m; h++)
				ar[in][h] = t[h-i];
			
			for(int h=0; h < n; h++)
				if(ar[in][h] == '?')
					ar[in][h] = 'a';
			
//			cout << ar[in] << "\n";
		}
	}
	
	if(in == 0) {
		cout << "UNRESTORABLE";
		return 0;
	}
	
	sort(ar+1, ar+in+1);
	cout << ar[1] << "\n";
//	for (int i = 1; i <=in; i++)
//		cout << ar[i] << "\n";
}

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

int main()
{
  int A,B,C,D,E,F ;
  cin>>A>>B>>C>>D>>E>>F ;
  
  /*操作1:水100*Ag入れる
    操作2:水100*Bg入れる
    操作3:砂糖Cg入れる
    操作4:砂糖Dg入れる
    ・水100gあたりEg砂糖が溶ける　・ビーカーに入れられる物質の質量がFg以下*/

  /*suger*100<=E*water*/
  //水x[g]:100*A*i+100*B*j
  //砂糖y[g]:C*k+D*l
 
  vector<float>Water ;
  for(int i=0;100*A*i<=F;i++){
    for(int j=0;100*(A*i+B*j)<=F;j++){
      if(i==0&&j==0) continue ;
      Water.push_back(100*(A*i+B*j)) ;
    }
  }
  
  int flag=0 ;
  float water,suger,ans_water,ans_suger ;
  float dense,max_dense=0 ;
  for(int i=0;i<Water.size();i++){
    water=Water.at(i) ;
    for(int j=0;C*j<=F-water;j++){
      for(int k=0;C*j+D*k<=F-water;k++){
        suger=C*j+D*k ;
        if(E*water<100*suger) continue ;
        else{
          flag=1 ;
          dense=(100*suger)/(water+suger) ;
          if(dense>=max_dense){
            max_dense=dense ;
            ans_water=water ;
            ans_suger=suger ;
          }
        }
      }
    }
  }
  if(flag==0) cout<<Water.at(0)<<" "<<0<<endl ;
  else cout<<ans_water+ans_suger<<" "<<ans_suger<<endl ;
  
  return 0 ;
}

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

const int N = 1e5 + 5;
int n;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int a,b;
    cin >> a >> b;
    cout << max({a+b, a-b, a*b}) << "\n";
    
    
    return 0;
}


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

// マクロ
// forループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(ll)(b);i--)
// xにはvectorなどのコンテナ
#define ALL(x) (x)begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
// 出力
#define PRINT(x) cout<<(x)<<endl
#define PRINTA(x,n) REP(i,n)PRINT(x[i])
// 定数
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
// 略記
#define PB push_back
#define MP make_pair



int main() {
    int a, b;
    cin >> a >> b;
    PRINT(a*b);
    return 0;
}

Measured memory_bytes: 3632