akhauriyash/Code-Regression huggingface dataset:
s = input()
q = int(input())
inv = False
left =''
right = ''

for i in range(1, q+1):
    try:
        t, f, c = input().split()
    except ValueError:
        t = '1'
    if t == '1':
        inv = not inv
    else:
        if inv:
            if f == '1':
                right = right + c
            else:
                left = c + left
        else:
            if f == '1':
                left = c + left
            else:
                right = right + c
#     print('%s, %s, %s, %s, %s' %(left, right, inv, t, f))

# # print(left)
# # print(right)
if inv:
    right = right[::-1]
    left = left[::-1]
    s = s[::-1]
    print(right + s + left)
else:
    print(left + s + right)

Measured memory_bytes: 4444
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
 
using namespace std;
 
#define MAX_N 8
#define MAX_M 30
#define INF (1<<29)
 
int N,M,a,b,t[MAX_N];
int d[MAX_M][MAX_M];
double dp[1<<MAX_N][MAX_M];
 
void solve(){
    for(int i = 0 ; i < 1<<N ; i++){
	fill(dp[i],dp[i]+M,INF);
    }
    dp[(1<<N)-1][a-1] = 0;
    double res = INF;
    for(int S = (1<<N)-1 ; S >= 0 ; S--){
	res = min(res,dp[S][b-1]);
	for(int v = 0 ; v < M ; v++){
	    for(int i = 0 ; i < N ; i++){
		if(S >> i & 1){
		    for(int u = 0 ; u < M ; u++){
			if(d[v][u] >= 0){
			    dp[S & ~(1<<i)][u] = min(dp[S & ~(1<<i)][u],
						     dp[S][v]+(double)d[v][u]/t[i]);
			}
		    }
		}
	    }
	}
    }
    if(res == INF){
	puts("Impossible");
    }else{
	printf("%.3f\n",res);
    }
}
 
int main(){
    int p;
    while(true){
	scanf("%d%d%d%d%d",&N,&M,&p,&a,&b);
	if(!N && !M && !p && !a && !b) break;
	memset(d,-1,sizeof(d));
	for(int i = 0 ; i < N ; i++){
	    scanf("%d",&t[i]);
	}
	for(int i = 0 ; i < p ; i++){
	    int x,y,z;
	    scanf("%d%d%d",&x,&y,&z);
	    d[x-1][y-1] = d[y-1][x-1] = z;
	}
	solve();
    }
    return 0;
}

Measured memory_bytes: 3184
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<string>
#include<string.h>
using namespace std;

class dice{
public:
	int a[7];
	int b;
	void moveN(){
		b = a[1];
		a[1] = a[2];
		a[2] = a[6];
		a[6] = a[5];
		a[5] = b;
	}
	void moveE(){
		b = a[3];
		a[3] = a[1];
		a[1] = a[4];
		a[4] = a[6];
		a[6] = b;
	}
	void moveW(){
		b = a[1];
		a[1] = a[3];
		a[3] = a[6];
		a[6] = a[4];
		a[4] = b;
	}
	void moveS(){
		b = a[2];
		a[2] = a[1];
		a[1] = a[5];
		a[5] = a[6];
		a[6] = b;
	}
	void spinR(){
		b = a[2];
		a[2] = a[4];
		a[4] = a[5];
		a[5] = a[3];
		a[3] = b;
	}
	void spinL(){
		b = a[2];
		a[2] = a[3];
		a[3] = a[5];
		a[5] = a[4];
		a[4] = b;
	}
};
int main(){
	dice A[101];
	int n;
	int exa = 0;
	cin >> n;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= 6; j++){
			cin >> A[i].a[j];
		}
	}
	for (int x = 1; x <= n; x++){
		for (int y = 1; y <= n; y++){
			if (x == y){
				continue;
			}
			int dif = 0;
			for (int i = 1; i <= 6; i++){
				int judge = 0;
				if (A[x].a[1] == A[y].a[i]){
					if (A[x].a[6] == A[y].a[7 - i]){
						if (i == 2){
							A[y].moveN();
						}
						if (i == 3){
							A[y].moveW();
						}
						if (i == 4){
							A[y].moveE();
						}
						if (i == 5){
							A[y].moveS();
						}
						if (i == 6){
							A[y].moveN();
							A[y].moveN();
						}
						for (int j = 1; j <= 4; j++){
							for (int k = 2; A[x].a[k] == A[y].a[k] && k <= 5; k++){
								judge++;
							}
							if (judge == 4){
								exa++;
								break;
							}
							else{
								judge = 0;
								A[y].spinL();
							}
						}
					}
				}
				if (judge < 4){
					dif++;
					if (dif == 6){
						break;
					}
				}
			}
		}
	}
	if (exa >= 2){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 3116
n = int(input())
e = [0] * (n+1)

# 素因数分解する  
for i in range(2, n+1):
    cur = i
    for j in range(2, i+1):
        # ひたすら割り算を繰り返す
        # 2で割り続ければ、4で割ろうとした時には2で割れない数になっている
        # 自動的に素因数分解ができる
        while cur % j == 0:
            e[j] += 1
            cur //= j

def num(m):
    return len([i for i in e if i >= m-1])

print(num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1) \
      + num(5) * (num(5) - 1) * (num(3) - 2) // 2)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
int dh[4] = {-1, 0, 0, 1};
int dw[4] = {0, -1, 1, 0}; 
using P = pair<int, int>;
const double pi = acos(-1.0);

using Graph = vector<vector<ll>>;

int main(){
  string s;
  cin>>s;

  vector<int>a(26);
  rep(i,s.size()){
    a[s[i]-'a']++;
  }
  rep(i,26){
    if(a[i]>1){cout<<"no"<<endl;return 0;}
  }

  cout<<"yes"<<endl;
    
  return 0;
}


Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str;
		String[] strArray;
		int n;
		double p[] = new double[3];

		str = br.readLine();

		n = Integer.parseInt(str);

		if(n <= 1000){
			for(int i=0; i<n; i++){
				str = br.readLine();

				strArray = str.split(" ");

				for(int j=0; j<strArray.length; j++){
					p[j] = Double.parseDouble(strArray[j]);
				}

				Arrays.sort(p);

				if((Math.pow(p[0], 2) + Math.pow(p[1], 2)) == Math.pow(p[2], 2) ){
					System.out.println("YES");
				}else{
					System.out.println("NO");
				}

			}
		}
	}
}

