akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

const int MAX = 2000010;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

void combinit() {
	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;
	}
}
ll comb(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() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	ll X, Y;
	cin >> X >> Y;
	combinit();
	if (-X + 2 * Y < 0 || 2 * X - Y < 0 || (-X + 2 * Y) % 3 != 0 || (2*X - Y) % 3 != 0)puts(0);
	else {
		ll A = (-X+2*Y) / 3;
		ll B = (2*X-Y) / 3;
		puts(comb(A+B,A));
	}

	return 0;
}

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

using namespace std;

int main() {
	int n; cin >> n;
	string s; cin >> s;
	int k = 0;
	for (int i = 0; i < n; i++)
		if (s[i] == 'R')
			k++;
	int ans = 0;
	for (int i = 0; i < k; i++)
		if (s[i] != 'R')
			ans++;
	cout << ans << '\n';
	return 0;
}


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

int main() {
	string s; cin >> s;
	
	int n = s.size(), l = 0, r = 0; bool ok = false;
	for(int i = 0; i < n;i++) {
		if (s[i] == s[i + 1]) {
			l = i + 1;
			r = i + 2;
			ok = true;
			break;
		}

		if (i < n - 2 && s[i] == s[i + 2]) {
			l = i + 1;
			r = i + 3;
			ok = true;
			break;
		}
	}
	if (ok) cout << l << " " << r << endl;
	else cout << -1 << " " << -1 << endl;

	return 0;
}

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

bool A(string s){
  string t=s;
  reverse(t.begin(),t.end());
  return s==t;
}
int main(){
  string s;
 
  cin>>s;
  bool ans=true;
  if(!A(s))ans=false;
  if(!A(s.substr(0,s.size()/2)))ans=false;
  
  cout<<(ans ? "Yes" : "No")<<endl;
}

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

int main() {
    int N,X,Y;
    cin >> N >> X >> Y;

    vector<int> ans(N);
    for (int i = 1; i <= N-1; i++){
        for (int j = i+1; j <= N; j++){
            int dis = 0;
            dis = min(abs(j-i),abs(X-i) + 1 + abs(Y-j));
            ans.at(dis)++;
        }
    }
    
    for (int i = 1; i < N; i++){
        cout << ans.at(i) << endl; 
    }
    
}

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

#include <boost/pending/disjoint_sets.hpp>
#include <boost/property_map/property_map.hpp>

using namespace std;
using ll = long long;
using ld = long double;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) ((x).begin()), ((x).end())

#define READ(x) (cin >> (x))
#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))
#define WRITE_YESNO(x) (WRITE_N((x) ? "Yes" : "No"))

#define PRECISE_COUT std::cout << std::setprecision(15) << std::fixed

bool xor_logic(bool x, bool y) { return (x && y) || (!x && !y); }

template <typename T1, typename T2>
bool pair_second_lt(const pair<T1, T2> &p1, const pair<T1, T2> &p2) {
  return p1.second < p2.second;
}

int solve(vector<int> &A, vector<int> &B, int N) {
  unordered_map<int, int> rank;
  unordered_map<int, int> parent;

  boost::disjoint_sets<boost::associative_property_map<unordered_map<int, int>>,
                       boost::associative_property_map<unordered_map<int, int>>>
      dset(boost::make_assoc_property_map(rank),
           boost::make_assoc_property_map(parent));

  for (size_t i = 0; i < N; i++) {
    dset.make_set(i);
  }

  for (size_t i = 0; i < A.size(); i++) {
    dset.union_set(A[i] - 1, B[i] - 1);
  }

  unordered_map<int, int> count;
  for (size_t i = 0; i < N; i++) {
    count[dset.find_set(i)]++;
  }

  auto max_pair = max_element(ALL(count), pair_second_lt<int, int>);
  return max_pair->second;
}

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;

  std::vector<int> A(M, 0), B(M, 0);
  for (size_t i = 0; i < M; i++) {
    cin >> A[i] >> B[i];
  }

  // main procedure
  int ans = solve(A, B, N);

  // output
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 27856
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include <bits/stdc++.h>
#define MAX 5003
#define reg register

using namespace std;

int n, m;
int p[MAX][205], cur_max[205], upper[205];
long long dis[MAX];

inline int Rd() {
	int x = 0; char ch = getchar();
	while(ch < '0' || ch > '9') ch = getchar();
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	return x;
}
inline void ChkMax(long long &aa, long long bb) {
	if(aa < bb) aa = bb;
	return;
}

