akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;
 
int N;
int V[21],C[21];
int nv[21];
int ans;
signed main(){
    cin>>N;
    rep(i,N)cin>>V[i];
    rep(i,N)cin>>C[i];
    rep(i,N)nv[i]=V[i]-C[i];
    rep(i,N){
        if(nv[i]>0){
            ans+=nv[i];
        }
    }
    cout<<ans<<endl;



    
 
}

Measured memory_bytes: 256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,m=INTM()
    alist=[]
    for i in range(n):
        ka=LIST()
        ka.pop(0)
        ka=set(ka)
        alist.append(ka)
    for i in range(n-1):
        alist[n-1]=alist[n-1]&alist[i]
    print(len(alist[n-1]))
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class CAverage
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var points = new List<Point>();

            for (int i = 0; i < n; i++)
            {
                var s = Console.ReadLine().Split(' ');
                points.Add(new Point(int.Parse(s[0]), int.Parse(s[1])));
            }

            List<double> allDistances = CreateAllDistances(points);

            // 2点の場合
            // ・2通り(2!)の経路
            // ・移動回数は1(2-1)回
            // ・移動パターンの全出現回数は2(2*1)回
            // ・移動パターンの各出現回数は1(2/2)回

            // 3点の場合
            // ・6(3!)通りの経路
            // ・移動回数は2(3-1)回
            // ・移動パターンの全出現回数は12(6*2)回
            // ・移動パターンの各出現回数は4(12/3)回

            int rootPattern = Factorial(points.Count);
            int moveCount = n - 1;
            int movePatternAllCount = rootPattern * moveCount;

            Console.WriteLine(CalcAvg(allDistances, rootPattern, movePatternAllCount));            
            //Console.ReadLine();
        }

        static List<double> CreateAllDistances(List<Point> points)
        {
            var allDistance = new List<double>();

            for (int i = 0; i < points.Count; i++)
            {
                for (int j = 0; j < points.Count; j++)
                {
                    if (j <= i)
                    {
                        continue;
                    }

                    allDistance.Add(CalcDistance(points[i], points[j]));
                }
            }

            return allDistance;
        }

        static double CalcAvg(List<double> allDistances, int rootPattern, int movePatternAllCount)
        {
            double distance = 0;
            int addCount = 0;
            while (addCount < movePatternAllCount)
            {
                foreach (var item in allDistances)
                {
                    distance += item;
                    addCount++;
                }
            }
            return distance / rootPattern;
        }

        static int Factorial(int n)
        {
            if (n == 0)
                return 1;
            return n * Factorial(n - 1);
        }

        static double CalcDistance(Point p1, Point p2)
        {
            return Math.Sqrt(Math.Pow(p1.X - p2.X, 2) + Math.Pow(p1.Y - p2.Y, 2));
        }
    }

    public class Point
    {
        public int X;
        public int Y;
        public Point(int x, int y)
        {
            this.X = x;
            this.Y = y;
        }
    }
}

Measured memory_bytes: 13268
# http://d.hatena.ne.jp/tomomii+programming/20100614/p2
# chompってつけることでcで標準出力する時に改行しないようにしてくれるので後ろに文字列を連結できる
c = STDIN.gets.chomp

puts ["a","i","u","e","o"].find{|i| i == c} != nil ? "vowel" : "consonant"


# c = STDIN.gets.chomp
# puts ["a", "i", "u", "e", "o"].find{|i| i == c} != nil ? "vowel" : "consonant"

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using vi = vector<ll>;
using vv = vector<vi>;
//const int MOD = 1000000007;
//const int MOD = 998244353;
const ll INF = 1001001001001001001;

