akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define speedX ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
template<typename T>
void __p(T a) { cout << a << " "; }
template<typename T, typename F>
void __p(pair<T, F> a) { cout << "{ "; __p(a.first); __p(a.second); cout << "}"; }
template<typename T>
void __f(const char* s, T t) { cout << s << " : "; __p(t); }
template<typename T>
void __t(const char* s, const T &x) { cout << s << " : { "; for (auto it : x) __p(it); cout << "} ";}
template<typename T, typename ... F>
void __f(const char* s, T t, F ... f) {
	int i = 0; for (;; ++i) if (s[i] == ',') break;
	cout.write(s, i) << " : "; __p(t); cout << " | "; __f(s + i + 1, f...);
}
#define trace(...) { cout<<"LINE: "<<__LINE__<<" || "; __f(#__VA_ARGS__,__VA_ARGS__); cout<<"\n\n"; }
#define debug(...) { cout<<"LINE: "<<__LINE__<<" || "; __t(#__VA_ARGS__,__VA_ARGS__); cout<<"\n\n"; }
int begtime = clock();
#define end_time() cout << "\n\nTime of execution: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define trace(...)
#define debug(...) 
#define end_time()
#endif
 
 
#define int long long 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;

inline bool equals(ld a, ld b) {return fabs(a - b) < 1e-9;}
inline int gcd(int a, int b) { a=abs(a); b=abs(b); while(a>0 && b>0) (a>b?a%=b:b%=a); return (a==0?b:a); } 
inline int power(int x, int n, int m = LLONG_MAX)
    {  int res=1; x = (x%m + m)%m;
       while(n) { if(n&1) res=(res*x)%m;  x=(x*x)%m;  n >>= 1; }  return res;
    }
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define mod 1000000007

void solve(){
	int n,k;
	cin>>n>>k;
	vi h(n);
	for(int i = 0; i<n; i++){
		cin>>h[i];
	}
	int dp[n] = {0};
	for(int i = 1; i<n; i++){
		int res = mod;
		for(int j = i-1; j>=max(i-k,0ll); j--){
			res = min(res,abs(h[i]-h[j])+dp[j]);
		}
		dp[i] = res;
	}
	cout<<dp[n-1]<<"\n";
}
signed main(){
	speedX;
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	int t=1;
	//cin>>t;
	for(int i=1;i<=t;++i) {
		//cout<<"Case #"<<i<<": ";
		solve();
	}
	end_time();
	return 0;
}


Measured memory_bytes: 4716
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>

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

using namespace std;

int main() {

	string a, b, c;
	cin >> a >> b >> c;
	
	int num_a, num_b, num_c;
	num_a = a.length();
	num_b = b.length();
	num_c = c.length();

	int count_a = 0;
	int count_b = 0;
	int count_c = 0;
	int sw = 0;

	while (count_a <= num_a && count_b <= num_b && count_c <= num_c) {

		switch (sw)
		{
		case 0:
			if(count_a != num_a)sw = a[count_a]-'a';
			count_a++;
			break;
		case 1:
			if (count_b != num_b)sw = b[count_b]-'a';
			count_b++;
			break;
		case 2:
			if (count_c != num_c)sw =  c[count_c]-'a';
			count_c++;
			break;
		default:
			break;
		}


	}


	if (count_a > num_a)cout << "A" << endl;
	else if (count_b > num_b)cout << "B" << endl;
	else cout << "C"<<endl;

	


	return 0;
}

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

int main()
{	
	int a[5], b[5], k = 0;
	char s[6] = "ABCDE";

	cin >> a[0] >> b[0];
	int m = a[0] + b[0];

	while (m > 0) {

		for (int i = 1; i < 5; i++) {
			cin >> a[i] >> b[i];

			if (a[i] + b[i] > m) {
				k = i;
				m = a[i] + b[i];
			}
		}

		cout << s[k] << " " << m << endl;

		cin >> a[0] >> b[0];
		m = a[0] + b[0];
		k = 0;
	}
	
	return 0;
}



Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
n,w = map(int,input().split())
wv = [tuple(map(int,input().split())) for i in range(n)]

dp = [0]*(w+1)
for i in range(n):
    for j in range(w,wv[i][0]-1,-1):
        dp[j] = max(dp[j],dp[j-wv[i][0]]+wv[i][1])

print(max(dp))

Measured memory_bytes: 42732
#include <iostream>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <utility>
using namespace std;
int ky[8] = {-1,1,-2,2,-2,2,-1,1}; 
int kx[8] = {-2,-2,-1,-1,1,1,2,2};
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int ddy[8] = {-1,0,1,-1,1,-1,0,1};
int ddx[8] = {-1,-1,-1,0,0,1,1,1};
typedef long long ll;
#define pi pair
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define rep1(i,a,b) for(int i = a; i < b; i++)
#define rep2(i,a,b) for(int i = a; i <= b; i++) 
#define INF 999999999999
const double PI = acos(-1.0); 
ll n;
vector<ll> v;
map<ll,ll> m;
ll ans;

ll compute(ll num){
    ll mx = -INF;
    for(ll i = 1; i <= num; i++)
        if(i * (i + 1) / 2 <= num)
            mx = max(mx, i);
    return mx;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> n;
    for(ll i = 2; i * i <= n; i++){
        while(n % i == 0){
            v.PB(i);
            n /= i;
        }
    }
    if(n > 1) v.PB(n);

    ll vs = v.size();
    rep1(i,0,vs) m[v[i]]++;

    for(auto c : m){
       // if(c.S == 1) ans++;
        ans += compute(c.S);
    }
    cout << ans;
	return 0;
}


