akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int n, m, x, y, z;
int p, q, r;
vector < int > edges[100009], tmp;
int parnts[100009];
int clrs[100009];
void dfs(int pos, int par)
{

    parnts[pos] = par;

    for(int i = 0; i < edges[pos].size(); i++){
        if(edges[pos][i] == par) continue;
        dfs(edges[pos][i], pos);
    }

}

void dfs2(int pos, int par, int clr)
{
    clrs[pos] = clr;

    for(int i = 0; i < edges[pos].size(); i++){
        if(edges[pos][i] == par) continue;

        if(clrs[edges[pos][i]] == 0) dfs2(edges[pos][i], pos, clr);
        else dfs2(edges[pos][i], pos, clrs[edges[pos][i]]);
    }
}

int main()
{
    cin >> n;
    for(int i = 1; i < n; i++){
        scanf("%d %d", &x, &y);
        edges[x].push_back(y);
        edges[y].push_back(x);
    }

    dfs(1, 0);

    int xx = n;

    while(xx != 0){
        tmp.push_back(xx);
        xx = parnts[xx];
    }

//    for(int i = 0; i < tmp.size(); i++) cout << tmp[i] << ' ';
//    cout << endl;

    for(int i = 0, j = tmp.size() - 1; i <= j; i++, j--){
        clrs[tmp[i]] = -1;
        clrs[tmp[j]] = 1;
    }

    dfs2(1, 0, 1);
    int kala = 0, dhola = 0;

    for(int i = 1; i <= n; i++){
        //cout << i << ' ' << clrs[i] << endl;
        if(clrs[i] == 1) dhola++;
        else kala++;
    }

    if(dhola <= kala) cout << "Snuke" << endl;
    else  cout << "Fennec" << endl;

    return 0;
}


Measured memory_bytes: 13304
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, m;
    cin >> n >> m;

    if(m == 0) {
        if(n == 1) {
            out(0);
        }
        else if(n == 2) {
            out(10);
        }
        else {
            out(100);
        }
        re0;
    }

    vl v(n, -1);
    rep(i, m) {
        ll s, c;
        cin >> s >> c;
        s--;
        if(v[s] == -1) {
            v[s] = c;
        }
        else if(v[s] != c) {
            out(-1);
            re0;
        }
    }

    if(n == 1 && v[0] == -1) {
        out(0);
        re0;
    }

    if(n > 1 && v[0] == 0) {
        out(-1);
        re0;
    }

    rep(i, n) {
        if(v[i] == -1) {
            if(i == 0) {
                v[i] = 1;
            }
            else {
                v[i] = 0;
            }
        }
    }

    rep(i, n) {
        cout << v[i];
    }
    
    cout << endl;
    re0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
vector<int> v[100000];
bool used[100000];
int endpoint = 0;
int maxx = 0;
 
int dfs(int cur) {
    used[cur] = true;
    if (v[cur].size() == 1) endpoint++;
    vector<int> w;
    w.push_back(0);
    w.push_back(0);
    for (int i = 0; i < v[cur].size(); i++) {
        if (!used[v[cur][i]]) {
            int to = v[cur][i];
            w.push_back(dfs(to));
        }
    }
    sort(w.rbegin(), w.rend());
    maxx = max(maxx, (v[cur].size() == 2) + w[0] + w[1]);
    return (v[cur].size() == 2) + w[0];
}
 