Measured memory_bytes: 22368
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,X;
  cin >> N >> X;
  
  int sum = 0;
  int count = 0;
  vector<int> m(N);
  for(int &x : m){
    cin >> x;
    sum += x;
  }
  
  X -= sum;
  count = N;
  sort(m.begin(),m.end());
  
  for (int i = 0; i<N; i++){
    while(X >= m.at(i)){
      X -= m.at(i);
      count++;
    }
  }
  
  cout << count << endl;
  return 0;
}

    

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int a,b;
    char op;
    while(1){
        cin>>a>>op>>b;
        if(op=='?'){
            break;
        }
        else if(op=='+'){
            cout<<a+b<<endl;
        }
        else if(op=='-'){
            cout<<a-b<<endl;
        }
        else if(op=='*'){
            cout<<a*b<<endl;
        }
        else{
            cout<<a/b<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3068
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  int A[N];
  for(int i=0;i<N;i++) cin >> A[i];
  sort(A,A+N);
  reverse(A,A+N);

  vector<ll> ans;
  int cnt = 1;
  for(int i=1;i<N;i++){
    if(A[i]==A[i-1]) cnt++;
    else cnt = 1;

    if(cnt >= 2){
      ans.push_back(A[i]);
      cnt = 0;
    }

    if(ans.size() == 2) break;
  }

  if(ans.size()!=2){
    cout << 0 << endl;
  } else {
    cout << ans[0] * ans[1] << endl;
  }
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long int;
const int MAX = 510000;
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() {

  int S;
  cin >> S;

  COMinit();

  ll ans = 0;
  for (int i = 1; i <= S / 3; i++) {
    ans += COM(S - 2 * i - 1, S - 3 * i);
    ans %= MOD;
    if (ans < 0) ans += MOD;
  }

  cout << ans << endl;
}

Measured memory_bytes: 15520
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) max_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)

char maze[105][105];
int N, M;
int sx, sy;//start
int gx, gy;//goal

int d[105][105];//各pointまでの最短距離

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

//startが大量にある場合
//https://atcoder.jp/contests/qupc2018/tasks/qupc2018_c

int bfs(){
    queue<i_i> que;
    rep(i,N) rep(j,M) d[i][j] = INF;//初期化
    que.push(i_i(sx,sy));  //que->start
    d[sx][sy] = 0; //startは距離0

    //queが空になるまでloop
    while(que.size()){
        //queの先頭を取りだす
        i_i p = que.front(); que.pop();
        //getがgoalならend
        if(p.fs == gx and p.sc == gy) break;

        rep(i,2) {
            int nx = p.fs + dx[i];
            int ny = p.sc + dy[i];
            if(0 <= nx and nx < N and 0 <= ny and ny < M){
                if(d[p.fs][p.sc] >= d[nx][ny]) continue;
                if(maze[p.fs][p.sc] == '#' and maze[nx][ny] == '.') {
					if(d[p.fs][p.sc] < d[nx][ny]) {
						d[nx][ny] = d[p.fs][p.sc];
						que.push(i_i(nx,ny));
					}
                    else continue;
				}
				else if(maze[p.fs][p.sc] == '.' and maze[nx][ny] == '#') {
					if(d[p.fs][p.sc] + 1 < d[nx][ny]) {
						d[nx][ny] = d[p.fs][p.sc] + 1;
						que.push(i_i(nx,ny));
					}
                    else continue;
				}
				else {
					d[nx][ny] = d[p.fs][p.sc];
					que.push(i_i(nx,ny));
				}
               //cout << nx << " " << ny << " " << d[nx][ny] << endl;
            }
        } 
    }
    return d[gx][gy];
}

