akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (long i = 0; i < n; ++i)
#define FOR(i, b, n) for (long i = b; i <= n; ++i)

using namespace std;

void solve(long N) {
  long ans(0);
  FOR(i, 1, N)
    if (to_string(i).length() % 2)
      ans++;
  cout << ans << endl;
}

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

  long N;
  cin >> N;

  solve(N);

  return 0;
}


Measured memory_bytes: 3696
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

from math import sqrt
def prime(n):
    if n<2:
        return False
    for i in range(2,int(sqrt(n)+1)):
        if n%i==0:
            return False
    return True
n=10*5-1
dp=[0 for i in range(10**5//2)]
dp[0]=0
for i in range(1,10**5//2):
    odd=2*i+1
    if prime(i+1) and prime(odd):
        dp[i]=dp[i-1]+1
    else:
        dp[i]=dp[i-1]
q=I()
for i in range(q):
    a,b=MI()
    if a==1:
        print(dp[(b+1)//2-1])
    else:
        print(dp[(b+1)//2-1]-dp[(a+1)//2-2])
        

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


using vi=vector<int>;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m, c;
    cin >> n >> m >> c;
    vi b(m);
    for (int i=0; i<m; ++i)
        cin >> b[i];
    int cnt = 0;
    for (int i=0; i<n; ++i) {
        int res = c;
        for (int j=0; j<m; ++j) {
            int aij;
            cin >> aij;
            res += aij*b[j];
        }
        cnt += (res > 0);
    }
    cout << cnt << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
typedef long long ll;
using namespace std;
int v[10001], w[10001];
ll cache[101][100001];

ll calc(int W, int n) {
	if(W < 0) {
		return INT_MIN;
	}
	
	if(n==0 || W==0) {
		return 0;
	}
	
	if(cache[n][W]!=-1) {
		return cache[n][W];
	}
	
	cache[n][W] = max(calc(W-w[n], n-1) + v[n], calc(W, n-1));
	return cache[n][W];
}
int main() {
	int n,W;
	cin>>n>>W;   
	for (int i=1; i<=n; i++) {
		cin>>w[i]>>v[i];
	}
	
	ll dp[101][100001];
	for (int i=1; i<=n; i++) {
		for(int j=1; j<=W; j++) {
			if(i==1 || j==1) {
				dp[i][j] = 0;
			}
			if(w[i] > j) {
				dp[i][j] = dp[i-1][j];
			} else {
				dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + v[i]); 
			}
		}
	}
	
	cout << dp[n][W];
	return 0;
}

Measured memory_bytes: 78720
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    for(int i = 1; i <= 60000; i++){
        if((i * 108) / 100 == n){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    var prev_place = Array(0, 0, 0)
    val n = io.StdIn.readLine().toInt

    var result = true
    var i = 0
    while (i < n && result == true) {
      val place = io.StdIn.readLine().split(' ').map({ _.toInt })
      val time = place(0) - prev_place(0)
      val move = place.zip(prev_place).map({ case (x, y) => x-y }).drop(1)

      if (move.sum > time)
        result = false

      if ((time + move.sum) % 2 == 1)
        result = false

      prev_place = place
      i += 1
    }

    if (result == true)
      println("Yes")
    else
      println("No")
  }
}


Measured memory_bytes: 62384
#include<stdio.h>

int main(){
  int a, b, x;
  
  scanf("%d %d", &a, &b);
  
  x = a + b;
  if(x % 2 == 0){
    x = x/2;
  } else {
    x = x/2 + 1;
  }
  
  printf("%d", x);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
typedef pair<ll,ll> P;

int main() {
    cin>>L>>R;
    ll R_MSB = 0, L_MSB = 0, temp;
    temp = R;
    while((temp >>= 1) > 0) ++R_MSB;
    temp = L;
    while((temp >>= 1) > 0) ++L_MSB;

    vector<P> data(63,{-1,-1}); //{下限,上限}
    reps(i,L_MSB, R_MSB + 1) data[i] = {(1LL << i),(1LL <<(i + 1)) - 1};
    data[L_MSB].fi = L;
    data[R_MSB].se = R;
    vector<mat> dp(63,mat(2,vec(2,0)));
    dp[0][0][0] = 1;
    ll ans = 0;
    reps(MSB,L_MSB,R_MSB+1){
        ll lb = data[MSB].fi, ub = data[MSB].se;
        reps(i,1,MSB + 1){
            ll l = (lb >> (MSB - i)) & 1, r = (ub >> (MSB - i))&1;
            rep(j,2){
                rep(k,2){
                    for(ll y = 0; y <= (j ? 1 : r); ++y){
                        for(ll x = (k ? 0 : l); x <= y; ++x){
                            (dp[i][j || (y < r)][k || (x > l)] += dp[i-1][j][k])%=MOD;
                        }
                    }
                }
            }
        }
        rep(j,2) rep(k,2) (ans += dp[MSB][j][k])%=MOD;
        reps(i,1,MSB+1) rep(j,2) rep(k,2) dp[i][j][k] = 0;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
tmp=readline()

A,V=parse.(BigFloat,split(tmp))
tmp=readline()
B,W=parse.(BigFloat,split(tmp))
tmp=readline()
T=parse(BigFloat,tmp)
#println("$A,$B,$V,$W,$T")
if T >= abs(B-A)/abs(V-W) && W < V
    println("YES")
else
    println("NO")
end


Measured memory_bytes: 183256
1.step do
  h, w = gets.chop.split(' ').map(&:to_i)
  break if h == 0 && w == 0

  1.step h do |hi|
    1.step w do |wi|
      if (hi + wi) % 2 == 0
        putc '#'
      else
        putc '.'
      end
    end
    puts ''
  end
  puts ''
end



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

int main(int argc, char *argv[]) {
	std::vector<std::string> image_a;
	std::vector<std::string> template_image_b;

	int image_a_size = 0;
	int template_image_b_size = 0;
	std::cin >> image_a_size;
	std::cin >> template_image_b_size;

	std::string current_str;
	for (int i = 0; i < image_a_size; i++) {
		std::cin >> current_str;
		image_a.push_back(current_str);
	}
	for (int j = 0; j < template_image_b_size; j++) {
		std::cin >> current_str;
		template_image_b.push_back(current_str);
	}

	bool found = false;
	for (int k = 0; k < image_a_size - template_image_b_size + 1; k++) {  // 平行移動
		std::string::size_type base_pos = 0;
		int find_count = 0;
		for (int l = 0; l < template_image_b_size; l++) {
			std::string::size_type pos = image_a[k + l].find(template_image_b[l], base_pos);
			if (pos != std::string::npos) {
				base_pos = pos;	  // 見つかったら、そこを基準とする
				find_count++;
			}
		}
		if (find_count == template_image_b_size) {
			found = true;
			break;
		}
	}

	std::cout << ((found) ? "Yes" : "No") << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cctype>
#include<cstring>
#define ll long long
using namespace std;
int read(){
	int w=0;
	bool s=0;
	char c=getchar();
	while(!isdigit(c)){
		s=(c=='-');
		c=getchar();
	}
	while(isdigit(c)){
		w=w*10+c-'0';
		c=getchar();
	}
	return s?-w:w;
}
const int N=20005,Mod=998244353,g=3,ig=332748118;
int n,m,len,l;
int r[N];
int add(int x,int y){
	if(x+y>Mod){
		return x+y-Mod;
	}
	return x+y;
}
int sub(int x,int y){
	y=Mod-y;
	if(x+y>Mod){
		return x+y-Mod;
	}
	return x+y;
}
int mul(int x,int y){
	return (ll)x*(ll)y%Mod;
}	
int power(int a,int b){
	int res=1;
	while(b){
		if(b&1){
			res=mul(res,a);
		}
		a=mul(a,a);
		b>>=1;
	}
	return res;
}
int pinv(int x){
	return power(x,Mod-2);
}
void NTT(int* a){
	for(int i=0;i<len;i++){
		if(i<r[i]){
			swap(a[i],a[r[i]]);
		}
	}
	for(int k=1;k<len;k<<=1){
		int w=power(g,(Mod-1)/(k<<1));
		for(int i=0;i<len;i+=(k<<1)){
			int wn=1;
			for(int j=0;j<k;j++){
				int x=a[i+j],y=mul(wn,a[i+j+k]);
				a[i+j]=add(x,y);
				a[i+j+k]=sub(x,y);
				wn=mul(wn,w);
			}
		}
	}
}
void INTT(int* a){
	for(int i=0;i<len;i++){
		if(i<r[i]){
			swap(a[i],a[r[i]]);
		}
	}
	for(int k=1;k<len;k<<=1){
		int w=power(ig,(Mod-1)/(k<<1));
		for(int i=0;i<len;i+=(k<<1)){
			int wn=1;
			for(int j=0;j<k;j++){
				int x=a[i+j],y=mul(wn,a[i+j+k]);
				a[i+j]=add(x,y);
				a[i+j+k]=sub(x,y);
				wn=mul(wn,w);
			}
		}
	}
	int dv=pinv(len);
	for(int i=0;i<len;i++){
		a[i]=mul(a[i],dv);
	}
}
int fac[N],inv[N],inv_fac[N];
int C(int m,int n){
	if(m>n){
		return 0;
	}
	return mul(fac[n],mul(inv_fac[m],inv_fac[n-m]));
}
int F[N],G[N],P[N],Q[N];
int ans;
int main(){
	n=read(),m=read();
	fac[0]=fac[1]=1;
	inv[0]=inv[1]=1;
	inv_fac[0]=inv_fac[1]=1;
	for(int i=2;i<N;i++){
		inv[i]=mul(sub(Mod,Mod/i),inv[Mod%i]);
		fac[i]=mul(fac[i-1],i);
		inv_fac[i]=mul(inv_fac[i-1],inv[i]);
	}
	len=1,l=0;
	while(len<=n+n){
		len<<=1;
		l++;
	}
	for(int i=0;i<len;i++){
		r[i]=(r[i>>1]>>1)|((i&1)<<(l-1));
	}
	G[0]=P[0]=1;
	for(int i=1;i<=n;i++){
		Q[i]=inv_fac[i+2];
	}
	NTT(Q);
	for(int i=0;i<m;i++){
		NTT(G);
		for(int j=0;j<len;j++){
			F[j]=mul(Q[j],G[j]);
		}
		INTT(F);
		for(int j=0;j<len;j++){
			if(j>n){
				F[j]=0;
				G[j]=0;
			}
			else{
				F[j]=mul(F[j],fac[j+2]);
				F[j]=add(F[j],mul(P[j],add(C(2,j),add(C(1,j),C(0,j)))));
				P[j]=F[j];
				G[j]=mul(F[j],inv_fac[j]%Mod);
			}
		}
	}
	for(int i=0;i<=n;i++){
		ans=add(ans,mul(C(i,n),F[i]));
	}		
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 768
n,*ww = open(0).read().split()

import sys
words = set()
prev = None
for w in ww:
    if w in words:
        print('No')
        sys.exit()
    words.add(w)
    
    if prev and prev[-1] != w[0]:
        print('No')
        sys.exit()
    prev = w
print('Yes')

Measured memory_bytes: 61912
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

void solve() {
    int N,K;
    cin >> N >> K;
    // vmx[i] i個選んだ時の最大値
    vector<ll> vmx(N+2,0);
    vector<ll> vmn(N+2,0);
    REP(i,N+1) {
        vmx[i+1] = (N-i) + vmx[i];
        vmn[i+1] = i + vmn[i];
    }
    ll sm = 0;
    FOR(i,K,N+2) sm+= (vmx[i]-vmn[i]+1);

    cout << (sm%ll(1e9+7)) << endl;
}

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


Measured memory_bytes: 6384
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <sstream>
#include <string>
#include <vector>

// lib/join.hpp
#ifndef JOIN_HPP
#define JOIN_HPP


namespace tools {
  template <typename Iterator>
  std::string join(const Iterator begin, const Iterator end, const std::string delimiter) {
    std::ostringstream ss;
    std::string current_delimiter = "";
    for (Iterator it = begin; it != end; ++it) {
      ss << current_delimiter << *it;
      current_delimiter = delimiter;
    }
    return ss.str();
  }
}

#endif

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


using i64 = ::std::int_fast64_t;
using u64 = ::std::uint_fast64_t;
using i32 = ::std::int_fast32_t;
using u32 = ::std::uint_fast32_t;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  while (true) {
    i64 n, x;
    std::cin >> n >> x;
    if (n == 0 && x == 0) break;

    std::vector<i64> dp2(x + 1);
    for (i64 i = 0; i <= x; ++i) {
      dp2[i] = (1 <= i - 2 && i - 2 <= n - 1 ? 1 : 0) + (0 <= i - 2 ? dp2[i - 2] : 0) - (1 <= i - 2 - n && i - 2 - n <= n - 1 ? 1 : 0);
    }

    std::vector<i64> dp3(x + 1);
    for (i64 i = 0; i <= x; ++i) {
      dp3[i] = (0 <= i - 3 ? dp2[i - 3] : 0) - (1 <= i - 3 - n && i - 3 - n <= n - 1 ? 1 : 0) + (0 <= i - 3 ? dp3[i - 3] : 0) - (0 <= i - 3 - n ? dp2[i - 3 - n] : 0) + (1 <= i - 3 - 2 * n && i - 3 - 2 * n <= n - 1 ? 1 : 0);
    }

    std::cout << dp3[x] << std::endl;
  }

  return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x) memset(x,0,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 1
/*------------------------------------------------------------*/
int n,m;
int main(){
	in2(n,m);
	out(n*n-m);
}


































Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, a[N], ans;

int main() {
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    sort(a, a+n); a[n] = 0;
    long long sum = accumulate(a, a+n, 0LL);
    for(int i = n-1; i >= 0; i--) {
        if(sum*2 >= a[i+1]) {
            ans++;
            sum -= a[i];
        }else {
            break;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 640
nk = gets.chomp.split
n = nk[0].to_i
k = nk[1].to_i

sum = 0
1.upto(n) do |i|
    if i >= k
        sum = sum += Rational(1, n)
    else   
      l = (Math.log2(k)-Math.log2(i)).ceil #1/2を何回かければいいか
      t = Rational(1, n) * (Rational(1, 2) ** l)
      sum += t
    end
end

p sum.to_f


Measured memory_bytes: 1916
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		List<Integer> absList = new ArrayList<Integer>();
		
		for (int i=0; i<k; i++) {
			list.add(sc.nextInt());
		}
		Collections.sort(list);
		
		for (int i=0; i<k-1; i++) {
			int a = list.get(i);
			int b = list.get(i + 1);
			absList.add(Math.abs(a - b));
		}
		Collections.sort(absList);
		Collections.reverse(absList);
		
		int count = 0;
		for (int i=n-1; i<absList.size(); i++) {
			count += absList.get(i);
		}
		
		System.out.println(count);
	}
}

Measured memory_bytes: 60448
#include <stdio.h>

int main(void)
{
    int a;
    int b;
    scanf("%d %d", &a, &b);
    if (a >= 9 || b >= 9)
    {
        printf(":(\n");
    }
    else
    {
        printf("Yay!\n");
    }
    return 0;
}


Measured memory_bytes: 128
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var input string
	fmt.Scanln(&input)
	n, _ := strconv.Atoi(input)

ROOT:
	for a := 1; a <= 3500; a++ {
		for b := a; b <= 3500; b++ {
			d := 4*a*b - n*a - n*b
			if d > 0 && n*a*b%d == 0 {
				c := n * a * b / d
				fmt.Println(a, b, c)
				break ROOT
			}
		}
	}

}


Measured memory_bytes: 512
// B - Frog 2
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000

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

	vector<int> h(N+1); for(int i=1; i<=N; i++) cin>>h[i];

	vector<int> dp(N+1);
	for(int n=2; n<=N; n++){
		int m = INF;
		for(int k=1; k<=K; k++){
			if(n<=k) break;
			int d = dp[n-k] + abs(h[n] - h[n-k]);
			if(m>d) m = d;
		}
		dp[n] = m;
	}
	cout<< dp[N] <<endl;
}

Measured memory_bytes: 1024
import math
import  numpy as np

N = int(input())
a = np.array(list(map(int, input().split())))

ans = 0
a_max = max(a)

if a_max==0:alog=1
else:alog = int(math.log2(a_max))+1

for i in range(alog):
    p = pow(2, i)
    cnt = np.count_nonzero((a >> i)& 1 == 1)
    
    ans += cnt * (N - cnt)*(2**i)
print(ans%(10**9+7))


Measured memory_bytes: 48828
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<i64>();
    let k = read::<i64>();
    let mut ans = 1;
    for _ in 0..n {
        if ans < k {
            ans *= 2;
        } else {
            ans += k;
        }
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <stdio.h>
int main(void){
    int N,X,i,L[100],D[101],cnt=0;
    scanf("%d %d",&N,&X);
    D[0]=0;
    for(i=0;i<N;i++){
    scanf("%d",&L[i]);
    D[i+1]=D[i]+L[i];
    }
    for(i=0;i<=N;i++){
        if(D[i]<=X)
        cnt++;
    }
    
    printf("%d",cnt);
    return(0);
}


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

using vi = vector<int>;
using vll = vector<long long>;

constexpr long long mod = 1000000007;

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

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

    int n;
    cin >> n;

    vi a(n);
    rep(i, n) cin >> a[i];
    map<int, int> mp;

    rep(i, n){
        mp[a[i]] = 0;
    }

    rep(i, n){
        mp[a[i]]++;
    }

    int cnt = 0;

    for(auto itr=mp.begin(); itr!=mp.end(); ++itr){
        if(itr->second>=3){
            if(itr->second%2==0){
                itr->second = 2;
            }else{
                itr->second = 1;
            }
        }

        if(itr->second==2){
            cnt++;
        }
    }

    if(cnt%2==0){
        cout << mp.size() << endl;
    }else{
        cout << mp.size() - 1 << endl;
    }

}

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

void fail()
{
  cout << 0 << '\n';
  exit(0);
}

int f(int x)
{
  int res = 0;

  while (x % 2 == 0) {
    x /= 2;
    ++res;
  }

  return res;
}

ll lcm(ll x, ll y)
{
  return x / __gcd(x, y) * y;
}

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

  ll n, m;
  cin >> n >> m;

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

  for (int i = 0; i < n; ++i) {
    if (a[i] & 1) fail();
    a[i] /= 2;
  }

  int d = f(a[0]);
  for (int i = 1; i < n; ++i) if (f(a[i]) != d) fail();

  ll l = 1;
  for (int i = 0; i < n; ++i) l = lcm(l, a[i]);

  ll ans = m / l;
  cout << (ans + 1) / 2 << '\n';

  return (0);
}

Measured memory_bytes: 4372
#include <vector>
#include <algorithm>
#include <set>
#include <iostream>
#include <unordered_set>
using namespace std;

int n, m;
vector<int> cords;

int main() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int x;
        cin >> x;
        cords.push_back(x);
    }
    if (n >= m) {
        cout << 0 << endl;
        return 0;
    }
    sort(cords.begin(), cords.end());
    int ans = cords[cords.size() - 1] - cords[0];
    vector<int> minus;
    for (int i = 1; i < cords.size(); i++) minus.push_back(cords[i] - cords[i - 1]);
    sort(minus.begin(), minus.end());
    for (int i = 1; i < n; i++) ans -= minus[minus.size() - i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; ++i)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define PB push_back
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> Point;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1ll << 60;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

#ifdef WIN32
#define dump(x) cerr << #x << " = " << (x) << "\n"
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n"
#else
#define dump(x)
#define debug(x)
#endif

string str[ 3 ];

void input() {
  for ( int i = 0; i < 3; i++ ) {
    cin >> str[ i ];
    if ( str[ i ] == "0" ) {
      break;
    }
  }
}

void solve() {
  if ( str[ 0 ][ 0 ] == str[ 1 ][ 1 ] && str[ 0 ][ 0 ] == str[ 2 ][ 2 ] && str[ 0 ][ 0 ] != '+' ) {
    cout << str[ 0 ][ 0 ] << "\n";
    return;
  }
  if ( str[ 0 ][ 2 ] == str[ 1 ][ 1 ] && str[ 0 ][ 2 ] == str[ 2 ][ 0 ] && str[ 0 ][ 2 ] != '+' ) {
    cout << str[ 0 ][ 2 ] << "\n";
    return;
  }

  for ( int i = 0; i < 3; i++ ) {
    if ( str[ i ][ 0 ] == str[ i ][ 1 ] && str[ i ][ 0 ] == str[ i ][ 2 ] && str[ i ][ 0 ] != '+' ) {
      cout << str[ i ][ 0 ] << "\n";
      return;
    }
    if ( str[ 0 ][ i ] == str[ 1 ][ i ] && str[ 0 ][ i ] == str[ 2 ][ i ] && str[ 0 ][ i ] != '+' ) {
      cout << str[ 0 ][ i ] << "\n";
      return;
    }
  }
  cout << "NA\n";
}

int main() {
  ios::sync_with_stdio( false );
  cin.tie( 0 );
  while ( true ) {
    input();
    if ( str[ 0 ] == "0" ) {
      break;
    }
#ifdef WIN32
    clock_t stime = clock();
#endif
    solve();
#ifdef WIN32
    clock_t etime = clock();
    cerr << "TIME : " << ( double ) ( etime - stime ) / CLOCKS_PER_SEC << "\n";
#endif
  }
return 0;
}

Measured memory_bytes: 1180
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int main() {
    ll n;
    std::cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        a[i]--;
    }
    ll now = 0;
    for (int i = 0; i < n; i++) {
        now = a[now];
        if(now==1){
            std::cout << i+1 << std::endl;
            return 0;
        }
    }
    std::cout << -1 << std::endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			int H = Integer.parseInt(sc.next());
			int W = Integer.parseInt(sc.next());
			int h = Integer.parseInt(sc.next());
			int w = Integer.parseInt(sc.next());
			int ret = (H - h) * (W - w);
			System.out.println(ret);
		} // Scanner Close
	}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

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

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}

void solve(){
    ll n, m, c, ans = 0;
    cin >> n >> m >> c;
    ll b[m];
    rep(i, m) cin >> b[i];
    rep(i, n)
    {
        ll tt = 0;
        rep(j, m)
        {
            ll x; cin >> x;
            tt += x*b[j];
        }
        if(tt+c > 0) ans++;
    }
    cout << ans;
}
main(){
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
from collections import defaultdict
def find(A,x):
    p = A[x]
    if p == x:
        return x
    a = find(A,p)
    A[x] = a
    return a
 
def union(A, x, y):
#    bx, by = sorted([find(A,x), find(A,y)]) # bx, by = find(A,x), find(A,y)だと無限ループ。
    if find(A,x) > find(A,y):
        bx, by = find(A,y), find(A,x)
    else:
        bx, by = find(A,x), find(A,y)
    A[y] = bx
    A[by] = bx

H, W = map( int, input().split())
S = [ input() for _ in range(H)]
A = [ i for i in range(H*W)]
D = defaultdict( lambda: (0,0))
for i in range(H):
    for j in range(W):
        if i > 0 and H != 1:
            if S[i][j] != S[i-1][j]:
                union(A, i*W+j, (i-1)*W + j)
        if i < H-1 and H != 1:
            if S[i][j] != S[i+1][j]:
                union(A, i*W+j, (i+1)*W + j)
        if j > 0 and W != 1:
            if S[i][j] != S[i][j-1]:
                union( A, i*W+j, i*W + j-1)
        if j < W-1 and W != 1:
            if S[i][j] != S[i][j+1]:
                union( A, i*W+j, i*W+j+1)
for i in range(H):
    for j in range(W):
        a, b = D[ find(A,i*W+j)]
        if S[i][j] == "#":
            D[ find(A,i*W+j)] = (a+1,b)
        else:
            D[ find(A,i*W+j)] = (a,b+1)
ans = 0
for d in D:
    a, b = D[d]
    ans += a*b
print(ans)


Measured memory_bytes: 28524
#include<cstdio>
#include<cstring>
char s[15];
int main(){
    int n,i;
    scanf("%s",s);n=strlen(s);
    if(n&1){
        puts("No");
        return 0;
    }
    for(i=0;i<n;i+=2)if(s[i]!='h'||s[i+1]!='i'){
        puts("No");
        return 0;
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
using namespace std;
vector<int> cond(8,-1), ans(8);
bool valid(int pos){
    bool ret = true;
    for(int i = 0; i < pos; i++){
        ret &= ans[i] != ans[pos];
        ret &= abs(ans[pos]-ans[i]) != pos-i;
    }
    return ret;
}
void dfs(int pos){
    if(pos == 8){
        for(int i = 0; i < 8; i++){
            if(cond[i] != -1 && cond[i] != ans[i])  return;
        }
        // found!
        for(int i = 0; i < 8; i++){
            for(int j = 0; j < 8; j++){
                if(ans[i] == j)    cout << "Q";
                else               cout << ".";
            }
            cout << endl;
        }
        exit(0);
    }
    for(int j = 0; j < 8; j++){
        ans[pos] = j;
        if(!valid(pos))  continue;
        dfs(pos+1);
    }
}
int main(){
    int n;cin >> n;
    while(n-- > 0){
        int i, j;
        cin >> i >> j;
        cond[i] = j;
    }
    dfs(0);
}


Measured memory_bytes: 3104
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int l=s.length();
    if(s[0]==s[l-1])
	{
        if(l%2==0)
		{
            cout<<"First";
            return 0;
        }
        else
		{
            cout<<"Second";
            return 0;
        }
    }
    else{
        if(l%2==0)
		{
            cout<<"Second";
            return 0;
        }
        else
		{
            cout<<"First";
            return 0;
        }
    }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
int N, X, Y;
set<int> xs[200000];
int main(){
  int Lj4PdHRW, i, j, k, res=1000000000;
  rd(X);
  rd(Y);
  rd(N);
  for(i=0;i<Y;i++){
    xs[i].insert(X);
  }
  for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
    rd(i);
    rd(j);
    i--;
    j--;
    xs[j].insert(i);
  }
  i = j = 0;
  for(;;){
    k = *(xs[j].lower_bound(i+1));
    chmin(res, k);
    if(k == i+1){
      break;
    }
    i++;
    if(j+1 == Y){
      break;
    }
    k = *(xs[j+1].lower_bound(i));
    if(k != i){
      j++;
    }
  }
  wt_L(res);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20180730-1

// --- original code ---
// int X, Y, N;
// 
// set<int> xs[2d5];
// 
// {
//   int i, j, k;
//   int res = 1d9;
//   
//   rd(X,Y,N);
//   rep(i,Y) xs[i].insert(X);
//   
//   rep(N){
//     rd(i,j);
//     i--; j--;
//     xs[j].insert(i);
//   }
// 
//   i = j = 0;
//   for(;;){
//     k = *(xs[j].lower_bound(i+1));
//     res <?= k;
//     if(k == i+1) break;
//     i++;
// 
//     if(j+1 == Y) break;
//     k = *(xs[j+1].lower_bound(i));
//     if(k != i) j++;
//   }
// 
//   wt(res);
// }


Measured memory_bytes: 28416
#define ll long long
#define lld long double
#define cn(n)  ll n;cin >> n;
#define tes(t) ll t;cin>>t;while(t--) 
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define al(v) v.begin(), v.end()
#define oset(X) tree<X, null_type, less<X>, rb_tree_tag, tree_order_statistics_node_update>
#define roset(X) tree<X, null_type, greater<X>, rb_tree_tag, tree_order_statistics_node_update>
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7;
const ll MOD2 = 998244353;
const long double PI = 3.141592653589793;
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <functional>
// using namespace __gnu_pbds;
using namespace std;
ll power(ll x, ll y, ll p){ll res = 1;x %= p;while (y > 0){if (y & 1)res = (res * x) % p;y = y >> 1;x = (x * x) % p;}return res;}
ll po(ll base, ll powerRaised){if (powerRaised != 0)return (base * po(base, powerRaised - 1));else return 1;}
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
ll lcm(ll a, ll b){return (a * b) / gcd(a, b);}
int main()
{
//   ios_base::sync_with_stdio(false);
//   cin.tie(NULL);
//   cout.tie(NULL);
// #ifndef ONLINE_JUDGE
//   freopen("input.txt", "r", stdin);
//   freopen("output.txt", "w", stdout);
// #endif //*
  // tes(t)
  // {
  // }
  ll x,y;
  cin>>x>>y;
  ll a=(4*x-y)/2;
  ll b=x-a;
  if(a>=0 && b>=0 && a+b==x && 2*a+4*b==y)
  cout<<"Yes";
  else cout<<"No";
}


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

template<typename T, typename U>
void swapArgs(T& a, U& b) {
	T t = a;
	a = (T)b;
	b = (U)t;
}

int main() {
	int n;
	cin >> n;
	int* a = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int flag = 1;
	int count = 0;
	while (flag) {
		flag = 0;
		for (int i = n-1; i > 0; i--) {
			if (a[i] < a[i - 1]) {
				swapArgs(a[i], a[i - 1]);
				flag = 1;
				count++;
			}
		}
	}
	cout << a[0];
	for (int i = 1; i < n; i++) {
		cout << " " << a[i];
	}
	cout << endl << count << endl;
	delete[] a;
	return 0;
}


Measured memory_bytes: 3092
import sys

N, K, Q = map(int, input().split())
a = list(int(input()) for i in range(Q))

anslst = ['YES'] * N
plst = [0] * N

for i in range(Q):
    plst[a[i] - 1] += 1

for i in range(N):
    if K - (Q - plst[i]) > 0:
        anslst[i] = 'Yes'
    else:
        anslst[i] = 'No'

for i in anslst:
    print(i)

Measured memory_bytes: 9420
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

double d[200000];
double dd[200000];
vector<vector<ll> > vv;

double f(ll p, ll parent){
	double ret = 0.0;
	ll c = 0;
	rep(i,0,vv[p].sz){
		if(vv[p][i] == parent)continue;
		ret += f(vv[p][i], p);
		c++;
	}
	if(c>0)ret = 1. + ret / c;
	return d[p] = ret;
}

void f1(ll p, double a, ll parent){
	double ret = 0.0;
	rep(i,0,vv[p].sz){
		if(vv[p][i] == parent){
			ret += 1. + a;
		}
		else{
			ret += 1. + d[vv[p][i]];
		}
	}
	dd[p] = ret / vv[p].sz;
	rep(i,0,vv[p].sz){
		if(vv[p][i] == parent)continue;
		if(vv[p].sz-1==0){
			f1(vv[p][i], 0.,p);
		}
		else{
			f1(vv[p][i], (ret-d[vv[p][i]]-1.)/(vv[p].sz-1),p);
		}
	}
}

int main() {
	ll n;
	cin>>n;
	vector<vector<ll> > vv_(n,vector<ll>());
	vv = vv_;
	rep(i,0,n-1){
		ll a,b;
		cin>>a>>b;
		a--;b--;
		vv[a].pb(b);
		vv[b].pb(a);
	}
	f(0,-1);
	f1(0,0,-1);
	rep(i,0,n){
		printf("%20.20f\n",dd[i]);
	}
	return 0;
}

Measured memory_bytes: 23552
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   string s,t;
   cin >> s >> t;
   int n = s.length();
   int ans = 0;
   f(i,0,n){
      ans += (s[i] != t[i]);
   }
   cout << ans << '\n';
   return 0;
} 

Measured memory_bytes: 3772
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
//#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();
	int A[300][300];
	bool owari = 0;
	rep(i, N) rep(j, N) A[i][j] = getint();

	ll kotae = 0;
	rep(i, N) {
		rep(j, i) {
			bool B = 1;
			rep(k, N) {
				if (i == k || j == k) continue;
				if (A[i][j] == A[i][k] + A[j][k]) B = 0;
				else if (A[i][j] > A[i][k] + A[j][k]) owari = true;
			}
			if (B) kotae += A[i][j];
		}
		if (owari) {
			printf("-1");
			return 0;
		}
	}

	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)

#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int n;
const int MAX_N = 200000;
ll a[MAX_N];

int main(){
  cin >> n;
  REP(i, n) cin >> a[i];

  deque<ll> deq;
  REP(i, n) {
    if(i % 2 == 0) deq.pb(a[i]);
    else deq.push_front(a[i]);
  }
  if(n % 2 == 0) {
    REP(i, n) {
      cout << deq[i];
      if(i != n - 1) cout << " ";
      else cout << endl;
    }
  } else {
    RREP(i, n) {
      cout << deq[i];
      if(i != 0) cout << " ";
      else cout << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 5504
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    vector<ll> sum(N+1);
    rep(i,N) sum[i+1] = sum[i] + A[i];
    ll ans = LINF;
    repr(i,2,N-1){
        ll k = sum[i]/2;
        int d = lower_bound(sum.begin(),sum.end(),k)-sum.begin();
        ll k2 = (sum[N]+sum[i])/2;
        int d2 = lower_bound(sum.begin(),sum.end(),k2)-sum.begin();
        ll P = -1,Q = -1,R = -1,S = -1;
        rep(j,5)rep(r,5){
            int a = d+j-2;
            if(a >= 1 && a < i){
                P = sum[a];
                Q = sum[i]-sum[a];
            }
            int b = d2+r-2;
            if(b > i && b < N){
                R = sum[b]-sum[i];
                S = sum[N]-sum[b];
            }
            //cout << P << " " << Q << " " << R << " " << S << endl;
            if(P == -1 || Q == -1 || R == -1 || S == -1) continue;
            ans = min(ans,max({P,Q,R,S})-min({P,Q,R,S}));
        }
    }
    cout << ans << endl;
}


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

int n;
string x;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll f(int v) {
  if(v==0) return 0;
  int ppp = __builtin_popcount(v);
  int v2 = v % ppp;
  if(v2==0) return 1;
  else return f(v2) + 1;
}

signed main() {
  cin >> n >> x;
  int pp = 0;
  rep(i, n) if(x[i]=='1') pp++;

  ll mpp=0, mpm=0;

  rep(i, n) {
    if(x[i] == '0') continue;
    mpp += modpow(2, n-1-i, pp+1);
    mpp %= pp+1;
  }
  if(pp==1) {
  }
  else {
    rep(i, n) {
      if(x[i] == '0') continue;
      mpm += modpow(2, n-1-i, pp-1);
      mpm %= pp-1;
    }
  }


  rep(pos, n) {
    char cp = x[pos];
    ll mp;

    if(x[pos] == '1') {
      if(pp==1) {
        cout << 0 << endl;
        continue;
      }
      else {
        mp = mpm - modpow(2, n-1-pos, pp-1);
        if(mp < 0) mp += pp-1;
      }
    }
    else {
      mp = mpp + modpow(2, n-1-pos, pp+1);
      mp %= pp+1;
    }
    cout << f(mp) + 1 << endl;
  }
}


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

int main(){
int D,N;
  cin>>D>>N;
  
  int ans=N;
  if(N==100){ans=101;} // N=100の時、100で1回割り切れてしまう。
                       // そのため、100番目に小さい数は101である
  if(D==0){cout<<ans;}
  else if(D==1){cout<<ans*100;}
  else{cout<<ans*10000;}
  
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a,b) cout << (a) << " " << (b) << endl
#define rt0 return 0;
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


signed main(void) 
{
    string s;
    int n;
    cin >>n >>s;
    rep(i, s.size()) {
        int c = s[i]+(n%26);
        if (c > 'Z') c -= 26;
        printf("%c", c);
    }
   
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int N;
long long X;
vector<long long> L(52, -1);
vector<long long> P(52, -1);
long long length(int n){
    if (n == 0) return 1;
    if (L[n] != -1) return L[n];
    L[n] = 3 + 2 * length(n-1);
    return L[n];
};

long long pat(int n){
    if (n == 0) return 1;
    if (P[n] != -1) return P[n];
    P[n] = 1 + 2 * pat(n-1);
    return P[n];
};

long long count(int n, long long x){
    if (x == 1LL){
      	if (n == 0) return 1;
        return 0LL;
    }
    if (x <= length(n-1) + 1){
        return count(n-1, x-1);
    }
    else if (length(n-1)+2 == x){
        return pat(n-1) + 1;
    }
    else if (2 * length(n-1) + 2 >= x){
        return pat(n-1) + 1 + count(n-1, x - length(n-1) - 2);
    }
    return 2 * pat(n-1) + 1;
}
int main() {
    cin >> N >> X;
    cout << count(N, X) << endl;
}




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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007


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

int main(){
	int n;cin >> n;
	int d,x;cin >> d >> x;
	d--;
	int ans = 0;
	vector<int> v(n);
	REP(i,n){
		int tmp;
		cin >> tmp;
		ans += d / tmp + 1;
	}
	cout << x + ans << endl;
		
	
	return 0;
}


Measured memory_bytes: 256
import sys

#fp = open("input.txt", "r")
fp = sys.stdin

while True:
    req = map(int, fp.readline()[:-1].split(" "))
    if req[0] + req[1] == 0:
        break

    n = req[0]
    k = req[1]

    sum_max = 0
    sum_prev = 0
    num_list = []
    
    for i in xrange(n):
        num = int(fp.readline()[:-1])
        num_list.append(num)
        if k > 0:
            sum_max += num
            k -= 1
            sum_prev = sum_max
            continue
        else:
            sum_tmp = sum_prev + num - num_list.pop(0)
            sum_prev = sum_tmp
            if sum_tmp > sum_max:
                sum_max = sum_tmp

    print sum_max

Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
char mp[100][2001];
int p,c,w,s;
int I,J;

void init(){
  I=J=0;
  memset(mp,'.',sizeof(mp));
  for(int i=0;i<p;i++)mp[i][c*w+(c-1)*s]='\0';
}

int Idx(int a){
  if(!a)return 0;
  return a*(s+w);
}

void write(string str){
  for(int i=0;i<(int)str.size();i++) mp[I][Idx(J)+i]=str[i];
  I++;

  if(I==p&&J>=c-1){
    for(int i=0;i<p;i++) printf("%s\n",mp[i]);
    cout<<"#"<<endl;
    init();
  }
  if(I==p)I=0,J++;

}


//p=tate, c=page , w=moji, s=space
int main(){
  
  while(1){
    cin>>p;
    if(!p)return 0;
    cin>>c>>w>>s;
    
    init();
    string str;
    getline(cin,str);

    while(1){
      getline(cin,str);
      if(str=="?")break;
      if(!str.size()){write("");continue;}

      string a="";
      for(int i=0;i<str.size();i++){
	a+=str[i];
	if((int)a.size()>=w)write(a),a="";
      }
      if(a.size())write(a);
    }
    if(I!=0||J!=0)I=p-1,J=c-1,write("");
    cout<<"?"<<endl;
  }

  return 0;
}

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

#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(void){
    int N , m;
    vector<int> vec;
    int count = 0;

    cin >> N;
    for(int i=0;i<N;i++){
        int x;
        cin >> x;
        vec.push_back(x);
    }
    while(true){
        int check = N;
        for(int i=0;i<N;i++){
            if(vec[i]%2 == 0){
                vec[i] = vec[i]/2;
                count ++;
            }else{
                check = check - 1;
            }
        }          
        if(check == 0) break;
    }
    cout << count << endl;

}

Measured memory_bytes: 384