int main(){
    ll n,k;
    cin>>n>>k;
    
    vi p(n), c(n);
    
    rep(i,n){
        cin>>p[i];p[i]--;
    }
    rep(i,n)cin>>c[i];
    
    vv gain(n, vi (n+1, 0));
    vi loop(n, 0);//ループしたとき得るコスト
    vi length(n,1);
    
    for(int i=0; i<n; i++){
        
        int j = i;
        
        while(1){
            gain[i][length[i]] = gain[i][length[i]-1] + c[p[j]];
            j = p[j];
            if(j==i)break;
            length[i]++;
        }
        
        loop[i] = gain[i][length[i]];
    }
    
    
    ll ans = -INF;
    
    rep(i,n){
        for(int j=1; j<=length[i] && j<=k; j++){
            ans=max(ans, gain[i][j]);
        }
        
        if(loop[i]>0){
            for(int j=0; j<length[i]; j++){
                if(j>k%length[i]){
                    ans = max(ans, loop[i]*(k/length[i]-1) + gain[i][j]);
                }
                else
                    ans = max(ans, loop[i]*(k/length[i]) + gain[i][j]);
            }
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 199288
S = input()

num = len(S)
half = num // 2

if num % 2 == 0:
    mae = S[:half]
    ushiro = S[half:]
else:
    mae = S[:half]
    ushiro = S[half+1:]

cnt = 0
for i in range(half):
    j = (half-1) - i
    if mae[i] != ushiro[j]:
        cnt += 1

print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define INF 800000000
#define MAX 1000

int main(){
  int A,B,Q;
  cin>>A>>B>>Q;
  vector<ll> s(A),t(B),x(Q);
  for(int i=0;i<A;i++){
    cin>>s.at(i);
  }
  for(int i=0;i<B;i++){
    cin>>t.at(i);
  }
  for(int i=0;i<Q;i++){
    cin>>x.at(i);
  }
  for(int i=0;i<Q;i++){
    int k1=lower_bound(s.begin(),s.end(),x.at(i))-s.begin();
    int k2=lower_bound(t.begin(),t.end(),x.at(i))-t.begin();
    ll ans=20000000000;
    if(k1==0&&k2==0){
      ans=min<ll>(ans,max<ll>(s.at(k1)-x.at(i),t.at(k2)-x.at(i)));
    }else if(k1==0){
      if(k2!=B){
        ans=min<ll>(ans,max<ll>(s.at(k1)-x.at(i),t.at(k2)-x.at(i)));
      }
      ans=min<ll>(ans,s.at(k1)-x.at(i)+2*(x.at(i)-t.at(k2-1)));
      ans=min<ll>(ans,2*(s.at(k1)-x.at(i))+x.at(i)-t.at(k2-1));
    }else if(k2==0){
      if(k1!=A){
        ans=min<ll>(ans,max<ll>(s.at(k1)-x.at(i),t.at(k2)-x.at(i)));
      }
      ans=min<ll>(ans,x.at(i)-s.at(k1-1)+2*(t.at(k2)-x.at(i)));
      ans=min<ll>(ans,2*(x.at(i)-s.at(k1-1))+t.at(k2)-x.at(i));
    }else if(k1==A&&k2==B){
      ans=min<ll>(ans,max<ll>(x.at(i)-s.at(k1-1),x.at(i)-t.at(k2-1)));
    }else if(k1==A){
      ans=min<ll>(ans,max<ll>(x.at(i)-s.at(k1-1),x.at(i)-t.at(k2-1)));
      ans=min<ll>(ans,x.at(i)-s.at(k1-1)+2*(t.at(k2)-x.at(i)));
      ans=min<ll>(ans,2*(x.at(i)-s.at(k1-1))+t.at(k2)-x.at(i));
    }else if(k2==B){
      ans=min<ll>(ans,max<ll>(x.at(i)-s.at(k1-1),x.at(i)-t.at(k2-1)));
      ans=min<ll>(ans,s.at(k1)-x.at(i)+2*(x.at(i)-t.at(k2-1)));
      ans=min<ll>(ans,2*(s.at(k1)-x.at(i))+x.at(i)-t.at(k2-1));
    }else{
      ans=min<ll>(ans,max(s.at(k1)-x.at(i),t.at(k2)-x.at(i)));
      ans=min<ll>(ans,max(x.at(i)-s.at(k1-1),x.at(i)-t.at(k2-1)));
      ans=min<ll>(ans,x.at(i)-s.at(k1-1)+2*(t.at(k2)-x.at(i)));
      ans=min<ll>(ans,2*(x.at(i)-s.at(k1-1))+t.at(k2)-x.at(i));
      ans=min<ll>(ans,s.at(k1)-x.at(i)+2*(x.at(i)-t.at(k2-1)));
      ans=min<ll>(ans,2*(s.at(k1)-x.at(i))+x.at(i)-t.at(k2-1));
    }
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define m_p			make_pair
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define sz(x)       (int)x.size()
#define f			first
#define debug		cout<<"##########3"<<endl
#define mod			1000000007
#define ll			long long int
#define lMax		LLONG_MAX
// queue<int> , prefix_sum(a,a+n) , reverse(a,a+n) , priority_queue <int> max heap , priority_queue <int, vector<int>, greater<int> > min heap;
// == precedence gretaer then &
// Experiment of Code EoC !!
ll n,m;
long double ph[3005];
long double dp[3000][3005];//say
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);

    ll i,j,k,c=0,t,z,x=0,y;
    long double ans = 0.0;
	cin>>n;//N W

	rep(i,0,n)
		cin>>ph[i];
	dp[0][0] = 1.0;
	dp[1][1] = ph[0];
	dp[1][0] = 1-ph[0];
	for(i=2;i<=n;i++){
		for(j=0;j<=i;j++){
			dp[i][j] = dp[i-1][j]*(1-ph[i-1]);
			if(j>0)
				dp[i][j] += dp[i-1][j-1]*ph[i-1];
		//	cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
		}
	}
	for(i=n/2+1;i<=n;i++)
		ans += dp[n][i];
	cout<<setprecision(12)<<ans;
 	return 0;
}

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

using ll=long long;

int main(){
    ll N,Q,L,R;
    cin>>N>>Q>>L>>R;

    vector<ll> A(N);
    for(int i=0;i<N;i++) cin>>A[i];
    sort(A.begin(),A.end());
    vector<int> q(Q);
    vector<ll> x(Q),s(Q),t(Q);
    for(int i=0;i<Q;i++) cin>>q[i]>>x[i]>>s[i]>>t[i];

    int lb=-1,ub=N;
    while(ub-lb>1){
        int mid=(lb+ub)/2;
        ll v = A[mid];

        for(int i=0;i<Q;i++){
            if(q[i]==1){
                if(v>=x[i]) v=(v+s[i])*t[i];
            }
            else{
                if(v<=x[i]) v=(v-s[i])/t[i];
            }
        }

        if(v<L) lb=mid;
        else ub=mid;
    } 
    int lid=ub;

    lb=-1,ub=N;
    while(ub-lb>1){
        int mid=(lb+ub)/2;
        ll v = A[mid];

        for(int i=0;i<Q;i++){
            if(q[i]==1){
                if(v>=x[i]) v=(v+s[i])*t[i];
            }
            else{
                if(v<=x[i]) v=(v-s[i])/t[i];
            }
        }

        if(v>R) ub=mid;
        else lb=mid;
    }
    
    int rid=ub;
    cout<<max(0,rid-lid)<<endl;
    
    return 0;
}


Measured memory_bytes: 9640
#include<bits/stdc++.h>
using namespace std;
int len;
char s[100005];
int main()
{
    cin>>s;
    len=strlen(s);
    if(s[0]==s[len-1])
	{
        if(len%2==0)
            printf("First\n");
        else
            printf("Second\n");
    }
    else
	{
        if(len%2==0)
            printf("Second\n");
        else
            printf("First\n");
    }
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
int main(){
	int x,y;
	while (true){
		std::cin >> x>>y;
		if (x == 0 && y == 0){
			break;
		}
		else if (x <= y){
			std::cout << x << " " << y << "\n";
		}
		else if (y < x){
			std::cout << y << " " << x << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>
#include<utility>

using namespace std;

int main() {
  int k;
  cin >> k;
  vector<long long> a(k);
  for(int i = 0; i < k; i++) cin >> a[i];
  long long minDP[k + 1];
  long long maxDP[k + 1];
  minDP[0] = 2;
  maxDP[0] = 2;
  for(int i = 0; i < k; i++) {
    if(maxDP[i] < a[k - 1 - i]) {
      cout << -1 << endl;
      return 0;
    }
    minDP[i + 1] = max((minDP[i] + a[k - 1 - i] - 1) / a[k - 1 - i] * a[k - 1 - i], a[k - 1 - i]);
    maxDP[i + 1] = maxDP[i] / a[k - 1 - i] * a[k - 1 - i] + a[k - 1 - i] - 1;
    if(minDP[i + 1] > maxDP[i + 1]) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << minDP[k] << " " << maxDP[k] << endl;
  return 0;
}


Measured memory_bytes: 2560
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
typedef long long LL;
typedef long double Lf;
#define in (void)scanf
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
//#define Rep(i,a,n)for(LL i=(LL)(a);i<(LL)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Repp(i,l,r,k)for(int i=(int)(l);i<(int)(r);i+=(int)(k))
//#define Repp(i,l,r,k)for(LL i=(LL)(l);i<(LL)(r);i+=(LL)(k))
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define MOD 1000000007//998244353,1000000007,1000000009,4999999999999997
int upi(const void* a, const void* b) { return*(int*)a<*(int*)b ? -1 : *(int*)a> * (int*)b ? 1 : 0; }
int downi(const void* a, const void* b) { return*(int*)a<*(int*)b ? 1 : *(int*)a> * (int*)b ? -1 : 0; }
void sortupi(int* a, int n) { qsort(a, n, sizeof(int), upi); } //1,2,3,4,...
void sortdowni(int* a, int n) { qsort(a, n, sizeof(int), downi); }
int upLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? -1 : *(LL*)a> * (LL*)b ? 1 : 0; }
int downLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? 1 : *(LL*)a> * (LL*)b ? -1 : 0; }
void sortupLL(LL* a, int n) { qsort(a, n, sizeof(LL), upLL); }
void sortdownLL(LL* a, int n) { qsort(a, n, sizeof(LL), downLL); }
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; } // a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); } // aaa,aab
LL gcd(LL p, LL q) { while (q) { LL t = p % q; p = q; q = t; }return p; }
LL modpow(LL a,LL n,LL m){LL x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invmodpow(b,p)modpow(b,p-2,p)// a/b≡a*b^{-1}(mod p)...return b^{-1}(mod p)
//typedef struct fac { LL n, exp; }F;
//LL fact(LL n,F*a){LL x=n,i,j,c=0;for(i=2;i*i<=x;i++){for(j=1;x%i==0;j++)x/=i;if(j>1){a[c].n=i;a[c++].exp=j-1;}}if(x-1){a[c].n=x;a[c++].exp=1;}return c;}
LL nibtan(LL* a,LL n,LL x){LL p=0,q=n/2,r=n-1;while(r-p>1){if(x>=a[q])p=q;if(x<=a[q])r=q;q=(p+r)/2;}return a[p]==x?p:r;}
//snippet

#define N 2009

void run(void) {
	LL s, ans = 0;
	in("%lld", &s);
	if (s > 2) {
		LL factorial[N] = { 1 };
		Rep(i, 1, N)factorial[i] = factorial[i - 1] * i % MOD;
		Rep(n, 1, 1 + s / 3) {
			ans += ((factorial[s - 2 * n - 1] % MOD * invmodpow(factorial[n - 1], MOD)) % MOD) * invmodpow(factorial[s - 3 * n], MOD) % MOD;
			ans %= MOD;
		}
	}
	printf("%lld\n", ans);
}

int main(void) {
	int test = 1;
//	in("%d", &test);
	while (test--) {
		run();
		fflush(stdout);
	}
	return 0;
}

Measured memory_bytes: 1744
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14 100兆
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  ll N, M, X;
  cin >> N >> M >> X;
  vector<ll> C(N);
  vector<vector<ll>> A(N, vector<ll>(M));
  rep(i, N){
    cin >> C.at(i);
    rep(j, M){
      cin >> A.at(i).at(j);
    }
  }
  ll ans = INF;
  rep(i, 1<<12){
    vector<ll> U(M, 0);
    ll money = 0;
    bitset<12> s(i);
    rep(j, N){
      if(s.test(j)){
        money += C.at(j);
        rep(k, M){
          U.at(k) += A.at(j).at(k);
        }
      }
    }
    bool dame = false;
    rep(j, M){
      if(U.at(j) < X){
        dame = true;
        break;
      }
    }
    if(dame){
      continue;
    }
    chmin(ans, money);
  }
  if(ans == INF){
    cout << -1 << endl;
  }
  else{
    cout << ans << endl;
  }
}

Measured memory_bytes: 3632
<?php
	list($n,$m) =  explode(" ",trim(fgets(STDIN)));
	$left = array();
	$right = array();
	
	
	
	for($i=0; $i<$m; $i++) {
		fscanf(STDIN,"%d %d",$x,$y);
		$left[$i] = $x;
		$right[$i] = $y;
	}
	
	$ans = min($right) - max($left) + 1;
	
	if ($ans < 0) {
		echo 0;
	} else {
		echo $ans;
	}
?>



Measured memory_bytes: 14840
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <cmath>

using namespace std;

template<class T>
class Input {
public:
    auto operator()() const {
        T v;
        cin >> v;
        return v;
    }
};

template<class L, class R>
class Input<pair<L, R>> {
public:
    auto operator()() const {
        L l;
        R r;
        cin >> l >> r;
        return make_pair(l, r);
    }
};

template<class U>
class Input<vector<U>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        return (*this)(n);
    }
    auto operator()(size_t n) const {
        vector<U> v;
        v.reserve(n);
        Input<U> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in();
            v.emplace_back(move(u));
        }
        return v;
    }
};

template<class U>
class Input<vector<vector<U>>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        auto m = in();
        return (*this)(n, m);
    }
    auto operator()(size_t n, size_t m) const {
        vector<vector<U>> v;
        v.reserve(n);
        Input<vector<U>> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in(m);
            v.emplace_back(move(u));
        }
        return v;
    }
};

