akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#define bogo_sort std::sort
#define bozo_sort std::stable_sort
#define alles(obj) obj.begin(), obj.end()
#define elif else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo std::cout <<
#define read std::cin >>
#define endl std::endl
#define fin << '\n'
#define bash push_back
#define makePair std::make_pair
#define _ << ' ' <<
// type-define
#define Stack std::stack
#define Queue std::queue
#define Set std::set
#define PQueue std::priority_queue
#define Vector std::vector
#define Pair std::pair
#define Map std::map
#define HashMap std::unordered_map
#define Greater std::greater
using String = std::string;
using llong = long long;
using boolean = bool;
using Pii = Pair<int, int>;
using Vi = Vector<int>;
using Vii = Vector<Pii>;
// utils
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    template<class A, class B> A power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    template<class A, class B> A power ( A x, B n ) { return power( x, n, 1000000007 ); }
    template<class A> A gcd ( A x, A y ) { return x % y ? gcd( y, x % y ) : y; }
    template<class A, class B> A lcm ( A x, B y ) { return ( x / gcd(x, y) * y ); }
    template<class A> inline A abs ( A n ) { return ( n < 0 ) ? -n : n; }
    template<class A, class B> inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B> inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    int min = INF;

    signed call_of_Cthulhu( signed datum ) {

        String s;
        read s;
        for ( int i = 0; i < s.size()-2; i++ ) {
            String tmp = s.substr(i, 3);
            chmin(min, abs(std::stoi(tmp)-753));
        }
        echo min fin;

        return 0;
    }
}
signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;

class Program {
    static void Main (string[] args) {
        long N = long.Parse (Console.ReadLine ());
        string[] strtemp1 = Console.ReadLine ().Split (' ');
        var numarray = new long[N];
        long allxor = 0;
        for (long i = 0; i < N; i++) {
            numarray[i] = long.Parse (strtemp1[i]);
            allxor ^= numarray[i];
        }
        for (long i = 0; i < N - 1; i++) {
            Console.Write ((allxor ^ numarray[i]).ToString ());
            Console.Write (" ");
        }
        Console.WriteLine ((allxor ^ numarray[N - 1]).ToString ());
    }
}

//dotnet run --project test

Measured memory_bytes: 54064
/*Saurav Paul*/
#include<bits/stdc++.h>
using namespace std;

#define ll 					  long long int
#define boost		          ios_base::sync_with_stdio(0);
#pragma GCC optimize("O3")
#define loop(i,a,b)           for(ll i=a;i<=b;++i)
#define eb                    emplace_back
#define itoc(c)               ((char)(((int)'0')+c))
#define ctoi(c)               ((int)(((int)c)-'0'))
#define all(p)                p.begin(),p.end()
#define bug()				  debug() <<