int main()
{
 
 //   ofstream myo;
  //  myo.open ("output01.txt");
 
//	ifstream myi;
 //   myi.open ("input01.txt");
    int n;
	cin>>n;
 
	for(int i=1;i<n;i++){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
    memset(used, 0, sizeof(used));
    dfs(0);
    cout << maxx + endpoint << endl;
    return 0;
}

Measured memory_bytes: 5888
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
string s[400];
int h, w;
bool used[400][400];
ll ct1=0, ct2=0;
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};
bool check(int x, int y){
	if(x<0 || x>=h || y<0 || y>=w) return false;
	return true;
}
void dfs(int x, int y){
	used[x][y]=1;
	if(s[x][y]=='#') ct1++;
	else ct2++;
	for(int k=0; k<4; k++){
		int x1=x+dx[k], y1=y+dy[k];
		if(used[x1][y1]) continue;
		if(check(x1, y1) && s[x1][y1]!=s[x][y]){
			dfs(x1, y1);
		}
	}
}
int main()
{
	cin>>h>>w;
	for(int i=0; i<h; i++) cin>>s[i];
	ll ans=0;
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(!used[i][j]){
				ct1=0, ct2=0;
				dfs(i, j);
				ans+=(ct1*ct2);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 15616
import numpy as np

N, T = map(int, input().split())

A = []
B = []

for _ in range(N):
    A_temp, B_temp = map(int,input().split())
    A.append(A_temp)
    B.append(B_temp)

A = np.array(A, np.int)
B = np.array(B, np.int)

idx = np.argsort(A)
A = A[idx]
B = B[idx]

dp = np.zeros((N, T), np.int)

for i in range(N - 1):
    dp[i+1, :A[i]] = dp[i, :A[i]]
    dp[i+1, A[i]:] = np.maximum(dp[i, A[i]:], dp[i, :-A[i]] + B[i])

print(np.max(dp[:, -1] + B))

Measured memory_bytes: 82756
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int X = Integer.parseInt(tokens[1]);
		List<Integer> points = new ArrayList<>();
		points.add(X);
		tokens = in.nextLine().split(" ");
		for (int i = 0; i < N; ++i) {
			points.add(Integer.parseInt(tokens[i]));
		}
		Collections.sort(points);
		Queue<Integer> queue = new PriorityQueue<Integer>(N + 1, new Comparator<Integer>() {
			@Override
			public int compare(Integer o1, Integer o2) {
				if (o1 > o2) {
					return -1;
				} else if (o1 < o2) {
					return 1;
				} else {
					return 0;
				}
			}
		});
		for (int i = 1; i < points.size(); ++i) {
			queue.add(points.get(i) - points.get(i - 1));
		}

		while (true) {
			if (queue.size() == 1) {
				break;
			}
			Integer a = queue.poll();
			Integer b = queue.poll();
			queue.add(gcd(a, b));
		}
		System.out.println(queue.poll());

		in.close();
	}

	private static int gcd(int large, int small) {
		if (small > large) {
			return gcd(small, large);
		}
		if (large % small == 0) {
			return small;
		}
		return gcd(small, large % small);
	}

}

Measured memory_bytes: 50172
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

int dp[3001][3001];

int main(void) {
    string s,t;

    cin>>s>>t;
    
    for(int i = 0;i < s.length();i++) {
        for(int j = 0;j < t.length();j++) {
            if(s[i] == t[j]) {
                dp[i+1][j+1] = dp[i][j]+1;
                
            } else {
                dp[i+1][j+1] = max({dp[i][j+1],dp[i+1][j]});
            }
        }
    }

    string ans = "";
    int i = s.length();
    int j = t.length();
    while(i > 0 && j > 0) {
        if(dp[i][j] == dp[i-1][j])
            --i;
        else if(dp[i][j] == dp[i][j-1])
            --j;
        else {
            ans = s[i-1]+ans;
            --i,--j;
        }

    }

    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 35456
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <numeric>
#include <limits>
#include <type_traits>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main () {
    int n;
    cin >> n;
    vector <int> a(n);
    vector <int> b(n);
    for(int i =0; i<n;i++) {
        cin >> a[i];
        b[a[i]-1] = i+1;
    }
    rep(i,n) {
        cout << b[i];
        if (i != n-1) cout <<' ';
    }
    cout << endl;
}