class InputType
{
public:
    template<class T>
    operator T() const {
        Input<T> i{};
        return i();
    }
};

auto input() {
    return InputType();
}

size_t bitcount(size_t n) {
    size_t c = 0;
    while (n) {
        if (n & 1ull)
            ++c;
        n >>= 1;
    }
    return c;
}

using ll = long long;
using ull = unsigned long long;

int main() {
    size_t n = input();
    size_t k = input();
    vector<size_t> a(n, 0);
    a.reserve(n);
    for (size_t i = 0; i < n; ++i)
        a[i] = input();
    size_t money = numeric_limits<size_t>::max();
    for (size_t i = 0; i < (1ull << (n - 1)); ++i) {
        auto bit = (i << 1ull) | 1ull;
        size_t count = bitcount(bit);
        if (count < k)
            continue;
        size_t prev = a[0];
        size_t m = 0;
        for (size_t j = 1; j < n; ++j) {
            if (bit & (1ull << j)) {
                if (a[j] <= prev) {
                    m += prev - a[j] + 1;
                    ++prev;
                }
            }
            prev = max(prev, a[j]);
        }
        money = min(money, m);
    }
    cout << money << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import numpy as np
import collections

def solve(N: int, S: "List[str]"):
    ans = collections.Counter(S)
    for a in ['AC', 'WA', 'TLE', 'RE']:
        print("{} x {}".format(a, ans[a]))
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)