//AGC033A

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

    cin >> N >> M;
    rep(i,N) rep(j,M) {
        cin >> maze[i][j];
    }
	sx = 0; sy = 0;
	gx = N - 1; gy = M - 1;
	int ans = bfs();
	if(maze[0][0] == '#') ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
S=list(input())
n=len(S)-1
a=0
while n>=0:
  if S[n]=="m":
    if n<4:
      a=1
      break
    if S[n-4:n+1]==["d","r","e","a","m"]:
      n=n-5
    else:
      a=1
      break
  elif S[n]=="e":
    if n<4:
      a=1
      break
    if S[n-4:n+1]==["e","r","a","s","e"]:
      n=n-5
    else:
      a=1
      break
  elif S[n]=="r":
    if n<5:
      a=1
      break
    if n==5:
      if S[0:n+1]==["e","r","a","s","e","r"]:
        n=n-6
    else:
      if S[n-5:n+1]==["e","r","a","s","e","r"]:
        n=n-6
      elif S[n-6:n+1]==["d","r","e","a","m","e","r"]:
        n=n-7
      else:
        a=1
        break
  else:
    a=1
    break
if a==0:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 4084
/*
读题不规范，爆零两行泪。
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define X first
#define Y second
const int N=2000;
int n;
int a[3*N+1];
int dp[N+1][N+1];
int mx_r[N+1],mx_c[N+1];
bool added;
int real_dp(int x,int y){return max(dp[x][y],max(mx_r[x],mx_c[y]))-added;}
vector<pair<int*,int> > chg;
void chkmx(int &x,int y){chg.pb(mp(&x,y));}
int main(){
	cin>>n;
	for(int i=1;i<=3*n;i++)scanf("%d",a+i);
	reverse(a+1,a+3*n+1);
//	for(int i=1;i<=3*n;i++)cout<<a[i]<<" ";puts("");
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)dp[i][j]=a[1]==i&&i==j;
	int add=0;
	for(int i=2;i<=n;i++){
		if(a[3*i-4]==a[3*i-3]&&a[3*i-3]==a[3*i-2])add++,added=true;
		else added=false;
		chg.clear();
		for(int j=3*i-4;j<=3*i-2;j++){
			vector<int> v;
			for(int k=3*i-4;k<=3*i-2;k++)if(k!=j)v.pb(a[k]);
			for(int k=1;k<=n;k++)chkmx(mx_r[k],real_dp(v[0],v[1]));
			chkmx(dp[a[j]][a[j]],real_dp(v[0],v[1])+1);
		}
		for(int j=1;j<=n;j++){
			for(int k=3*i-4;k<=3*i-2;k++){
				chkmx(mx_r[j],real_dp(j,a[k])),chkmx(mx_c[j],real_dp(j,a[k]));
				vector<int> v;
				for(int o=3*i-4;o<=3*i-2;o++)if(o!=k)v.pb(a[o]);
				if(v[0]==v[1])chkmx(dp[j][v[0]],real_dp(j,a[k])+1),chkmx(dp[v[0]][j],real_dp(j,a[k])+1);
			}
		}
		for(int j=0;j<chg.size();j++)*chg[j].X=max(*chg[j].X,chg[j].Y);
	}
	added=false;
	cout<<real_dp(a[3*n],a[3*n-1])+add;
	return 0;
}

Measured memory_bytes: 19628
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define mod 1e9+7

int main(){
      ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);
       ll n,wt;
        cin>>n>>wt;
        vector<ll >dp(wt+1);
        ll k=1;
          while(k!=n+1){
			 
	       k++;
		  ll v,w;
		  cin>>w>>v;
		 
		  for(ll  i=wt-w; i>=0; i--){
		     dp[i+w]=max(dp[i+w],dp[i]+v);
		  }
		    
		  }
		  cout<<dp[wt]<<endl;
         
    }

// a  A  z  Z  q  Q  !  1 


Measured memory_bytes: 1024
#include<iostream>
#include<string>

using namespace std;

string s;

int main()
{
    cin>>s;
    int l=s.size();
    for(int i=0;i<l;i++) if(s[i]=='C')
        for(int j=i+1;j<l;j++)
                if(s[j]=='F')
                {
                    cout<<"Yes\n";
                    return 0;
                }
    cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <assert.h>
#include <sys/time.h>
#include <fstream>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define REP(i,n)  FOR(i,0,n)
#define each(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define deb(x) cerr << #x << " = " << (x) << " , ";
#define debl cerr << " (L" << __LINE__ << ")"<< endl;
#define sz(s) (int)((s).size())


#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizeof(a))
#define pb push_back
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define MP(x,y) make_pair((x),(y))

double pi=3.14159265358979323846;

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

template<typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& z){
	os << "[ ";
	REP(i,z.size())os << z[i] << ", " ;
	return ( os << "]" << endl);
}

template<typename T> std::ostream& operator<<(std::ostream& os, const set<T>& z){
	os << "set( ";
	EACH(p,z)os << (*p) << ", " ;
	return ( os << ")" << endl);
}

template<typename T,typename U> std::ostream& operator<<(std::ostream& os, const map<T,U>& z){
	os << "{ ";
	EACH(p,z)os << (p->first) << ": " << (p->second) << ", " ;
	return ( os << "}" << endl);
}

template<typename T,typename U> std::ostream& operator<<(std::ostream& os, const pair<T,U>& z){
	return ( os << "(" << z.first << ", " << z.second << ",)" );
}

double get_time(){
	struct timeval tv;
	gettimeofday(&tv, NULL);
	return tv.tv_sec + tv.tv_usec*1e-6;
}

typedef unsigned int uint32_t;
struct RND{
	uint32_t x;
	uint32_t y;
	uint32_t z;
	uint32_t w;
	RND(){
		x=123456789;
		y=362436069;
		z=521288629;
		w=88675123;
	}
	void init(int seed){
		x=123456789;
		y=362436069;
		z=521288629;
		w=seed+100;
		REP(i,10)get();
	}
	uint32_t get(){
		uint32_t t;
		t=x^(x<<11);
		x=y;y=z;z=w;
		w=(w^(w>>19))^(t^(t>>8));
		return w;
	}
};
RND rnd;

ll f(ll n, ll k){
	while(true){
		if(n<k)return 0;
		if(n%k==0)return n/k;
		ll m = n/k+1;
		ll d = (n - (n/k*k+1) )/m + 1;
		n -= m*d;
	}
}

void _main(istream &inp){
	ll N;
	inp >> N;
	ll ret = 0;
	rep(i,N){
		ll A,K;
		inp >> A >> K;
		ret ^=( f(A,K) );
	}
	if(ret==0){
		cout << "Aoki" << endl;
	}
	else{
		cout << "Takahashi" << endl;
	}
}

int main(){
	if(0){
		ifstream ifs("test.txt");
		_main(ifs);
	}
	else{
		_main(cin);
	}
	return 0;
}


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

const int N = 1e5 + 233;

int n, h, A[N], B[N], C[N], D[N];
int out[N], in[N], fa[N], vis[N];

int find(int x) {
  return x == fa[x] ? x : fa[x] = find(fa[x]);
}

inline bool check() {
  for (int i = 0; i < h; ++i)
    if (in[i] > out[i]) return 0;
  for (int i = 1; i <= h; ++i)
    if (in[i + h] < out[i + h]) return 0;
  for (int i = -h; i <= h; ++i)
    if ((!in[i + h] && !out[i + h]) || (in[i + h] != out[i + h]))
      vis[find(i + h)] = 1;
  for (int i = -h; i <= h; ++i)
    if (!vis[find(i + h)]) return 0;
  return 1;
}

int main() {
  scanf("%d %d", &n, &h);
  for (int i = 0; i <= h * 2 + 5; ++i)
    fa[i] = i;
  for (int i = 1; i <= n; ++i) {
    scanf("%d %d %d %d", A + i, B + i, C + i, D + i);
    int x = C[i] == 0 ? h - A[i] : h + C[i];
    int y = D[i] == 0 ? h + B[i] : h - D[i];
    ++out[x], ++in[y];
    x = find(x), y = find(y);
    if (x != y) fa[x] = y;
  }
  puts(check() ? "YES" : "NO");
  return 0;
}



Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int posA = -1;
    int posC = -1;
    for(int i = 0; i < s.length(); i++){
        if(isupper(s[i])){
           if((s[i]!='A')&&(s[i]!='C')){
               cout << "WA" << endl;
               return 0;
           }
            if(s[i]=='A'){
                if(posA==-1){
                    posA=i;
                }else{
                    cout << "WA" << endl;
                    return 0;
                }
            }
            if(s[i]=='C'){
                if(posC==-1){
                    posC=i;
                }else{
                    cout << "WA" << endl;
                    return 0;
                }
            }
        }
    }
    if(posA!=0){
        cout << "WA" << endl;
        return 0;
    }
    if((posC>=2)&&(posC<=s.length()-2)){
        cout << "AC" << endl;
        return 0;
    }
    cout << "WA" << endl;
    return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n, k; std::cin >> n >> k;
  int ans = 0;
  rep(i, n) {
    int x; std::cin >> x;
    ans += min(abs(x-k), x) * 2;
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep (i, n) cin >> a[i];

  ll ans = 1000;
  for (int i = 0; i < n - 1; i++) {
    if (a[i] < a[i + 1]) {
      ans += (a[i + 1] - a[i]) * (ans / a[i]);
    } else if (a[i] > a[i + 1]){
      while (a[i] > a[i + 1]) i++;
      i--;
    }
  }

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


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define ll long long
const int maxn=1e5+10;
using namespace std;

ll quickpow(ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1) ans*=a;
		a*=a;b>>=1;
	}
	return ans;
}
ll gcd(ll a,ll b)
{
	return b==0?a:gcd(b,a%b);
}

int main()
{
	ll h;
	cin>>h;
	if(h>1)
	{
		ll acout=0,ans=0;
		while(1)
		{
			if(h==1) break;
			acout++;h/=2;
		}
		for(int i=0;i<acout;i++) ans+=quickpow(2,i);
		ans+=quickpow(2,acout);
		cout<<ans<<endl;
	}
	else
	{
		cout<<1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int pw(int a, int b)
{
    int ret=1;
    while(b)
    {
        if(b&1) ret*=a;
        a*=a;
        b>>=1;
    }
    return ret;
}

vector<int> p;
const int sz=1010101;
int sp[sz], e[sz], phi[sz], mu[sz], tau[sz], sigma[sz];

int main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int i, j, temp=0;
    phi[1]=mu[1]=tau[1]=sigma[1]=1;
    for(i=2;i<sz;i++)
    {
        if(!sp[i])
        {
            p.push_back(i);
            e[i]=1;
            phi[i]=i-1;
            mu[i]=-1;
            tau[i]=2;
            sigma[i]=i+1;
        }
        for(auto j:p)
        {
            if(i*j>=sz) break;
            sp[i*j]=j;
            if(i%j==0)
            {
                e[i*j]=e[i]+1;
                phi[i*j]=phi[i]*j;
                mu[i*j]=0;
                tau[i*j]=tau[i]/e[i*j]*(e[i*j]+1);
                sigma[i*j]=sigma[i]*(j-1)/(pw(j, e[i*j])-1)*(pw(j, e[i*j]+1)-1)/(j-1);//overflow
                break;
            }
            e[i*j]=1;
            phi[i*j]=phi[i]*phi[j];
            mu[i*j]=mu[i]*mu[j];
            tau[i*j]=tau[i]*tau[j];
            sigma[i*j]=sigma[i]*sigma[j];
        }
    }
    
    ll n, ans = 0; cin >> n;
    for(int i=1; i<n; i++) ans += tau[i];
    cout << ans;
}

Measured memory_bytes: 27568
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
using namespace std;
//start
const int limit = 2e5 + 1;
int k;
vector<int> g[limit];
bool vis[limit];

void dfs(int s,int k){
    if(k >= 2) return;

    for(auto it:g[s]){
        if(!vis[it]){
            vis[it] = true;
            dfs(it, k+1);
        } 
    }
}


int main(){
    int k;
    string s;
    cin >> s >> k;
    vector<vector<string>> ss(50);
    set<string> st;
    string x;
    for(int l = 0;l < s.size(); l++){
        for(int r = 1 ; r <= k;r++){
            x = s.substr(l,r);
            st.insert(x);
            
        }
    }
    int cnt =0;
    for(auto itr = st.begin(); itr != st.end(); itr++){
        cnt++;
        if(cnt == k){
            cout << *itr <<endl;
            return 0;
        }
    }

    if(k == 1){
        cout << s <<endl;
    }


}


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

using namespace std;

const int MAX_N = 1e5 + 5;
const int DAYS = 3;

int n, k;

int points[MAX_N][DAYS];

int dp[MAX_N][DAYS];

int main() {
  // dp[day][guy] = the maximum cost to make a last vacation in the day "day" where "guy" wants
  // dp[day][guy] = points[day][guy] + max(dp[day - 1][the rest of the guys])
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < DAYS; ++j) {
      cin >> points[i][j];
    }
  }
  for (int i = 0; i < DAYS; ++i) {
    dp[1][i] = points[1][i];
  }
  for (int day = 1; day < n; ++day) {
    dp[day + 1][0] = points[day + 1][0] + max(dp[day][1], dp[day][2]);
    dp[day + 1][1] = points[day + 1][1] + max(dp[day][0], dp[day][2]);
    dp[day + 1][2] = points[day + 1][2] + max(dp[day][1], dp[day][0]);
  }
  cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << "\n";
  return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

int main(){
	int N;
	long long a[200000];

	long long sum = 0;
	long long s[200000];

	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%lld",&a[i]);
		sum += a[i];
		s[i] = sum;
	}

	int min = 0;
	int minsum = s[0];

	for(int i=1;i<N-1;i++){
		if(abs(2*s[i]-sum) < abs(2*s[min]-sum)){
			min = i;
		}
	}

	printf("%lld\n", abs(2*s[min]-sum));
	return 0;
}


Measured memory_bytes: 3328
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#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 <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 <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

//constexpr int inf = 2147483647;
//constexpr int64_t inf64 = 9223372036854775807;
//constexpr int mod = 1e9+7;

int digit_sum(int n){
  if(n < 10)  return n;
   return digit_sum(n/10) + n%10;
}

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

  int n, a, b;
  cin >> n >> a >> b;

  int res = 0;
  rep(i,n+1) {
    int sum = digit_sum(i);
    if (a <= sum && sum <= b) res += i;
  }

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (ll i = ll(a); i <= ll(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
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; }
// template end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll A, B, C;
    in >> A >> B >> C;

    if((B+C)<A){
        out << "0" << endl;
    }else{
        out << B+C-A << endl;
    }

 

 

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define mp make_pair
#define ld long double
#define ull unsigned long long int
#define mod 1000000007
int main()
{
	ll a,b,c,ans=0;
	cin>>a>>b>>c;
	if(a==b)
	{
		if(c!=a)
		{
			ans=1;
		}
	}
	if(a==c)
	{
		if(b!=a)
		{
			ans=1;
		}
	}
	if(c==b)
	{
		if(c!=a)
		{
			ans=1;
		}
	}
	if(ans==1)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int A, B, C, D; cin >> A >> B >> C >> D;
    cout << min(A, B) + min(C, D) << endl;
}

Measured memory_bytes: 256
s=input()
f=s[:2]
t=s[2:]
f=int(f)
t=int(t)
flagMM = 0
flagYY = 0
if 1<=f and f<=12:
    flagMM=1
if 1<=t and t<=12:
    flagYY=1
if flagMM and flagYY:
    print("AMBIGUOUS")
elif flagMM:
    print("MMYY")
elif flagYY:
    print("YYMM")
else:
     print("NA")


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static final long MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] params = sc.nextLine().split(" " );
        long n = Long.parseLong( params[0] );
        int k = Integer.parseInt( params[1] );



        System.out.println( Long.toString( n , k ).length() );

    }


}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  string s;
  R s;
  int n=s.size();
  bool dp[n+1];
  mem(dp);
  dp[0]=1;
  rep(i,n) {
    if(!dp[i]) continue;
    if(i+5<=n) {
      string t=s.substr(i,5);
      if(t=="dream"||t=="erase") dp[i+5]=1;
    }
    if(i+6<=n) {
      string t=s.substr(i,6);
      if(t=="eraser") dp[i+6]=1;
    }
    if(i+7<=n) {
      string t=s.substr(i,7);
      if(t=="dreamer") dp[i+7]=1;
    }
  }
  if(dp[n]) pr("YES");
  else pr("NO");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    int A;
    for(int i=0; i<N; i++){
        cin >> A;
        if(A%2==0){
            if(A%3!=0&&A%5!=0){
                cout << "DENIED" ;
                return 0;
            }
        }
    }
    cout << "APPROVED" ;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mxn 1000010
#define db double
#define LL long long
#define ldb long double
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair<int,int> 
#define mp make_pair
#define fr first
#define sc second
#define x1 faqx1
#define y1 faqy1
#define x2 faqx2
#define y2 faqy2
using namespace std;
const ldb eps=1e-12,PI=acos(-(ldb)1.0);
const int inf=1e9;
ldb a,b,x,ans;
int sl,fh;
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
int main()
{
	a=rd();b=rd();x=rd();
	if(x*2<=a*a*b)
	{
		ans=atan((a*b*b)/(2.0*x))*180.0/PI;
		printf("%.20Lf\n",ans);
	}
	else
	{
		ans=atan((2.0*(a*a*b-x))/(a*a*a))*180.0/PI;
		printf("%.20Lf\n",ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll a, b, cnt[5];

int main(){
	memset(cnt, 0, sizeof(cnt));
	
	for(ll i = 1; i <= 3; i++){
		cin >> a >> b;
		cnt[a]++;
		cnt[b]++;	
	}
	
	string ans = "YES"; 
	for(ll i = 1; i <= 4; i++){
		if(cnt[i] > 2){
			ans = "NO";
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n;
    cin>>n;

    /*
    LL ans_t = 0;
    for(LL m = 1; m <= n;m++){
        //cout<<m<<":"<<n/m<<" "<<n%m<<endl;
        if(n/m == n%m)ans_t += m;
    }
    PUTS(ans_t);
    */

    LL ans = 0;
    //x = N/m;
    for(LL x = 1; x * x <= n; x++){
        if(n % x == 0){
            LL m = n/x - 1;
            if(m > 0 && n/m == n%m)ans += m;
        }
    }

    PUTS(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define vb vector<bool>
#define vs vector<string>
#define px(x) cout << x << endl
#define pfi(x) printf("%d\n", x)
#define pfs(x) printf("%s\n", x)
#define sfi(x) scanf("%d", &x)
#define sfs(x) scanf("%s", x)

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

    string s;
    map<string, int> mp;
    int max = INT_MIN;
    string name;
    
    for (int i = 0; i < n; ++i)
    {
        cin >> s;
        mp[s] += 1;
        if(mp[s] > max){
            max = mp[s];
            name = s;
        }
    }

    for(auto val : mp){
        if(val.second == max){
            cout << val.first << endl;
        }
    }














	return 0;
}

