akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

class SegmentTree {
    int n;
    vector<int> node;

public:
    SegmentTree(vector<int> v) {
        n = 1;
        int s = v.size();
        while (n < s) n *= 2;
        node.resize(2 * n - 1, INT_MAX);
        for (int i = 0; i < s; i++) node[i + n - 1] = v[i];
        for (int i = n - 2; i >= 0; i--) node[i] = min(node[2 * i + 1], node[2 * i + 2]);
    }

    void update(int x, int val) {
        x += (n - 1);
        node[x] = val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = min(node[2 * x + 1], node[2 * x + 2]);
        }
    }

    int getmin(int a, int b, int k = 0, int l = 0, int r = -1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return INT_MAX;
        if(a <= l && r <= b) return node[k];

        int vl = getmin(a, b, 2 * k + 1, l, (l + r) / 2);
        int vr = getmin(a, b, 2 * k + 2, (l + r) / 2, r);
        return min(vl, vr);
    }
};

void solve() {
    int n, q;
    cin >> n >> q;
    vector<int> v(n, INT_MAX);
    SegmentTree st(v);
    REP(i, q) {
        int c, a, b;
        cin >> c >> a >> b;
        if (c == 0) {
            st.update(a, b);
        } else {
            cout << st.getmin(a, b + 1) << endl;
        }
    }
}



Measured memory_bytes: 4608
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF 1e17
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	getline(cin,s);
	s[5]=' ';
	s[13]=' ';
	cout<<s<<"\n";
	return 0;
}





























Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<fstream>
#include <set>
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
const int  MAXN =2e5+10;
const int mod = 1e9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf= 0x3f3f3f3f;
#define eps 1e-8
#define PI 3.1415926535898
#define lowbit(x) (x&(-x))
using namespace std ;
//getline(cin,s);
//set<ll>::iterator it;
//map<int,int>::iterator it;
typedef long long ll;
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	printf("%d\n",a*b);
	return 0;
}

Measured memory_bytes: 3816
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String line=sc.nextLine();
        String[] num=line.split("");
        int tar=Integer.parseInt(num[num.length-1]);
        if(tar==2||tar==4||tar==7||tar==9||tar==5){
            System.out.println("hon");
        }else if(tar==3){
            System.out.println("bon");
        }else{
            System.out.println("pon");
        }
    }
}

Measured memory_bytes: 35748
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
int solve(){
  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  if(k % 2 == 0)cout << a - b << endl;
  else cout << b - a << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n,k = nm()
p = [0] + nl()
for i in range(n):
    p[i+1] += p[i] + 1
ans = max(p[i+k] - p[i] for i in range(n+1-k))
print(ans/2)


Measured memory_bytes: 24404
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

void Acout(int A[],int N){
    rep(i,N){
        if(i)cout<<" ";
        cout<<A[i];
    }
    cout<<endl;
}

int main(){
    int N,q;
    string s;
    int t;
    int c=0;
    pair<string,int> tmp;
    cin>>N>>q;
    queue<pair<string,int> > a,ans;

    rep(i,N){
        cin>>s>>t;
        a.push(pair<string, int>(s,t));
    }

    while(a.size()!=0){
        tmp = a.front();a.pop();
        tmp.second -=q;
        if(tmp.second>0)a.push(tmp),c+=q;
        else c+=tmp.second+q,ans.push(pair<string, int>(tmp.first,c));
    }

    rep(i,N)cout<<ans.front().first<<" "<<ans.front().second<<endl,ans.pop();

}


Measured memory_bytes: 6368
#include<iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include <functional>
using namespace std;

int main(void) {
	int N, T, A;
	int H[1000];
	double o[1000];
	double best;
	int ans = 0;
		cin >> N >> T >> A;
	for (int i = 0;i < N;i++) {
		cin >> H[i];
		o[i] = (double)T-H[i]* 0.006;
	}
	for (int i = 0;i < N;i++) {
		if (abs(o[ans] - A) > abs(o[i] - A))
			ans = i;
	}
	cout << ans+1 << endl;
	return 0;
}


Measured memory_bytes: 256
import bisect

card_count, rewrite_count = map(int, input().split(" "))

cards = {}
for card in list(map(int, input().split(" "))):
    count = cards.get(card, 0)
    cards[card] = count + 1

for _ in range(rewrite_count):
    stock_count, rewrite_number = map(int, input().split(" "))
    count = cards.get(rewrite_number, 0)
    cards[rewrite_number] = count + stock_count

number_list = list(cards.keys())
number_list.sort(reverse=True)

total = 0
for number in number_list:
    if cards[number] < card_count:
        total += number * cards[number]
    else:
        total += number * card_count
        break
    card_count -= cards[number]

print(total)


Measured memory_bytes: 32064
import java.util.Scanner;

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

        int card[][];
        card = new int[4][13];
        for(int i=0;i<4;i++){
          for(int j=0;j<13;j++){
            card[i][j] = 0;
          }
        }

        for(int k=1;k<=c;k++){
          String m = sc.next();
          int n = sc.nextInt();
            if (m.equals("S")){
              card[0][n-1] = 1;
            }
            if (m.equals("H")){
              card[1][n-1] = 1;
            }
            if (m.equals("C")){
              card[2][n-1] = 1;
            }
            if (m.equals("D")){
              card[3][n-1] = 1;
            }
        }

        for(int x=0;x<4;x++){
          for(int y=0;y<13;y++){
            if (card[x][y] == 0){
              if (x==0){
                System.out.println("S " + (y+1));
              }
              if (x==1){
                System.out.println("H " + (y+1));
              }
              if (x==2){
                System.out.println("C " + (y+1));
              }
              if (x==3){
                System.out.println("D " + (y+1));
              }
            }
          }
        }
    }
}