if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const int INF = 1e9;

int main(void){

	int X, Y, Z; cin >> X >> Y >> Z;
	printf("%d %d %d\n", Z, X, Y);

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define SORTR(v,n) sort(v, v+n, greater<int>());
#define SORTPairSecond(v, n) sort(v, v+n, pairCompareSecond);
// #define int long long    // %d=>%lld
#define pb push_back
#define INF 1000000007
#define llINF 1e17
#define EPS 1e-9
#define pi acos(-1)

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> piii;
typedef pair<ll, pll> plll;
bool pairCompareSecond(const pii& firstEl, const pii& secondEl) {
    return firstEl.second > secondEl.second;
}

int a,b,c;



signed main(){
    cin >> a >> b >> c;

    if(c>=a && c<=b)
        cout<< "Yes\n";
    else {
        cout<< "No\n";
    }

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstdlib>
#include<utility>

typedef long long ll;
#define INF 1000000000
#define MOD 1000000007

using namespace std;

ll dp[100001][3];

int main() {
	ll n;
	int ac[100001][3];
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
		    cin >> ac[i][j];
		}
	}

	ll ans = 0;
	for (int i = 0; i < n; i++) {
		dp[i + 1][0] = ac[i][0] + max(dp[i][1], dp[i][2]);
		dp[i + 1][1] = ac[i][1] + max(dp[i][0], dp[i][2]);
		dp[i + 1][2] = ac[i][2] + max(dp[i][0], dp[i][1]);
		ans = max(dp[i + 1][0], max(dp[i + 1][1], dp[i + 1][2]));
	}
	cout << ans << endl;
}


Measured memory_bytes: 3712
#include <stdio.h>