Measured memory_bytes: 25216
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp14
{
    class Class5
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            List<int> nums = new List<int>();
            int i;
            for(i = n - 1; i >= 0; i -= 2)
            {
                nums.Add(a[i]);
            }
            i = i == -1 ? 0 : 1;
            for (; i < n; i += 2)
            {
                nums.Add(a[i]);
            }
            Console.WriteLine(string.Join(" ", nums));
        }
    }
}


Measured memory_bytes: 47288
#include<iostream>
#include<string>
#include<map>
using namespace std;

int main(){
	char ch[32+1]="ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";
	string table[256];
	for(int i=0;i<32;i++){
		string code;
		for(int j=0;j<5;j++)code+=(i>>(4-j)&1)+'0';
		table[ch[i]]=code;
	}
	map<string ,char> mp;
	map<string ,char>::iterator it;
	mp["101"]=' ';
	mp["000000"]='\'';
	mp["000011"]=',';
	mp["10010001"]='-';
	mp["010001"]='.';
	mp["000001"]='?';
	string codes[26]={"100101","10011010"
		,"0101","0001","110","01001","10011011","010000","0111","10011000"
		,"0110","00100","10011001","10011110","00101","111","10011111","1000"
		,"00110","00111","10011100","10011101","000010","10010010","10010011","10010000"};
	for(int i=0;i<26;i++)mp[codes[i]]='A'+i;

	
	string s;
	while(getline(cin,s)){
		string t,r,ans;
		for(int i=0;i<s.size();i++){
			t += table[s[i]];
		}
		for(int i=0;i<t.size();i++){
			r+=t[i];
			it=mp.find(r);
			if(it!=mp.end()){
				ans+=it->second;
				r.clear();
			}
		}
		cout<<ans<<endl;
	}
	return 0;	
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
const int MAXN=2e5+10;
int a[MAXN],f[MAXN];
pair<int,int>qu[MAXN];
int n;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		scanf("%d",&a[i]); if (a[i]>(i-1)) {
			printf("%d\n",-1); return 0;
		}
	}
    for (int i=1;i<=n;i++) {
    	f[i-a[i]]=max(f[i-a[i]],i);
	}
	int head=1,tail=0;
	for (int i=1;i<=n;i++) {
		if (f[i]) {
		tail++; qu[tail]=make_pair(i,f[i]);}
		if (a[i]!=i-qu[head].first) {
			printf("%d\n",-1) ;return 0;
		}
		while (head<=tail&&qu[head].second==i) head++;
	}
	long long ans=0;
	for (int i=1;i<=n;i++) if (f[i]) ans+=(long long)(f[i]-i);
	printf("%lld\n",ans);
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = (int)1e9+7;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n,k;
	cin>>n>>k;
	vector<ll> a(n),dp(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	ll ans = 0;
	for(int i=0;i<n;i++){
		if(i<k)
			dp[i] = (i==0 ? a[i] : dp[i-1] + a[i]);
		else dp[i] = dp[i-1] + a[i] - a[i-k];	
		//ctrl + /cout<<dp[i]<<" "; 
		ans = max(ans,dp[i]);
	}
	cout<<setprecision(14)<<0.5*(ans +k);
	

	return 0;
}
	
	
	
	
	
	
	
	
	
	
	

























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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n,m;
  cin>>n>>m;

  vvll a(n,vll(m));
  REP(i,n)REP(j,m)cin>>a[i][j];

  vector<queue<ll>> b(n);
  REP(i,n){
    REP(j,m){
      a[i][j]--;
      b[i].push(a[i][j]);
    }
  }


  ll ans=LLINF;
  vll removed(m);
  REP(i,m){
    vpl picked(m);
    REP(j,m)picked[j].SE=j;

    REP(j,n){
      ll t=b[j].front();
      picked[t].FI++;
    }

    sort(ALL(picked), greater<pll>());
    ll now=picked[0].FI;
    ll max_a=picked[0].SE;
    ans=min(ans,now);

    //remove most picked
    removed[max_a]=1;
    REP(j,n){
      while(!b[j].empty()){
        ll t=b[j].front();

        if(removed[t])
          b[j].pop();
        else
          break;
      }
    }

  }

  cout<<ans<<endl;
}



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