Measured memory_bytes: 3644
import Data.List
import Data.List.Split
import Data.Char (isSpace)

trim :: String -> String
trim = f . f
  where
    f = reverse . dropWhile isSpace

calc :: Int -> Int -> (Int, Int)
calc a b = (min a b, max a b)

main :: IO ()
main = do
  s <- getContents
  let xs = splitOn "\n" $ trim s
  putStrLn $ intercalate "\n" [show a' ++ " " ++ show b' |
                               t <- xs,
                               let [a, b] = map read $ words t :: [Int],
                               a /= 0 || b /= 0,
                               let (a', b') = calc a b]

Measured memory_bytes: 5564
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	ll n, ans = 1e16,sum = 0 ,S =0;cin >> n;vector<ll>a(n + 1);
	rep(i, n) {
		cin >> a[i];
		S += a[i];
	}
	rep(i, n) {
		sum += a[i];
		ans = min(ans, abs(2 * sum - S));
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
using namespace std;
int main() {
	int n, ans = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		if (i % 2 == 1) {
			int cnt = 0;
			for (int j = 1; j <= i; ++j) {
				if (i % j == 0) cnt++;
			}
			if (cnt == 8) ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
using namespace std;
int N;
int m[333][333],w[333][333];
long long ans;
priority_queue<tuple<int,int,int>,vector<tuple<int,int,int>>,greater<tuple<int,int,int>>>pq;
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>N;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            cin>>m[i][j];
            w[i][j]=1e9+1;
            pq.push(make_tuple(m[i][j],i,j));
        }
    }
    while(!pq.empty()){
        auto tp=pq.top();
        pq.pop();
        int x=get<0>(tp);
        int y=get<1>(tp);
        int z=get<2>(tp);
        int a=2e9;
        for(int i=0;i<N;i++){
            a=min(a,w[y][i]+w[i][z]);
        }
        if(x>a){
            cout<<-1;
            return 0;
        }
        else if(x<a){
            ans+=x;
        }
        w[y][z]=x;
    }
    cout<<ans/2;
    return 0;
}


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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long Int;
typedef pair<Int, Int> P;

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

bool sosuu(int x){
	bool b = 1;
	if(x == 1) b = 0;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			b = 0;
			break;
		}
	}
	return b;
}

int n, m, ans = 0;
pair<string,bool> s[200];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> s[i].first;
		s[i].second = 0;
	}
	cin >> m;
	for(int i = 0; i < m; i++){
		cin >> s[i+n].first;
		s[i+n].second = 1;
	}
	sort(s, s+n+m);
	int c = 0;
	for(int i = 0; i < n+m; i++){
		if(i == 0){
			if(s[i].second) c--;
			else c++;
		}
		else if(s[i].first == s[i-1].first){
			if(s[i].second) c--;
			else c++;
		}
		else{
			ans = max(ans, c);
			if(s[i].second) c = -1;
			else c = 1;
		}
	}
	ans = max(ans, c);
	
	cout << ans << endl;
	
	return 0;
}

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

int main()
{
    ll a, b;
    cin >> a >> b;
    if ((a + b) % 2 == 0)
    {
        cout << (a + b) / 2 << endl;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import itertools
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

nn = list(range(1,n + 1))

c = itertools.permutations(nn, n)

p_p = 0
q_p = 0
for i, j in enumerate(c):
    if list(j) == p:
        p_p = i
    if list(j) == q:
            q_p = i
print(abs(q_p - p_p))

Measured memory_bytes: 9120
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
typedef double D;
typedef complex<D> P;
const D EPS = 1e-8;

int n,r,q,r2;
P p[30];
int cur;
D min_s[30],x,y;

inline D dot(const P &x, const P &y){return real(conj(x)*y);}

inline P rotate(const P &v, const D &s){
  return P(real(v)*cos(s) - imag(v)*sin(s), real(v)*sin(s) + imag(v)*cos(s) );
}

inline D arg(const P &a,const P &b,const P &c){return dot(b-a,c-a)/(abs(b-a)*abs(c-a));}

inline D rot_seta(const int &end){
  D seta = acos( 1 - norm(p[end]-p[cur])/r2 );
  P nxt = rotate(p[cur],-seta);
  return arg(p[cur],p[end],nxt);
}

int main(){
  while(scanf("%d%d%d",&n,&r,&q), n){
    r2 = 2*r*r;
    rep(i,n){
      scanf("%lf%lf",&x,&y);
      p[i] = P(x,y);
      if(abs(abs(p[i])-r)<EPS)cur = i;
    }
    
    vector<int> nxt(n,-1);
    bool f = false;

    rep(i,q){
      if(nxt[cur]>=0)f = true;

      if(!f){
	min_s[cur] = 5;
	rep(j,n){
	  if(cur==j)continue;
	  D s = rot_seta(j);
	  if(nxt[cur]<0 || s > min_s[cur]+EPS)nxt[cur] = j, min_s[cur] = s;
	}
	min_s[cur] = acos(min_s[cur]);
      }

      rep(j,n){
	if(j==cur || (f&&nxt[cur]<0))continue;
	p[j] = rotate(p[j]-p[cur],min_s[cur]) + p[cur];
      }
      printf("%.9lf %.9lf\n",p[nxt[cur]].real(), p[nxt[cur]].imag());

      if(i==0){
	int tmp = nxt[cur];
	nxt[cur] = -1;
	cur = tmp;
      }else{
	cur = nxt[cur];
      }
    }
  }
}

Measured memory_bytes: 1332
import os
import sys
from io import BytesIO, IOBase


def main():
    n,k=list(map(int,input().split()))
    a=list(map(int,input().split()))
    
    print(sum(sorted(a)[:k]))



# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 63172
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61 + 1<<29)
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) _OUTPUT_IMPL_(__VA_ARGS__)
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))