int main(){
  int train[10];
  int num, i = 0;
  while(scanf("%d", &num) != EOF){
    if(num == 0){
      i--;
      printf("%d\n", train[i]);
    }else if(1 <= num && num <= 10){
      train[i] = num;
      i++;
    }
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {

  long long A;
  double B;
  cin>>A>>B;
  
  long long x=(long long)(B*100+0.0001);
  cout<<A*x/100<<endl;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long long unsigned int ull;
#define INF 1LL << 29

int main() {
	string t, b;
	cin >> t;
	b = "ABC";
	vector<vector<ll> > dp(t.size() + 1, vector<ll>(b.size() + 1, 0));//dp[i][j] 後ろからi番目にj個選んだ時の場合の数
	dp[t.size()][b.size()] = 1;
	for (int i = t.size() - 1; i >= 0; i--)for (int j = b.size(); j >= 0; j--) {
		if(t[i] == '?')dp[i][j] += dp[i + 1][j] * 3;
		else dp[i][j] += dp[i + 1][j];
		if (j != b.size() && (t[i] == '?' || t[i] == b[j]))dp[i][j] += dp[i + 1][j + 1];
		if (dp[i][j] > 1000000007)dp[i][j] %= 1000000007;
	}
	cout << dp[0][0] << endl;
	return 0;
}

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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 100000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

ll GCD(ll a,ll b){
    if(a < b)return GCD(b,a);
    ll r = INF;
    while(r){
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}

int main(){
   int N,K = 0,A;
   cin >> N;
   map<int,int> mp;
   for(int i = 0;i < N;i++){
       cin >> A;
       if(mp[A] == 0){
           K++;
       }
       mp[A]++;
   }
   if(K % 2 == 1){
       cout << K << endl;
   }else{
       cout << K - 1 << endl;
   }
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
using namespace std;
int main(void)
{
	int i, n, flag=1, count=0;

	cin>>n;

	vector<int> a(n);

	for(i=0; i<n; i++){
		cin>>a[i];
	}

	while(flag){
		flag=1;
		for(i=0; i<n; i++){
			if(a[i]%2){
				flag=0; break;
			}else{
				a[i]=a[i]>>1;
			}
		}
		if(!flag){
			break;
		}else{
			count++;
		}
	}
	cout<<count<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>

using namespace std;

struct Node{
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k){
	Node *y = NIL;
	Node *x = root;
	Node *z;
	
	z = (Node*)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	
	while (x != NIL) {
		y = x;
		if (z->key < x->key) {
			x = x->left;
		}else {
			x = x->right;
		}
	}
	
	z->parent = y;
	if (y == NIL) {
		root = z;
	}else {
		if (z->key < y->key) {
			y->left = z;
		}else {
			y->right = z;
		}
	}
}

void inOrder(Node* u){
	if (u == NIL) {
		return;
	}
	inOrder(u->left);
	printf(" %d", u->key);
	inOrder(u->right);
}

void preOrder(Node* u)
{
	if (u == NIL) {
		return;
	}
	printf(" %d", u->key);
	preOrder(u->left);
	preOrder(u->right);
}

Node* find(Node* root, int k)
{
	while (root != NIL && root->key != k) {
		if (k < root->key) {
			root = root->left;
		}else {
			root = root->right;
		}
	}
	return root;
}

Node* treeMin(Node* x){
	while (x->left != NIL) {
		x = x->left;
	}
	return x;
}

Node* treeSuccessor(Node* x)
{
	if (x->right != NIL) {
		return treeMin(x->right);
	}
	Node* y = x->parent;
//	while (y != NIL && x == y->right) {
//		x = y;
//		y = y->parent;
//	}
	return y;
}

void deleteNode(Node* z)
{
	Node *y, *x;

	if (z->left == NIL|| z->right == NIL) {
		y = z;
	}else {
		y = treeSuccessor(z);
	}
	
	if (y->left != NIL) {
		x = y->left;
	}else {
		x = y->right;
	}
	
	if (x != NIL) {
		x->parent = y->parent;
	}
	
	if (y->parent == NIL) {
		root = x;
	}else {
		if (y == y->parent->left) {
			y->parent->left = x;
		}else {
			y->parent->right = x;
		}
	}
	
	if (y != z) {
		z->key = y->key;
	}
	
	free(y);
}

int main(int argc, char *argv[]) {
	int n, i, x;
	string com;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++) {
		cin >> com;
		if (com == "insert") {
			scanf("%d", &x);
			insert(x);
		}else if (com == "print") {
			inOrder(root);
			printf("\n");
			preOrder(root);
			printf("\n");
		}else if (com == "find") {
			scanf("%d", &x);
			Node *t = find(root, x);
			if (t != NIL) {
				printf("yes\n");
			}else {
				printf("no\n");
			}
		}else if (com == "delete") {
			scanf("%d", &x);
			deleteNode(find(root, x));
		}
	}
	return 0;
}


Measured memory_bytes: 21936
import sys
input = sys.stdin.readline
N = int(input())
a = []
D = 0
S = 0
for _ in range(N):
  d, c = list(map(int, input().split()))
  a.append((d, c))
for i in range(N):
  d, c = a[i]
  D += c
  S += d * c
print(D - 1 + (S - 1) // 9)

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;



int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A(N), B(M), C(M);;
  vector<pair<int, int>> p(M);
  priority_queue<int, vector<int>, greater<int>> pq;
  ll ans = 0;

  REP(i, N){
    cin >> A[i];
    pq.push(A[i]);
    ans += A[i];
  }
  REP(i, M){
    cin >> B[i] >> C[i];
    p[i] = make_pair(C[i], B[i]);
  }
  sort(p.begin(), p.end());
  int cnt = 0;
  for(int i = 0; (i < M )&& (cnt <= N); ++i){
    REP(j, p[M-1-i].second){
      int x = pq.top();
      if(x < p[M-1-i].first){
        pq.pop();
        pq.push(p[M-1-i].first);
        ans = ans - x + p[M-1-i].first;
        cnt++;
      }
      else{
        break;
      }
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 2812
#include<bits/stdc++.h>
#define SC scanf
using namespace std;

long long n,ans,tong[100001];
bool vis[100001];

int main()
{
	SC("%lld",&n);
	for(long long i = 1; i <= n; i++)
	{
		SC("%lld",&tong[i]);
		if(!tong[i]) vis[i] = true;
		ans += tong[i]/2;
		tong[i] %= 2;
	}
	for(long long i = 1; i <= n; i++)
		if(tong[i])
		{
			if(tong[i-1] && i!=1)
			{
				tong[i]--;
				tong[i-1]--;
				ans++;
			}
		}
		else if(tong[i-1] && i!=1 && !vis[i])
		{
			tong[i-1] = 0;
			tong[i] = 1;
		}

	printf("%lld",ans);
}

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

int main(){
  int A, B, C, X;
  cin >> A;	//500
  cin >> B;	//100
  cin >> C; //50
  cin >> X;
  
  int sum, combination_count = 0;
  for (int i = 0; i < A+1; i++){
    for (int j = 0; j < B+1; j++){
      for(int k = 0; k < C+1; k++){
        sum = 500 * i + 100 * j + 50 * k;
        if (sum == X)	combination_count++;
      }
    }
  }
  
  cout << combination_count << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <list>
#include <bitset>
#include <array>

using namespace std;

#define fi first	
#define se second
#define long long long
typedef pair<int,int> ii;

const long BIG = 4e18;

int n;
long X;
long A[400003];
long pref[400003];
long RSQ(int a, int b)
{
	return (a > 0)? pref[b]-pref[a-1] : pref[b];
}
long sum(long a, long b)
{
	if(BIG-b < a) return BIG;
	else return a+b;
}
long mul(long a, long b)
{
	if(BIG/b < a) return BIG;
	else return a*b;
}
long f(long i)
{
	if(i == 1) return 5;
	else return 2*i+1;
}

int main()
{
	// ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);

	scanf("%d %lld", &n, &X);
	for(int i = 1; i <= n; i++)
		scanf("%lld", &A[i]);
	
	for(int i = 1; i <= 400000; i++)
		pref[i] = pref[i-1]+A[i];

	long res = BIG;
	for(int i = 1; i <= n; i++)
	{
		long cnt = i*X;
		long idx = n;
		long no = 1;
		while(idx > 0)
		{
			cnt = sum(RSQ(idx-i+1,idx)*f(no),cnt);
			idx -= i;
			no++;
		}
		// printf("%d %lld\n", i, cnt);
		res = min(res,cnt);
	}
	printf("%lld\n", sum(res,n*X));
}











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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	char c;
	int r=0,b=0;
	while(cin>>c){
		if(c=='0')++r;
		else ++b;
	}
	cout<<min(r,b)*2<<"\n"s;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define R(i,n) for(int i=0;i<n;i++)
int n,a=1e9,c[2][20],p[1<<18][51];main(){cin>>n;R(i,n)cin>>c[0][i];R(i,n)cin>>c[1][i];fill(p[0],p[1<<n],1e9);p[0][0]=0;R(B,1<<n){int o=0,d[n];R(i,n)if(!(B&1<<i))d[i]=o++;R(i,n){int k=c[abs(i-n+o)%2][i];R(j,k+1)p[B|1<<i][k]=min(p[B|1<<i][k],p[B][j]+d[i]);}}R(i,51)a=min(a,p[(1<<n)-1][i]);cout<<(a>1e8?-1:a);}

Measured memory_bytes: 52480
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        int positionCount = 5;
        long N = sc.nextLong();
        long minLimit = sc.nextLong();
        while (positionCount-- > 1) {
            minLimit = Math.min(minLimit, sc.nextLong());
        }
        
        long answer = (long)Math.ceil((double)N / minLimit) + 4;
        System.out.println(answer);
    }
}

Measured memory_bytes: 21716
#include<stdio.h>
int main()
{
    int A,B;

    scanf("%d %d", &A , &B);

    if(A>=1 && A<=13 && B>=1 && B<=13)
    {
        if(A==B)
        printf("Draw\n");
        else if (A==1)
        printf("Alice\n");
        else if(B == 1)
            printf("Bob\n");
        else if(A>B)
        printf("Alice\n");
        else if(A<B)
        printf("Bob\n");
    }
    else
            return;

}


Measured memory_bytes: 128
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a1: u32,
    }

    let sum: u32 = a1 + a1 * a1 + a1 * a1 * a1;

    println!("{}", sum)
}


Measured memory_bytes: 2112
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
const int N=110;
int dp[N][10010],v[N],w[N];
int n,W;
int solve(int i,int j){
    if(dp[i][j]>=0) return dp[i][j];
    int res;
    if(i==n) res=0;
    else if(j<w[i]) res=solve(i+1,j);
    else res=max(solve(i+1,j),solve(i+1,j-w[i])+v[i]);
    return dp[i][j]=res;
}
int main(){
    cin>>n>>W;
    for(int i=0;i<n;i++){
        cin>>v[i]>>w[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<solve(0,W)<<endl;
    return 0;
}

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

bool compare(ll a, ll b){
    return a>b;
}

int main(){
    ll N; cin>>N;
    ll array[N];
    for(int i=0; i<N; ++i) cin>>array[i];
    sort(array, array+N, compare);
    ll ans = 0;
    deque<int> que;
    que.push_back(array[0]);
    for(int i=1; i<N; ++i){
        ans = ans + que.front();
        que.pop_front();
        que.push_back(array[i]);
        que.push_back(array[i]);
    }
    cout<<ans<<endl;
}

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

int main(){
    int S, a[4];
    cin >> S;
    a[0] = S/1000;
    a[1] = (S/100) % 10;
    a[2] = (S/10) % 10;
    a[3] = S % 10; 
    if(a[0] == a[1]){
        cout << "Bad" << endl;
        return 0;
    }else{
        if(a[1] == a[2]){
            cout << "Bad" << endl;
            return 0;
        }else{
            if(a[2] == a[3]){
                cout << "Bad" << endl;
                return 0;
            }
        }
    }
    cout << "Good" << endl;
    return 0;
}

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

void insertionSort(vector<int> A, int N);

int main(void){
    int N;
    cin >> N;
    
    vector<int> A(N);
    for (int i=0; i<N; i++) {
        cin >> A.at(i);
    }
    
    insertionSort(A, N);
    
}

void insertionSort(vector<int> A, int N) {
    for (int i=0; i<N; i++) {
        int value = A.at(i);
        int j = i-1;
        
        while (j >= 0 && A.at(j) > value) {
            A.at(j+1) = A.at(j);
            j--;
        }
        A.at(j+1) = value;
        
        for (int k=0; k<N; k++) {
            cout << A.at(k) ;
            if (k != N-1) {
                cout << ' ';
            } else {
                cout << endl;
            }
        }
        
    }
}




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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int a, b, c;
    cin >> a >> b >> c;

    if(a+b>=c) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define PI 3.1415926535

int main(void)
{

    int n;
    cin >> n;
    int a[n] = {};
    map<int, int> m;
    set<int> num;
    rep(i, n)
    {
        cin >> a[i];
        m[a[i]]++; //mapに、出てきた数字の個数を記録
        num.insert(a[i]);
    }

    //ｎ個の中から同じものを2つ取り出す場合の数を求める
    ll cnt = 0;
    auto itr = num.begin();
    while (itr != num.end())
    {
        //数字が2つ以上ある時
        if (m[*itr] >= 2)
        {
            cnt += (ll)m[*itr] * (m[*itr] - 1) / 2;
        }
        itr++;
    }

    rep(i, n)
    {
        ll ans = cnt;
        if (m[a[i]] >= 2)
            ans -= m[a[i]]-1;

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 16000
N = int(input()) # 地点の候補数
T, A = map(int, input().split()) # T:平均気温 A:温度
H = list(map(int, input().split())) #標高(x)

list = [abs(A-(T - i * 0.006)) for i in H]

print(list.index(min(list))+1)


Measured memory_bytes: 3060
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;


LL f(string N,int K){
	LL s=N.size();
	if(K==0){
		return 1;
	}
	if(s==0){
		return 0;
	}
	LL ret=0;
	for(int i=0;i<=N[0]-'0';i++){
		if(i==N[0]-'0'){
			if(i==0){
				ret+=f(N.substr(1),K);
			}
			else{
				ret+=f(N.substr(1),K-1);
			}
		}
		else if(i==0){
			if(K==1){
				ret+=9*(s-1);
			}
			else if(K==2){
				ret+=9*9*(s-1)*(s-2)/2;
			}
			else{
				ret+=9*9*9*(s-1)*(s-2)*(s-3)/6;
			}
		}
		else if(K==1){
			ret+=1;
		}
		else if(K==2){
			ret+=9*(s-1);
		}
		else{
			ret+=9*9*(s-1)*(s-2)/2;
		}
	}
	return ret;
}


int main(){
	string N;
	int K;
	cin >> N >> K;
	cout << f(N,K) << endl;

    return 0;
}


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

int main()
{
    std::string s;
    std::cin >> s;
    std::reverse(s.begin(), s.end());

    std::vector<long long> reminders(13, 0);
    reminders[0] = 1;

    int pos = 1;
    const int mod = 1000000007;
    for (auto c : s) {
        std::vector<long long> new_reminders(13, 0);
        if (c == '?') {
            for (int i = 0; i < 10; i++) {
                for (int j = 0; j < 13; j++) {
                    new_reminders[(i * pos + j) % 13] += reminders[j];
                    new_reminders[(i * pos + j) % 13] %= mod;
                }
            }
        } else {
            int i = c - '0';
            for (int j = 0; j < 13; j++) {
                new_reminders[(i * pos + j) % 13] += reminders[j];
                new_reminders[(i * pos + j) % 13] %= mod;
            }
        }
        pos *= 10;
        pos %= 13;
        reminders = new_reminders;
    }

    std::cout << reminders[5] << std::endl;
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = sc.next().split("");
		String[] a  = new String[2 * s.length - 1];
		for (int i = 0; i < a.length; i += 2)
			a[i] = s[i / 2];
		int d = s.length - 1;
		long ans = 0;
		for (int i = 0; i < (1<<d); i++) {
			for (int j = d - 1, k = 0; j >= 0; j--, k++) {
				if (((i>>j) & 1) == 1)
					a[2 * k + 1] = "+";
				else
					a[2 * k + 1] = " ";
			}
			long c = 0;
			for (int j = 0; j < a.length; j++) {
				if (a[j].equals(" ")) continue;
				if (a[j].equals("+")) {
					ans += c;
					c = 0;
				}
				else {
					c = c * 10 + Integer.parseInt(a[j]);
				}
			}
			ans += c;
		}
		System.out.println(ans);
	}
}

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

const int N = 100010;

int book[N];
int n;
long long cnt;

int main() {
	scanf("%d",&n);
	for(int i = 1;i <= n;i++) {
		scanf("%d",&book[i]);
	}
	for(int i = 1;i <= n;i++) {
		cnt += (book[i] / 2);
		book[i] %= 2;
		if(book[i] && book[i + 1] && i < n) {
			cnt++;
			book[i]--;
			book[i + 1]--;
		}
	}
	printf("%lld\n",cnt);
}

Measured memory_bytes: 640
n,y = map(int,input().split())
for i in range(n+1):
    for j in range(n+1):
        if 10000*i+5000*j+(n-i-j)*1000 == y and n-i-j >= 0:
            print(i,j,n-i-j)
            exit()
print(-1,-1,-1)

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    ll ans = 1;
    for(ll i=1; i<=N; i++){
        ans *= i;
        ans = ans % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,a[100005];
set<int>zan;
vector<int>ans;
bool solve_small(int pre = 0){
	vector<int>vec;
	for(auto a:zan) vec.pb(a);
	SORT(vec);
	do{
		if(a[pre] == vec[0]) continue;
		int bad = 0;
		for(int i=1;i<vec.size();i++){
			if(a[vec[i-1]] == vec[i]) bad=1;
		}
		if(bad) continue;
		rep(i,ans.size()) cout << ans[i] << '\n';
		rep(i,vec.size()) cout << vec[i] << '\n';
		return 1;
		fail:;
	}while(next_permutation(vec.begin(),vec.end()));
	return 0;
}
set<P>S;
int in[100005];
bool make(int i,int pre){
	if(i == n-4){
		if(solve_small(pre)) return true;
		else return false;
	}
	vector<int>vi;
	for(auto z:zan){
		vi.pb(z);
		if(vi.size() == 3) break;
	}
	while(S.size() && zan.find((*S.begin()).sc) == zan.end()) S.erase(S.begin());
	P p = (*S.begin());
	vi.pb(p.sc);
	int aa = p.fi;
	int must = 0;
	if(-aa == n+1-i){
		must = 1;
	}
	rep(ii,vi.size()){
		if(a[pre] == vi[ii]) continue;
		if(must && vi[ii] != p.sc) continue;
		ans.pb(vi[ii]);
		zan.erase(zan.find(vi[ii]));
		S.erase(S.find(mp(-in[vi[ii]],vi[ii])));
		in[vi[ii]]--;
		S.insert(mp(-in[vi[ii]],vi[ii]));
		if(make(i+1,vi[ii])){
			return true;
		}
		S.erase(S.find(mp(-in[vi[ii]],vi[ii])));
		in[vi[ii]]++;
		S.insert(mp(-in[vi[ii]],vi[ii]));
		ans.pop_back();
		zan.insert(vi[ii]);
	}
	return false;
}
int main(){
	cin >> n;
	repn(i,n){
		cin >> a[i];
		in[a[i]]++;
		zan.insert(i);
	}
	repn(i,n) S.insert(mp(-in[i],i));
	bool flag;
	if(n <= 8){
		flag = solve_small();
	}
	else{
		flag = make(1,0);
	}
	if(!flag) puts("-1");
}


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

using namespace std;

int main()
{
    string s;
    cin >> s;

    if(s[0] != 'A'){
        cout << "WA" << endl;
        return 0;
    }

    bool existC = false;
    int indexC = 0;
    for(int i = 2; i < s.size() -1; ++i){
        if(s[i] == 'C' ){
            if(!existC){
                existC = true;
                indexC = i; 
            }else{
                existC = false;
                break;
            }
        }

    }

    if(!existC){
        cout << "WA" << endl;
        return 0;
    }

    for(int i = 1; i < s.size(); ++i){
        if((s[i] > 'z' || s[i] < 'a') && i != indexC){
            cout << "WA" << endl;
            return 0;
        }
    }
     
    cout << "AC" << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

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

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int m1, d1, m2, d2;
	cin >> m1 >> d1 >> m2 >> d2;
	if (d2 == 1) cout << 1 << endl;
	else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
def matches(pattern, text):
    for i in range(len(text)-len(pattern), -1, -1):
        good = True
        for j in range(len(pattern)):
            if not text[i+j] in ['?', pattern[j]]:
                good = False
        if good:
            return i
    return -1

Sprime = input()
T = input()

match = matches(T, Sprime)
if match == -1:
    print('UNRESTORABLE')
else:
    print((Sprime[:match]+T+Sprime[match+len(T):]).replace('?','a'))

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

int main(){
	int n;
	cin >>n;
	string s[n];
	int t[n];
	rep(i,n){
		cin >> s[i]>>t[i];
	}
	string x;
	cin >> x;
	bool ok=0;
	int ans=0;
	rep(i,n){
		if(ok){
			ans+=t[i];
		}
		if(s[i]==x){
			ok=1;
		}
		
	}
	cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 998244353
using namespace std;
long long calc1(string &s);
map<string,long long> M1;
map<string,long long> M2;
long long calc2(string &s){
     //cout << "calc2" << " " << s << endl;
   long long ans=0;

    string what="";
    if(s.size()==1 && s[0]=='0') return 1;
    else if(s.size()==1) return 2;
   // cout << s << endl;
    if(M2.find(s)!=M2.end()) return M2[s];
    for(int i=2;i<=s.size();++i){
        int u=s.size();
        if(u%i) continue;
        what="";
        int part=u/i;
        int j=0;
        for(;j<part;++j) what+=s[j];
        while(j<s.size()){
            if(s[j]=='1' && what[(j%part)]=='1'){

            }
            else{
                what[(j%part)]='0';
            }
            ++j;
        }
        ans=(ans+calc1(what))%MOD;


    }
    return M2[s]=ans;

}
long long calc1(string &s){
    //cout << "calc1" << " " << s << endl;
    long long temp[100];
    
    if(s.size()==1 && s[0]=='0') return 1;
    else if(s.size()==1) return 2;
    if(M1.find(s)!=M1.end()) return M1[s];
    for(int i=0;i<=s.size();++i){
        temp[i]=0;
    }
    temp[0]=1;
    if(s[0]=='1') temp[1]=2;
    else temp[1]=1;
    for(int i=1;i<s.size();++i){
        for(int j=i;j>=0;--j){
            string what=s.substr(j,i-j+1);

            temp[i+1]=(temp[i+1]+temp[j]*calc2(what))%MOD;
           // cout << temp[i+1] << endl;
        }
    }
    return M1[s]=temp[s.size()];
}

int main(){
    string s;
    cin >> s;
    cout << calc1(s) << endl;
    return 0;
}


Measured memory_bytes: 8704