int main() {
	n = Rd(), m = Rd();
	for(reg int i = 2; i <= n; ++i) {
		dis[i] = Rd();
		dis[i] += dis[i - 1];
	}
	for(reg int i = 1; i <= n; ++i) {
		for(reg int j = 1; j <= m; ++j) {
			p[i][j] = Rd();
			if(upper[j] < p[i][j]) upper[j] = p[i][j];
		}
	}
	long long maxp = 0;
	for(reg int i = 1; i <= m; ++i) maxp += upper[i];
	reg long long ans = 0, cur_p = 0;
	for(reg int i = 1; i <= n; ++i) {
		cur_p = 0;
		memset(cur_max, 0, sizeof cur_max);
		for(reg int j = i; j <= n; ++j) {
			for(reg int k = 1; k <= m; ++k) {
				if(p[j][k] > cur_max[k]) {
					cur_p += p[j][k] - cur_max[k];
					cur_max[k] = p[j][k];
				}
			}
			if(maxp - (dis[j] - dis[i]) <= ans) break;
			ChkMax(ans, cur_p - (dis[j] - dis[i]));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4352
//                                              Question ki ma ki chut !!
#include<bits/stdc++.h>
using namespace std;
#define Going_supersonic ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(a) a.begin(),a.end()
#define allr(v) v.rbegin(),v.rend()
#define sz() size()
#define l() length()
#define lli long long int
#define ed endl
#define iv vector<lli>
#define bg() begin()
#define e() end()
#define ff first
#define ss second
lli sti(string s)
{
    lli num=0;
    lli p=1;
    for(lli it=s.l()-1;it>=0;p*=10)
        num+=(s[(it--)]-48)*p;
    return num;
}
lli n,m,cnt,mx,mn,l,sm,r;
lli dp[100002];
lli solve(iv &a, lli pos,lli n)
{
   // cout<<"calling for "<<pos<<" "<<pos<<ed;
    if(dp[pos]!=-1)
        return dp[pos];
    if(pos==n-2)
    {
       return dp[pos]=abs(a[pos]-a[n-1]);
    }
    else if(pos==n-3)
    {
        return dp[pos]=min(abs(a[pos]-a[pos+1])+abs(a[pos+1]-a[pos+2]),abs(a[pos]-a[pos+2]));
    }

    return dp[pos]=min(abs(a[pos]-a[pos+1])+solve(a,pos+1,n),abs(a[pos]-a[pos+2])+solve(a,pos+2,n));
}
int main(){
    Going_supersonic
    lli T=1;
    //cin>>T;
    while(T--){
            lli i,j,k;
            cin>>n;
            iv a(n);
            for(i=0;i<n;cin>>a[i++]);
            memset(dp,-1,sizeof(dp));
            cout<<solve(a,0,n);


    }

    return 0;
}


Measured memory_bytes: 8728
#include <bits/stdc++.h>
#define int long long int
#define ld long double
#define MOD 1000000007
#define N 1000006
#define INF 1000000000000000000
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define randright srand(chrono::steady_clock::now().time_since_epoch().count());

using namespace std;

void solve(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n%2==1){
        cout<<"No\n";
        return;
    }
    string a = s.substr(0,(n/2));
    string b = s.substr((n/2), (n/2));
    if(a==b){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
}

signed main(){
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

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

const int MAX = 700000;
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 x,y; cin >>x >>y;
  ll ans;
  if ((x+y)%3 != 0) ans = 0;
  else{
    int moves = (x+y)/3;
    // 移動回数。この数だけ絶対にx,y座標とも増える
    x -= moves; y -= moves; // このときx+y = moves
    // この時のx,yの値が(+2,+1),(+1,+2)の回数に対応
    if (x<0 || y<0) ans = 0;
    else if (x==0 || y==0) {ans = 1;}
    else{
      // x=3,y=2ならxxxyyって感じでならべるやつが何通りあるか
      // この場合だと5C3とかになるはず
      COMinit();
      ans = COM(moves, x);
    }
  }
  cout <<ans <<endl;
}


Measured memory_bytes: 16640
//BISMILLAHIR RAHMANIR RAHIM
//RABBI ZIDNI ILMA
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define endl "\n"
#define inf (1LL<<61)
#define pi acos(-1)
#define mod 1000000007
#define MOD 998244353
#define all(x) x.begin(), x.end()
#define int_pow(n, p) (ll)(pow(n, p) + 0.5)
#define fastio ios_base::sync_with_stdio(0);cout<< fixed<< setprecision(10);
#define debug(x) cout<<"["<<#x<<": "<<x<<"]\n"
#define debug2(x, y) cout<<"["<<#x<<": "<<x<<"]"<<"  ["<<#y<<": "<<y<<"]\n"
#define debug3(x, y, z) cout<<"["<<#x<<": "<<x<<"]"<<"  ["<<#y<<": "<<y<<"]"<<"  ["<<#z<<": "<<z<<"]\n"
#define debug4(x, y, z, k) cout<<"["<<#x<<": "<<x<<"]"<<"  ["<<#y<<": "<<y<<"]"<<"  ["<<#z<<": "<<z<<"]"<<"  ["<<#k<<": "<<k<<"]\n"

const ll N = 1e5 + 9;

int main()
{
    fastio
    bool a;
    cin>> a;
    cout<< !a;
}



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


int main() {

    int n, cnt = 0;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    rep(i,n-2) {
        vector<int> a;
        for (int j = i; j < i+3; j++) {
            a.push_back(p[j]);
        }
        int s = a[1];
        sort(a.begin(), a.end());
        if (a[1] == s) {
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val a = readLine()!!.toInt()
    val b = readLine()!!.toInt()
    val c = readLine()!!.toInt()
    val x = readLine()!!.toInt()

    var count = 0
    for (ai in a downTo 0) {
        for (bi in b downTo 0) {
            for (ci in c downTo 0) {
                if ((500 * ai + 100 * bi + 50 * ci) == x) {
                    count++
                }
            }
        }
    }
    println(count)
}

Measured memory_bytes: 33688
h,w,n = map(int,input().split())
coord = [list(map(int,input().split())) for i in range(n)]

num = {}

for i in range(n):
  for j,k in [[0,0],[0,1],[0,-1],[1,0],[1,1],[1,-1],[-1,0],[-1,1],[-1,-1]]:
    if not(2<=coord[i][0]+j<=h-1) or not(2<=coord[i][1]+k<=w-1):
      continue
    if not coord[i][0]+j in num:
      num[coord[i][0]+j] = {}
    if not coord[i][1]+k in num[coord[i][0]+j]:
      num[coord[i][0]+j][coord[i][1]+k] = 1
    else:
      num[coord[i][0]+j][coord[i][1]+k] += 1

ans = [0]*10
for i in num:
  for value in num[i].values():
    ans[value] +=1

print((h-2)*(w-2)-sum(ans))
for i in range(1,10):
  print(ans[i])

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


int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    sort(A.begin(),A.end());
    cout << (A[N-1] - A[0]) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

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

    int m;
    cin >> m;

    ll r = 0;
    for (int i = 0; i < m; i++) {
        ll d, c;
        cin >> d >> c;

        r += d * c + c * 9;
    }

    r -= 10;

    cout << r / 9 << endl;

    //9で割ったあまりは不変
    //0は消える サンプル2は桁数を保つ操作ができない
    //桁数が変わらないときは、全体の和は9減る 桁数が減るときは、和は変化しない
    //つまり、各桁の和+桁数*9が1回の操作で9ずつ減っていく
    //この値は1桁のとき最大で18、2桁のとき最小で19 18以下になったら終わり

    return 0;
}

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

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    vector<int> candy(3);
    for (int i=0; i<3; i++) cin >> candy[i];
    sort(candy.begin(), candy.end());

    bool ans = candy[0] + candy[1] == candy[2];
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 384
import sys

N = int(sys.stdin.readline())
ans = 0
for i in range(1, N+1, 2):
    count = 0
    for j in range(1, i+1):
        if i % j == 0:
            count += 1
    if count == 8:
        # print(i)
        ans += 1
print(ans)

Measured memory_bytes: 38768
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            for (int i = 0; i < n; i++) {
                if (in.next().equals("Y")) {
                    out.print("Four");
                    return;
                }
            }
            out.print("Three");

        }

    }
}



Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <functional>
#include <algorithm>
#include <stack>
#include <list>
#include <queue>
#include <bitset>
//#include <iostream>
//#include <sstream>
using namespace std;
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define pf printf
#define sf scanf
#define test_ fprintf(stderr, ">>>>>>>>>>>>>>>>>>>> in <<<<<<<<<<<<<<<<<<<<")
#define deb(x) cerr << ">>>>>>>>>>>>>>>>>>>> " << #x << " = " << x << " <<<<<<<<<<<<<<<<<<<<\n"
#define debd(x) fprintf(stderr, ">>>>>>>>>>>>>>>>>>>> %s = %d <<<<<<<<<<<<<<<<<<<<\n", #x, x)
#define debs(x) fprintf(stderr, ">>>>>>>>>>>>>>>>>>>> %s = %s <<<<<<<<<<<<<<<<<<<<\n", #x, x)
#define debll(x) fprintf(stderr, ">>>>>>>>>>>>>>>>>>>> %s = %lld <<<<<<<<<<<<<<<<<<<<\n", #x, x)
#define deblf(x) fprintf(stderr, ">>>>>>>>>>>>>>>>>>>> %s = %lf <<<<<<<<<<<<<<<<<<<<\n", #x, x)
#define fr(i, a, b) for(int i = a ; i < b ; i++)
#define frr(i, a, b) for(int i = a ; i >= b ; i--)
#define tr(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define trr(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define its(x) static_cast< ostringstream & >( ( ostringstream() << dec << x ) ).str()
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ln puts("")
#define mems(a) memset(a, 0, sizeof(a))
#define has(cont, x) ((cont).find((x)) != (cont).end())
#define sz(x) ((int)(x).size())
//typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vll;
//bitmask
int onbit(int x, int pos) {x |= (1 << pos); return x;}
int offbit(int x, int pos) {x &= ~(1 << pos); return x;}
int test(int x, int pos) {return x & (1 << pos);}
int flip(int x, int pos) {x ^= (1 << pos); return x;}
int lsb(int x) {return x & (-x);}
int onbitall(int x, int pos) {x = (1 << pos)-1; return x;}
//constants
const double EPS = 1e-9;
const double PI = 2*acos(0.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
//moves
const int dx1[] = {0, 1, 0, -1};
const int dy1[] = {1, 0, -1, 0};
const int dx2[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dy2[] = {-1, 0, 1, -1, 1, -1, 0, 1};

char a[5];

int main() {
//  freopen("input.in", "r", stdin);
	sf("%s", a);
  
  
  int cnt = 0;
  fr(i, 0, strlen(a)) {
    cnt += (a[i] == '1');
  }
  
  pf("%d\n", cnt);
	return 0;
}


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

int main(){
	string s,t;	cin>>s>>t;
	int a,b;	cin>>a>>b;
	string u;	cin>>u;
	if(s==u)--a;
	else --b;
	cout<<a<<" "<<b<<endl;

	return 0;
}


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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

typedef long long ll;
typedef unsigned long long ull;

const int INF = 999999999;

int main(){
   int n;cin>>n;
   vector<int> a(n);
   rep(i,n){
      cin>>a[i];
   }
   rep(i,INF){
      rep(j,n){
         if(a[j]%2 == 0){
            a[j]/=2;
         }else{
            cout << i;
            return 0;
         }
      }
   }
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#define int long long
using namespace std;

typedef pair<int,int> P;

signed main(){
	int n,a[200000],right[200000],num[200000];
	cin >> n;
	vector<P> vec;
	for(int i = 0;i < n;i++) {
		cin >> a[i];
		num[i] = 1;
		vec.push_back(P(a[i],i));
	}
	sort(vec.begin(),vec.end());
	set<int> st;
	st.insert(n);
	for(int i = 0;i < n;i++){
		int pos = vec[i].second;
		right[pos] = *(st.lower_bound(pos)) - pos;
		st.insert(pos);
	}
	int sum = 0;
	for(int i = 0;i < n;i++){
		sum += a[i] * right[i] * num[i];
		num[i + right[i]] += num[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 18156
using System;
using System.Linq;

namespace ABC153
{
    class E
    {
        static void Main(string[] args)
        {
            long[] input = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long H = input[0];
            long N = input[1];

            long[,] DP = new long[N + 10, H + 10];
            long[] A = new long[N];
            long[] B = new long[N];

            for (int i = 0; i < N; i++)
            {
                input = Console.ReadLine().Split().Select(long.Parse).ToArray();
                A[i] = input[0];
                B[i] = input[1];
            }

            for (int i = 0; i <= N; i++)
            {
                for (int h = 0; h <= H; h++)
                {
                    DP[i, h] = int.MaxValue;
                }
            }

            for (int i = 0; i <= N; i++)
            {
                DP[i, 0] = 0;
            }

            for (int i = 0; i < N; i++)
            {
                for (int h = 0; h <= H; h++)
                {
                    DP[i + 1, h] = Math.Min(DP[i + 1, h], DP[i, h]);
                    DP[i + 1, Math.Min(h + A[i], H)] = Math.Min(DP[i + 1, Math.Min(h + A[i], H)], DP[i + 1, h] + B[i]);
                }
            }
            Console.WriteLine(DP[N, H]);
        }
    }
}


Measured memory_bytes: 91480
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		long count = 0;
		int[] s = new int[S.length()+1];
		int[] b = new int[S.length()+1];
		for (int i = 0; i < S.length(); i++) {
			char c = S.charAt(i);
			if (c == '<') {
				s[i+1] = s[i]+1;
			}
		}
		for (int i = S.length()-1; -1 < i; i--) {
			char c = S.charAt(i);
			if (c == '>') {
				b[i] = b[i+1]+1;
			}
		}
		for (int i = 0; i < s.length; i++) {
			count += Math.max(s[i], b[i]);
		}
		System.out.println(count);
		
	}
}

Measured memory_bytes: 34204
a, b, c = map(int, input().split())
divisors = []
i = 1
while(i * i < c):
    if(c % i == 0):
        divisors.append(i)
        divisors.append(c // i)
    i += 1
if(i * i == c):
    divisors.append(i)
ans = 0
for i in range(len(divisors)):
    if(a <= divisors[i] <= b):
        ans += 1
print(ans)

Measured memory_bytes: 7692
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> t(n), a(n+1, 0), h(n+1, 0);
	rep(i,n){
		cin >> t[i];
		if(t[i] > t[i-1]) h[i] = t[i];
	}
	rep(i,n) cin >> a[i];
	for(int j = n-1; j >= 0; --j){
		if(a[j] != a[j+1]){
			if(h[j] == 0) h[j] = a[j];
			else{
				if(h[j] != a[j]){
					cout << 0 << endl;
					return 0;
				}
			}
		}
	}
	mint ans = 1;
	rep(i,n){
		if(h[i] == 0) ans *= min(t[i], a[i]);
		else{
			if(t[i] < h[i] || a[i] < h[i]){
				cout << 0 << endl;
				return 0;
			}
		}
		//cout << i << " " << ans.x << endl;
	}
	cout << ans.x << endl;
	return 0;
}

Measured memory_bytes: 4524
#include <stdio.h>
int main() {
  int n;
  scanf("%d", &n);
  int a[n];
  int count = 1;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] % 2 == 0) {
      if (a[i] % 3 == 0 || a[i] % 5 == 0) {

      } else {
        count = 0;
      }
    }
  }
  if (count == 0) {
    printf("DENIED\n");
  } else {
    printf("APPROVED\n");
  }
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;

long long cnt;

struct SSS
{
	string str;
	int val;
	SSS(string s = "", int v = 0) :str(s), val(v){};
};

void print(vector<SSS> &data){
	for (int i = 0; i < data.size(); ++i){
		cout << data[i].str << " " << data[i].val << endl;
	}
}

void print(vector<int> &data){
	for (int i = 0; i < data.size(); ++i) {
		cout << data[i];
		if (i == data.size() - 1) cout << endl;
		else cout << " ";
	}
}

void print_endl(vector<int> &data){
	for (int i = 0; i < data.size(); ++i) {
		cout << data[i] << endl;
	}
}

void insS(vector<int> &data){
	for (int i = 0; i < data.size(); ++i){
		int v = data[i];
		int j = i - 1;
		while (j >= 0 && data[j] > v){
			data[j + 1] = data[j];
			j--;
		}
		data[j + 1] = v;
	}
}

void insS2(vector<int> &data, int d){
	for (int i = 0; i < data.size(); ++i)
	{
		int v = data[i];
		int j = i - d;
		while (j >= 0 && data[j] > v) {
			data[j + d] = data[j];
			j -= d;
			cnt++;
		}
		data[j + d] = v;
	}
}


void sheS(vector<int> &data){
	vector<int> dist;
	for (int i = 1; i <= data.size(); i = i * 3 + 1) dist.push_back(i);

	cout << dist.size() << endl;

	for (int i = dist.size() - 1; i >= 0; --i){
		cout << dist[i];
		if (i == 0) cout << endl;
		else cout << " ";
		insS2(data, dist[i]);
	}
	cout << cnt << endl;
	print_endl(data);
}


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

	return 0;
}

Measured memory_bytes: 6656
#include "bits/stdc++.h" // {{{
using namespace std;
#define eb          emplace_back
#define emp         emplace
#define fi          first
#define se          second
#define X           first
#define Y           second
#define outl(x)     cout << (x) << '\n'
#define rep(i,n)    for(int i=0; i < (int)(n); ++i)
#define ALL(x)      begin(x), end(x)
#define TMPLT(T,U)  template<class T, class U>
#define ten(p)      (int)(1e##p)
#define FILL(a,val) memset((a), (val), sizeof(a))
#define FAST()      ios::sync_with_stdio(false), cin.tie(nullptr)
#ifdef DEBUG
#define debug(...)  fprintf(stderr, __VA_ARGS__)
#define show(x)     clog << #x << " \t= " << (x) << '\n'
#define line()      fputs("\n--------------------------------\n", stderr)
#else
#define debug(...)
#define show(x)
#define LN()
#endif
using ll  = long long;
using pii = pair<int,int>;
TMPLT(T,U) inline bool chmax(T &a, U b){return b>a ? a=b,1 : 0;}
TMPLT(T,U) inline bool chmin(T &a, U b){return b<a ? a=b,1 : 0;}
TMPLT(T,U) inline constexpr common_type_t<T,U> gcd(T x, U y) { return (x<y)? gcd(y,x) : (y <= 0)? x : gcd(y, x % y); }
TMPLT(T,U) inline constexpr ll lcm(T x, U y) { return (ll)x/gcd(x,y) * y; }
inline bool inner(int val, int min, int max){ return min <= val && val < max; }
constexpr int INF   = 0x3f3f3f3f;
constexpr ll LINF   = 0x3f3f3f3f3f3f3f3fLL;

namespace ydk{ // }}}

constexpr int MXN = ten(5) + 10;

signed _vim_is_god_()
{
    int A, B,C, X, Y, N, M;
    cin >> X >> Y;
    outl(X + Y/2);
    return 0;
}

} // {{{

signed main(){cout << fixed << setprecision(9); ydk::_vim_is_god_(); return 0;} // }}}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdlib.h>
#include<stdio.h>
#include<vector>
#include<utility>
#include<stdbool.h>
using namespace std;
typedef long long ll;
#define N (1000000000+7)

int main(void) {
	string s;
	cin >> s;
	ll ans = 0;
	for (ll i = 0;i < s.length();i++) {
		ll a = s[i] - '0';
		ans += a;
	}
	ll c = s[0] - '0';
	if (ans == c + 9 * (s.length() - 1))cout << ans << endl;
	else {
		cout << c - 1 + 9 * (s.length() - 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9)+7)

int main()
{
  int n;
  cin >> n;
  vector<ll> h;
  for(int i = 0;i < n;i++){
    ll a;
    cin >> a;
    h.push_back(a);
  }
  vector<int> count;
  int co = 0;
  for(int i = 1;i < n;i++){
    if(h[i-1] >= h[i]) co++;
    else{
      count.push_back(co);
      co = 0;
    }
  }
  count.push_back(co);
  sort(count.rbegin(),count.rend());
  cout << count[0] << endl;
}


Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> P;

int dig(int a){
  if(a%2) return 0;
  return 1+dig(a/2);
}

int main(){
  int n;
  cin >> n;
  int ans = pow(10,9);
  rep(i,n){
    int tmp;
    cin >> tmp;
    ans = min(ans,dig(tmp));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1, 105):
    for j in range(1, 105):
        for k in range(1, 105):
            v = i*i+j*j+k*k+i*j+j*k+k*i
            if v < 10050:
                ans[v] += 1
for i in range(n):
    print(ans[i+1])


Measured memory_bytes: 74352
#include <stdio.h>

int main()
{
	int W, H;
	int x, y, r;

	scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
	W -= r, H -= r;
	if (r <= x && x <= W && r <= y && y <= H) printf("Yes\n");
	else printf("No\n");
	return 0;}



Measured memory_bytes: 2612
#include <stdio.h>
 
int main(void)
{
    char w[10],text[1001];
    int cnt=0,i;
    scanf("%s",&w);
    while(1){
        scanf("%s",text);
        if(strcmp(text,"END_OF_TEXT")==0) break;
         
        for(i=0;strlen(text)>i;i++){
            if('A'<=text[i]&&'Z'>=text[i]) text[i]+=32;
        }
        if(strcmp(w,text)==0) cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 2060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader sc = new FastReader();
        PrintWriter out = new PrintWriter(System.out);

        int n = sc.nextInt();

        Set<String> dic = new HashSet<>();
        char prev = 'a';
        for (int i = 0; i < n; i++) {
            String t = sc.next();
            if (dic.contains(t)) {
                out.println("No");
                out.flush();
                return;
            }
            dic.add(t);

            if (0 < i) {
                if (prev != t.charAt(0)) {
                    out.println("No");
                    out.flush();
                    return;
                }
            }
            prev = t.charAt(t.length()-1);
        }

        out.println("Yes");
        out.flush();
    }

    //    public static void calcD(Map<Integer, Integer> dic, int index, )

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 23124
n = int(input())
a = [int(input()) for _ in range(n)]
cur = 1
cnt = 0
while True:
    if cur == 2:
        print(cnt)
        exit()
    elif cnt > n:
        print(-1)
        exit()
    else:
        cur = a[cur - 1]
        cnt += 1

Measured memory_bytes: 7084
N, K = map(int,input().split(' '))
stage = list(map(int, input().split(" ")))

INF = float('inf')
DP = [INF for i in range(N)]
#DP[0] = 0


for i in range(N):
    candidate = [INF for i in range(K)]
    if i == 1:
        DP[i] = abs(stage[i] - stage[i-1])
    elif i > 1:
        for j in range(min(K+1,i+1)):
            if i == j:
                candidate[0] = (abs(stage[i]-stage[0]))
            else:
                candidate[K-1-j]=(DP[i-j] + abs(stage[i]-stage[i-j]))
        DP[i] = min(candidate)

print(DP[N-1])

Measured memory_bytes: 58336
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
 
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
 
using namespace std;
 
typedef long long int64;
typedef unsigned long long uint64;
#define two(X) (1<<(X))
#define twoL(X) (((int64)(1))<<(X))
#define contain(S,X) (((S)&two(X))!=0)
#define containL(S,X) (((S)&twoL(X))!=0)
const double pi=acos(-1.0);
const double eps=1e-11;
template<class T> inline void ckmin(T &a,T b){if(b<a) a=b;}
template<class T> inline void ckmax(T &a,T b){if(b>a) a=b;}
template<class T> inline T sqr(T x){return x*x;}
typedef pair<int,int> ipair;
#define SIZE(A) ((int)A.size())
#define LENGTH(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,a) for(int i=0;i<(a);++i)
#define ALL(A) A.begin(),A.end()
 
const int maxsize=(1<<20);
 
int n;
int a[maxsize];
int f[20][maxsize];
int pos[maxsize];
int l2[maxsize];
priority_queue<pair<int,ipair>> heap;
 
int rmq(int s,int t)
{
	int c=(t-s)/2+1;
	int d=l2[c];
	return min(f[d][s],f[d][t-2*((1<<d)-1)]);
}
void add(int s,int t)
{
	if (s>t) return;
	int x=rmq(s,t-1);
	heap.push(MP(-x,MP(s,t)));
}
int main()
{
#ifdef _MSC_VER
	freopen("input.txt","r",stdin);
#endif
	std::ios::sync_with_stdio(false);
	cin>>n;
	REP(i,n) { cin>>a[i]; --a[i]; pos[a[i]]=i; }
	l2[0]=0;
	FOR(i,1,n+1)
	{
		int d=l2[i-1];
		if (two(d+1)<=i) ++d;
		l2[i]=d;
	}
	REP(i,n) f[0][i]=a[i];
	for (int d=1,l=2;d<20;d++,l*=2)
		REP(i,n)
		{
			f[d][i]=f[d-1][i];
			if (i+l<n) ckmin(f[d][i],f[d-1][i+l]);
		}
	add(0,n-1);
	REP(i,n/2)
	{
		if (i>0) printf(" ");
		pair<int,ipair> state=heap.top();
		heap.pop();
		int s=state.second.first;
		int t=state.second.second;
		int v1=rmq(s,t-1);
		int p1=pos[v1];
		int v2=rmq(p1+1,t);
		int p2=pos[v2];
		printf("%d %d",v1+1,v2+1);
		add(s,p1-1);
		add(p1+1,p2-1);
		add(p2+1,t);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 47992
#include <stdio.h>
#include <stdlib.h>
#define INF 1145141919
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))

int dp[501][10001];

int compare_int(const void *a, const void *b){
    return *(int*)b - *(int*)a;
}

int main(void) {
	int M,N,i,j,x,sum,cost;
	int *P,*C,*E;
	
	scanf("%d %d",&M,&N);
	P = (int *)malloc(sizeof(int)*M);
	C = (int *)malloc(sizeof(int)*N);
	E = (int *)malloc(sizeof(int)*N);
	sum = 0;
	
	for(i = 0;i < M;i++){
		scanf("%d",&P[i]);
		sum += P[i];
	}
	qsort(P,M,sizeof(int),compare_int);
	for(i = 0;i < N;i++){
		scanf("%d %d",&C[i],&E[i]);
	}
	
	for(i = 0;i <= N;i++){
		for(j = 0;j <= M;j++){
			dp[i][j] = INF;
		}
	}
	
	x = 0;
	dp[0][0] = 0;
	for(i = 1;i <= N;i++){
		x += C[i-1];
		for(j = 0;j <= min(x,M);j++){
			dp[i][j] = min(dp[i-1][j],dp[i-1][max(j-C[i-1],0)]+E[i-1]);
		}
	}
	cost = 0;
	for(i = M;i > 0;i--){
		if(cost < sum-dp[N][i]){
			cost = sum-dp[N][i];
		}
		sum -= P[i-1];
	}
	
	printf("%d\n",cost);
	
	return 0;
}

Measured memory_bytes: 20296
using System;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using System.Text;
 
class DandA {
    static void Main(string[] args) {
        string[] ary = new string[] {"Sunny", "Cloudy", "Rainy", "Sunny"}; 
        string s = ReadLineStr();
        Console.WriteLine(ary[Array.IndexOf(ary, s) + 1]);
    }
 
    static string Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
  
    static private string ReadLineStr() {return Console.ReadLine();}
    static private int ReadLineInt() {return int.Parse(Console.ReadLine());}
    static private long ReadLineLong() {return long.Parse(Console.ReadLine());}
    static private double ReadLineDouble() {return double.Parse(Console.ReadLine());}
    static private string[] ReadLineStrArray() {return Console.ReadLine().Trim().Split();}
    static private int[] ReadLineIntArray() {return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToArray();}
    static private long[] ReadLineLongArray() {return Console.ReadLine().Trim().Split().Select(a => long.Parse(a)).ToArray();}
    static private double[] ReadLineDoubleArray() {return Console.ReadLine().Trim().Split().Select(a => double.Parse(a)).ToArray();}
    static private decimal[] ReadLineDecimalArray() {return Console.ReadLine().Trim().Split().Select(a => decimal.Parse(a)).ToArray();}
    static private string[][] ReadMLineStrArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split()).ToArray();}
    static private int[][] ReadMLineIntArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();}
 
    static private bool IsPrime(int num) {
        if (num < 2) return false;
        if (num == 2) return true;
        else if (num % 2 == 0) return false;
        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2) {
            if (num % i == 0) return false;
        }
        return true;
    }
}

Measured memory_bytes: 11100
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(int i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  int n; cin >> n;
  vector<int> a(n); rep(i, n) cin >> a[i];
  vector<int> b;
  rep(i, n) {
    if(i%2)
      b.insert(b.begin(),a[i]);
    else
      b.push_back(a[i]);
  }
  if(n%2) for(int i=n-1; i>=0; --i) cout << b[i] << " ";
  else for(int i:b) cout << i << " ";
  cout << endl;
}


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

ll N,M,K,C;
ll a,b,c,d;
string s;
int main(){
    cin>>s;
    map<char,int> mp;
    for(auto c:s){
        mp[c]++;
    }
    if(mp.size()!=2){
        cout<<"No";
        return 0;
    }
    for(auto o:mp){
        if(o.second!=2){
            cout<<"No";
            return 0;
        }
    }
    
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 764
n=int(input())
dic={}
for _ in range(n):
  inp=input()
  dic.setdefault(inp,0)
  dic[inp]+=1
maxval=0
maxkey=[]
for key,val in dic.items():
  if maxval==val:
    maxkey.append(key)
  elif val>maxval:
    maxkey=[key]
    maxval=val
maxkey.sort()
for i in maxkey:
  print(i)

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

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

    string ans = "";
    for (char ch: s) {
        if (!ans.empty() && ans.back() == 'S' && ch == 'T') ans.pop_back();
        else ans.push_back(ch);
    }

    cout << ans.length() << endl;

    return 0;
}

Measured memory_bytes: 776
#include<stdio.h>

#define N 100

int main(){
  int i, j, n, A[N], flag=1, cnt=0, a=0;

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }

  i = 0;
  while(flag == 1){
    flag = 0;
    for(j = n-1; j >= i+1; j--){
      if(A[j] < A[j-1]){
	a = A[j-1];
	A[j-1] = A[j];
	A[j] = a;
	cnt++;
	flag = 1;
      }
    }
    i++;
  }

  for(i = 0; i < n-1; i++){
    printf("%d ", A[i]);
  }
  printf("%d\n%d\n",A[i],cnt);

  return 0;
}

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