int main() {
	in(int, x);
	if (x < 1200) cout << "ABC" << endl;
	else cout << "ARC" << endl;
}

Measured memory_bytes: 256
#template
def inputlist(): return [int(k) for k in input().split()]
#template

N,M = inputlist()
li = []
for i in range(N):
    A,B = inputlist()
    B *= -1
    li.append([A,B])
ans = 0
from heapq import *
li.sort()
k = []
heapify(k)
flag = 0
for i in range(1,M+1):
    if flag == N:
        for i in range(M+1-i):
            ans -= heappop(k)
        break
    while li[flag][0] <= i:
        heappush(k,li[flag][1])
        flag = flag + 1
        if flag == N:
            break
    if len(k)>=1:
        ans -= heappop(k)
print(ans)

Measured memory_bytes: 20816
num,weight = (int(n) for n in input().split(" "))
query = []
for n in range(num):
    query.append([int(n) for n in input().split(" ")])
nap = [[0 for n in range(weight + 1)] for m in range(num + 1)]
query = sorted(query,key = lambda x:x[1],reverse = True)
for n in range(num):
    for w in range(weight + 1):
        if w == 0:
            continue
        elif w >= query[n][1]:
            nap[n + 1][w] = max(nap[n+1][w-query[n][1]] + query[n][0] ,nap[n][w-query[n][1]] + query[n][0] ,nap[n][w])

print(nap[num][weight])

Measured memory_bytes: 44520
#include <stdio.h>

