akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
	int H, W;
	cin >> H >> W;
	string mass[H];
	for(int i = 0; i < H; i++){
		cin >> mass[i];
	}
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			int ans = 0;
			if(mass[i][j] != '#'){
				if(i != 0){
					if(mass[i - 1][j] == '#'){
						ans++;
					}
				}
				if(i != H){
					if(mass[i + 1][j] == '#'){
						ans++;
					}
				}
				if(i != 0 && j != 0){
					if(mass[i - 1][j - 1] == '#'){
						ans++;
					}
				}
				if(i != 0 && j != W){
					if(mass[i - 1][j + 1] == '#'){
						ans++;
					}
				}
				if(j != 0){
					if(mass[i][j - 1] == '#'){
						ans++;
					}
				}
				if(j != W){
					if(mass[i][j + 1] == '#'){
						ans++;
					}
				}
				if(i != H && j != 0){
					if(mass[i + 1][j - 1] == '#'){
						ans++;
					}
				}
				if(i != H && j != W){
					if(mass[i + 1][j + 1] == '#'){
						ans++;
					}
				}
			}
			if(mass[i][j] != '#'){
				cout << ans;
			}else{
				cout << "#";
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mst(a,b) memset((a),(b),sizeof(a))
#define pi acos(-1)
#define pii pair<int,int>
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int MAXN = 1e5 + 10;
const int MAXM = 2e6 + 10;
const ll mod = 1e9 + 7;



int main() {
#ifdef local
    freopen("data.txt","r",stdin);
//    freopen("data.txt","w",stdout);
#endif
    string s;
    cin>>s;
    s[3]='8';
    cout<<s;
    return 0;
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	int n, k; cin >> n >> k;
	int ret = 0;
	for (int i=0; i<n; i++) {
		int h; cin >> h;
		if (h >= k) ret++;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main()
{
    long long int l,i,j,r,c=2019;
    cin>>l>>r;
    if((((r%2019)-(l%2019))!=r-l) || r-l>=2019)
    {
        cout<<0;
    }
    else
    {
        for(i=l;i<r;i++)
        {
            for(j=i+1;j<=r;j++)
            {
                if(((i*j)%2019)<c)
                    c=(i*j)%2019;
            }
        }
        cout<<c;
    }
    return 0;
}


Measured memory_bytes: 256
# include <iostream>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if (a + b < a - b) {
    if (a - b < a * b) {
      cout << a * b << endl;
    } else {
      cout << a - b << endl;
    }
  } else {
    if (a + b < a * b) {
      cout << a * b << endl;
    } else {
      cout << a + b << endl;
    }
  }
  return 0;
}


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

int main(){
    string s,ans="Good";
    cin >> s;
    for(int i=1;i<4;i++){
        if(s[i]==s[i-1]){
            ans="Bad";
            break;
        }else continue;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>

int main(void){
	
	int n; scanf("%d", &n);
	std::vector<int> b;
	for(int i=0; i<n; i++){
		int temp; scanf("%d", &temp);
		b.push_back(temp);
	}
	
	std::vector<int> history;
	while(true){
		bool removed = false;
		std::vector<int> nextb;
		for(int i=b.size()-1; i>=0; i--){
			if(b[i] == i+1){
				for(int j=0; j<b.size(); j++) if(j != i) nextb.push_back(b[j]);
				history.push_back(i);
				removed = true;
				b = nextb;
				break;
			}
		}
		if(!removed) break;
	}
	
	if(b.empty()) for(int i=history.size()-1; i>=0; i--) printf("%d\n", history[i]+1);
	else printf("-1");
	
	return 0;
}

Measured memory_bytes: 256
n, k = gets.to_s.split.map{|t| t.to_i }
a    = gets.to_s.split.map{|t| t.to_i }.sort
f    = gets.to_s.split.map{|t| t.to_i }.sort.reverse

m = []
n.times do |i|
   m << [a[i] * f[i], f[i]]
end

m.sort_by!{|(af, _)| -af }

ans = (0 .. m[0][0]).bsearch do |x|
  
  k_x = 0
  m.each do |(m_i, f_i)|
    break if m_i <= x
    k_x += ( m_i - x + f_i - 1 ) / f_i
  end
  
  k_x <= k
end

puts ans

Measured memory_bytes: 47148
class segmentTreeSum():
    initValue = 0
    dat = []
    lenData = -1

    def __init__(self):
        pass

    def load(self, l):
        # len(l)個よりも大きい2の二乗を得る
        self.lenData = 2 ** (len(l) - 1).bit_length()  # len 5 なら 2^3 = 8
        self.dat = [self.initValue] * (self.lenData * 2)
        # 値のロード
        for i in range(len(l)):
            self.dat[self.lenData - 1 + i] = l[i]
        self.build()

    def build(self):
        for i in range(self.lenData - 2, -1, -1):
            self.dat[i] = self.dat[2 * i + 1] + self.dat[2 * i + 2]

    # 若干無駄なインストラクションあるのでコードレベルでマージしたほうがいいかも
    def addValue(self, i, a):
        nodeId = (self.lenData - 1) + i
        self.dat[nodeId] += a
        self.setValue(i, self.dat[nodeId])

    def setValue(self, i, a):
        """
        set a to list[i]
        """
        #print("setValue: {0}, {1}".format(i, a))
        nodeId = (self.lenData - 1) + i
        #print(" first nodeId: {0}".format(nodeId))
        self.dat[nodeId] = a
        while nodeId != 0:
            nodeId = (nodeId - 1) // 2
            #print(" next nodeId: {0}".format(nodeId))
            self.dat[nodeId] = self.dat[nodeId * 2 + 1] + self.dat[nodeId * 2 + 2]

    def querySub(self, a, b, nodeId, l, r):
        """
        [a,b) 区間の親クエリに対するノードnodeへ[l, r)の探索をデリゲート
        区間については、dataの添え字は0,1,2,3,4としたときに、
        [0,3)なら0,1,2の結果を返す
        """
        # print("querySub: a={0}, b={1}, nodeId={2}, l={3}, r={4}".format(a, b, nodeId, l, r))
        if (r <= a or b <= l):
            return self.initValue
        if a <= l and r <= b:
            return self.dat[nodeId]
        resLeft = self.querySub(a, b, 2 * nodeId + 1, l, (l + r) // 2)
        resRight = self.querySub(a, b, 2 * nodeId + 2, (l + r) // 2, r)
        return resLeft + resRight

    def query(self, a, b):
        return self.querySub(a, b, 0, 0, self.lenData)

initVal = 0
n, q = map(int, input().split())
dat = [initVal] * n
st = segmentTreeSum()
st.load(dat)
st.build()
#print(st.dat)
for _ in range(q):
    # indexの入力が1 originなので注意 (以下で-1しているのはそのため)
    cmd, a, b = map(int, input().split())
    if cmd == 0: # update
        st.addValue(a - 1, b)
    else:
        print(st.query(a - 1 , b + 1 -1))



Measured memory_bytes: 11536
#include<stdio.h>

int main(void){

int a[5];
int k;
int i,j;
int judge=1;
for(i=0;i<5;i++){
scanf("%d",&a[i]);
}
scanf("%d",&k);

for(i=0;i<5;i++){
  for(j=4;j>=0;j--){
    if(a[j]-a[i]>k){
      judge=0;
      break;
    }
    if(a[j]-a[i]>k){
      break;
  }
}
}
if(judge==0){
  printf(":(\n");
}
else{
  printf("Yay!\n");
}
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int R0, W0, C, R;
    cin >> R0 >> W0 >> C >> R;
    if (R0 == 0 && W0 == 0 && C == 0 && R == 0){
      break;
    }
    cout << max((W0 * C - R0 + R - 1) / R, 0) << endl;
  }
}


Measured memory_bytes: 3100
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a,vector<vector<ll>> b,int n){
	int i,j,k,t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k]*b[k][j] % M)%M;
			c[i].push_back(t);
		}
	}
	return c;
}
int main() {
	int a[5], i,k,p,ans=0,ma=0;
	for (i = 0; i < 5; i++)
		cin >> a[i];
	for (i = 0; i < 5; i++) {
		p = a[i] % 10;
		if (p == 0)
			p = 10;
		ma = max(ma, 10-p);
		ans += a[i] + 10 - p;
	}
	ans -= ma;
	cout <<ans << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define L long long

using namespace std;

L n;
char st[200010];
L a[200010];

void go(){
   L i;
   for(i=2;i<n;i++)
   {
      a[i]=a[i-1]^a[i-2]^st[i-1];
   }
   a[n]=a[0];
   a[n+1]=a[1];
   a[n+2]=a[2];
   if(a[n]==a[n-1]^a[n-2]^st[n-1])
      if(a[n+1]==a[n]^a[n-1]^st[n])
      {
         for(i=0;i<n;i++)
         {
            printf("%c",a[i]?'W':'S');
         }
         exit(0);
      }
   /*for(i=0;i<n;i++)
   {
      printf("%c",a[i]?'W':'S');
   }
   puts("");*/
}

int main()
{
   scanf("%lld",&n);
   scanf("%s",st);
   L i;
   for(i=n;i<2*n;i++)
   {
      st[i]=st[i-n]=st[i-n]=='o'?0:1;
   }
   a[0]=a[n]=1;
   go();
   a[1]=a[n+1]=1;
   go();
   a[0]=a[n]=0;
   go();
   a[1]=a[n+1]=0;
   go();
   puts("-1");
}

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


int main() {

    int a, b, c, k;
    cin >> a >> b >> c >> k;
    cout << a + b + c + max({a,b,c}) * ((1 << k) - 1) << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var L = new List<P>[n]; 
            for(int i=0;i<n;i++)
            {
                L[i] = new List<P>();
            }
            for(int i = 0; i < n-1; i++)
            {
                string[] In = Console.ReadLine().Split(' ');
                int u = int.Parse(In[0]);
                int v = int.Parse(In[1]);
                int w = int.Parse(In[2]);
                u--;v--;
                L[u].Add(new P(v, w));
                L[v].Add(new P(u, w));
            }
            int root = -1;
            int max = 0;
            for(int i = 0; i < n; i++)
            {
                if (L[i].Count > max) root = i;
            }
            int[] Color = new int[n];
            Color = Enumerable.Repeat(-1, n).ToArray();
            var q = new Queue<int>();
            Color[root] = 0;
            q.Enqueue(root);
            while (q.Count != 0)
            {
                int t = q.Dequeue();
                foreach(var l in L[t])
                {
                    if (Color[l.ver] != -1) continue;
                    q.Enqueue(l.ver);
                    if (l.dis % 2 == 0) Color[l.ver] = Color[t];
                    else Color[l.ver] = 1 - Color[t];//0->1,1->0反転
                }
            }
            for(int i = 0; i < n; i++)
            {
                Console.WriteLine(Color[i]);
            }
        }
        public struct P
        {
            public int ver;//vertex
            public int dis;
            public P(int ver, int dis)
            {
                this.ver = ver;
                this.dis = dis;
            }
        }
    }
}


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