const int N = 110;

namespace Dinic
{
const int S = 0, inf = 1e9 + 100;
typedef int arrn[2 * N];
typedef int arrm[2 * N * N];
int T, cnt;
arrn ed, vis, ls;
arrm nx, c, e;

void add(int x, int y, int cap)
{
    e[cnt] = y;
    nx[cnt] = ed[x];
    c[cnt] = cap;
    ed[x] = cnt++;
    e[cnt] = x;
    nx[cnt] = ed[y];
    c[cnt] = 0;
    ed[y] = cnt++;
}
int bfs()
{
    deque<int> q;
    q.push_back(S);
    for (int i = S; i <= T; i++)
        vis[i] = inf;
    vis[S] = 1;
    while (!q.empty())
    {
        int x = q[0];
        q.pop_front();
        for (int i = ed[x]; i != -1; i = nx[i])
        {
            int y = e[i];
            if (!c[i] || vis[y] <= vis[x] + 1)
                continue;
            vis[y] = vis[x] + 1;
            q.push_back(y);
        }
    }
    return vis[T] < inf;
}
int dfs(int p, int flow)
{
    if (p == T)
        return flow;
    int i, ret = 0;
    for (i = ls[p]; i != -1 && flow > ret; i = nx[i])
    {
        int y = e[i];
        if (!c[i] || vis[y] != vis[p] + 1)
            continue;
        int tmp = dfs(y, min(flow - ret, c[i]));
        ret += tmp;
        c[i] -= tmp;
        c[i ^ 1] += tmp;
    }
    ls[p] = i;
    return ret;
}
void init(int t)
{
    cnt = 0;
    T = t;
    for (int i = S; i <= T; i++)
        ed[i] = -1;
}
int go()
{
    int ans = 0;
    while (bfs())
    {
        for (int i = S; i <= T; i++)
            ls[i] = ed[i];
        ans += dfs(S, inf);
    }
    return ans;
}
}