Measured memory_bytes: 26492
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
    ll X, Y;
    cin>>X>>Y;
    vector<ll> arr;
    arr.push_back(X);
    while(X*2<=Y) {
        arr.push_back(X*2);
        X *= 2;
    }
    cout<<arr.size()<<endl;
}



Measured memory_bytes: 256
import numpy as np

N = int(input())
A = list(map(int, input().split(' ')))

modn = int(1e9 + 7)

ruiseki = sum(A)

ret = 0
for i in range(0, len(A)-1):
  ruiseki -= A[i]
  ret += A[i] * ruiseki

print(np.mod(ret, modn))

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

int main()
{
   /// BISMILLAHIR RAHMANIR RAHIM
	int n;
	cin >> n;
	ll ans = 1;
	ll a[n+1];
	for (int i = 0;i < n;i++) {
		cin >> a[i];
		if (a[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	for (int i = 0;i < n;i++) {
		ans = ans * a[i];
	}
	if (ans <= 1000000000000000000 && ans > 0) {
		cout << ans << endl;
	}
	else cout << -1 << endl;
	return 0;

    /// ALHAMDULILLAH
}


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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    ll a,b; cin >> a >> b;
    ll k; cin >> k;
    ll tmp=max(a-k,0LL);
    
    cout << tmp << " " << max(b-max(k-a,0LL),0LL) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
typedef pair <LL, LL> pii;
const LL MOD = 1000000007LL;
const int MAXN = 105, INF = 1000000001;

int n, h[MAXN];

inline LL mul(LL a, LL b){return a * b % MOD;}
inline LL quickPow(LL base, int times){
	LL ret = 1LL;
	while(times){
		if(times & 1) ret = ret * base % MOD;
		base = base * base % MOD;
		times >>= 1;
	} return ret;
}
pii solve(int l, int r, int b){
	int i, j, mn = INF; pii f, tmp;
	for(i = l; i <= r; ++ i)
		if(h[i] < mn) mn = h[i];
	for(i = l; i <= r; i = j + 1)
		if(h[i] > mn){
			for(j = i; j < r && h[j + 1] > mn; ++ j) ;
			tmp = solve(i, j, mn);
			if(i == l) f = pii(mul(tmp.first, 2), tmp.second);
			else f = pii(mul(mul(tmp.first, f.first), 2), (mul(mul(f.first, tmp.first), 4) + mul(mul(f.first, tmp.second), 2) + mul(mul(f.second, tmp.first), 4) + mul(f.second, tmp.second)) % MOD);
		}else{
			j = i;
			if(i == l) f = pii(1, 0);
			else f = pii(f.first, (f.first * 2 + f.second * 2) % MOD);
		}
	return pii(f.first * quickPow(2, mn - b - 1) % MOD, f.second);
}
int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++ i)
		scanf("%d", &h[i]);
	auto ret = solve(1, n, 0);
	printf("%d\n", int((ret.first * 2 + ret.second) % MOD));
	return 0;
}

Measured memory_bytes: 256
x,n=map(int,input().split())
plist=list(map(int,input().split()))

if n == 0:
    print(x)
    exit()

alist = list(range(-200,200))
for i in plist:
    alist.remove(i)

alist.sort()
alist.reverse()
ans = 0
count = 1000
for j in alist:
    if count >= abs(x - j):
        count = abs(x-j)
        ans = j

print(ans)

Measured memory_bytes: 9168
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

template<typename T>
void cout_vec(vector<T> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}

int main(){
    int N;
    cin >> N;
    vector<vector<ll>> LR(N,vector<ll>(2,0));
    for(int i=0; i<N; i++){
        cin >> LR[i][0] >> LR[i][1];
    }

    sort(LR.rbegin(),LR.rend());
    vector<ll> minR_from_i(N+1,MOD);
    for(ll i=N; i>0; i--){
        minR_from_i[i-1]=min(minR_from_i[i],LR[i-1][1]);
    }

    //cout_vec(minR_from_i);

    ll ans=0;
    ll L1=LR[0][0];
    ll R1=LR[0][1];
    for(int i=1; i<N; i++){
        ans=max(ans, max(0LL,R1-L1+1)+max(0LL,minR_from_i[i]-LR[i][0]+1));
        ans=max(ans, max(0LL,min(minR_from_i[i+1],R1)-L1+1)+max(0LL,LR[i][1]-LR[i][0]+1));
        R1=min(R1,LR[i][1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 9580
package main

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

var sc *bufio.Scanner

const BufferSize = 1024

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

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

type bc struct {
	idx   int
	value int
}

type bcs []bc

func (b bcs) Len() int           { return len(b) }
func (b bcs) Less(i, j int) bool { return b[i].value < b[j].value }
func (b bcs) Swap(i, j int)      { b[i], b[j] = b[j], b[i] }



func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := make([]bc, n)
	ans := make([]int, n)

	for i := range a {
		a[i].idx = i
		a[i].value = nextInt()
	}
	sort.Sort(sort.Reverse(bcs(a)))

	for i := range a {
		if i != a[0].idx {
			ans[i] = a[0].value
		} else {
			ans[i] = a[1].value
		}
	}

	for i := range a {
		_, _ = fmt.Fprintf(writer, "%d", ans[i])
		if i < len(a) - 1 {
			_, _ = fmt.Fprint(writer, "\n")
		}
	}
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


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

int main(){
    int N;
    cin >> N;
    vector<int> T(N);
    vector<double> A(N), M(N+1, 1);
    for(int i=0; i<N; i++){
        double a;
        cin >> T[i] >> a;
        A[i] = 1-a/10;
        M[i+1] = M[i] * A[i];
    }
    int Q;
    cin >> Q;
    while(Q--){
        int l, r;
        cin >> l >> r;
        int lb = lower_bound(T.begin(), T.end(), l) - T.begin();
        int ub = upper_bound(T.begin(), T.end(), r) - T.begin();
        double ans = 1e9 * M[ub] / M[lb];
        cout << fixed << setprecision(10) << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 4692
// 5/4
// 過去問ガリガリ

#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>;
using Graph = vector<vector<int>>;

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

    if (N < 10) cout << R + 100 * (10 - N) << endl;
    else cout << R << endl;
}

Measured memory_bytes: 256
s = input()
tmp = ""
count = 0
for i in range(len(s)):
    if i % 2 == 0:
        tmp += "0"
    elif i % 2 == 1:
        tmp += "1"
    if s[i] != tmp[i]:
        count += 1
print(count if count*2 <= len(s) else len(s)-count)


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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



void solve() {
    int N; cin >> N;
    vec v(105, 0);
    rep1(i, N) cin >> v[i];
    vec res;
    while(1){
        int cnt = 0;
        rep1(i, N){
            if(i == v[i]) cnt = i;
        }
        if(cnt == 0) break;
        res.push_back(cnt);
        v.erase(v.begin()+cnt);
    }
    if(res.size() != N){
        cout << -1 << endl;
    }else{
        reverse(all(res));
        rep(i, N){
            cout << res[i] << endl;
        }
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
# -*- coding: utf-8 -*-
N = int(input())

a_b_ab_list = [ ]
for _ in range(N):
    a, b = map(int, input().split(' '))
    a_b_ab_list.append((a, b, a+b))

a_b_ab_list.sort(key=lambda x: x[2], reverse=True)

t, a = 0, 0
for i in range(0, N, 2):
    t += a_b_ab_list[i][0]

for i in range(1, N, 2):
    a += a_b_ab_list[i][1]

print(t - a)

Measured memory_bytes: 63832
package main

import (
	"fmt"
	"math"
)

type point struct {
	x float64
	y float64
}

func pointOf(r int, t float64) point {
	return point{
		(float64(r)) * math.Cos(t),
		(float64(r)) * math.Sin(t),
	}
}

func longAng(h int, m int) float64 {
	return (2*math.Pi)/12*(float64(h)) + (2*math.Pi)/(12*60)*(float64(m))
}

func shortAng(m int) float64 {
	return (2 * math.Pi) / 60 * (float64(m))
}

func dist(p1 point, p2 point) float64 {
	return math.Sqrt(math.Pow(p1.x-p2.x, 2) + math.Pow(p1.y-p2.y, 2))
}

func main() {
	var a, b, h, m int
	fmt.Scanf("%d %d %d %d", &a, &b, &h, &m)
	lp := pointOf(a, longAng(h, m))
	sp := pointOf(b, shortAng(m))
	fmt.Println(dist(lp, sp))
}


Measured memory_bytes: 1820
import math
import fractions
import collections
import itertools
import pprint
N,M=map(int,input().split())

#rotateすれば他の部屋で同じ組み合わせが出てしまう<=>他の部屋の2数の数字の差が同じになってしまう
#前半分を偶数差、後ろ半分を奇数差と言った感じで上から詰めれば良い
#部屋数をMとして、1,2,...,Mの差を考える
l=[]
maemin=1
usiromax=N
for i in range(M,0,-1):
    if i%2==0:
        l.append([maemin,maemin+i])
        maemin=maemin+1
    else:
        l.append([usiromax-i,usiromax])
        usiromax=usiromax-1
#print(l)

for i in range(M):
    print(*l[i],sep=" ")





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

using namespace std;

int n, m;
char s[100010], t[100010];

int main(){
    scanf("%d %d", &n, &m);
    scanf("%s%s", s, t);
    int g = __gcd(n, m);
    for(int a = 0, b = 0; a < n && b < m; a += n / g, b += m / g){
        if(s[a] != t[b]) return puts("-1"), 0;
    }
    printf("%lld\n", n * 1ll * m / g);
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct Point{
  double x,y,z;
  Point(){}
  Point(double x,double y,double z):x(x),y(y),z(z){}
  Point operator+(Point a){return Point(x+a.x,y+a.y,z+a.z);}
  Point operator-(Point a){return Point(x-a.x,y-a.y,z-a.z);}
  Point operator*(double k){return Point(x*k,y*k,z*k);}
  Point operator/(double k){return Point(x/k,y/k,z/k);}
  
};
double norm(Point a){
  return a.x*a.x+a.y*a.y+a.z*a.z;
}
double abs(Point a){
  return sqrt(norm(a));
}
typedef Point Vector;

struct st{
  int p,q;
  double t;
  st(){}
  st(int p,int q,double t):p(p),q(q),t(t){}
  bool operator<(const st&a)const{
    return t>a.t;
  }
};


signed main(){
  int n;
  while(cin>>n,n){
    Point ps[n];
    Vector vs[n];
    double r[n],v[n];
    for(int i=0;i<n;i++){
      cin>>ps[i].x>>ps[i].y>>ps[i].z;
      cin>>vs[i].x>>vs[i].y>>vs[i].z;
      cin>>r[i]>>v[i];
    }
    priority_queue<st> q;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	double L=0,R=100;
	bool I=0;
	for(int k=0;k<200;k++){
	  double M1=L+(R-L)/3,M2=L+(R-L)*2/3;
	  if((r[i]-v[i]*M2)<=0||(r[j]-v[j]*M2)<=0){
	    R=M2;
	    continue;
	  }
	  Point a1=ps[i]+vs[i]*M1,b1=ps[j]+vs[j]*M1;
	  Point a2=ps[i]+vs[i]*M2,b2=ps[j]+vs[j]*M2;
	  double d1=abs(a1-b1)-((r[i]-v[i]*M1)+(r[j]-v[j]*M1));
	  double d2=abs(a2-b2)-((r[i]-v[i]*M2)+(r[j]-v[j]*M2));
	  if(d1<=0) I=1;
	  if(d1<d2) R=M2;
	  else L=M1;
	}
	if(!I) continue;
	R=L;L=0;
	for(int k=0;k<200;k++){
	  double M=(L+R)/2;
	  Point a1=ps[i]+vs[i]*M,b1=ps[j]+vs[j]*M;
	  double d1=abs(a1-b1)-((r[i]-v[i]*M)+(r[j]-v[j]*M));
	  if(d1<=0) R=M;
	  else L=M;
	}
	q.push(st(i,j,R));
      }
    }
    vector<double> ans(n,-1);
    while(!q.empty()){
      st p=q.top();q.pop();
      if(ans[p.p] >=0 || ans[p.q] >= 0) continue;
      ans[p.p]=ans[p.q]=p.t;
    }
    for(int i=0;i<n;i++){
      if(ans[i]<0) ans[i]=r[i]/v[i];
      printf("%.12f\n",ans[i]);
    }
  }
  return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define fi first
#define sec second
#define PB push_back
#define MP make_pair
#define endl '\n'
#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,a,b)     for(int i=b;i>=a;i--)
#define all(v)          v.begin(),v.end()
void fast(){ ios::sync_with_stdio(false); cin.tie(NULL);}
void file()
{ 
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin); 
    freopen("output.txt","w",stdout);
    #endif
}

string s;
string ans="";

int main()
{
    fast();
    

    cin>>s;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='B')
        {
            if(!ans.empty())
                ans.pop_back();
        }
        else
            ans.push_back(s[i]);
    }
    cout<<ans;
}


Measured memory_bytes: 3592
#include <iostream>

int main(){
    int animalNum = 0;
    int legNum = 0;
    std::cin >> animalNum;
    std::cin >> legNum;
    if(legNum%2==0){
        int kame = legNum/2-animalNum;
        int turu = animalNum - kame;
        if(kame >=0 && turu>=0&& animalNum == turu + kame && legNum == 2*turu + 4*kame){
            std::cout << "Yes" <<std::endl;
            return 0;
        }
    }
    std::cout << "No" <<std::endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>
#include <algorithm>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define all(v) ((v).begin(),(v).end())
#define Sort(v) sort(all(v))
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
    int n;
    int a;
    cin>>a;
    n+=a*100;
    cin>>a;
    n+=a*10;
    cin>>a;
    n+=a;
    if(n%4==0)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}



    



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

using namespace std;

const long long INF = 1ll << 60;

int main(){
  int N;
  long long K;
  cin >> N >> K;
  
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
    --A[i];
  }
  
  vector<int> B(N, -1);
  int c = 0;
  int r = 0;
  for(int i = 0;; i = A[i], ++c){
    if(B[i] != -1){
      r = B[i];
      break;
    }
    B[i] = c;
    if(c == K){
      cout << i + 1 << endl;
      return 0;
    }
  }
  
  for(int i = 0; i < N; i++){
    if(B[i] == r + (K - r) % (c - r)){
      cout << i + 1 << endl;
      break;
    }
  }
  
  return 0;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;constexpr ll INF=1LL<<60,MOD=1e9+7;//998244353;
void solve();int main(){cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();return 0;}
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d>0?i<n:i>n;i+=d)
#define endl "\n"
#ifdef __LOCAL
#include "ostreams.h"
#endif
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> vector<T> make_vector(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_vector(size_t a,Ts... ts){return vector<decltype(make_vector(ts...))>(a,make_vector(ts...));}
void print(){cerr<<endl;} template<class T,class... Ts> void print(const T& a,const Ts&... ts){cerr<<a<<' ';print(ts...);}

void solve(){
    ll n; cin >> n;
    unordered_map<ll, ll> odd_counter, even_counter;
    odd_counter[-1] = 0;
    even_counter[-1] = 0;
    rep(i, n){
        ll v; cin >> v;
        v --;
        if(i & 1) odd_counter[v] ++;
        else even_counter[v] ++;
    }

    vector<pll> odd, even;
    for(const auto& p : odd_counter){
        ll key, val; tie(key, val) = p;
        odd.emplace_back(val, key);
    }
    for(const auto& p : even_counter){
        ll key, val; tie(key, val) = p;
        even.emplace_back(val, key);
    }
    sort(odd.rbegin(), odd.rend());
    sort(even.rbegin(), even.rend());
    odd.erase(odd.begin() + 2, odd.end());
    even.erase(even.begin() + 2, even.end());

    ll res = n;
    for(const auto& p : odd){
        ll odd_key, odd_val; tie(odd_val, odd_key) = p;
        for(const auto& q : even){
            ll even_key, even_val; tie(even_val, even_key) = q;
            if(odd_key == even_key) continue;
            chmin(res, n - odd_val - even_val);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 6672
s = input()

def is_palindrome(t):
	# print("Checking", t)
	for i in range(len(t)//2):
		if t[i] != t[~i]:
			# print(t[i], "!=", t[~i])
			return False
	return True

n = len(s)
if is_palindrome(s) and is_palindrome(s[:(n-1)//2]) and is_palindrome(s[(n+3) // 2 -1:]):
	print("Yes")
else:
	print("No")

Measured memory_bytes: 38384
a,b,c = [int(s) for s in input().split()]

cnt = 0

# cを食べられる枚数を追加
if (a + b + 1) >= c:
    max_c = c
else:
    max_c = a + b + 1
    
# bを食べられる枚数を追加
cnt = max_c + b
print(cnt)

Measured memory_bytes: 2940
require "prime"
Q = gets.to_i
P = (0..10**5).map{ |n| n.prime? }
ss = [0]
(1..10**5).each{ |n| ss << ss[-1] + (P[n] && P[(n+1)/2] ? 1 : 0) }
Q.times {
  l,r = gets.split.map &:to_i
  p ss[r] - ss[l-1]
}

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

int main(){
    string s;
    cin >> s;
    if(s.at(0)=='R'){
        if(s.at(1)=='R'){
            if(s.at(2)=='R'){
                cout << 3 << endl;
            }
            else cout << 2 << endl;
        }
        else cout << 1 << endl;
    }
    else if(s.at(0)=='S'){
        if(s.at(1)=='R'){
            if(s.at(2)=='R'){
                cout << 2 << endl;
            }
            else cout << 1 << endl;
        }
        else if(s.at(1)=='S'){
            if(s.at(2)=='R'){
                cout << 1 << endl;
            }
            else cout << 0 << endl;
        }
    }
    
    
    
    return 0;
}


Measured memory_bytes: 3624
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    // #. NG
    // .# OK

    val n = readInteger()
    val s = br.readLine()!!

    val whiteSums = IntArray(n + 1)
    val blackSums = IntArray(n + 1)
    for ((i, c) in s.withIndex()) {
        whiteSums[i + 1] = whiteSums[i] + if (c == '.') 1 else 0
        blackSums[i + 1] = blackSums[i] + if (c == '#') 1 else 0
    }

    var ans = Int.MAX_VALUE
    for (i in 0..n) {
        ans = min(ans, blackSums[i] + whiteSums[n] - whiteSums[i])
    }
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 39540
from collections import deque
k,t = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
a = deque(a)
length = len(a)
if length ==1:
    print(sum(a)-1)
    exit()
while length > 1:
    mx = a.pop()
    mn = a.popleft()
    mx -= 1
    mn -= 1
    if mx != 0:
        a.append(mx)
    else:
        length -=1
    if mn != 0:
        a.appendleft(mn)
    else:
        length-=1    
print(max(sum(a)-1,0))     


Measured memory_bytes: 3316
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

int main(int argc, char const *argv[])
{
	int n,m,c;
	int ans,type = 0;
	int B[20];
	int A[20][20];
	scanf("%d%d%d",&n,&m,&c);
	for (int i = 0; i < m; ++i)	scanf(" %d",&B[i]);
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			scanf(" %d",&A[i][j]);
		}
	}
	for (int i = 0; i < n; ++i)
	{
		ans = 0;
		for (int j = 0; j < m; ++j)
		{
			ans += B[j] * A[i][j];
		}
		if(ans + c > 0)	++type;
	}
	printf("%d\n", type);
	return 0;
}

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

int main(){
	char mark;
	int i,j,n;

	cin >> n;
	int a[4][13]={0};

	for(i=0;i<n;i++){
		cin >> mark >> j;
		switch(mark){
			case'S':a[0][j-1]=1;break;
			case'H':a[1][j-1]=1;break;
			case'C':a[2][j-1]=1;break;
			case'D':a[3][j-1]=1;break;
		}
	}

	for(i=0;i<4;i++){
		for(j=1;j<14;j++){
			if(a[i][j-1]==0){
				if(i==0)cout <<"S "<<j<<endl;
				if(i==1)cout <<"H "<<j<<endl;
				if(i==2)cout <<"C "<<j<<endl;
				if(i==3)cout <<"D "<<j<<endl;
			}
		}
	}
}

Measured memory_bytes: 1160
import itertools

if __name__ == '__main__':
    n, m, q = map(int, input().split())
    query = []
    for i in range(q):
        a, b, c, d = map(int, input().split())
        query.append((a - 1, b - 1, c, d))

    lists = list(itertools.combinations_with_replacement([i + 1 for i in range(m)], n))
    ans = 0
    for i in lists:
        total = 0
        for a, b, c, d in query:
            if i[b] - i[a] == c:
                total += d
        ans = max(ans, total)

    print(ans)


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

int main() {
  int n,m;
  cin >> n >> m;
  priority_queue<ll> q;
  rep(i, n) {//各要素をキューに追加
    ll a; cin >> a;
    a*=-1;
    q.push(a);
  }

  vector<pair<ll,ll>> bc;
  
  rep(i,m){
    ll b, c; cin >> b >> c;
    c *=-1;
    bc.emplace_back(c,b);
  }
  sort(bc.begin(), bc.end());
  ll count=0;
  for(auto p:bc){
//    cout << p.first << ' ' << p.second << endl;
    rep(j,p.second){
      ll x=q.top();
      if(p.first<x && count<=n) {
        q.pop();
        q.push(p.first);
        count +=1;
      }
      else{
        ll ans = 0;
        while (!q.empty()) {
          ans += q.top(); q.pop();
          }
          ans *= -1;
          cout << ans << endl;
          return 0;
      }
    }
  }
  ll ans = 0;
  while (!q.empty()) {
    ans += q.top(); q.pop();
    }
    ans *= -1;
    cout << ans << endl;
    return 0;
  

/*
  int count=0;
  for(auto p: bc){
    for(i,p.second){

      }

    }
*/
}


Measured memory_bytes: 6152
#include <stdio.h>

int main(void)
{
    int count[26];
    char c;
    // Init count array
    for (int i = 0; i < 26; i++)
    {
        count[i] = 0;
    }

    while (scanf("%c", &c) != EOF)
    {
        if (c >= 'A' && c <= 'Z')
        {
            c -= 'A' - 'a';
        }
        count[c - 97]++;
    }

    for (int i = 0; i < 26; i++)
    {
        printf("%c : %d\n", (char)(i + 97), count[i]);
    }
    return 0;
}


Measured memory_bytes: 2116
# 次の日曜日（明日以降）が何日後か求めてください
S = input()

if S == 'SUN':
    print('7')
elif S == 'MON':
    print('6')
elif S == 'TUE':
    print('5')
elif S == 'WED':
    print('4')
elif S == 'THU':
    print('3')
elif S == 'FRI':
    print('2')
elif S == 'SAT':
    print('1')
else:
    print('以下の表記で入力してください。（例：「月曜日」=> 「MON」')

Measured memory_bytes: 9020
#include <iostream>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    if (n % 2 == 0) {
        for (int i = 0; i < m; i++) {
            if ((n - i) - (i + 1) > n / 2) cout << i + 1 << " " << n - i << "\n";
            else cout << i + 1 << " " << n - i - 1 << "\n";
        }
    } else {
        for (int i = 0; i < m; i++) cout << i + 1 << " " << n - i << "\n";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    lld a, b, x;
    cin >> a >> b >> x;
    if (a * a * b / 2 <= x)
    {
        lld ans = atan((2.0 * b / a) - (2.0 * x / (a * a * a)));
        //cerr << ans << endl;
        printf("%.10Lf\n", ans * (180.0 / M_PI));
    }
    else
    {
        lld ans = M_PI / 2 - atan(2.0 * x / (a * b * b));
        //cerr << ans << endl;
        printf("%.10Lf\n", ans * (180.0 / M_PI));
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cmath>
#include<cstdio>
using namespace std;
typedef long long LL;
const int maxn = 1e5;
int n, a, b, m[maxn+3];
bool judge(LL x)
{
    LL sum = 0;
    for(int i=0; i<n; ++i)
    {
        LL t = (LL)m[i]-x*b;
        if(t>0)
        {
            sum += (int)ceil(t*1.0/(a-b));
            if(sum > x || sum < 0)
                return false;
        }
    }
    return true;
}
int main()
{
    while(scanf("%d%d%d",&n,&a,&b)!=EOF)
    {
        int imax = 0;
        for(int i=0; i<n; ++i) scanf("%d",&m[i]), imax = max(imax, m[i]);
        LL l=0, r=imax;
        while(l<r)
        {
            LL mid = l+r>>1;
            if(judge(mid)) r=mid;
            else l=mid+1;
        }
        printf("%lld\n",r);
    }
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x1 = sc.nextInt();
        int y1 = sc.nextInt();
        int x2 = sc.nextInt();
        int y2 = sc.nextInt();
        int a = x1 - x2;
        int b = y1 - y2;
        int x3 = x2 + b;
        int y3 = y2 - a;
        int x4 = x3 + a;
        int y4 = y3 + b;
        System.out.println(x3 + " " + y3 + " " + x4 + " " + y4);
    }
}

Measured memory_bytes: 22608
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)
args = sys.argv


def dump_impl(*objects):
    print(*objects, file=sys.stderr)
def dump_dummy(*objects):
    print(*objects, file=sys.stderr)
    
dump = dump_impl if len(args) == 2 and args[1] == "DEBUG" else dump_dummy

N = int(input())
S =[input() for i in range(N)]

D={'M':[],'A':[],'R':[],'C':[],'H':[]}
for Si in S:
    if Si[0] in D:
        D[Si[0]].append(Si)

dump(D)

ans=0
for x in it.combinations("MARCH", 3):
    x0,x1,x2=x
    dump(x0,x1,x2)
    ans += len(D[x0])*len(D[x1])*len(D[x2])
print(ans)


Measured memory_bytes: 13488
#include<iostream>
using namespace std;
int main(){
	int r;cin>>r;
	if(r<1200){
		cout<<"ABC"<<endl;
	}
	else if(r<2800){
		cout<<"ARC"<<endl;
	}
	else {
		cout<<"AGC"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{

	int K;
	cin >> K;

	for (int i = 0; i < K; i++) {
		cout << "ACL";
	}
	cout << endl;
	
	
}


Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main(void){
  int N;
  cin >> N;
  int V[N], C[N];

  for (int i = 0; i < N; i++) {
    cin >> V[i];
  }

  for (int i = 0; i < N; i++) {
    cin >> C[i];
  }

  int X = 0;
  int Y = 0;

  for (int i = 0; i < N; i++) {
    if (V[i] > C[i]) {
      X += V[i];
      Y += C[i];
    }
  }

  cout << X - Y << '\n';

  return 0;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

/*vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
*/
// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, k, m, r;
string s;

// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n;
	vll od, ev;
	for (ll i = 0; i < n; i++) {
		cin >> x;
		if (i % 2 == 0) ev.pb(x);
		else od.pb(x);
	}
	if (n % 2 == 0) {
		reverse(all(od));
		for (auto it : od) cout << it << " ";
		DISP(ev);
	}
	else {
		reverse(all(ev));
		for (auto it : ev) cout << it << " ";
		DISP(od);
	}
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 5156
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
using namespace std;
#define MS0(I) memset(I, 0, sizeof(I));
#define MS1(I) memset(I, -1, sizeof(I));
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, s, n) for(int i = (s); i < (n); ++i)
#define per1(i, a, b) for(int i = a; i >= b; --i)
#define DRI(A) int A; scanf("%d", &A);
#define DRII(A, B) int A, B; scanf("%d %d", &A, &B);
#define DRIII(A, B, C) int A, B, C; scanf("%d %d %d", &A, &B, &C);
#define SZ(X) ((int)X.size() )
#define MP make_pair 
#define pb push_back
#define F first
#define S second
#define ALL(I) (I).begin(), (I).end()
typedef const void CV;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LDB;
typedef pair<int, int> PII; 
const double eps = 1e-7;
const double PI = acos(-1);
const LL INFF = (LL)1e18;
const int INF = (int)1e8;
const int mod = (int)1e9+7;
const int MAX = (int)3e5+7;
int cnt[MAX], cnt2[MAX];
char s[MAX];
int main(void){
	int n;
	scanf("%d %s", &n, s + 1);
	rep1(i, 1, n+1){
		cnt[i] = cnt[i-1];
		if(s[i] == 'W') cnt[i]++;
	}
	per1(i, n, 1){
		cnt2[i] = cnt2[i+1];
		if(s[i] == 'E') cnt2[i]++;
	}
	int bst = INF;
	rep1(i, 1, n+1){
		bst = min(bst, cnt[i-1] + cnt2[i+1]);
	}
	printf("%d\n", bst);
	return 0;
}


Measured memory_bytes: 2944
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

use rand::prelude::*;

const CN: usize = 26;

fn calc(cv: &[isize], sv: &[Vec<isize>], tv: &[usize]) -> isize {
    let mut last = vec![0; CN];
    let mut res = 0;
    for i in 0..sv.len() {
        let t = tv[i];
        res += sv[i][t];
        last[t] = i + 1;
        for j in 0..CN {
            res -= cv[j] * (i + 1 - last[j]) as isize;
        }
    }
    res
}

fn gen_tv(rng: &mut rand::rngs::ThreadRng, d: usize) -> Vec<usize> {
    (0..d)
        .into_iter()
        .map(|_| rng.gen::<usize>() % CN)
        .collect::<Vec<_>>()
}

fn main() {
    input! {
        d: usize,
        cv: [isize; CN],
        sv: [[isize; CN]; d],
    };

    let mut rng = rand::thread_rng();
    let mut tv = gen_tv(&mut rng, d);
    let mut res = calc(&cv, &sv, &tv);
    for _ in 0..50000 {
        let tv2 = gen_tv(&mut rng, d);
        let p = calc(&cv, &sv, &tv2);
        if p > res {
            tv = tv2;
            res = p;
        }
    }
    for _ in 0..300000 {
        let di = rng.gen::<usize>() % d;
        let q = rng.gen::<usize>() % CN;
        let old = tv[di];
        tv[di] = q;
        let p = calc(&cv, &sv, &tv);
        if p > res {
            res = p;
        } else {
            tv[di] = old;
        }
    }
    println!("{}", tv.into_iter().map(|x| x + 1).join("\n"));
}


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

int main(){
    int num;
    bool ans = true;
    string w;
    vector<int> moji(26);
    cin >> w;

    for (int i = 0; i < w.size(); i++){
        num = w.at(i) - 'a';
        moji.at(num)++;
    }

    for (int i = 0; i < 26; i++){
        if((moji.at(i) % 2) == 1){
            ans = false;
            break;
        }
    }

    if(ans) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
n = int(input())
k = int(input())
x = list(map(int,input().split()))
ans = 0
for i in range(0,n) :
    if x[i] >= abs(k-x[i]) :
        ans += 2*abs(k-x[i])
    else :
        ans += 2*x[i]
print(ans)

Measured memory_bytes: 3060
from math import factorial
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
b = c.values()
ans = sum([factorial(i)//(factorial(i-2)*2) for i in b if i >= 2])
for i in range(n):
    print(ans-c[a[i]]+1)

Measured memory_bytes: 34200
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int r = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();
		
		int result = x;

		for (int i = 0; i < 10; i++) {
			result = result * r - d;
			System.out.println(result);
		}
	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main()
{
    ll n;
    cin >> n;
    if (n % 2 == 1)
    {
        cout << 0 << endl;
    }
    else
    {
        ll ans = 0;
        ll m = 5;
        while (n >= m)
        {
            ans += (n / m) / 2;
            m *= 5;
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 987654321;
const ll MOD = 1000000007;

int main(void) {
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL); 
  cout.tie(NULL);
  //freopen("in.txt", "r", stdin);
  int h,w,a,b;
  cin >> h >> w >> a >> b;
  vector<vi> v(h, vi(w));
  rep(i,0,b) rep(j,0,a) {
    v[i][j] = 1;
  }
  rep(i,b,h) rep(j,a,w) {
    v[i][j] = 1;
  }

  rep(i,0,h) {
    rep(j,0,w) {
      cout << v[i][j];
    }
    cout << endl;
  }
  return 0;
}

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

int main(){
  while(true){
    int sam1,sam2;
    cin>>sam1>>sam2;
    if(sam1==sam2&&sam1==0){
      break;
    }
    if(sam1>=sam2){
      cout<<sam2<<" "<<sam1<<endl;
    }else if(sam1<sam2){
      cout<<sam1<<" "<<sam2<<endl;
    }
  }
}	



Measured memory_bytes: 3040
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def main():
    N = int(input())
    X = int((N - 1) / 1.08)

    while True:
        if N == int(X * 1.08):
            print(X)
            return
        elif N < int(X * 1.08):
            print(":(")
            return
        X += 1


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import numpy as np

def main():
    n = int(input())
    h = list(map( int, input().split()))

    kosuu = 1
    for i in range(n):
        if i > 0:
            if h[i]>=h[i-1]:
                if h[i] >= np.max(h[0:i]):
                    kosuu += 1
    print(kosuu)
    
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 12488
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    int tot=0;
    int res=0;
    for(int i=1; i<=N; i++){
        int N5=i/10000;
        int N4=i/1000-N5*10;
        int N3=i/100-N5*100-N4*10;
        int N2=i/10-N5*1000-N4*100-N3*10;
        int N1=i-N5*10000-N4*1000-N3*100-N2*10;
        if(N5+N4+N3+N2+N1>=A && N5+N4+N3+N2+N1<=B) tot+=i ;
    }
    
    cout << tot << endl;
    
    return 0;
}


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

int N ,M;
string board[60];
string pattern[60];
bool match(int x, int y) {
  for (int i=0; i<M; i++) {
    for (int j=0; j<M; j++) {
      if (board[x+i][y+j]!=pattern[i][j]) {
        return false;
      }
    }
  }
  return true;
}
int main() {
  cin >> N >> M;
  for (int i=0; i<N; i++) {
    cin >> board[i];
  }
  for (int i=0; i<M; i++) {
    cin >> pattern[i];
  }
  bool found=false;
  for (int i=0; i<=N-M; i++) {
    for (int j=0; j<=N-M; j++) {
      if (match(i,j)) {
        found=true;
      }
    }
  }
  cout << (found?"Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 256