Measured memory_bytes: 1664
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c;
  ll ans = 0;
  cin>>n>>a>>b;
  rep(i,n+1) {
    ll p = i;
    ll o = 0;
    while(p!=0){
      o += p % 10;
      p= p / 10;
      // cout<<p<<endl;
    }
    // cout<<o<<endl;
    if(o>=a and o<=b) {
      ans+=i;
      // cout<<i<<endl;
    }
  }
  cout<<ans<<endl;



}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll maxn = 300005;
const ll mm = 1e+18;
void solve()
{
    int n;
    cin>>n;
    int x=n%10;
    if(x==3) cout<<"bon";
    else if(x==0||x==1||x==6||x==8) cout<<"pon";
    else cout<<"hon";
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    // srand(time(0));
    //freopen("sp.txt","r",stdin);
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  double gusu,kisu;
 for(int i=1;i<N+1;i++){
 if(i%2==0){
 	gusu++;
  }
   else{
   kisu++;
   }
 }
  double kotae=kisu/(gusu+kisu);
cout<<kotae<<endl;  
  
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long 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; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    int ans = n;
    for(int i = 1; i < n; ++i){
        if(s[i] != s[i-1]){
            int cost = max(n-i, i);
            chmin(ans, cost);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b;
    cin>>a>>b;
    if(a%b<=abs(b-a%b)){
      cout<<a%b<<endl;
    }
    else{
      cout<<abs(b-a%b)<<endl;
    }
    return(0);
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
using ll = long long;
int main(){ 
    ll n;
    cin>>n;
    vector<ll> a(n);
    double b=0;
    REP(i,n) cin>>a[i];
    REP(i,n){
    b+=a[i];
    } 
    b/=a.size();
    b=round(b);
    ll c=0;
    REP(i,n){
        c+=(a[i]-b)*(a[i]-b);
    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 256
//file_name:ABC109_B.cpp
#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");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&y);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */

ll gcd(ll a,ll b){
    if(b%a==0){
        return a;
    }else{
        gcd(b%a,a);
    }
}
int main() {
    int n;
    scanf("%d",&n);
    ll x;
    scanf("%lld",&x);
    ll a[n] = {};
    rep(i,n){
        ll aaa;
        scanf("%lld",&aaa);
        a[i]=abs(aaa-x);
    }
    sort(a, a+n);
    ll ans = a[0];
    rep(i,n){
        if(a[i]%ans==0){
            continue;
        }else{
            ans = gcd(ans,a[i]);
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>
struct circle{
    long long int ori;
    long long int rad;
    void in(){
        scanf("%lld%lld",&ori,&rad);
        return ;
    }
    long long int right(){
        return ori+rad;
    }
    long long int left(){
        return ori-rad;
    }
    double dis(double pos){
        return sqrt(rad*rad-(ori-pos)*(ori-pos));
    }
};
const int N=1e5+10;
double min(double a,double b){return a>b?b:a;}
long long int max(long long int a,long long int b){return a>b?a:b;}
long long int min(long long int a,long long int b){return a<b?a:b;}
int n;
circle a[N];
double test(double pos){
    double ans=N*20;
    for(int i=0;i<n;i++)ans=min(ans,a[i].dis(pos));
    return ans;
}
int main(){
    long long int mr,ml;
    double l,r,lv,rv;
    scanf("%d",&n);
    a[0].in();
    mr=a[0].right();
    ml=a[0].left();
    for(int i=1;i<n;i++){
        a[i].in();
        mr=min(mr,a[i].right());
        ml=max(ml,a[i].left());
    }
    l=ml;
    r=mr;
    while(r-l>0.00001){
        lv=(r+l*2)/3;
        rv=(r*2+l)/3;
        if(test(lv)>test(rv))r=rv;
        else l=lv;
    }
    printf("%.20lf\n",test(l));
}


Measured memory_bytes: 4280
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
void solve(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a+b+c>=22) cout <<"bust";
    else cout << "win";
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    while(t--) solve();
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

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


int main(){
    int n; cin >> n;
    string S, T; cin >> S >> T;
    REP(i, n) cout << S[i] << T[i];
    cout << "\n";
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    long  a, b, c, d;
    long l = 1;
    cin>>a>>b;
    c = a;
    d = b;
   if (a > b){
       b = c;
       a = d;
   }

    while(true){
        if (a%b==0){
            cout << d*c / l;
            break;
        }
            l = a % b;
            a = b;
            b = l;
    }
}

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

int main() {
  int N; cin >> N;
  int p[N];
  for(int i = 0; i < N; ++i) {
    cin >> p[i];
  }
  int ans = 0;
  for(int i = 1; i < N-1; ++i) {
    if((p[i-1] < p[i] && p[i] < p[i+1]) || (p[i+1] < p[i] && p[i] < p[i-1])) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(void){
    
    bool isFirst = true;
    while(true){
        int H,W;
        cin >> H >> W;
        if (H == 0 && W == 0) break;
        if (isFirst) isFirst = false;
        else cout << endl;
        for(int r = 0; r < H; r++){
            for(int c = 0; c < W; c++){
                cout << "#";
            }
            cout << endl;
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3116
#include<stdio.h>

#define MAX 100000

void swap(int& a, int& b)
{
    int c;
    c = a; a = b; b = c;
}

int partition(int* A, int p, int r)
{
    int i, j, x;
    x = A[r];
    i = p - 1;
    for(j = p; j < r; j++){
        if(A[j] <= x){ i++; swap(A[i], A[j]); }
    }
    swap(A[i + 1], A[r]);

    return i + 1;
}

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

    q = partition(A, 0, n - 1);

    for(i = 0; i < q; i++){ printf("%d ", A[i]); }

    printf("[%d]", A[q]);

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

    printf("\n");

    return 0;
}

Measured memory_bytes: 1424
def main():
    import sys
    input = sys.stdin.readline
    n = int(input())
    l = list(map(int,input().split()))
    check = [[1]*n for i in range(n)]
    d =  [[min(i, n-i-1, j, n-j-1) for j in range(n)] for i in range(n)]

    ans = 0
    for t in l:
        t -=1
        x = t//n
        y = t%n
        check[x][y] = 0
        ans += d[x][y]
        q = []
        q.append((x,y,d[x][y]))
        while q:
            bx,by,z = q.pop()

            if bx != 0:
                if d[bx-1][by] > z:
                    d[bx-1][by] = z
                    q.append((bx-1,by,z+check[bx-1][by]))
            if bx != n-1:
                if d[bx+1][by] > z:
                    d[bx+1][by] = z
                    q.append((bx+1,by,z+check[bx+1][by]))
            if by != 0:
                if d[bx][by-1] > z:
                    d[bx][by-1] = z
                    q.append((bx,by-1,z+check[bx][by-1]))
            if by != n-1:
                if d[bx][by+1] > z:
                    d[bx][by+1] = z
                    q.append((bx,by+1,z+check[bx][by+1]))  
    print(ans)
if __name__ =="__main__":
    main()

Measured memory_bytes: 197940
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int N = 1e6 + 5;

int h[N], ans[N];

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int t = 1; 
    // cin >> t; 
    while (t--) {
    	int n;
    	cin >> n;
    	int a[n];
    	for(int i = 0; i < n; i++) {
    		cin >> a[i];
    		h[a[i]]++;
    	}

    	for(int i = 1; i < N; i++) {
			for(int j = i; j < N; j += i)
				ans[j] += h[i];
		}

    	int cnt = 0;
    	for(int i = 0; i < n; i++)
    		cnt += ans[a[i]] == 1;
    	cout << cnt << '\n';


        
    }
    
    return 0;
}



Measured memory_bytes: 20728
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const ll D = 32;

vector<vector<pair<ll,ll>>> db;

ll f(ll pos, ll k, ll r) {
    ll cur = pos;
    ll ret = 0;
    for(int i = 0; i < D; i++) {
        if(k & (1LL<<i)) {
            ret += db[i][cur].second;
            cur = db[i][cur].first;
        }
    }

    ll nax = ret;
    for(int i = k; i < r; i++) {
        ret += db[0][cur].second;
        cur = db[0][cur].first;
        nax = max<ll>(nax, ret);
    }

    return nax;
}



int main()
{
    ll n, k;
    cin >> n >> k;
    db.resize(D, vector<pair<ll,ll>>(n));
    vector<ll> prev(n);
    for(ll i = 0; i < n; i++)cin >> db[0][i].first,db[0][i].first--,prev[db[0][i].first] = i;
    for(ll i = 0; i < n; i++)cin >> db[0][prev[i]].second;

    for(ll i = 1; i < D; i++) {
        for(ll j = 0; j < n; j++) {
            db[i][j].first = db[i - 1][db[i - 1][j].first].first;
            db[i][j].second= db[i - 1][db[i - 1][j].first].second + db[i - 1][j].second;
        }
    }


    ll nax = -1000000000000;
    for(int i = 0; i < n; i++) {

        {//一周だけ
            nax = max(nax, f(i,1, min(k, n)) );

        }

        {//ギリギリまで回す

            int lim = k - (k / n) * n;
            int def = (k / n) * n;
            if(def == 0)continue;
            nax = max(nax, f(i, max<int>(k - n - 1, 1), k));

        }

    }

    cout << nax << endl;

}


Measured memory_bytes: 5920
#include<stdio.h>
int main(void)
{
  int debt=100000, a, i=0;

  scanf("%d", &a);

  for (i=0;i<a;i++){
    debt=debt*1.05;

    if(debt%1000)
      debt=debt-debt%1000+1000;
  }

  printf("%d\n",debt);

  return 0;
}

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


int main() {
  int N;
  cin >> N;
  int sup = -1;
  int inf = 1001;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    sup = max(sup, a);
    inf = min(inf, a);
  }
  cout << sup - inf << endl;
}

Measured memory_bytes: 256
/*
 * author :Sadik Hassan
 *
*/
#include "bits/stdc++.h"
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define fi            first
#define se            second
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define rep(i,n)      for(int i=0;i<n;i++)
#define repn(i,n)     for(int i=1;i<=n;i++)
#define rrep(i,n)     for(int i=n-1;i>=0;i--)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
#define TSFL(s)       transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSFH(s)       transform(s.begin(),s.end(),s.begin(),::tolower);
/*---------------------------------------------------------------------*/
const int N = 2e5+10;
const int INF = (int)1e9+5;

int main()
{
    _SAD()
    int a,b;
    cin>>a>>b;
    int ans=b*10;
    while(ans/10==b)
    {
        if((ans*8)/100==a)
        {
            cout<<ans<<nl;return 0;
        }
        ans++;
    }
    cout<<-1<<nl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

int list[] = {59049,6561,729,81,9,46656,7776,1296,216,36,6,1};

int memo[111111];

int solve(int n){
  if(n == 0)return 0;
  if(memo[n] != -1)return memo[n];
  int res = 1111111111;
  for(int i = 0;i<12;i++){
    if(n-list[i] < 0) break;
    res = min(res,solve(n-list[i])+1);
    //cout<<"n:"<<n<<"\tres:"<<res<<endl;
  }

  memo[n] = res;
  return res;
}

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

  memset(memo,-1,sizeof(int)*(n+1));

  sort(list,list+12);
  cout<<solve(n)<<endl;
  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007

//read question carefully!

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        int a[n + 1];
        int ct = 0;
        for (int i = 1; i <= n; ++i)
        {
            cin >> a[i];
        }
        for (int i = 1; i <= n; ++i)
        {
            if (i % 2)
            {
                if (a[i] % 2)
                    ct++;
            }
        }
        cout << ct << "\n";
    }
}

Measured memory_bytes: 3648
#include<iostream>

using namespace std;

typedef pair<int,int> P;
int mon,c1,c2,q1,q2;
P ans;

void solve(){
  
  ans.first = min(mon/c1,q2);
  mon -= ans.first*c1;
  ans.second = mon/c2;

  if(ans.first == 0){
    cout << "NA" << endl;
    return;
  }
  while(ans.first+ans.second < q1){
    ans.first--;
    if(ans.first <= 0){
      cout << "NA" << endl;
      return;
    }
    mon += c1;
    ans.second = mon/c2;
  }

  cout << ans.first << " " << ans.second << endl;
}

int main(){
  while(cin >> q1 && q1){
    cin >> mon >> c1 >> c2 >> q2;
    ans = P(0,0);
    solve();
  }

  return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  unsigned int key;
  struct node *next;//自己参照型構造体変数
  struct node *prev;
};
//外部変数
typedef struct node *NodePointer;
NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur = nil->next;
  while(cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
  
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
    while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  if(t==nil)return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if(t == nil) return;
  deleteNode(t);
}
void delete(int key){
  deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  //メモリの領域確保
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key);
	nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}

  


Measured memory_bytes: 32972
n,m = map(int,input().split())
dict = {}
su = 0
kounyu = 0
 
for i in range(n):
  A,B = map(int,input().split())
  if A in dict:
    dict[A] += B  #同じAがありうる！！！！！！
  else:
    dict[A] = B
  

d = sorted(dict.items())
 
for i in range(10**99):
  if d[i][1] >= m - kounyu:
    print(su + d[i][0]*(m - kounyu))
    exit()
    
  kounyu += d[i][1]
  su += d[i][1]*d[i][0]

Measured memory_bytes: 22992
while 1:
	H,W = map(int,raw_input().split())
	if H == 0: break
	M = [raw_input() for i in range(H)]
	A = [[0]*W for i in range(H)]
	B = [[0]*W for i in range(H)]
	ans = 0
	for h in range(H):
		L = 0
		for w in range(W):
			if M[h][w] == ".":
				L += 1
			else:
				L = 0
			A[h][w] = L
			try: B[h][w] = B[h-1][w] + 1 if L > 0 else 0
			except: B[h][w] = 1 if L > 0 else 0
			if L*B[h][w] > ans:
				a = L
				for hi in range(B[h][w]):
					a = min(a,A[h-hi][w])
					if a*B[h][w] <= ans:
						break
					ans = max(ans,a*(hi+1))
	print ans

Measured memory_bytes: 10312
#include<stdio.h>

int main(){

	int i=0;
	int j=0;
	
	for(i=1;i<10;i++)
	{
		for(j=1;j<10;j++)
		{
			printf("%dx%d=%d\n",i,j,i*j);
		}
	}
    return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define fi first
#define se second
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int N = 5e3 + 5;

typedef unsigned long long ull;
template <unsigned mod, unsigned base>
struct rolling_hash {
    unsigned int pg[N], val[N]; // val:1,2...n
    rolling_hash() {
        pg[0] = 1;
        for(int i = 1; i < N; i++) pg[i] = 1ull * pg[i - 1] * base % mod;
        val[0] = 0;
    }
    void build(const char *str) {
        for(int i = 0; str[i]; i++) {
            val[i + 1] = (str[i] + 1ull * val[i] * base) % mod;
        }
    }
    unsigned int operator() (int l, int r) {
        ++r; //
        return (val[r] - 1ull * val[l] * pg[r - l] % mod + mod) % mod;
    }
};
struct dm_hasher {
    //str:0,1...len-1
    rolling_hash<997137961, 753> h1;
    rolling_hash<1003911991, 467> h2;
    void build(const char *str) {
        h1.build(str); h2.build(str);
    }
    ull operator() (int l, int r) {
        return ull(h1(l, r)) << 32 | h2(l, r);
    }
}hasher;

int n;
char s[N];

bool chk(int x) {
    for(int i = 0; i + x - 1 < n; i++) {
        for(int j = i + x; j + x - 1 < n; j++) {
            if(hasher(i, i + x - 1) == hasher(j, j + x - 1)) return true;
        }
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    cin >> s;
    hasher.build(s);
    int l = 1, r = n, mid;
    while(l < r) {
        mid = (l + r) >> 1;
        if(chk(mid)) l = mid + 1;
        else r = mid;
    }
    cout << r - 1;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
int main() {
    int N;
    cin>>N;
    vector<int>X(N);
    rep(i,N){
        cin>>X[i];
    }
  	vector<int>Y(N);
  rep(i,N){
    Y[i]=X[i];
  }
  	sort(X.begin(),X.end());
        int mi=X[N/2-1];
        int ma=X[N/2];
        rep(i,N){
            if(ma<=Y[i]){
                cout<<mi<<endl;
            }
            else{
                cout<<ma<<endl;
            }
        }
    }


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")


int main()
{
	
int N;
	pairs(A);
	cin >> N;
	vec(B);
	vec(C);
	fx(N) {
		pairsp(A);
		pb(B,A[x].first+A[x].second)
			pb(C, A[x].first - A[x].second)
	}

	sorts(B);
	sorts(C);
	ce(max(B[N-1]-B[0],abs(C[N-1] - C[0])))
    return 0;
}



Measured memory_bytes: 7692
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Y = sc.nextInt();
		for(int x=0; x<=N; x++) {
			for(int y=0; y<=N; y++) {
				int z = N - x - y;
				if(z<0) continue;
				if(10000*x+5000*y+1000*z==Y) {
					System.out.println(x + " " + y + " " + z);
					return;
				}
			}
		}
		System.out.println("-1 -1 -1");
	}
	
	static int binarySearch(int[] A, int x) {
		int l = 0;
		int r = A.length;
		while(l<r) {
			int mid = (l+r)/2;
			if(A[mid] == x) return mid;
			else if(x<A[mid]) r = mid;
			else l = mid+1;
		}
		return -1;
	}
	
	static long upper_bound(int[] A, int b) {
		// bよりおおきい値がはじめて出てくるindexを返す
		return lower_bound(A, b+1);
	}

	static long lower_bound(int[] A, int b) {
		// b以上の値がはじめて出てくるindexを返す
		int lb=0;
		int ub=A.length;
		while(ub>lb) {
			int mid = (lb+ub)/2;
			if(A[mid]>=b) ub = mid;
			else lb = mid+1;
		}
		return lb;
	}
	
	// union find lib
	// usage:
	// 最初にinitを呼ぶ
	// root: 直接は呼ばないで
	// unite: まとめる
	// same: グループ判定
	static void init(int par[], int N) {
		for(int i=0; i<N; i++) {
			par[i] = i;
		}
	}
	
	static int root(int x, int [] par) {
		if(par[x] == x) {
			return x;
		} else {
			return (par[x] = root(par[x], par));
		}
	}
	
	static boolean same(int x, int y, int[] par) {
		return root(x, par) == root(y, par);
	}
	
	static void unite(int x, int y, int[] par) {
		x = root(x, par);
		y = root(y, par);
		if(x == y) return;
		par[x] = y;
	}
	
	// end union find lib
	
	// number lib
	
	static int max(int...ls) {
		int ans = Integer.MIN_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.max(ans, ls[i]);
		}
		return ans;
	}
	
	static int min(int...ls) {
		int ans = Integer.MAX_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.min(ans, ls[i]);
		}
		return ans;
	}
	
	static long lcm(long a, long b) {
		return a*(b/gcd(a, b));
	}
	
	static long gcd(long a, long b) {
		long ta = Math.max(a, b);
		long tb = Math.min(a, b);
		long tmp;
		while((tmp = ta%tb) != 0) {
			ta = tb;
			tb = tmp;
		}
		return tb;
	}
	
	static long modcomb(long n, long k, long mod) {
		if(k==1) {
			return n;
		}
		
		long ans = 1;
		for(long i=n; i>=n-k+1; i--) {
			ans = (ans * i)%mod;
		}
		for(long i=k; 0<i; i--) {
			ans = (ans * modpow(i, mod-2, mod)) % mod;
		}
		return ans;
	}
	
	static long modpow(long a, long b, long mod) {
		if(b==0) return 1;
		if(b%2==0) {
			long d = modpow(a, b/2, mod);
			return (d*d)%mod;
		} else {
			return (a*modpow(a, b-1, mod))%mod;
		}
	}
	
	static int disit(long a, long d) {
		int count = 0;
		while(a!=0) {
			a = a/d;
			count++;
		}
		return count;
	}
	
	// end number lib
}

Measured memory_bytes: 23252
n = int(input())
a = input().split()
ans=[]
if n%2==0:
    for i in range(n - 1, -1, -2):
        ans.append(a[i])
    for i in range(0, n, 2):
        ans.append(a[i])
else:
    for i in range(n - 1, -1, -2):
        ans.append(a[i])
    for i in range(1, n, 2):
        ans.append(a[i])
print(' '.join(ans))

Measured memory_bytes: 25668
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

k = ri()
a = k%10
if a in [1, 3, 7, 9]:
    s = 7
    cnt = 1
    while s%k:
        s = s*10 + 7
        s %= k
        cnt += 1
    print(cnt)
else:
    print(-1)




Measured memory_bytes: 27048
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	s := getString()

	ans := "Yes"
	if s[2] != s[3] {
		ans = "No"
	}
	if s[4] != s[5] {
		ans = "No"
	}
	out(ans)
}


Measured memory_bytes: 640
#include<stdio.h>

int main(void){
	int N,i;

	scanf("%d",&N);

	for(i = 0;N-7*i>=0;i++){
		if((N-7*i)%4 == 0){
			printf("Yes\n");
			break;
		}
	}
	if(N-7*i<0)
		printf("No\n");

	return 0;
}

Measured memory_bytes: 128
N,K = map(int,input().split())
dt = sorted(tuple(map(int,input().split()))[::-1] for _ in range(N))[::-1]
a = [] #種類があぶれたやつを保管するリスト
s = set()
ans,cur = 0,0
for i,(d,t) in enumerate(dt,1):
    if t in s:
        if i <= K:
            a.append(d)
            cur += d
    else:
        if i > K:
            if not a:
                break
            cur -= a.pop() #種類があぶれていて価値の最も低い寿司を抜く
        cur += d
        s.add(t)
    ans = max(ans,len(s)**2+cur) #f(i-1)とf(i)の値を比べていく
print(ans)

Measured memory_bytes: 59864
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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

		while(true){
			int a[] = new int[4];
			int b[] = new int[4];

			if((Astr=br.readLine())==null)
				break;
			if((Bstr=br.readLine())==null)
				break;

			String aArray[] = Astr.split(" ");
			String bArray[] = Bstr.split(" ");

			for(int i=0; i<4; i++){
				a[i] = Integer.parseInt(aArray[i]);
				b[i] = Integer.parseInt(bArray[i]);
			}
			judge(a,b);
		}
	}

	static void judge(int a[],int b[]){
		int hit = 0;
		int blow = 0;

		for(int i=0; i<b.length; i++){
			for(int j=0; j<a.length; j++){
				if(b[i]==a[j]){
					if(i==j){
						hit++;
					}else{
						blow++;
					}
					break;
				}
			}
		}
		System.out.println(hit + " " + blow);
	}
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Mll = M<ll, ll>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin(),ie=(c).rend();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, c;
VVl diff;
Vi clist;

ll dfs(int depth) {
    if (depth == 3) {
        ll res = 0;
        REP(i, 3) {
            res += diff[i][clist[i]];
        }
        return res;
    }
    ll mini = 1e18;
    REP(i, c) {
        if (depth >= 1 && i == clist[depth-1]) continue;
        if (depth >= 2 && i == clist[depth-2]) continue;
        clist[depth] = i;
        mini = min(mini, dfs(depth+1));
    }
    return mini;
}

int main() {
    cin >> n >> c;
    VVl d(c, Vl(c));
    REP(i, c) REP(j, c) cin >> d[i][j];
    VVi x(n, Vi(n));
    REP(i, n) REP(j, n) {
        cin >> x[i][j];
        x[i][j]--;
    }

    diff = VVl(3, Vl(c, 0));
    REP(i, n) REP(j, n) {
        int mod = (i+j+2) % 3;
        int color = x[i][j];
        REP(k, c) {
            diff[mod][k] += d[color][k];
        }
    }

    clist = Vi(3);
    cout << dfs(0) << '\n';

    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define CHMAX(a,b) a = max(a,b)
#define CHMIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define newline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
const double pi = 3.141592653589793;
const VI dx = {1, 0, -1, 0};
const VI dy = {0, 1, 0, -1};

ll mypow(ll a, ll b)
{
    ll r = 1ll;
    while(b != 0){
        if(b&1) r = r * a % MOD;
        a = a * a % MOD;
        b /= 2;
    }
    return r;
}

vector<ll> fac;
vector<ll> ifac;

void factorial_init(ll n)
{
    fac.resize(n+1);
    ifac.resize(n+1);
    fac[0] = 1;
    REP(i,n) {
        fac[i+1] = fac[i] * (i + 1) % MOD;
    }
    ifac[n] = mypow(fac[n], MOD - 2) % MOD;
    RREP(i,n) {
        ifac[i] = ifac[i+1] * (i + 1) % MOD;
    }
}

ll Combination(ll a, ll b)
{
    if(a == 0 && b == 0) return 1;
    if(a < b || a < 0) return 0;
    ll r = ifac[a-b] * ifac[b] % MOD;
    return r * fac[a] % MOD;
}

ll P(ll a, ll b) {
    return fac[a] * ifac[a-b] % MOD;
}

int main()
{
    ll n,m;
    cin>>n>>m;
    factorial_init(m);
    ll ans = P(m,n) * P(m,n);
    FOR(i,1, n+1) {
        ans = (ans + MOD + (ll)pow(-1,i)
                * ((P(m-i, n-i) * P(m-i,n-i) % MOD) * (P(m,i) * Combination(n,i) % MOD) % MOD)) % MOD;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 11104