int main() {
    ll a,b,x,ans;
    cin>>a>>b>>x;
    if (a!=0) ans=b/x-(a-1)/x;
    else ans=b/x+1;
    cout<<ans<<endl;
}



Measured memory_bytes: 256
# A の末とB の頭文字、B の末とC の頭文字が一致しているか

A, B, C = map(str, input().split())

initial_1 = A[-1]
end_1 = B[0]
initial_2 = B[-1]
end_2 = C[0]

if initial_1 == end_1 and initial_2 == end_2:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 9088
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

const ll MOD = 1e9 + 7;

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, M;
  while (cin >> N >> M) {
    vector<int> A(M);
    for (int& x : A) cin >> x;
    vector<int> broken(N + 1);
    for (int x : A) broken[x] = 1;
    vector<ll> dp(N + 1, 0);
    dp[0] = 1;
    for (int i = 1; i <= N; i++) {
      if (broken[i]) continue;
      dp[i] += dp[i - 1];
      if (i > 1) {
        dp[i] += dp[i - 2];
      }
      dp[i] %= MOD;
    }
    cout << dp[N] << endl;
  }
  return 0;
}


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

void hit();
void homerun();
void out();
void is_end_of_game();

int inning = 0;										// イニング数
int first = 0, second = 0, third = 0;				// 0...走者無し　1...走者有り
int runs = 0, outs = 0;								// 1イニング毎のアウト数と得点
bool end_of_game = false;							// trueで試合終了
vector<int> score_board;							// スコアボード