int n, x[2 * N], y[2 * N];

int main()
{
    cin >> n;
    for (int i = 1; i <= n * 2; i++)
        scanf("%d%d", x + i, y + i);
    Dinic::init(2 * n + 1);
    for (int i = 1; i <= n; i++)
        for (int j = n + 1; j <= 2 * n; j++)
            if (x[i] < x[j] && y[i] < y[j])
                Dinic::add(i, j, 1);
    for (int i = 1; i <= n; i++)
        Dinic::add(0, i, 1), Dinic::add(i + n, 2 * n + 1, 1);
    int ans = Dinic::go();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
/*
    Author - Param Kothari
    Ah shit, here we go again
*/
 
/* Ordered Set Implementaton:

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;

typedef tree<
    int,
    null_type,
    less<int>,
    rb_tree_tag,
    tree_order_statistics_node_update>
ordered_set;
*/

#include <bits/stdc++.h>
 
using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair 
 
typedef long long ll;
typedef long double ld;

void solve(){
    string s, t;
    cin >> s >> t;
    cout << t + s << "\n";
    return;
}
 
int main(){
    IOS;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
import Data.List ((\\))

main :: IO ()
main = do
  nabc <- map read . words <$> getLine
  ls <- map read . lines <$> getContents
  let
    patterns = filter (null . ([1, 2, 3] \\)) . sequence . replicate (nabc !! 0) $ [0, 1, 2, 3]
    m = minimum . map mp $ patterns
    mp pattern = sum . flip map [1, 2, 3] . (\pls i -> let lsi = map snd . filter ((==  i) . fst) $ pls in (10 * (length lsi - 1) + abs (sum lsi - (nabc !! i)))) . zip pattern $ ls
  print m


Measured memory_bytes: 3836
import java.io.PrintWriter

@JvmField val _writer = PrintWriter(System.out, false)
fun main(args: Array<String>) { _writer.solve(); _writer.flush() }
fun PrintWriter.solve() {
    val (h, w) = readLine()!!.split(' ').map { it.toInt() }
    val sArr = Array<String>(h + 1) {""}

    val yoko = Array(h + 1) {IntArray(w + 1){-1}}
    val tate = Array(h + 1) {IntArray(w + 1){-1}}
    fun yokoCheck(r:Int, c:Int, len: Int): Int {
        if (yoko[r][c] != -1) return yoko[r][c]
        if (sArr[r][c] == '#') {
            yoko[r][c] = 0
        }else if (sArr[r][c + 1] == '#' || c + 1 == w) {
            yoko[r][c] = len
        } else {
            val tmp = yokoCheck(r, c+1, len+1)
            yoko[r][c] = tmp
        }
        return yoko[r][c]
    }

    fun tateCheck(r:Int, c:Int, len: Int): Int {
        if (tate[r][c] != -1) return tate[r][c]
        if (sArr[r][c] == '#') {
            tate[r][c] = 0
        }else if (sArr[r + 1][c] == '#' || r + 1 == h) {
            tate[r][c] = len
        } else {
            val tmp = tateCheck(r+1, c, len+1)
            tate[r][c] = tmp
        }
        return tate[r][c]
    }

    repeat(h) {row->
        val s = readLine()!! + "#"
        sArr[row] = s
        repeat(w) {col ->
            yokoCheck(row, col, 1)
        }
    }
    val sb = StringBuffer("")
    repeat(w+1) { sb.append('#') }
    sArr[h] = sb.toString()

    var max = 0 to 0
    repeat(w) { col ->
        repeat(h) {row ->
            tateCheck(row, col, 1)
            if (max.first + max.second -1 <= tate[row][col] + yoko[row][col] -1) max = tate[row][col] to yoko[row][col]
        }
    }
    println(max.first + max.second -1)
}



Measured memory_bytes: 151952