int main(void){
    int N;
    scanf("%d", &N);

    if(N == 10 || N == 100 || N == 1000 || N == 10000 || N == 100000){
        printf("10\n");
    }else{
        printf("%d\n", N/10000 + (N%10000)/1000 + (N%1000)/100 + (N%100)/10 + (N%10));
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdlib>
#include<cstdio>
#include<utility>
#include<list>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int city[n]; for(int i=0;i<n;i++)city[i]=0;
	int a[m],b[m];
	for(int i=0;i<m;i++){
		a[i]=0; b[i]=0;
	}
	for(int i=0;i<m;i++)cin>>a[i]>>b[i];

	for(int i=0;i<m;i++){
		city[a[i]-1]++;
		city[b[i]-1]++;
	}
	for(int i=0;i<n;i++)cout<< city[i] <<endl;

	return 0;
}


Measured memory_bytes: 384
str = STDIN.gets
alp = {D: "A",E: "B", F: "C",G: "D",H: "E",I: "F", J: "G",K: "H",L: "I",M: "J",N: "K",O: "L",P: "M",Q: "N",R: "O",S: "P",T: "Q", U: "R", V: "S", W: "T",X: "U",Y: "V", Z: "W", A: "X", B: "Y", C: "Z"}

str.split("").each do |i|
  print alp[i.to_sym]
end
 puts 

Measured memory_bytes: 8732
import std.string;
import std.algorithm;
import std.math;
import std.array;
import std.format;
import std.range;
import std.stdio;
import std.conv;

int pred(int h, int w, int H, int W)
{
    int r2 = h^^2 + w^^2;
    int R2 = H^^2 + W^^2;
    if(r2 == R2) return h - H;
    else return r2 - R2;
}


void main()
{
    while(1){
        auto hw = readln().chomp().split().map!(to!uint),
             H = hw[0],
             W = hw[1];

        if(!H) break;

        uint resH = 150, resW = 150;

        foreach(h; 1 .. 150)
            foreach(w; h+1 .. 150){
                if(pred(h, w, H, W) > 0 && pred(h, w, resH, resW) < 0){
                    resH = h;
                    resW = w;
                }
            }

        writefln("%s %s", resH, resW);
    }
}

Measured memory_bytes: 1060
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REPR(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define FOR(i, x, n) for (int i = x; i < (int)(n); ++i)
#define ALL(n) begin(n), end(n)
#define ll long long
#define INF 1e9
int main() {
    int n;
    double d;
    cin >> n >> d;
    vector<double> x(n), y(n);
    REP(i, n) { cin >> x[i] >> y[i]; }
    int count = 0;
    REP(i, n) {
        // cout << x[i] * x[i] + y[i] * y[i] << "  " << d * d << endl;
        if (x[i] * x[i] + y[i] * y[i] <= d * d) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 6492
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }




int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, M, Q; cin >> N >> M >> Q;
    vvl cnt(N, vl(N, 0));
    rep(i, M){
        ll l, r; cin >> l >> r; l--; r--;
        cnt[l][r]++;
    }
    vvl sum(N, vl(N+1, 0));
    rep(i, N){
        rep(j, N){
            sum[i][j+1] = sum[i][j] + cnt[i][j];
        }
    }
    
    rep(i, Q){
        ll p, q; cin >> p >> q; p--;
        ll res = 0;
        FOR(j, p, q){
            res += sum[j][q] - sum[j][j];
        }
        cout << res << endstr;
    }
    
    return 0;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
     
struct edge{
    int to;
    long long int cost;
};
     
struct Node{
    int point;
    long long int cost;
};
     
long long int cost[100001]={0};
vector<edge> tree[100001];
     
int main(){
    int n;
    cin >> n;
    for(int i=0;i<=n;++i)cost[i] = LLONG_MAX;
    for(int i=0;i<n-1;++i){
        int a,b,c;
        cin >> a >> b >> c;
        tree[a].push_back((edge){b,c});
        tree[b].push_back((edge){a,c});
    }
    int q, k;
    cin >> q >> k;
    queue<Node> que;
    que.push((Node){k, 0});
    cost[k] = 0;
    while(!que.empty()){
        Node now = que.front(); que.pop();
        for(int i=0;i<tree[now.point].size();++i){
            if(cost[tree[now.point][i].to] == LLONG_MAX){
                long long int newcost = now.cost + tree[now.point][i].cost;
                cost[tree[now.point][i].to] = newcost;
                que.push((Node){tree[now.point][i].to, newcost});
            }
        }
    }
    for(int i=0;i<q;++i){
        int x, y;
        cin >> x >> y;
        cout << cost[x] + cost[y] << endl;
    }
     
    return 0;
}

Measured memory_bytes: 10736
'use strict'

const INF = 900719925474099;


function Main(input){
    let temp = input.trim().split(' ').map((v)=>parseInt(v));
    let a = temp.shift();
    let p = temp.shift();

    let ans = Math.floor((a*3 + p)/2)


    console.log(ans);
    
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 22080
#include<stdio.h>
int main(void){
int A[3], ch, a, b, c;
for(int i=0;i<3;i++){
scanf("%d",&A[i]);//昇順に並べる
}
for(int i=0;i<3;i++){
    for(int j=i+1;j<3;j++){
        if(A[i]>A[j]){
    ch=A[j];
    A[j]=A[i];
    A[i]=ch;
        }
    }
}
a=A[1]-A[0];
b=A[2]-A[1];
c=A[2]-A[0];

if(a+b>=a+c && b+c>=a+c)printf("%d\n",a+c);
else if(a+c>=a+b && b+c>=a+b)printf("%d\n",a+b);
else printf("%d\n",b+c);
return 0;
}

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

int main() {
  double h;

  cin >> h;

  long ans = 1, mon = 2;

  h /= 2;

  while (h >= 1) {
    ans += mon;
    mon *= 2;
    h /= 2;
  }

  cout << ans;

  return 0;
}

Measured memory_bytes: 256
// Tazoe

#include <iostream>
using namespace std;

int main()
{
	bool F[30];
	for(int i=0; i<30; i++){
		F[i] = false;
	}

	for(int i=0; i<28; i++){
		int x;
		cin >> x;

		F[x-1] = true;
	}

	for(int i=0; i<30; i++){
		if(!F[i]){
			cout << i+1 << '\n';
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int main(void)

{

int x,y,z,a,b,c;

scanf("%d %d %d",&x,&y,&z);

if(x<y)

{


}


else


{


a=x;


x=y;


y=a;


}


if(x<z)


{


}


else


{


b=x;


x=z;


z=b;


}


if(y<z)


{


}


else


{


c=y;


y=z;


z=c;


}


printf("%d %d %d\n",x,y,z);


return 0;


}

Measured memory_bytes: 596
def divisors(n)
  b = Array.new
  for i in 2..((n**0.5))
    while n % i == 0
      b.push(i)
      n = n / i
    end
  end
  b.push(n) if n != 1
  b
end
n = gets.to_i
hash = Hash.new(0)
cnt74 = 0
cnt24 = 0
cnt14 = 0
cnt4 = 0
cnt2 = 0
n.times do |i|
  divisors(i+1).each do |x|
    hash[x] += 1
    if hash[x] == 2
      cnt2 += 1
    elsif hash[x] == 4
      cnt4 += 1
    elsif hash[x] == 14
      cnt14 += 1
    elsif hash[x] == 24
      cnt24 += 1
    elsif hash[x] == 74
      cnt74 += 1
    end
  end
end
puts cnt4 * (cnt4-1) * (cnt2-2) / 2 + cnt14 * (cnt4-1) + cnt24 * (cnt2-1) + cnt74

Measured memory_bytes: 14532
import sys
def input():
	return sys.stdin.readline().strip()

N, M, C = list(map(int, input().split()))
B = list(map(int, input().split()))
A =[]
for i in range(N):
	A.append(list(map(int, input().split())))

total = 0
for i in range(N):
	num = C
	for j in range(M):
		num += A[i][j]*B[j]
	if num > 0:
		total += 1

print(total)

Measured memory_bytes: 38384
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>

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

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

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

int main()
{
	string s;
	cin >> s;
	cout << ((s[2] == s[3] && s[4] == s[5]) ? "Yes" : "No");
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
#define INF 1e9
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end(), std::greater<int>()
#define rep(i, n) for(int i = 0; i < n; i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define max(v) *max_element(v.begin(), v.end())
#define min(v) *min_element(v.begin(), v.end())
using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<long double> x(n), y(n);
    rep(i, n)
        cin>>x[i]>>y[i];
    long double ans = 0;
    long double sum = 0;
    vector<int> v;
    rep(i, n)
        v.pb(i);
    do {
        sum = 0;
        rep(i, n-1)
            sum += sqrt((x[v[i]]-x[v[i+1]])*(x[v[i]]-x[v[i+1]]) + (y[v[i]]-y[v[i+1]])*(y[v[i]]-y[v[i+1]]));
        ans += sum;
    } while( next_permutation(v.begin(), v.end()) );     // 次の順列を生成
    int fac = 1;
    for(int i = 2; i < n+1; i++){
        fac *= i;
    }
    cout << fixed << setprecision(10) << ans / fac << endl;
    return 0;
}

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


int main(){
    int N;cin>>N;
    vector<int> A(N);
    A[0]=0;
    for(int i=1;i<N;i++)
    {cin>>A[i];}
    vector<int>answer(N);
    for(int i=0;i<N;i++){answer[i]=0;}
    for(int i=1;i<N;i++){answer[A[i]-1]++;}
    for(int i=0;i<N;i++){cout<<answer[i]<<endl;}
}



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

#define _overload3(_1, _2, _3, name, ...) name
#define rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define REP(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)

typedef long long int ll;
typedef unsigned long long int ull;

const int MOD=(int)1e9+7;
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};

ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll g=gcd(a,b);return a/g*b;}
ll digitsum(ll a){ll x=0;while(a>0){x+=a%10;a/=10;}return x;}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    int s=(a+b+c)/2;
    cout<<sqrt(s*(s-a)*(s-b)*(s-c))<<endl;
}

Measured memory_bytes: 256
import numpy as np
D = []
c = []
d0 = {}
d1 = {}
d2 = {}

N,C = map(int,input().split())
a = np.zeros((3,C))
for i in range(C):
    D.append(list(map(int,input().split())))
for i in range(N):
    c.append(list(map(int,input().split())))

D = np.array(D)
c = np.array(c)

for i in range(N):
    for j in range(N):
        a[(i+j)%3] += D[c[i][j]-1]

l = []
for C1 in range(C):
    for C2 in range(C):
        for C3 in range(C):
            if C1 != C2 and C2 != C3 and C3 != C1:
                l.append(a[0][C1]+a[1][C2]+a[2][C3])

print(int(min(l)))

Measured memory_bytes: 21304
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
using graph = vector<vector<int>>;
typedef long long ll;

int main() {
	ll n,sum=0,rednum,greennum,bluenum;
	string s;
	vector<ll> red;
	vector<ll> green;
	vector<ll> blue;
	vector<ll> num;
	cin >> n;
	cin >> s;
	for (ll i = 0; i < n; i++) {
		if (s[i] == 'R') {
			red.push_back(i);
		}
		else if (s[i] == 'G') {
			green.push_back(i);
		}
		else {
			blue.push_back(i);
		}
	}
	sum = red.size() * green.size() * blue.size();
	for (ll i = 0; i < n; i++) {
		for (ll j = i + 1; j < n; j++) {
			if (2 * j - i >= n) {
				continue;
			}else if (s[i] != s[j] && s[j] != s[2 * j - i] && s[i] != s[2 * j - i]) {
				sum--;
			}
		}
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3672
import java.util.*
import java.math.*

fun main(args: Array<String>) {
    var (N,L) = readLine()!!.split(" ").map { it.toInt() }
//    var N = readLine()!!.toInt()
//    val S = readLine()!!.toInt()
//    val L = readLine()!!.split(" ").map { it.toInt() }.toIntArray()

    var sum = 0
    var ans = IntArray(N){L+it}

    println(ans.sum() - ans.minBy(Math::abs)!!)
}



Measured memory_bytes: 36064
// Copyright 2020 yaito3014
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> str(N, 0), last(N, 0);
  iota(begin(last), end(last), 0);
  for (; str < last; ++str[N - 1]) {
    vector<int> base(N, 2);
    for (int i = 0; i < N - 1; ++i)
      base[i + 1] = max(base[i], str[i] + 2);
    for (int i = N - 1; i >= 0; --i) {
      if (str[i] >= base[i]) {
        str[i] = str[i] - base[i];
        ++str[i - 1];
      }
    }
    for (int i = 0; i < N; ++i)cout << char('a' + str[i]);
    cout << '\n';
  }
  for (int i = 0; i < N; ++i)cout << char('a' + str[i]);
  cout << '\n';
}


Measured memory_bytes: 1536
#include<stdio.h>
int main(void)
{
	char x,y;
	scanf("%c %c",&x,&y);
	if(y>x){
		printf("<\n");
	}
	else if(y<x){
		printf(">\n");
	}
	else{
		printf("=\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std ;
int n , m , k ;
int a[20][1200] ;
int main()
{
  int s ;
  cin >> n >> m >> s ;
  for(int i = 1; i <= n ;i ++)
   {
     string s ;
     cin >> s ;
     for(int j = 0 ;j < m ;j ++)
      if(s[j] == '1')
       a[i][j + 1] = 1 ;
   }
   int ans = 0x3f3f3f3f ;
   for(int i = 0 ;i < (1 << (n - 1)) ;i ++)
    {
      vector<int> pos ;
      pos.push_back(0) ;
      for(int j = 1 ;j < n  ;j ++)
       if(i & (1 << (j  - 1)))
        pos.push_back(j) ;
      pos.push_back(n) ;
      int now = pos.size() - 2 ;
      vector<int> cnt(pos.size() - 1 , 0) ;
      for(int j = 1; j <= m ;j ++)
       {
         bool ok = true ;
         vector<int> cnt0(pos.size() - 1,  0) ;
         for(int k = 0 ;k < cnt.size() ;k ++)
          {
            for(int h = pos[k] + 1 ;h <= pos[k + 1] ;h ++)  cnt0[k] += a[h][j] ;
            if(cnt0[k] > s) goto label_end ;
            if(cnt[k] + cnt0[k] > s) ok = false ;
          }
          if(ok) for(int k = 0 ;k < cnt.size() ;k ++)
           cnt[k] += cnt0[k] ;
          else now ++ , cnt = cnt0 ;
       }
       ans = min(ans , now) ;
       label_end: ;
    }
    cout << ans << endl ;
  return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define VECCIN(vec) const int size = (vec).size(); REP(i,size) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    string S;
    cin >> S;
    for (int n = S.length() - 2; n >= 0; n -= 2) {
        string s1 = S.substr(0, n / 2);
        string s2 = S.substr(n / 2, n / 2);
        if (s1 == s2) {
            cout << n << endl;
            return 0;
        }
    }

    return 0;
}

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

int main(){
  int n,a,b; cin >> n >> a >> b;
  
  if(a+b<=n){cout << min(a,b) << ' ' << 0;}
  else{cout << min(a,b) << ' ' << a+b-n;}
  
  return 0;
}

Measured memory_bytes: 256
n, p = input().split()
n, p = int(n), int(p)
d = 2
ans = 1
while d * d <= p:
	if p % d == 0:
		cnt = 0
		while p % d == 0:
			cnt += 1
			p //= d
		ans *= d ** (cnt // n)
	d += 1
if p != 1 and n == 1:
	ans *= p
print(ans)

Measured memory_bytes: 39152
#include<iostream>
#include<cstring>
using namespace std;
int main(){
  int n,joi=0,ioi=0;
  char s[10010];
  while(cin >> s){
    joi=0;
    ioi=0;
    n=strlen(s);
    for(int i=0;i<n;i++){
      if(s[i]=='J')if(s[i+1]=='O')if(s[i+2]=='I'){
	    joi++;
	  }
      if(s[i]=='I')if(s[i+1]=='O')if(s[i+2]=='I'){
	    ioi++;
	  }
    }
    cout << joi << endl << ioi << endl;
  }
}

Measured memory_bytes: 1148
number = input()
numberlist = number.split(" ")
A = int(numberlist[0])
B = int(numberlist[1])
C = int(numberlist[2])
temp = 0
con1 = A + B + C
if con1 >= 3 and con1 <= 300:
    temp = A
    A = B
    B = temp
    temp = C
    C = A
    A = temp
    print(str(A) + " " + str(B) + " " + str(C))
else:
    print()


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


// 組み合わせ数を計算する。nCr
map<ll, vector<ll>> _combinations;
ll combination(int n, int r) {
    if(n < 1 || r < 1 || n < r) return 0;
    if(n == r) return 1;
    if(r > n - r) r = n - r;
    if(!_combinations.count(n)) {
        vector<ll> vec = {0, n};
        _combinations.emplace_hint(_combinations.end(), n, vec);
    }
    auto&& vec = _combinations.find(n)->second;
    if(r > n - r) r = n - r;
    if(vec.size() <= r) {
        int i = vec.size();
        vec.resize(r + 1);
        for(; i <= r; i++) {
            vec[i] = vec[i - 1];
            vec[i] *= (n - i + 1);
            vec[i] /= i;
        }
    }

    return vec[r];
}
int main() {
    cin.tie(0); ios::sync_with_stdio(false); cout << fixed << std::setprecision(20);

    int n;
    cin >> n;
    vector<ll> as(n), counts(n + 1, 0);
    
    for(auto&& a : as) {
        cin >> a;
        counts[a]++;
    }
    
    ll total = 0;
    
    for(auto&& count : counts) {
        if(count > 0) {
            total += combination(count, 2);
        }
    }

    for(auto&& a : as) {
        cout << total - combination(counts[a], 2) + combination(counts[a] - 1, 2) << endl;
    }
}

Measured memory_bytes: 5760
N = int(input())
jud = [0,0,0,0]
for i in range(N):
  s = str(input())
  if(s == "AC"):
    jud[0]+=1
  elif(s == "WA"):
    jud[1] += 1
  elif(s == "TLE"):
    jud[2]+=1
  else:
    jud[3]+=1
print("AC x " +str(jud[0]))
print("WA x " +str(jud[1]))
print("TLE x " +str(jud[2]))
print("RE x " + str(jud[3]))
  


Measured memory_bytes: 9200
#include<stdio.h>
int main()
{
	int P, Q, R;
	int A = 0;
	scanf("%d%d%d", &P, &Q, &R);
	if (P > 100)
		P == 100;
	if (Q > 100)
		Q == 100;
	if (R > 100)
		R == 100;
	A = P + Q;
	if (A > P + R) {
		A = P + R;
	}
	if (A > Q + R) {
		A = Q + R;
	}
	printf("%d\n", A);

	
	return 0;
}

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

using namespace std;

#define int long long

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

const int mod = 1e9 + 7;

int N, C;
int A[405], B[405];
int Sum[405][405];

int dp[405][405];

inline int modpow(int a, int x, int m)
{
    int res = 1;

    while (x > 0) {
        if (x & 1) (res *= a) %= m;

        (a *= a) %= m;
        x /= 2;
    }

    return res;
}

signed main()
{
    cin >> N >> C;

    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];

    int v = 0;

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= C; ++j) {
            for (int k = A[i]; k <= B[i]; ++k) {
                (Sum[i][j] += modpow(k, j, mod)) %= mod;
            }
        }
    }

    for (int i = 0; i <= C; ++i) {
        dp[0][i] = Sum[0][i];
    }

    for (int i = 1; i < N; ++i) {
        for (int j = 0; j <= C; ++j) {
            for (int k = 0; k <= C - j; ++k) {
                (dp[i][j + k] += dp[i - 1][j] * Sum[i][k]) %= mod;
            }
        }
    }

    cout << dp[N - 1][C] << endl;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll i,ans=0,n,m;
	scanf("%lld%lld",&n,&m);
	for(i=1;i*i<=m;i++) if(m%i==0)
	{
		if(n*i<=m) ans=max(ans,i);
		if(n<=i) ans=max(ans,m/i);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
num = 0

n = int(input())
for _ in range(n):
    x = int(input())
    z = 1
    if x == 2:
        z = 1
        num += 1
        continue
    elif x < 1 or x % 2 == 0:
        continue
    y = int(x**0.5)
    for v in range(3, y+1, 2):
        if x % v == 0:
            z = 0
            break
    if z == 1:
        num += 1

print(num)


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

int main()
{
	char b, ans;
	cin >> b;

	if (b == 'A') ans = 'T';
	else if (b == 'T') ans = 'A';
	else if (b == 'C') ans = 'G';
	else if (b == 'G') ans = 'C';

	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from collections import deque

n, *a = map(int, sys.stdin.read().split())

def main():
    b = deque()
    for i in range(n):
        if i & 1:
            b.appendleft(a[i])
        else:
            b.append(a[i])
    res = list(b)
    if n & 1:
        res = res[::-1]

    return res

if __name__ == '__main__':
    ans = main()
    print(*ans, sep=' ')

Measured memory_bytes: 25948
#include <bits/stdc++.h>
    using namespace std;
    typedef long long lint;
    typedef pair<int,int> pint;
    #define rep(i, n) for(int i = 0; i < n; i++)
    #define rep2(elem, vec) for(auto elem: vec)
    #define SORT(V) sort((V).begin(),(V).end())
    #define RSORT(V) sort((V).rbegin(), (V).rend())
    lint gcd(int a,int b){return b?gcd(b,a%b):a;}
    lint lcm(int a,int b){return a*b/gcd(a,b);}
    lint comb(int a,int b){return b?comb(a-1,b-1)*a/b:1;}
int main(){
    string s,t;
    cin >> s >> t;
    cout << t << s;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
void comp(int &i, int &j);

int main(){
	int a,b,c,temp;
	std::cin >> a >> b >> c;
	comp(a,b);
	comp(b,c);
	comp(a,b);
	std::cout << a  << " " << b  << " " << c << std::endl;
}
void comp(int &i, int &j){
	if(i > j){
		int temp = i;
		i = j;
		j = temp;
	}
}



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

#define ll long long

int main() {
    std::ios::sync_with_stdio(false);
    using namespace std;
    int n, k;
    cin >> n >> k;

    vector<int> A(n);
    for(int i = 0; i < n; i++) cin >> A[i];

    vector<bool> B(k + 1, false); // is winning
    for(int i = 1; i <= k; i++) {
        for(auto x : A)
            if(i - x >= 0 && !B[i - x])
                B[i] = true;
    }

    cout << (B[k] ? "First" : "Second") << "\n";

    return 0;
}


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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

long long MOD = 1000000000 + 7;
long long MAX = LLONG_MAX;

int main(){
  cout << setprecision(10);
  int N,K;
  cin >> N >> K;
  vector<ll> A(N), B(N);
  vector<pll> v(N);

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

    v.at(i) = make_pair(A[i],B[i]);
  }

  sort(A.begin(), A.end());
  sort(B.begin(), B.end());

    // 入力: H × W のグリッド
  int H, W; 
  H = N; W = N;
  vector<vector<int> > a(H, vector<int>(W, 0));

  for(int i = 0; i < N; i++){
    ll x = v[i].first;
    ll y = v[i].second;

    int x_index = lower_bound(A.begin(), A.end(), x) - A.begin();
    int y_index = lower_bound(B.begin(), B.end(), y) - B.begin();

    a[x_index][y_index]++;

  }

  // 二次元累積和
  vector<vector<int> > s(H+1, vector<int>(W+1, 0));
  for (int i = 0; i < H; ++i){
    for (int j = 0; j < W; ++j){
      s[i+1][j+1] = s[i][j+1] + s[i+1][j] - s[i][j] + a[i][j];
    }
  }

  ll ans = MAX;
  for(int x1 = 0; x1 < N; x1++){
    for(int x2 = x1+1; x2 <= N; x2++){
      for(int y1 = 0; y1 < N; y1++){
        for(int y2 = y1+1; y2 <= N; y2++){
          int num = s[x2][y2] - s[x1][y2] - s[x2][y1] + s[x1][y1];
          if(num >= K){
            ll area = ( A[x2-1] - A[x1] ) * (B[y2-1] - B[y1]);
            ans = min(ans, area);
          }
        }
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int N;
int a[100010];

int main(void) {
	cin >> N;
	rep(i, N) cin >> a[i];

	int god = 0, even = 0, odd = 0;
	rep(i, N) {
		int d = a[i];
		if(d % 4 == 0) god++;
		else if(d % 2 == 0) even++;
		else odd++;
	}

	bool flag = false;

	if(even == 0) {
		if(N % 2) {
			if(god + 1 >= odd) flag = true;
		}else {
			if(god > odd) flag = true;
		}
	}else {
		int ext = N - even;
		if(ext % 2) {
			if(god > odd) flag = true;
		}else {
			if(god >= odd) flag = true;
		}
	}

	if(flag) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 640
h, w = map(int, input().split())

if h % 3 == 0 or w % 3 == 0:
    print(0)
else:
    ans = min(h, w)

    if w == 2:
        a = 1
        a1 = a * h
        b = h // 2
        a2 = (w-a) * b
        a3 = (w-a) * (h-b)
        ans = min(ans, max(a1, a2, a3) - min(a1, a2, a3))
    else:
        for i in range(3):
            a = w // 3 + i
            a1 = a * h
            b = h // 2
            a2 = (w-a) * b
            a3 = (w-a) * (h-b)
            ans = min(ans, max(a1, a2, a3) - min(a1, a2, a3))

    if h == 2:
        a = 1
        a1 = a * w
        b = w // 2
        a2 = (h-a) * b
        a3 = (h-a) * (w-b)
        ans = min(ans, max(a1, a2, a3) - min(a1, a2, a3))
    else:
        for i in range(3):
            a = h // 3 + i
            a1 = a * w
            b = w // 2
            a2 = (h-a) * b
            a3 = (h-a) * (w-b)
            ans = min(ans, max(a1, a2, a3) - min(a1, a2, a3))
    
    print(ans)

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int X = sc.nextInt();
        if (K*500 >= X) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

int main(){
  int d;
  cin>>d;
  if(d == 25)cout<<"Christmas"<<endl;
  else if(d == 24)cout<<"Christmas Eve"<<endl;
  else if(d == 23)cout<<"Christmas Eve Eve"<<endl;
  else if(d == 22)cout<<"Christmas Eve Eve Eve"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int maxf(int a, int b);

main(){
    int a, b, max;
    scanf("%d%d",&a,&b);
    max = maxf(a, b);
    if (max > 8) printf(":(");
    else printf("Yay!");
}

int maxf(int a, int b){
    return a > b ? a : b ;
}

Measured memory_bytes: 128
<?php

function input() {
    return trim(fgets(STDIN));
}
function input_array() {
    return explode(' ', input());
}

$n = (int)input();
$as = array_map(function($numeric_string) {
    return (int)$numeric_string;
}, input_array());

$avg = array_sum($as) / $n;

$diffs = array_map(function($a, $idx) use ($avg) {
    return [$idx, abs($a - $avg)];
}, $as, range(0, $n - 1));


$min = INF;
$min_idx = null;

foreach ($diffs as $diff) {
    if ($min > $diff[1]) {
        $min = $diff[1];
        $min_idx = $diff[0];
    }
}

echo $min_idx . "\n";

Measured memory_bytes: 4604
require 'prime'

$primes = Prime.first 1300
$is_prime = Array.new(10010, false)
def main

  $primes.each do |num|
    $is_prime[num] = true
  end
  while n = gets 
    n = n.chomp.to_i
    puts solve(n)   
  end
end

def solve n
  res = 0
  (1..n).each do |i|
    o = n - i + 1
    res += 1 if $is_prime[i] and $is_prime[o]
  end
  res
end

main

Measured memory_bytes: 6340
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
typedef long long int llint;

int main(void){

  int n, r;
  std::cin >> n >> r;

  if(n <= 10) std::cout << r + 100*(10-n) << std::endl;
  else        std::cout << r << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
pa tmp[500010];
int n,a[500010],b[500010],ts,p[500010],t,ans,X,Y;
/*
bool cmp(int x,int y){
	if (a[x]+X==a[y] && b[x]+Y==b[y]) return 1;
	else return 0;
}
*/
int main(){
	cin>>n;
	FOR(i,1,n) getint(a[i]),getint(b[i]);
	FOR(i,1,n)
		FOR(j,1,n)
			if (a[i]!=a[j] || b[i]!=b[j]) tmp[++ts]=mp(a[j]-a[i],b[j]-b[i]);
	ans=n;
	FOR(rp,1,ts){
		X=tmp[rp].fi,Y=tmp[rp].se;
		FOR(i,1,n) p[i]=i;
	//	sort(p+1,p+n+1,cmp1);
		t=0;
		FOR(i,1,n){
			bool ok=0;
			FOR(j,1,n){
				if (a[p[j]]+X==a[p[i]] && b[p[j]]+Y==b[p[i]]) ok=1;
			}
			if (!ok) ++t;
		}
		ans=min(ans,t);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4352