int main()
{
	string event;
	cin >> inning;
	while(true) {
		cin >> event;
		if (event=="HIT")
			hit();
		else if (event=="HOMERUN")
			homerun();
		else if (event=="OUT")
			out();
		else {
			cout << "error; wrong order\n";
			return -1;
		}
		if(end_of_game)
			break;
	}
	for(int i=0;i<score_board.size();i++)
		cout << score_board[i] << '\n';

	return 0;
}

void hit()
{
	if(third==1) {
		third = 0;
		runs++;
	}
	if(second==1) {
		second = 0;
		third =1;
	}
	if(first==1) 
		second = 1;
	first = 1;
}

void homerun()
{
	runs += (first + second + third + 1);
	first = second = third = 0;
}

void out()
{
	outs++;
	if(outs==3) {
		score_board.push_back(runs);
		first = second = third = 0;
		outs = 0;
		runs = 0;
	}
	is_end_of_game();
}

void is_end_of_game()
{
	if(score_board.size()==inning)
		end_of_game = true;
}

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

int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
			  cin>>a[i];
			  
	int dp[n];
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++){
		dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
	}		   
	cout<<dp[n-1];
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <set>
using namespace std;
int main() {
  int a,b,c; cin>>a>>b>>c;
  string ans="YES";
  if(c-a<0) ans="NO";
  else if(c-a>b) ans="NO";
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>

typedef long long ll;

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

#define debug(x) cout << #x << "=" << x << endl;

using namespace std;

int main(void){

  int N,K;
  cin >> N >> K;

  int ans = (int)1e+9;
  int candidate = 1;
  FOR(i,1,N+1){
    candidate = 1;
    candidate = pow(2,i) + (N-i)*K;
    ans = min(ans,candidate);
  }

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


Measured memory_bytes: 384
#include <stdio.h>

int	main(void)
{
  	int	n;
  	int	r;
  	
  	scanf("%d", &n);
  
  	r = n % 10;
  
  	if (r == 2 || r == 4 || r == 5 || r == 7 || r == 9)
    {
    	printf("hon");
    }
  	else if(r == 0 || r == 1 || r == 6 || r == 8)
    {
      	printf("pon");
    }
  	else if(r == 3)
    {
      	printf("bon");
    }
  	
  	return (0);
}

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

int main(){
	string s;
	int K;
	cin >> s >> K;
	int N=s.size();
	
	for(int i=0;i<N;i++){
		if(i==N-1){
			K%=26;
			s[i]='a'+((s[i]-'a'+K)%26);
		}
		else if(s[i]!='a' && K>='z'-s[i]+1){
			K-='z'-s[i]+1;
			s[i]='a';
		}
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 512