///////////////////////

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef PAUL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define dbg(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#ifdef ONLINE_JUDGE
#define cerr if (false) cerr
#endif

///////////////////////
const int INF = 1e9 + 90;
const ll LINF = 1e18 + 90 ;
using pii = pair<int,int >;
using vec = vector<int> ;

int main()
{
    string s , p ;
    cin >> s >> p ;
    s += p[p.size()-1] ;
    cout << (s==p?"Yes" : "No") << endl ;

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define fi first
#define se second
#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 srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n;
    cin >> n;
    vi p(n);
    rep(i, n) cin >> p[i];
    int mx = p[0];
    int ans = 1;
    rrep(i, n-1) {
        if (mx >= p[i]) ans++;
        mx = min(mx, p[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

const int N = 1e+6+5;
int big = 1e+18+3;
int mod = 1e+9+7;

signed main()
{
    IOS;
        
    int s; cin>>s;

    map<int,int>exist;
    exist[s]=1;
    int prev = s;
    for (int i=2; ;i++)
    {
        int res;
        if ( prev%2==0 )
            res = prev/2;
        else
            res = prev*3+1;
        if (exist[res])
        {
            cout<<i<<endl;
            return 0;
        }
        exist[res]=1;
        prev = res;
    }

}

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

constexpr int N = 100'020;
char s[N];
int n;

int main() {
  cin >> (s + 1);
  n = strlen(s + 1);
  int mn = n;
  for (int i = 1; i < n; ++i) {
    if (s[i] != s[i + 1])
        mn = min(mn, max(i, n - i));
  }
  cout << mn << '\n';

  return 0;
}

Measured memory_bytes: 3728
#include <iostream>

using namespace std;

int main(void) {
	while (1) {
		int x, y, s;
		cin >> x >> y >> s;
		if (x == 0 && y == 0 && s == 0) break;

		int q[s];
		int m = 0;
		q[0] = 0;
		for (int p = 1; p < s; p++) {
			q[p] = p * (100 + x) / 100;
		}
		for (int i = 1; i < s; i++) {
			for (int j = 1; j < s; j++) {
				if (q[i] + q[j] == s) {
					int a = i * (100 + y) / 100;
					int b = j * (100 + y) / 100;
					int t = a + b;
					m = max(t, m);
				}
			}
		}

		cout << m << endl;
	}
	return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  Graph G(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vector<int> dist(n, -1); // 全頂点を「未訪問」に初期化
  queue<int> que;
  vector<int> guide(n);

  // 初期条件 (頂点 0 を初期ノードとする)
  dist[0] = 0;
  que.push(0); // 0 を橙色頂点にする

  // BFS 開始 (キューが空になるまで探索を行う)
  while (!que.empty()) {
      int v = que.front(); // キューから先頭頂点を取り出す
      que.pop();

      for (int nv : G[v]) {
          if (dist[nv] != -1) continue;

          guide[nv] = v;
          dist[nv] = dist[v] + 1;
          que.push(nv);
      }
  }

  cout << "Yes" << endl;
  for (int i = 1; i < n; i++) {
    cout << guide[i] + 1 << endl;
  }

  return 0;
}

Measured memory_bytes: 10648
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 2e5+100;
int len;
char str[N];

bool check(int l, int r)
{
	char ct = str[r+1];
	str[r+1] = '\0';
	char *p = strstr(str+l, "...");
	str[r+1] = ct;
	return p != 0;
}

int getl(int l)
{
		while (l >= 0) {
			if (l >= 2 && str[l-2] == '.') l-=2;
			else if (l >= 1 && str[l-1] == '.') l-=1;
			else break;
		}
		return l;
}
int getr(int r)
{
		while (r < len) {
			if (r+2<len && str[r+2] == '.') r+=2;
			else if (r+1<len && str[r+1] == '.') r+=1;
			else break;
		}
		return r;
}

int main()
{
	int n, a, b, c, d;
	while (scanf("%d%d%d%d%d", &n, &a, &b, &c, &d) != EOF) {
		scanf("%s", str);
		--a; --b; --c; --d;
		len = strlen(str);
		int al=getl(a), ar = getr(a);
		int bl=getl(b), br = getr(b);
		if (br < d || ar < c) {
			puts("No");
		} else if (d > c) {
			puts("Yes");
		} else if (c > d) {
			if (check(b-1, d+1)) puts("Yes");
			else puts("No");
		}
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
#define INF 1e9 //10^9
#define MOD 1000000007
#define INFL 100000000000000000//10^18 = 2^60


#define MAX_V 1000010

struct edge {
    int to, cap, rev;
};

vector<vector<edge>> G(MAX_V);
bool used[MAX_V];


void add_edge(int from, int to, int cap){
    edge F;
    edge T;
    F.to = to;
    F.cap = cap;
    F.rev = G[to].size();
    G[from].push_back(F);
    
    T.to = from;
    T.cap = 0;
    T.rev = G[from].size() - 1;
    G[to].push_back(T);
}

int dfs(int v, int t, int f){
    if(v == t) return f;
    used[v] = true;
    for(int i = 0; i < G[v].size(); i++){
        edge &e = G[v][i];
        if(!used[e.to] && e.cap > 0){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t){
    int flow = 0;
    while(1){
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if(f == 0) return flow;
        flow += f;
    }
}


int main(void){
    int V, E;
    cin >> V >> E;
    int s = 0, t = V - 1;
    for(int i = 0; i < E; i++){
        int u, v, c;
        cin >> u >> v >> c;
        add_edge(u, v, c);
    }
    
    cout << max_flow(s, t) << endl;
    
}



Measured memory_bytes: 27448
#include<stdio.h>

int a, b, c;
int ans[9999],p;
int now;
int ok = 0;
int yes = 0;
int main(){
	scanf("%d %d %d",&a,&b,&c);
	while ( ok == 0 ){

		now = (now + a) % b;
		for(int i = 1; i <= p ; i++){
			if(now == ans[i]){
				ok = 1;
				break ;
			}
		}
		if(ok == 0)ans[++p] = now;
	}
	for(int i = 1; i <= p ; i++){
		if(c == ans[i]){
			yes = 1;
			printf("YES");
			break;
		}
	}
	if(yes == 0)printf("NO");
	
}

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

using namespace std;

#define MAX 1010

int Levenshtein_Distance(char *s,char *t){
  int N = strlen(s),M = strlen(t);
  int dp[N+1][M+1];
  for(int i = 0 ; i <= N ; i++){
    dp[i][0] = i;
  }
  for(int i = 0 ; i <= M ; i++){
    dp[0][i] = i;
  }
  for(int i = 1 ; i <= N ; i++){
    for(int j = 1 ; j <= M ; j++){
      int cost = !(s[i-1] == t[j-1]);
      dp[i][j] = min(dp[i-1][j]+1,
                     min(dp[i][j-1]+1,dp[i-1][j-1]+cost));
    }
  }
  return dp[N][M];
}

int main(){
  char s[MAX],t[MAX];
  cin >> s >> t;
  cout << Levenshtein_Distance(s,t) << endl;
  return 0;
}

Measured memory_bytes: 5060
#include<stdio.h>
int main(void)
{
	char s[3];
	int count = 0;
	scanf("%s", s);
	for (int i = 0; i < 3; i++) {
		if (s[i]-'0' == 1) {
			count++;
		}
	}
	printf("%d", count);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;

int gcd(int m, int n){
    if(n == 0)
        return m;
    else
        return gcd(n, m % n);
}

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

    int res = 0;
    for(int i = 0; i <= n; ++i){
        res = gcd(res, a[i]);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define int long long
#define veb vector<bool>
#define vveb vector<veb>
#define vel vector<long long>
#define vvel vector<vel>
#define vvvel vector<vvel>
void mmin(int &a, int b) { a = min(a, b); }
void mmax(int &a, int b) { a = max(a, b); }
void sor(vel &v) { sort(v.begin(), v.end()); }
int zero(void) { return 0; }
signed main() {
	double t;
	double x;
	cin >> t >> x;
	double ans = t / x;
	printf("%6.9lf", ans);
	return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.meta;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long N, long M, long[] A, long[] B, long[] C) {
    long[long] counter;
    foreach (a; A)
        counter[a]++;
    foreach (b, c; zip(B, C))
        counter[c] += b;
    
    long left = N;
    long ans;
    foreach (k; counter.keys.sort!"a > b") {
        auto consumption = min(left, counter[k]);
        ans += k * consumption;
        left -= consumption;
        if (left <= 0)
            break;
    }

    return ans;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long M;
    M = input.front.to!long;
    input.popFront;

    long[] A = new long[](cast(size_t) (N));
    foreach (i; 0 .. cast(size_t) (N)) {
        A[i] = input.front.to!long;
        input.popFront;
    }

    long[] B = new long[](cast(size_t) (M));
    long[] C = new long[](cast(size_t) (M));
    foreach (i; 0 .. cast(size_t) (M)) {
        B[i] = input.front.to!long;
        input.popFront;
        C[i] = input.front.to!long;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, M, A, B, C);
    else
        solve(N, M, A, B, C).writeln;
}


Measured memory_bytes: 26432
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

bool comp(vector<int>& ids,vector<int>& solves,vector<int>& psums,int i,int j)
{
	if(solves[i]!=solves[j])
		return solves[i]>solves[j];
	if(psums[i]!=psums[j])
		return psums[i]<psums[j];
	if(ids[i]!=ids[j])
		return ids[i]<ids[j];
	return false;
}

void swap(vector<int>& ids,vector<int>& solves,vector<int>& psums,int i,int j)
{
	swap(ids[i],ids[j]);
	swap(solves[i],solves[j]);
	swap(psums[i],psums[j]);
}

int main()
{
	for(int t,p,r;cin>>t>>p>>r,t|p|r;){
		vector<int> teams(r),probs(r),times(r),ress(r);
		for(int i=0;i<r;i++){
			string s;
			cin>>teams[i]>>probs[i]>>times[i]>>s;
			teams[i]--; probs[i]--;
			ress[i]=s=="CORRECT";
		}
		
		vector<vector<int>> wrongs(t,vector<int>(p)),penals(t,vector<int>(p));
		for(int i=0;i<r;i++){
			int te=teams[i],pr=probs[i];
			if(penals[te][pr]>0)
				continue;
			if(ress[i])
				penals[te][pr]=wrongs[te][pr]*1200+times[i];
			else
				wrongs[te][pr]++;
		}
		
		vector<int> ids(t),solves(t),psums(t);
		for(int i=0;i<t;i++){
			ids[i]=i+1;
			solves[i]=count_if(penals[i].begin(),penals[i].end(),[](int x){return x>0;});
			psums[i]=accumulate(penals[i].begin(),penals[i].end(),0);
		}
		
		for(int i=0;i<t;i++)
			for(int j=i;j-->0;)
				if(!comp(ids,solves,psums,j,j+1))
					swap(ids,solves,psums,j,j+1);
		for(int i=0;i<t;i++)
			cout<<ids[i]<<' '<<solves[i]<<' '<<psums[i]<<endl;
	}
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    int min_a = 1000*1000*1000+1; //10**9
    int min_a_index;
    for (int i = 0; i < n; ++i){
        cin >> a[i];
        if (a[i] <= min_a){
            min_a = a[i];
            min_a_index = i;
        }
    }

    int ans = 0;
    while (true){
        int zero_count = 0;
        for (int i = 0; i < n; ++i){
            if (i==min_a_index){
                continue;
            }
            a[i] = a[i]%min_a;
//            cout << "i: " << i << " a[i]: " << a[i] << " min_a: " << min_a << endl;
            if (a[i]<min_a&&a[i]!=0){
                min_a = a[i];
                min_a_index = i;
            }
            if (a[i]==0){
                zero_count++;
            }
//            cout << endl << min_a << " " << a[0] << " " << a[1] << " " << a[2] << endl;
        }
        if (zero_count==n-1){
            ans = min_a;
            break;
        }
    }

    cout << ans << endl;
}


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

constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int L[100010];
int R[100010];
int ans[100010];

void solve() {
  string s;
  cin >> s;
  int pos = 0;
  REP(i,sz(s)) {
    if (s[i] == 'R') pos = i;
    else {
      L[i] = pos;
    }
  }
  for (int i = sz(s) - 1; i >= 0; i--) {
    if (s[i] == 'L') pos = i;
    else {
      R[i] = pos;
    }
  }
  REP(i,sz(s)) {
    if (s[i] == 'R') {
      int d = R[i] - i;
      if (d & 1) {
        ans[R[i] - 1]++;
      } else {
        ans[R[i]]++;
      }
    } else {
      int d = i - L[i];
      if (d & 1) {
        ans[L[i] + 1]++;
      } else {
        ans[L[i]]++;
      }
    }
  }
  REP(i,sz(s)) {
    cout << ans[i] << " \n"[i == sz(s) - 1];
  }
}

int main(int argc, char *argv[]){

  /* Regular */
  int case_num = 1;
  if (argc > 1 && stoi(argv[1])) cin >> case_num;
  REP(case_no, case_num) {
    cerr << endl << "case " << case_no + 1 << endl;
    solve();
  }
  
  // /* AOJ */
  // solve();
  return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int S;
    cin >> S;
    int X = S/100;
    int Y = S % 100;
    bool Xm, Ym;
    Xm = Ym = true;
    if(X > 12 || X == 0) Xm = false;
    if(Y > 12 || Y == 0) Ym = false;
    if(Xm && Ym) cout << "AMBIGUOUS" << endl;
    else if(!Xm && Ym) cout << "YYMM" << endl;
    else if(Xm && !Ym) cout << "MMYY" << endl;
    else cout << "NA" << endl;
}

Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

n,k=map(int, input().split())
h = list(map(int, input().split()))

h.sort(reverse=True)
ans = 0
for i in range(k,n):
    ans += h[i]

print(ans)





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

int main()
{
	int n, m;
	while (scanf("%d %d", &n, &m), n){
		int grid[100][100];
		int pic[4][50][50];
		for (int i = 0; i < n; i++){
			for (int j = 0; j < n; j++){
				scanf("%d", &grid[i][j]);
			}
		}
		for (int i = 0; i < m; i++){
			for (int j = 0; j < m; j++){
				int x;
				scanf("%d", &x);
				pic[0][i][j] = x;
				pic[1][m - j - 1][i] = x;
				pic[2][m - i - 1][m - j - 1] = x;
				pic[3][j][m - i - 1] = x;
			}
		}
		
		pair<int, int> res(114514, 114514);
		
		for (int p = 0; p < 4; p++){
			for (int x = 0; x <= n - m; x++){
				for (int y = 0; y <= n - m; y++){
					bool f = true;
					pair<int, int> t(114514, 114514);
					for (int i = 0; i < m; i++){
						for (int j = 0; j < m; j++){
							if (pic[p][i][j] == -1) continue;
							if (pic[p][i][j] != grid[x + i][y + j]) f = false;
							t = min(t, pair<int, int>(x + i, y + j));
						}
					}
					if (f) res = min(res, t);
				}
			}
		}
		
		if (res == pair<int, int>(114514, 114514)) puts("NA");
		else printf("%d %d\n", ++res.second, ++res.first);
	}
}

Measured memory_bytes: 1272
def pw(o , e):
    ans = ""
    olist = list(o)
    elist = list(e)

    for i in range(len(e)):
        ans += olist[i]
        ans += elist[i]

    if len(o) != len(e):
        ans += olist[-1]

    return ans


def main():
    o = str(input())
    e = str(input())
    print(pw(o , e))

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;
using namespace std;


char str[100005];

int main(int argc, char* argv[])
{
    scanf("%s", str);
    int K;
    scanf("%d", &K);
    int n=strlen(str);
    int i;
    for(i=0; i<n; i++) {
        if(i==n-1) {
            str[i]='a'+(str[i]+K-'a')%26;
        }
        else {
            int tmp='z'+1-str[i];
            if(tmp<26 && tmp<=K) {
                str[i]='a';
                K-=tmp;
            }
        }
    }
    printf("%s\n", str);

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <iomanip>
#include <math.h>
#include <algorithm>

int main()
{
	int N = 0, K = 0;
	double ans = 0;

	std::cin >> N >> K;
	std::vector<double> P(N);
	std::vector<double> E(N, 0.0);

	double Q = 0.0, tmp = 0.0;
	for (int i = 0; i < N; i++)
	{
		std::cin >> P[i];
		E[i] = (P[i] + 1.0) / 2.0;
      	tmp += E[i];
		if (i > K -1){
          	tmp -= E[i - K];
		}
      	ans = std::max(ans, tmp);
	}
	std::cout << std::fixed << std::setprecision(12) << ans << std::endl;
	return 0;
}

Measured memory_bytes: 3328
import java.util.*;

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

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

typedef long long ll;

ll N, K;
vector<ll> P;
ll Res;

int main() {
  cin >> N >> K;
  P.resize(N);
  for (ll i = 0; i < N; ++i) cin >> P[i];
  sort(P.begin(), P.end());
  for (ll i = 0; i < K; ++i) Res += P[i];
  cout << Res << endl;
  return 0;
}


Measured memory_bytes: 3648
def main():
    from bisect import bisect_left
    N = int(input())
    L = [int(i) for i in input().split()]
    L.sort()
    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            ab = L[i] + L[j]
            ri = bisect_left(L, ab)
            le = j + 1
            ans += ri - le

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 42204
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
using lli = long long;

#define MAX_N 1000

int N;
int T[MAX_N] = {0};
int A[MAX_N] = {0};


void solve(){
    lli x, y, q;
    x = T[0];
    y = A[0];
    for(int i = 1; i < N; i++){
        q = max(((x + T[i] - 1) / T[i]), ((y + A[i] - 1)/ A[i]));  
        x = T[i] * q;
        y = A[i] * q;
    }
    cout << x + y << endl;
    return ;
}


int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> T[i] >> A[i];
    }
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
int n;
double a[1000];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;

    double b;
    double sum = 0.0;
    for (int i = 0; i < n; i++)
    {
        cin >> b;
        a[i] = 1 / b;
        sum += a[i];
    }

    cout << setprecision(11) << double(1 / sum) << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
const int inf=2147483647;
int a[2010],t[2010],al[2010],n,k,q;
int work(int x){
	int i,j,s,M;
	s=M=0;
	for(i=1;i<=n+1;i++){
		if(a[i]>=a[x]){
			if(s==0)s=i;
		}else if(s){
			if(i-s>=k){
				for(j=s;j<i;j++)t[j-s+1]=a[j];
				sort(t+1,t+i-s+1);
				for(j=1;j+k-1<=i-s;j++){
					M++;
					al[M]=t[j];
				}
			}
			s=0;
		}
	}
	if(M<q)return inf;
	sort(al+1,al+M+1);
	return al[q]-a[x];
}
int main(){
	int i,ans;
	scanf("%d%d%d",&n,&k,&q);
	for(i=1;i<=n;i++)scanf("%d",a+i);
	ans=inf;
	for(i=1;i<=n;i++)ans=min(ans,work(i));
	printf("%d",ans);
}

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


int main(){
    int count[5][4][11], n;
    
    for ( int s = 1; s <= 4; s++){
        for ( int t = 1; t <= 3; t++)
            for ( int u = 1; u <= 10; u++)
            count[s][t][u] = 0;
    }
    cin >> n;
    for ( int i = 0 ; i < n; i++){
    int b, f, r, v;
    cin >> b >> f >> r >> v;
    count[b][f][r] += v;
}
    
    
    for ( int s = 1; s <= 4; s++){
        if (s > 1) cout << "####################\n";
        for ( int t = 1; t <= 3; t++){
            for ( int u = 1; u <= 10; u++){
                cout << " " << count[s][t][u];
            }
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3088
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= b; --i)
#define range(i, a, b, c) for (int i = a;             \
                               c > 0 ? i < b : i > b; \
                               i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define dump(x) cerr << #x << " = " << (x) << endl
#define int long long
#ifdef _MSC_VER
const bool test = true;
#else
const bool test = false;
#endif

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while (getline(ss, buffer, sep))
    {
        v.push_back(buffer);
    }
    return v;
}

template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
    return accumulate(begin, end, 0ll);
}

void solve();

signed main()
{
    cout << fixed << setprecision(20);
    solve();
    while (true)
    {
        char s[MAX];
        if (scanf("%s", s) == EOF)
            break;
        int n = strlen(s);
        for (int i = n - 1; i > -1; i--)
        {
            ungetc(s[i], stdin);
        }
        solve();
    }
    return 0;
}

int N, K;
int c[MAX];

void solve()
{
    cin >> N >> K;
    K--;
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        c[a] += b;
    }
    int sum = 0;
    rep(i, MAX) {
        sum += c[i];
        if (sum > K) {
            cout << i << endl;
            return;
        }
    }
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int N, M;
    cin >> N >> M;
    const int NMMAX = 50;
    int A[NMMAX], B[NMMAX];
    for (int i = 0; i < M; ++i) {
        cin >> A[i] >> B[i];
    }
    int road[NMMAX];
    for (int i = 0; i < N; ++i) {
        road[i] = 0;
    }
    for (int i = 0; i < M; ++i) {
        road[A[i] - 1] += 1;
        road[B[i] - 1] += 1;
    }
    for (int i = 0; i < N; ++i) {
        cout << road[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

int N, L;
int main() {
  cin >> N >> L;
  string s[N];
  for (int i = 0; i < N; ++i) cin >> s[i];

  sort(s, s + N);

  for (int i = 0; i < N; i++) {
    cout << s[i];
  }

  cout << endl;
}


Measured memory_bytes: 256
# coding: utf-8

import sys
import math
import collections
import itertools
def input(): return sys.stdin.readline().strip()
def gcd(x, y): return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y): return (x * y) // gcd(x, y)
MOD = 10 **9 + 7

# N = int(input())
# S = input()
A, B = map(int, input().split())
# 横
# L = [int(x) for x in input().split()]
# 縦
# A = [int(input()) for _ in range(N)]
# 多次元
# L = [[int(x) for x in input().split()] for _ in range(N)]

print(max(max(A + B, A - B), A * B))



Measured memory_bytes: 38384
/*
   AUTHOR :- Gaurang_Kothiya
   
   Quote:-" Great things never come from comfort zones."                                                                                                                
*/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
 
using namespace std;
using namespace __gnu_pbds;  

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> data_set; 
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long  
#define ld long double
#define f(i,x,n) for(ll i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(ll i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 1000000007



void solver()
{
	string s;
	cin>>s;
	if(s=="AAA" || s=="BBB")cout<<"No";
	else cout<<"Yes";	
}

signed main() 
{
	speed	
		
	ll q=1;	
	//cin>>q;	
	
	while(q--)	
	solver();	
	
	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}

 
 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Integer n = sc.nextInt();
		int[] result = new int[45];
		result[0] = 1;
		result[1] = 1;
		System.out.println(fib(n, result));
	}

//	public static Integer fib(Integer n, int[] result) {
//		Integer ret;
//		if(result[n] == 0) {
//			ret = fib(n -1, result) + fib(n - 2, result);
//			result[n] = ret;
//		}
//		else {
//			ret = result[n];
//		}
//		return ret;
//	}

	public static Integer fib(Integer n, int[] result) {
		for(int i = 2; i <= n; i++) {
			result[i] = result[i - 1] + result[i -2];
		}
		return result[n];
	}
}



Measured memory_bytes: 26324
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace A {
	class main {
		public main() { }
		public static int Main() {
			new main().run();
            return 0;
        }
		void run() {
			Scanner cin = new Scanner();
			int b=4280;
			while(true) {
				int n = cin.nextInt();
				if(n==-1) break;
				int a=1150;
				n-=10;
				if(n>0 && n<=10) a+=n*125;
				else if(n>10 && n<=20) {
					a+=1250;
					n-=10;
					a+=n*140;
				} else if(n>20) {
					n-=20;
					a+=1250;
					a+=1400;
					a+=n*160;
				}
				Console.WriteLine(b-a);
			}
		}
	}

	class Scanner {
		string[] s;
		int i;
		
		char[] cs = new char[] { ' ' };
		
		public Scanner() {
			s = new string[0];
			i = 0;
		}
		public string next() {
			if (i < s.Length) return s[i++];
			s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
			i = 0;
			return s[i++];
		}
		public int nextInt() {
			return int.Parse(next());
		}
		public long nextLong() {
			return long.Parse(next());
		}
		public double nextDouble() {
			return double.Parse(next());
		}
	}
}


Measured memory_bytes: 5616
N,M=map(int,input().split())
A=list(map(int,input().split()))

T=[0,2,5,5,4,5,6,3,7,6]
B=[]
for i in A:
    B.append(T[i])
B=sorted(list(set(B)))
dp=[0 for i in range(N+1)]
AB=[[i,T[i]] for i in A]
AB=sorted(AB,reverse=True)

for i in range(1,N+1):
    for j in B:
        if i-j>=0 and dp[i-j]!=-1:
            dp[i]=max(dp[i],dp[i-j]+1)
            #print(i,j,dp[i])
    if dp[i]==0:
        dp[i]=-1
#print(dp)
#print(AB)

c=N
U=[0 for i in range(8)]
while c>0:
    for i in range(len(AB)):
        if c-AB[i][1]>=0 and dp[c]==dp[c-AB[i][1]]+1:
            U[AB[i][1]]+=1
            c-=AB[i][1]
            break
#print(U)

ans=""
if 9 in A:
    ans+='9'*U[6]
    U[6]=0
if 8 in A:
    ans+='8'*U[7]
if 7 in A:
    ans+='7'*U[3]
if 6 in A:
    ans+='6'*U[6]
if 5 in A:
    ans+='5'*U[5]
    U[5]=0
if 4 in A:
    ans+='4'*U[4]
if 3 in A:
    ans+='3'*U[5]
    U[5]=0
if 2 in A:
    ans+='2'*U[5]
if 1 in A:
    ans+='1'*U[2]

print(ans)

Measured memory_bytes: 3412
n,q=map(int,input().split())
nextlist=[[] for _ in range(n)]
pointlist=[0]*n
for i in range(n-1):
    tmpa,tmpb=map(int,input().split())
    nextlist[tmpa-1].append(tmpb)
    nextlist[tmpb-1].append(tmpa)

for i in range(q):
    tmpp,tmpx=map(int,input().split())
    pointlist[tmpp-1] += tmpx

#for i,next in enumerate(nextlist):
#    next.append(pointlist[i])
outlist=[0]*n
done=[False]*n
nextp=[[],[]]

outlist[0]=pointlist[0]
done[0]=True
for j in nextlist[0]:
    nextp[0].append([j,pointlist[0]])
    done[j-1]=True

i=0

while True:
    x = -i+1
    if nextp[i] == []:
        break
    else:
        for ne in nextp[i]:
            n=ne[0]
            p=ne[1]
            outlist[n-1] = pointlist[n-1] + p

            for j in nextlist[n-1]:
                if not done[j-1]:
                    nextp[x].append([j,outlist[n-1]])
                    done[j-1]=True
        nextp[i]=[]
        i=x

for out in outlist:
    print(out,end=' ')

Measured memory_bytes: 72100
#include<iostream>
 
using namespace std;
 
int n,m;
 
int solve(){
  int ans=m;
  int tmp=m;
 
  while(n--){
    int a,b;
    cin >> a >> b;
    tmp+= a-b;
    ans = max(ans,tmp);
    if(tmp < 0) return 0;
  }
  return ans;
}
int main(){
 
  cin >> n >> m;
 
   
  cout << solve() << endl;
  return 0;
}

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

int main(){
  int h,w,n;
  cin >> h >> w >> n;
  vector<vector<int>>ans(h,vector<int>(w));
  vector<int>a(n);
  for(int i=0;i<n;i++)cin >> a.at(i);
  for(int i=0,c=0;i<h;i++){
    if(i%2==0){
      for(int j=0;j<w;j++){
        if(a.at(c)==0)c++;
        ans.at(i).at(j)=c+1;
        a.at(c)--;
      }
    }else{
      for(int j=w-1;j>=0;j--){
        if(a.at(c)==0)c++;
        ans.at(i).at(j)=c+1;
        a.at(c)--;
      }
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++)
    cout << ans.at(i).at(j) << (j==w-1?'\n':' ');
  }
  return 0;
}

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

#define MAX 1000

int N;
int H;
int W;
int A[MAX];
int B[MAX];


int main() {
	cin >> N >> H >> W;
	for( int i = 0; i < N; i++ ) {
		cin >> A[i] >> B[i];
	}

	int ans = 0;
	for( int i = 0; i < N; i++ ) {
		if( A[i] >= H && B[i] >= W ) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const LL INF=1<<17;

int main(){
    int N;cin >> N;
    int sum=0;
    vector<int> l(N);
    int m=0;
    for (int i = 0; i < N; i++) {
        cin >> l[i];
        sum+=l[i];
        m=max(m,l[i]);
    }
    if(2*m<sum) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

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

    deque<int> q;
    rep(i,n){
        if(i%2==1){
            q.push_front(a[i]);
        } else {
            q.push_back(a[i]);
        }
    }

    if(n%2==1){
        rep(i,n){
            int a = q.back();
            q.pop_back();
            cout << a << " ";
        }
    } else {
        rep(i,n){
            int a = q.front();
            q.pop_front();
            cout << a << " ";
        }
    }
    cout << endl;
}


Measured memory_bytes: 4800
#include <iostream>
#include <fstream>
#include <iomanip>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>

#include <algorithm>
#include <numeric>
#include <random>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define endl '\n'

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7;
const int MAXN = static_cast<int>(1e6) + 17;

struct fenwick {
    int n;
    vector<int> F;

    fenwick(int n) : n(n), F(vector<int>(n, 0)) { }

    int sum(int r) {
        int res = 0;

        for (; r >= 0; r &= r + 1, --r)
            res += F[r];

        return res;
    }

    void upd(int l, int dx) {
        for (; l < n; l |= l + 1)
            F[l] += dx;
    }

    int sum(int l, int r) { return sum(r) - sum(l - 1); }
};

int n;
int a[MAXN], ps[MAXN];

bool read() {
    if (!(cin >> n))
        return false;

    forn (i, n)
        cin >> a[i];

    return true;
}

ll calc(int x) {
    forn (i, n)
        ps[i + 1] = ps[i] + (a[i] <= x ? 1 : -1);

    fenwick F(2 * n + 1);
    ll res = 0;
    F.upd(n, 1);

    forn (i, n) {
        res += F.sum(0, ps[i + 1] + n - 1);
        F.upd(ps[i + 1] + n, 1);
    }

    return res;
}

void solve() {
    int l = 1, r = INF;
    ll k = (n * 1ll * (n - 1) / 2 + n) / 2 + 1;

    for (; l < r; ) {
        auto m = (l + r) / 2;
        
        if (calc(m) >= k)
            r = m;
        else
            l = m + 1;
    }

    cout << l << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::mt19937 rand('S' + 'E' + 'R' + 'E' + 'Z' + 'H' + 'K' + 'A');

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 5516
def intersection_sort(arr, n)
  for i in 1..(n-1)
    v = arr[i]
    j = i-1
    while j >= 0 and arr[j] > v
      arr[j+1] = arr[j]
      j = j - 1
    end
    arr[j+1] = v
    puts arr.join(' ')
  end
end

n = gets.chomp.to_i
arr = gets.chomp.split(' ').map(&:to_i).shift(n)
puts arr.join(' ')

intersection_sort(arr, n)



Measured memory_bytes: 6892
import sys

indata = sys.stdin.read().strip().splitlines()[1]
numbers = sorted(map(int, indata.split(" ")))
if len(numbers) % 2 != 0:
  print(0)
  sys.exit(0)

center = len(numbers) // 2
v1, v2 = numbers[center - 1], numbers[center]
if v1 == v2:
  print(0)
  sys.exit(0)
print(v2 - v1)


Measured memory_bytes: 14452
/*

I will just keep trying.I know can do it.And I will!!. 

 
   PPPPPPPP    UU      UU     CCCCCCCC    CCCCCCCC     HH     HH     UU      UU
   PP    PP    UU      UU     CC          CC           HH     HH     UU      UU
   PP    PP    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   PPPPPPPP    UU      UU     CC          CC           HHHHHHHHH     UU      UU
   PP          UU      UU     CC          CC           HH     HH     UU      UU
   PP          UUUUUUUUUU     CCCCCCCC    CCCCCCCC     HH     HH     UUUUUUUUUU
  

*/
   
   
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
typedef long long ll;
#define loop(i,n)  for(int i=0;i<n;i++)
#define ford(i,a,b) for(int i=b;i>=a;i--)
#define read(a) int a; cin >>a;
#define readarr(a,n) int a[n] ; for(int i=0;i<n;i++) cin >> a[i];
#define readmat(a,n,m) int a[n][m]; for(int i=0;i<n;i++) for(j=0;j<m;j++) cin >> a[i][j];
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define pi pair<int,int>
#define vii vector<vector<int>>
#define sti set<int>
#define vpi vector<pair<int,int>>
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define printmat(a,n,m) for(int i=0;i<n;i++) {for(j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define endl "\n"
#define mp make_pair
const ll inf = 1e18;
const ll mod = 1e9 + 7;
 
signed main()
{
 
    fast;
    int h1,s1,h2,s2;
    cin >> h1>>s1>>h2>>s2;
    int t=1;
    while(1){
    if(h2-s1<=0 && t==1) { 
    	cout<<"Yes"<<endl;
    	break;
    }
    else
    if(t==1){
    	h2-=s1;
    	t=2;
    }
    else if(h1-s2<=0 && t==2) {
    	cout<<"No"<<endl;
    	break;
    }
    else
    if(t==2){
    	h1-=s2;
    	t=1;
    }
   }
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#include <assert.h>
#include <bitset>
#define Endl endl
#define mp make_pair
#define ll long long 
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define quickcin ios_base::sync_with_stdio(false);
template <typename T1,typename T2> inline void chmin(T1 &x,T2 b) {if(b<x) x=b;}
template <typename T1,typename T2> inline void chmax(T1 &x,T2 b) {if(b>x) x=b;}
template <typename T1,typename T2> inline void chmod(T1 &x,T2 b) {x%=b,x+=b;if(x>=b) x-=b;}
const int inf=1039074182;
const ll llinf=1LL*inf*inf;
using namespace std;

using namespace std;
template <typename T>
ostream & operator << (ostream& cout,vector<T> vec)
{
	cout<<"{";
	for(int i=0;i<vec.size();i++)
	{
		cout<<vec[i];
		if(i!=(int)vec.size()-1) cout<<',';
	}
	cout<<"}";
	return cout;
}

template <typename T1,typename T2>
ostream & operator << (ostream & cout,pair<T1,T2> p)
{
	cout<<"("<<p.first<<','<<p.second<<")";
	return cout;
}

template <typename T>
T operator * (vector <T> v1,vector <T> v2)
{
	assert(v1.size()==v2.size());
	int n=v1.size();
	T res=0;
	for(int i=0;i<n;i++)
	{
		res+=v1[i]*v2[i];
	}
	return res;
}

template <typename T1,typename T2>
pair<T1,T2> operator - (pair<T1,T2> x)
{
	return make_pair(-x.first,-x.second);
}

template <typename T>
vector<vector<T> > operator ~ (vector<vector <T> > vec)
{
	vector <vector<T> > v;
	int n=vec.size(),m=vec[0].size();
	v.resize(m);
	for(int i=0;i<m;i++)
	{
		v[i].resize(n);
	}
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<n;j++)
		{
			v[i][j]=vec[j][i];
		}
	}
	return v;
}

template <int D>
struct XorSpace
{
	vector <pair<bitset <D>,int> > basis;
	inline int findBit(bitset <D> &x,int pos=0)
	{
		int fb=-1;
		for(fb=pos;fb<D;fb++)
		{
			if(x[fb]) break;
		}
		return fb;
	}
	inline void normalize(bitset <D> &x)
	{
		int fb=findBit(x);
		for(auto &v:basis)
		{
			if(v.second<fb) continue;
			if(v.second>fb) break;
			x^=v.first;
			fb=findBit(x,fb);
		}
	}
	inline void add(bitset <D> x)
	{
		normalize(x);
		if(x==0) return;
		int fb=findBit(x);
		pair<bitset<D>,int> o;
		basis.push_back(o);
		for(int i=basis.size()-1;i>=0;i--)
		{
			if(i==0 || basis[i-1].second<fb)
			{
				basis[i].first=x;
				basis[i].second=fb;
				break;
			}
			basis[i]=basis[i-1];
		}
	}
	inline bool query(bitset <D> x)
	{
		normalize(x);
		return (x==0);
	}
	inline void clear()
	{
		basis.clear();
	}
	inline void print()
	{
		for(auto &o:basis)
		{
			cout<<o<<endl;
		}
	}
};

XorSpace <200> xs;
void solve()
{
	int n;
	string s;
	ll a[205];
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	cin>>s;
	xs.clear();
	for(int i=n-1;i>=0;i--)
	{
		if(s[i]=='0') xs.add(a[i]);
		else
		{
			if(xs.query(a[i])) continue;
			cout<<1<<endl;
			return;
		}
	}
	cout<<0<<endl;
}

int main()
{
//	freopen("input.txt","r",stdin);
	int T;
	cin>>T;
	while(T--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3608