int main(){
	int n,a,b;cin>>n>>a>>b;
	int ans=0;
	for(int i=1;i<=n;i++){
		int cnt=0;
		int A=i;
		while(A){
			cnt+=A%10;
			A/=10;
		}
		if(a<=cnt&&cnt<=b)ans+=i;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+5;
vector<int> g[maxn];
bool visited[maxn] = {false};
int dist[maxn], cnt[maxn];
void dfs(int v){
    visited[v] = true;
    for(int u : g[v]){
        dist[u] = max(dist[u],dist[v]+1);
        cnt[u]--;
        if(cnt[u] == 0)dfs(u);
    }
}
int main()
{
    int n, m;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        cnt[v]++;
    }
    for(int i=1;i<=n;i++){
        if(!visited[i] && cnt[i] == 0)dfs(i);
    }
    int ans=0;
    for(int i=1;i<=n;i++)ans=max(ans,dist[i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9728
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define B begin()
#define E end()
using namespace std;
int main()
{
    ll n,k; cin>>n>>k;
    vector<ll>v;
    for(ll i=0;i<n;i++)
    {
        ll a; cin>>a; v.pb(a);
    }
    sort(v.B,v.E);
    ll s=0;
    for(ll i=0;i<k;i++) s+=v[i];
    cout<<s;
}


Measured memory_bytes: 3640
D = [
    (1, 5, 2, 3, 0, 4), # 'U'
    (3, 1, 0, 5, 4, 2), # 'R'
    (4, 0, 2, 3, 5, 1), # 'D'
    (2, 1, 5, 0, 4, 3), # 'L'
]

N = int(input())
L = [None]*N
for i in range(N):
    *L[i], = map(int, input().split())

p = (0, 0, 0, 1, 1, 2, 2, 3)
ok = 1
for i in range(N):
    Li = L[i]
    for j in range(i+1, N):
        Lj = L[j]
        for k in range(24):
            if Li == Lj:
                ok = 0
            Lj[:] = (Lj[e] for e in D[p[k%8]])
print("Yes" if ok else "No")



Measured memory_bytes: 5608
import math
a, b, x = map(int, input().split())
t = b/a

l = 0
r = math.pi/2
for i in range(100):
    c = (l+r)/2
    tx = math.tan(c)
    if tx < t:
        d = a**2 * (2*b - a*tx)/2
    else:
        d = a * b * b / (2*tx)
    if d < x:
        r = c
    else:
        l = c
print(math.degrees(r))

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

using namespace std;
int a[10000],x,n;
int main(){
    cin >> n >> x;
    for(int i = 1;i <= n; ++i) cin >> a[i];
    int d = 0,ans = 1;
    for(int i = 2;i <= n+1; ++i){
        d += a[i-1]; 
        if(d <= x) ans++;
        else break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
from bisect import bisect_left, bisect_right
N,M,K=map(int, sys.stdin.readline().split())
A=map(int, sys.stdin.readline().split())
B=map(int, sys.stdin.readline().split())

RUISEKI_A=[0]
RUISEKI_B=[0]
for a in A: RUISEKI_A.append(RUISEKI_A[-1]+a)
for b in B: RUISEKI_B.append(RUISEKI_B[-1]+b)

ans=0
for i in range(N+1):
    nokori=K-RUISEKI_A[i]
    if 0<=nokori:
        ans=max(ans,i+bisect_right(RUISEKI_B,nokori)-1)

print ans

Measured memory_bytes: 131860
N = int(input())
S = input()

L = []
R = []
tmp = set()
for s in S:
    tmp.add(s)
    L.append(tmp.copy())
tmp = set()
for s in S[::-1]:
    tmp.add(s)
    R.append(tmp.copy())
R = R[::-1]

ans = set()

for i in range(1,N-1):
    b = S[i]
    for a in L[i-1]:
        for c in R[i+1]:
            ans.add((a,b,c))

print(len(ans))

Measured memory_bytes: 47988
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
const int  COMMAX = 510000;

long long fac[COMMAX], finv[COMMAX], inv[COMMAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < COMMAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> rank;
  vector<bool> isodd;
  int num;
  UnionFind(int N) : par(N) , rank(N),isodd(N) { //最初は全てが根であるとして初期化
    num = N;
    for(int i = 0; i < N; i++){
      par[i] = i;
      rank[i] = 0;
      isodd[i] = false;
    }
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    if(rank[rx] < rank[ry]){
      par[rx] = ry;  
      isodd[ry] = isodd[rx] ^ isodd[ry];
    }else{
      par[ry] = rx;
      if(rank[rx] == rank[ry])rank[rx]++;
      isodd[rx] = isodd[ry] ^ isodd[rx];
    }
    num--;
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
};
int hako[100100];
int main(){
  int n,m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i,0,n){
    cin >> hako[i];
    uf.isodd[i] = (i+1 == hako[i]);
  }
  rep(i,0,m){
    int a,b;
    cin >> a >> b;
    uf.unite(a-1,b-1);
  }
  int res = 0;
  rep(i,0,n){
    if(uf.same(hako[i]-1,i))res++;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1408
#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 clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

int main() {
	string s;
	cin>>s;
	int flag1 = 0;
	int flag2 = 0;
	rep(i,0,s.sz){
		if(s[i]=='C')flag1 = 1;
		if(s[i]=='F'&&flag1==1)flag2=1;
	}
	if(flag2==1)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); 	
	
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	vector<bool> w(f + 1, false), s(f + 1, false);
	w[0] = s[0] = true;
	for(int i = 0; i <= f; i++) {
		if(w[i]) {
			if(i + a * 100 <= f) w[i + a * 100] = true;
			if(i + b * 100 <= f) w[i + b * 100] = true;
		}
		if(s[i]) {
			if(i + c <= f) s[i + c] = true;
			if(i + d <= f) s[i + d] = true;
		}
	}
	int all = 0, suger = 0;
	double conc = 0;
	for(int i = 0; i <= f; i++) {
		for(int j = 0; j <= f; j++) {
			if(w[i] && s[j]) {
				double total = i + j;
				if(i + j <= f && conc <= 1.0 * j / total && 1.0 * j / (1.0 * i) <= 1.0 * e / (1.0 * 100)) {
					all = total;
					suger = j;
					conc = 1.0 * j / total;
				}
			}
		}
	}
	cout << all << " " << suger << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-10;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    cout<<(n+1)/2<<endl;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fori(i,a,b) for(int i=a,b_=b;i<=b_;++i)
#define ford(i,a,b) for(int i=a,b_=b;i>=b_;--i)
#define forv(i,a) for(auto &i:a)
#define ll long long
#define pb push_back
#define pp pop_back()
#define pii pair<ll,ll>
#define fi first
#define se second
#define Max(a,b) ((a>b)?a:b)
#define Min(a,b) ((a<b)?a:b)
#define ___ << "\n"
#define __ << " " <<
#define _ << " "
using namespace std;

const int N=105,V=100005;
int n,v[N],w[N],W;
ll f[N][V];

int main()
{
    cin >> n >> W;
    int sum=0;
    fori(i,1,n) cin >> w[i] >> v[i], sum+=v[i];

    memset(f,127,sizeof(f));
    ll lim=f[0][0]; f[0][0]=0;
    fori(i,0,n-1) fori(j,0,sum) if(f[i][j]<lim)
    {
        f[i+1][j+v[i+1]]=min(f[i+1][j+v[i+1]], f[i][j]+w[i+1]);
        f[i+1][j]=min(f[i+1][j], f[i][j]);
    }
    while(sum>=0 && f[n][sum]>W) sum--;
    cout << sum;
}



Measured memory_bytes: 82304
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
int n;
int d[200005];
int m;
int t[200005];
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin>>n;
    map<int,int> M;
    for(int i=0;i<n;i++){
        cin>>d[i];
        M[d[i]]++;
    }
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>t[i];
        if(M[t[i]]==0){
            cout<<"NO"<<endl;
            return 0;
        }else{
            M[t[i]]--;
        }
    }
    cout<<"YES"<<endl;
    
}


Measured memory_bytes: 14400
<?php
  fscanf(STDIN,"%d %d %d %d",$x1, $y1, $x2, $y2);
  $x3 = $x2-($y2-$y1);
  $x4 = $x1-($y2-$y1);
  $y3 = $y2+($x2-$x1);
  $y4 = $y1+($x2-$x1);
  echo $x3." ".$y3." ".$x4." ".$y4."\n";

Measured memory_bytes: 4604
N, M, X = map(int,input().split())
lines = [list(map(int,input().split())) for i in range(N)]

#print(lines)

import itertools

result = []
for n in range(1,len(lines)+1):
    for conb in itertools.combinations(lines, n):
        result.append(list(conb)) #タプルをリスト型に変換

candidates = set()
for r in result:
    #print(r)
    tmp = [0 for _ in range(M+1)]
    for line in r:
        for i, l in enumerate(line):
            tmp[i] += l
    #print(r, tmp)#, list(enumerate(r)))
    flag_add = True
    for i in range(M):
        if tmp[1+i] < X:
            flag_add = False
            break
    if flag_add:
        candidates.add(tmp[0])

ans = min(candidates) if len(candidates) != 0 else -1
print(ans)

Measured memory_bytes: 9520
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <stack>
#include <string>
using namespace std;
int main(){
    int A,B;
    int flagA=0;
    int K;
    cin>>A>>B>>K;
    while(K--){
        if(flagA==0){
            if(A%2==0){
            }else{
                A=A-1;
            }
            A=A/2;
            B=B+A;
            flagA=1;
        }else{
            if(B%2==0){
            }else{
                B=B-1;
            }
            B/=2;
            A=A+B;
            flagA=0;
        }

    }
    cout<<A<<" "<<B<<endl;
    
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 100010

ll N, K;

// 今 i 回目で現在地が cur である
ll dfs(int i, int cur) {
    if(i >= N) { return cur; }
    ll cand1 = dfs(i+1, cur * 2);
    ll cand2 = dfs(i+1, cur + K);
    return min(cand1, cand2);
}
signed main()
{
    cin >> N >> K;
    printf("%lld\n", dfs(0, 1));
    return 0;
}


Measured memory_bytes: 256
# include <iostream>
using namespace std;
const int N=56;
struct node
{
	int x,y;
}a[N];
long long s,t;
int n,m;
void work (void)
{
	int i,j,k,u,v,p,w,x,y,z,f;
	for (i=1;i<n;i++)
	for (j=i+1;j<=n;j++)
	{
		if (a[i].x<a[j].x)
		{
			w=a[i].x;
			x=a[j].x;
		}
   else
        {
        	w=a[j].x;
        	x=a[i].x;
        }
        f=0;
        p=0;
        for (k=1;k<=n;k++)
        if (a[k].x>=w&&a[k].x<=x)
        {
        	p++;
        	if (p==m)
        	{
        		f=1;
        		break;
        	}
        }
        if (f==1)
        {
        	for (k=1;k<n;k++)
        	for (u=k+1;u<=n;u++)
        	{
        		if (a[k].y<a[u].y)
				{
					y=a[k].y;
					z=a[u].y;
				}
   		   else
        		{
        			y=a[u].y;
        			z=a[k].y;
        		}
        		t=(long long)(x-w)*(z-y);
        		if (t<s)
        		{
        			f=0;
        			p=0;
        			for (v=1;v<=n;v++)
        			if (a[v].x>=w&&a[v].x<=x&&a[v].y>=y&&a[v].y<=z)
        			{
        				p++;
        				if (p==m)
        				{
        					f=1;
        					break;
        				}
        			}
        			if (f==1)
        			s=t;
        		}
        	}
        }
	}
	cout<<s;
}
int main (void)
{
	int i;
	s=9000000000000000000;
	cin>>n>>m;
	for (i=1;i<=n;i++)
	cin>>a[i].x>>a[i].y;
	work ();
	return 0;
}


Measured memory_bytes: 256
maxn = 2000 * 4 + 3
maxnh = maxn // 2
 
def check(s, t, d):
    for i in range(max(0, d), min(len(s), len(t) + d)):
        if s[i] != '?' and t[i - d] != '?' and s[i] != t[i - d]:
            return False
    return True
 
def ca(s, t):
    res = [True] * maxn
    for i in range(-len(t), len(s) + 1):
        res[i + maxnh] = check(s, t, i)
    return res
 
a, b, c = (input() for _ in range(3))
ans = sum(map(len, (a, b, c)))
ab, bc, ac = ca(a, b), ca(b, c), ca(a, c)
 
for i in range(maxn):
    if not ab[i]:
        continue
    for j in range(maxn):
        if not bc[j]:
            continue
        if (0 <= i + j - maxnh < maxn) and not ac[i + j - maxnh]:
            continue
        ans = min(ans, max(len(a), len(b) + i - maxnh, len(c) + i + j - maxnh * 2) - min(0, i - maxnh, i + j - maxnh * 2))
 
print(ans)

Measured memory_bytes: 55516
def win?(a, i, j, b)
    return false if b.empty?
    return true if a.empty?
    ret = false
    if a.include?(i)
        ret = ! win?(b, i - 1, j, a - [i])
    end
    if !ret && a.include?(j)
        ret = ! win?(b, i, j + 1, a - [j])
    end
    if !ret && !a.include?(i) && !a.include?(j)
        ret = ! win?(b, i, j, a)
    end
    return ret
end
n = gets.to_i
n.times do
    a = gets.split.map(&:to_i)
    puts win?(a, 6, 8, (1..13).to_a - a - [7]) ? 'yes' : 'no'
end


Measured memory_bytes: 8984
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <queue>

#include <unordered_map>
#include <stack>
#include <bitset>
#include <cstdlib>
#include <sstream>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll pow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = pow(N, P/2);
        return t*t;
    }
    return N * pow(N, P-1);
}
ll modpow(ll N, ll P,ll k){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2,k)%k;
        return t*t%k;
    }
    return N * modpow(N, P-1,k)%k;
}
ll modkai(ll n,ll m,ll k){//n*(n-1)*(n-2)*...(m+1)%k
    if(n == m)return 1;
    return modkai(n-1,m,k)*n%k;
}
ll mod_cnb(ll n,ll m,ll k){//nCm%k,kは十分大きい素数
  int m_=modkai(m,0,k);
  return modkai(n,n-m,k)*modpow(m_,k-2,k)%k;
}
ll gcd(ll n,ll m){
    n=abs(n);
    m=abs(m);
    if(n*m==0)return max(n,m);
    ll n_ = max(n,m);
    ll m_ = min(n,m);
    if(n_%m_ == 0)return m_;
    return gcd(m_,n_%m_);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}
int main() {
    ll x;cin>>x;
    ll m=100;
    rep(i,10000000){
        m*=1.01;
        if(m>=x){cout<<i+1<<endl;
        return 0;
        }
    }

}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<28)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long

signed main(){
  int a,b;
  cin>>a>>b;
  if(a<=5) cout<<0<<endl;
  else if(a<=12) cout<<b/2<<endl;
  else cout<<b<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

lint bits(lint x) {
    lint ret = 0;
    while (x % 2 == 0) {
        ret++;
        x >>= 1;
    }
    return ret;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint a, b, c;
    cin >> a >> b >> c;

    if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
        cout << 0 << "\n";
        return 0;
    }
    lint a2 = bits(a), b2 = bits(b), c2 = bits(c);
    if (a == b && b == c && c == a) {
        cout << -1 << "\n";
    } else if (a2 == b2 && b2 == c2 && c2 == a2) {
        cout << a2 + 1 << "\n";
    } else {
        cout << min({a2, b2, c2}) << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  int x = a * b;
  if(x % 2 == 1){
    cout << "Odd" << endl;
  }
  else{
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int s, h, m, input_s;

  scanf("%d", &input_s);
  h = input_s / 3600;
  m = (input_s % 3600) / 60;
  s = (input_s % 3600) % 60;

  printf("%d:%d:%d\n", h, m, s);

  return 0;
}


Measured memory_bytes: 2108
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t  ll;
typedef uint64_t ull;
#define rep(i,n) for (int i = 0; i < (n); i++)

ll d[50];
ll drv[50];
ll n, k, ans, asum, bsum, sum;
int main(void) {
    cin >> n >> k;
    rep(i,n) {
        cin >> d[i];
        drv[i] = d[i];
    }
    reverse(drv, drv+n);

    rep(i,k+1) {
        if (i > n) break;
        rep(j,k+1-i) {
            if (i+j > n) break;
            priority_queue<ll> pq;
            asum = 0;
            rep(l,i) {
                asum += d[l];
                if (d[l] < 0) pq.push(abs(d[l]));
            }
            bsum = 0;
            rep(l,j) {
                bsum += drv[l];
                if (drv[l] < 0) pq.push(abs(drv[l]));
            }
            sum = 0;
            rep(l,k-(i+j)) {
                if (pq.size() == 0) break;
                sum += pq.top();
                pq.pop();
            }
            sum += asum + bsum;
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int n;
  cin>>n;
  
  int a[n];
  
  for(int i=0;i<n;i++)
    cin>>a[i];
  
  int dp[n];
 	
  dp[0] = 0;
  
  for(int i=1;i<n;i++){
   	 dp[i] = dp[i-1]+abs(a[i]-a[i-1]);
     if(i-2>=0)
       dp[i] = min(dp[i],dp[i-2]+abs(a[i-2]-a[i]));
  }
  
  cout<<dp[n-1];
  
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#define rep(i,N) for(int i = 0; i < N;i++)
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;


/* template */
int main (){
 int N;
 vector<int> vec(N);
 cin >> N;
 rep(i,N){
    cin >> vec[i];
 }
 sort(vec.begin(),vec.end());
 reverse(vec.begin(), vec.end());
 
 int a=0, b=0;
 rep(i,N){
   if( i % 2==0){
      a+=vec[i];
   }
   else b+=vec[i];
 }
 cout << a-b <<endl;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

ll H,W,a[50][50];

int main(void){
	cin>>H>>W;
	rep(i,H){
		string s;
		cin>>s;
		rep(j,W)if(s[j]=='#'){
			a[i][j]=-9999;
			if(i<H-1)a[i+1][j]++;
			if(j<W-1)a[i][j+1]++;
			if(i<H-1 && j<W-1)a[i+1][j+1]++;
			if(i<H-1 && j>0)a[i+1][j-1]++;
			if(i>0 && j<W-1)a[i-1][j+1]++;
			if(i>0)a[i-1][j]++;
			if(j>0)a[i][j-1]++;
			if(i>0&&j>0)a[i-1][j-1]++;
		}
	}
	rep(i,H){
		rep(j,W)if(a[i][j]<0){printf("#");}else{printf("%lld",a[i][j]);}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <string>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define ii inline int in
#define bs inline bool scan
ii(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;}
ii() {return in(gcu());}
bs(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
bs(char &c){c=gcu();gcu();return c!=EOF;}
bs(string &s){int c; s = "";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#undef ii
#undef bs
#define pcu putchar_unlocked
#define vo inline void out
template <typename T>
vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
vo(const char *s){while(*s)pcu(*s++);}
vo(char c){pcu(c);}
vo(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail>
vo(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T>
//vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef vo

int main() {
	for (int n = in(); n--;) {
		string s, r;
		set<string> ss;
		scan(s);
		r = s;
		reverse(r.begin(), r.end());
		ss.insert(s);
		ss.insert(r);
		for (int i = 1; i < (int) s.size(); i++) {
			string a = s.substr(0, i), b = r.substr(0, s.size() - i),
				   c = r.substr(s.size() - i), d = s.substr(i);
			for (auto p : vector<pair<string *, string *>>{
				 {&a, &b}, {&c, &d}, {&c, &b}, {&d, &a}, {&b, &a}, {&d, &c}})
				ss.insert(*(p.first) + *(p.second));
		}
		out(ss.size(), '\n');
	}
}


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

int main() {
  int D, N;
  cin >> D >> N;
  
  int ans = 0;
  
  ans = N*pow(100, D);
  if(N == 100) ans = 101*pow(100, D);
  
  cout << ans <<endl;
}

Measured memory_bytes: 384
N,K = map(int,input().split())
S = input()

O = __import__("re").findall(r"(R+|L+)",S)
P = min(len(O)//2,K)
for k in range(len(O)):
    if not(k % 2 and k // 2 < P):
        continue
    O[k] = (lambda OO:("R" if OO[0] == "L" else "L")*len(OO))(O[k])

Sdash = ''.join(O)
happy = lambda i: (lambda j:(0 <= j < N) and (Sdash[i] == Sdash[j]))(i + (-1 if Sdash[i] == "L" else 1))

print(sum(map(happy,range(N))))

Measured memory_bytes: 5236
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(),(a).end()

using namespace std;

int main(int argc, char const *argv[]) {
  int n,s=2;
  scanf("%d",&n);
  while (1) {
    if(s>n){
      printf("%d\n",s/2);
      break;
    }else{
      s*=2;
    }
  }
  return 0;
}


Measured memory_bytes: 256
//by sdfzchy
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL inf=(1ll<<50);
inline LL in()
{
	char ch=getchar();
	LL f=1,tmp=0;
	while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') {tmp=(tmp<<1)+(tmp<<3)+(ch-'0');ch=getchar();}
	return tmp*f;
}

const int N=100010;

int n;
LL C;
LL x[N],v[N],f[N],g[N];
LL ans,ff[N],gg[N];

LL sum[N];
LL sum2[N];
LL A,B;
int main()
{
	n=in();
	C=in();
	for(int i=1;i<=n;i++) x[i]=in(),v[i]=in();
	
	for(int i=1;i<=n;i++) sum[i]=sum[i-1]+v[i];
	for(int i=n;i>=1;i--) sum2[i]=sum2[i+1]+v[i];
	
	for(int i=1;i<=n;i++) f[i]=max(f[i-1],sum[i]-x[i]);
	for(int i=n;i>=1;i--) g[i]=max(g[i+1],sum2[i]-(C-x[i]));
	for(int i=1;i<=n;i++) ff[i]=max(ff[i-1],sum[i]-2ll*x[i]);
	for(int i=n;i>=1;i--) gg[i]=max(gg[i+1],sum2[i]-2ll*(C-x[i]));
	
	for(int i=1;i<=n;i++) ans=max(ans,f[i]+gg[i+1]);
	for(int i=n;i>=1;i--) ans=max(ans,g[i]+ff[i-1]);
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

#define MOD 1000000007

using lli = long long int;
using ulli = unsigned long long int;

#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

lli N, T;
lli buf, big = 0, fin, ans = 0;
int main(){
  cin >> N >> T;
  fin = T;
  for(int l = 0; l < N; l++){
    cin >> buf;
    if(buf <= fin){
      fin = buf + T;
    }else{
      ans += fin - big;
      big = buf;
      fin = buf + T;
    }
    dbug(big);
    dbug(fin);
    dbug(ans);
    dbugln;
  }
  ans += fin - big;
  cout << ans;
  return 0;}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
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; }
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll INF = 1LL<<58;
 
int main(){
    ll N,x;
  	vector<ll> a;
  	cin >> N >> x;
  	ll ans = 0;
  	a.resize(N);
    for(int i = 0; i < N; ++i){
      cin >> a[i];
    }
  	sort(all(a));
  	for(int i = 0; i < N; ++i){
      if(x >= a[i]){       
        if(i == N - 1 && x > a[i]) --ans;
        ++ans;
        x -= a[i];
      }
    }
  	cout << ans << endl;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
node=[1 for _ in range(N+1)] #深さiで、葉にならない頂点の個数node[i]
S=sum(A) #生産しなければならない葉の枚数の合計
ans=1 #深さ0である根は最初にカウントする

#深さiの時点であと何枚の葉が必要か計算しつつ、必要な分だけノードを生産する
#ノードの個数がその時点でのSまで届いたら、あとは各頂点が1つずつノードを生産し、
#各層でA[i]個のノードが生産を止めて葉となる

for i in range(1,N+1): 
    if node[i-1]*2<=S: #葉の生産量はノードの2倍ずつ、ノルマを超えるまでは最速で生産する
        ans+=node[i-1]*2
        node[i]=node[i-1]*2
    elif node[i-1]<=S<node[i-1]*2: #全てのノードが2倍になるとノルマを過ぎてしまう場合はノルマピッタリで止める
        node[i]=S
        ans+=S
    node[i]-=A[i] #葉となるノード数を差し引き、生産に寄与するノード数にして次の層に引き継ぐ
    S-=A[i] #葉になった枚数だけノルマも減らす
    if node[i]<0: #生産が間に合わなかった場合(要求された葉＞生産可能なノード数)はループ停止
        ans=-1
        break

if A[0]>0: #深さ0に葉があったら基本的にアウトだが…
    ans=-1
if N==0 and A[0]==1: #N=0の時だけ、深さ0に葉が1つという状況が許される
    ans=1

print(ans)

Measured memory_bytes: 20140
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

int main() {
  int n, s[200];
  cin >> n;
  int sum = 0;
  for(int i = 0; i < n; i++) {
    cin >> s[i];
    sum += s[i];
  }
  sort(s,s+n);
  
  for(int i = 0; i < n; i++) {
    if(sum % 10 == 0) {
      if(s[i] % 10 != 0) {
        sum -= s[i];
        cout << sum << endl;
        return 0;
      }
    }
    else {
      cout << sum << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}


Measured memory_bytes: 3644
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	int A,B;
	scanf("%d %d",&A,&B);
	if((A>=1)&&(A<=13)&&(B>=1)&&(B<=13))
	{
	
	if(A==B)
	printf("Draw");
	if((A==1)&&(A!=B))
	printf("Alice");
	if((B==1)&&(A!=B))
	printf("Bob");
	 if((A>B)&&(B!=1))
	printf("Alice");
	else if ((B>A)&&(A!=1))
	printf("Bob");
}
	return 0;
}

Measured memory_bytes: 256
//Vector
#include <iostream>
#include <vector>

using namespace std;
vector<long> A;

// pushBack(x) Aの末尾に整数xを挿入する
void pushBack(long x){
  A.push_back(x);
}

//randomAccess(p) A要素apの値を出力する
void randomAccess(long p){
    cout << A[p] << endl;
}

//popBack() Aの末尾の要素を削除する
void popBack(){
  A.pop_back();
}

int main(){
  int q,func;
  long p,x;
  vector<long> A;
  cin >> q;
  // input q times
  for(int i = 0 ; i < q ; i++){
    cin >> func;
    switch (func) {
      case 0: // pushBack(x) Aの末尾に整数xを挿入する
        cin >> x;
        pushBack(x);
        break;
      case 1://randomAccess(p) A要素apの値を出力する
        cin >> p;
        randomAccess(p);
        break;
      case 2: //popBack() Aの末尾の要素を削除する
        popBack();
        break;
    }
  }
  return 0;
}



Measured memory_bytes: 4892
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		long X = sc.nextLong();
		long A = X/500*1000;
		long B = X%500/5*5;
		System.out.println(A+B);
	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <queue>
#include <cstdio>
#include <cstring>

using namespace std;

const int MAXN = 4000;

struct Edge{
    int to, next;
};

Edge Edges[MAXN << 1];
int head[MAXN], cnt, Nx, Ny;

int Mx[MAXN], My[MAXN];
queue<int> Q;
int dx[MAXN], dy[MAXN];
bool vis[MAXN];

bool HopcroftKarpDfs(int u){
    for(int i = head[u]; ~i; i = Edges[i].next){
        int v = Edges[i].to;
        if(!vis[v] && dy[v] == dx[u] + 1){
            vis[v] = true;
            if(!My[v] || HopcroftKarpDfs(My[v])){
                Mx[u] = v, My[v] = u;
                return true;
            }
        }
    }
    return false;
}

int HopcroftKarp(){
    memset(Mx, 0, sizeof(Mx));
    memset(My, 0, sizeof(My));
    int ans = 0;
    while(true){
        bool flag = false;
        while(!Q.empty()) Q.pop();
        memset(dx, 0, sizeof(dx));
        memset(dy, 0, sizeof(dy));
        for(int i = 1; i <= Nx; i++) if(!Mx[i]) Q.push(i);
        while(!Q.empty()){
            int u = Q.front();
            Q.pop();
            for(int i = head[u]; ~i; i = Edges[i].next){
                int v = Edges[i].to;
                if(!dy[v]){
                    dy[v] = dx[u] + 1;
                    if(My[v]){
                        dx[My[v]] = dy[v] + 1;
                        Q.push(My[v]);
                    }else flag = true;
                }
            }
        }
        if(!flag) break;
        memset(vis, false, sizeof(vis));
        for(int i = 1; i <= Nx; i++) if(!Mx[i] && HopcroftKarpDfs(i)) ans++;
    }
    return ans;
}

int a[MAXN], b[MAXN], c[MAXN], d[MAXN];

int main()
{
    int N;

    cin >> N;

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

    for (int i = 1; i <= N; i++) {
        cin >> c[i] >> d[i];
    }

    memset(head, -1, sizeof(head));
    cnt = 0;

    for (int i = 1; i <= N; i++) {
        for (int j = N + 1; j <= (N << 1); j++) {
            if (a[i] < c[j - N] && b[i] < d[j - N]) {
                Edges[cnt].to = i, Edges[cnt].next = head[j], head[j] = cnt++;
                Edges[cnt].to = j, Edges[cnt].next = head[i], head[i] = cnt++;
            }
        }
    }

    Nx = Ny = (N << 1);
    int ans = HopcroftKarp();

    cout << ans / 2;

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cstdio>

using namespace std;

int main(){
	int sen[10000];
	int bit[1024];
	int num[1024],s;
	for(int i=0;i<1024;i++)
		for(num[i]=0,s=i;s>0;s >>= 1)num[i]+=s&1;
	
  int r,c,cc;
  while(true){
		scanf("%d %d",&r,&c);
		if (!r&&!c)break;
		for(int i=0;i<c;i++) sen[i] = 0;
		
		for(int j=0;j<r;j++){
			for(int i=0;i<c;i++){
				scanf("%d",&cc);
				sen[i] <<= 1;
				sen[i] += cc;
			}
		}
		for(int i=0;i<1024;i++) bit[i] = 0;
		for(int i=0;i<c;i++) bit[sen[i]]++;

		int n,sum = 0,smax = 0,k=1,l;
		k <<= r-1;
		for(int i=0;i<k;i++){
			sum = 0;
			for(int j=0;j<1024;j++){
				if(bit[j]){
					s = j^i;
					sum += max(num[s],r-num[s]) * bit[j];
				}
			}
			if (sum>smax)smax = sum;
		}
		printf("%d\n",smax);
  }
  return 0;
}

Measured memory_bytes: 928
N = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0

for i in range(N):
    s = input().strip()
    if s == "AC":
        AC += 1
    if s == "WA":
        WA += 1
    if s == "TLE":
        TLE += 1
    if s == "RE":
        RE += 1

print("AC x " + str(AC))
print("WA x " + str(WA))
print("TLE x " + str(TLE))
print("RE x " + str(RE))


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

int main(){
  int N;
  int i;
  int count = 1;
  
  cin >> N;
  vector<int> mochi(N);
  for(i=0;i<N;++i){
    cin >> mochi.at(i);
  }

  sort(mochi.begin(),mochi.end());
  for(i=1;i<N;++i){
    if(mochi.at(i) != mochi.at(i-1)){
      count += 1;
    }
  }

  cout << count <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = int_fast64_t;
#define REP(i,b,e) for(ll i=b; i<e; i++)

int main(){
	std::string s;
	std::cin >> s;
	int n = s.size();

	for(char alp='a'; alp<='z'; alp++){
	    int min = 0, cnt = (s[n-1]==alp? 1:-1), r = n;
	    for(int i=n-2; i>=0; i--){
		int pre = cnt;
		if(s[i]==alp) cnt++;
		else cnt--;
		if(cnt-min>0){
		    printf("%d %d\n", i+1, r);
		    return 0;
		}
		if(pre<min){
		    r = i+1;
		    min = pre;
		}
	    }
	}
	puts("-1 -1");
	return 0;
}



Measured memory_bytes: 3772
n = int(input())

anser = 0

if n > 200:
    anser += 100
else:
    anser += 900

if n % 100 > 20:
    anser += 10
else:
    anser += 90
    
if n % 10 > 2:
    anser += 1
else:
    anser += 9

print(anser)

Measured memory_bytes: 2940
N,M,Q=list(map(int,input().split()))
t=[list(map(int,input().split())) for _ in range(M)]
query=[list(map(int,input().split())) for _ in range(Q)]

train=[[0]*(N+1) for _ in range(N+1)]
c=[[0]*(N+1) for _ in range(N+1)]

for l,r in t:
    train[l][r]+=1

for l in range(1,N+1):
    for r in range(1,N+1):
        c[l][r]=c[l][r-1]+train[l][r]

for p,q in query:
    tmp=0
    for l in range(p,q+1):
        tmp+=c[l][q]-c[l][p-1]
    
    print(tmp)

Measured memory_bytes: 117688
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;

typedef long long ll;



int main() {
    ll N,A,B;
    cin >> N >> A >> B;
    string S;
    cin >> S;

    ll count=0,bc=0;
    for(ll i=0;i<N;i++){
        if(S[i] == 'a'){
            if(count < A+B){
                count++;
                cout << "Yes" << endl;
            }else{
                cout << "No" << endl;
            }
            
        }else if(S[i] == 'b'){
            bc++;
            if(count < A+B && bc <= B){
                count++;
                cout << "Yes" << endl; 
            }else{
                cout << "No" << endl;
            }
        }else{
            cout << "No" << endl;
        }
    }

}

Measured memory_bytes: 896
#include <iostream>

using namespace std;

int main()
{
    string s1, s2;
    int n1, n2;
    cin >> s1 >> s2 >> n1 >> n2;
    string s;
    cin >> s;
    if (s1 == s)
    {
        cout << n1 - 1 << ' ' << n2 << endl;
    }
    else
    {
        cout << n1 << ' ' << n2 - 1 << endl;
    }
}

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

int main(void) {
	long long a, b, d,ans = 0;
	scanf("%lld %lld %lld", &a, &b, &d);
	ans = (b / d) - (a / d);
	if (a % d == 0)ans++;

	printf("%lld\n", ans);
}

Measured memory_bytes: 128