akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unordered_map> 
using namespace std; 
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI1 3.14159265358979311599796346854418516159057617187500
 
typedef long long int ll;  

long double power(long double a , ll n)
{
    ll result=1.0;
    long double x=a;
    while(n>0)
    {
        if(n % 2 ==1)
            result = (result * x);
        x = (x * x);
        n=n/2;
    }
    return result;
}
 
int main() 
{ 
    FIO
    int t;
    t=1;
 
    while(t--)
    {
        ll x;
        cin >> x;

        ll till_now = 100;
        for(int i=1;i<=1000000;i++)
        {
            if(till_now>=x)
            {
                cout << i-1 << endl;
                return 0;
            }

            ll in1 = till_now*(1.01);
            till_now = in1;
        }

    }
 
    return 0; 
} 

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int, int> mii;
typedef set<int> si;
//---------------------------------------------------------------------------------------------------

int main(void){
    // Your code here!
    string A,B,C; cin >> A >> B >> C;
    queue<char> Sa,Sb,Sc;
    rep(i,A.size()) Sa.push(A[i]);
    rep(i,B.size()) Sb.push(B[i]);
    rep(i,C.size()) Sc.push(C[i]);
    char now ;
    rep(i,A.size()+B.size()+C.size()+2) {
        if (now == 'a' && Sa.empty()){
            cout << 'A' << endl;
            return 0;
        }
        if (now == 'b' &&Sb.empty()){
            cout << 'B' << endl;
            return 0;
        }
        if (now == 'c' &&Sc.empty()){
            cout << 'C' << endl;
            return 0;
        }
        if (i == 0) {
            now = 'a';
            continue;
        }
        if (now == 'a') {
            now = Sa.front();
            Sa.pop();
            continue;
        }
        if (now == 'b') {
            now = Sb.front();
            Sb.pop();
            continue;
        }
        if (now == 'c') {
            now = Sc.front();
            Sc.pop();
            continue;
        }
    }
}


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

using namespace std;

int main(){
 	int h1,h2,m1,m2,k;
 	cin>>h1>>m1>>h2>>m2>>k;
  	int minutes;
  	if(m1>m2){
     	minutes = m2+60-m1;
      	minutes += (h2-1-h1)*60;
    }else{
      minutes = m2-m1;
      minutes += (h2-h1)*60;
    }
  cout<<minutes-k<<endl;
  return 0;
  
}


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

l = list(map(int, input().split()))

cnt=0
maxcnt=0

#print(l[0])

for i in range(0,n):
    if(l[i]==1):
        cnt=cnt+1
        if(cnt>maxcnt):
            maxcnt=cnt
            #print(maxcnt)
    else:
        cnt=0
print(maxcnt+1)


Measured memory_bytes: 5596
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String c = sc.next();
		boolean jdg =true;
		for(int i =  c.length()-1;i >=2;i-=1) {
			if(i%2==1)continue;
			for(int k = 0;k < i/2;k++) {
				if(c.charAt(k) != c.charAt(k+(i/2))) {
					jdg = false;
					break;
				}
			}
			if(jdg == true) {
				System.out.println(i);
				break;
			}
			jdg = true;
		}
	}

}

Measured memory_bytes: 21972
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

a,b,c,k=mii()


ans=0

for i,abc in [[a,"a"],[b,"b"],[c,"c"]]:
    if k<i:
        if abc=="a":
            ans+=k
            k=0
        elif abc=="b":
            ans+=0
            k=0
        else:
            ans-=k
            k=0
    else:
        if abc=="a":
            ans+=a
            k-=a
        elif abc=="b":
            ans+=0
            k-=b
        else:
            ans-=c
            k-=c
    if k==0:
        print(ans)
        exit()
print(ans)

Measured memory_bytes: 77160
N, K = map(int, input().split(' '))
S = list(input())
if S[K-1] == 'A':
    S[K-1] = 'a'
elif S[K-1] == 'B':
    S[K-1] = 'b'
else:
    S[K-1] = 'c'
print(''.join(S))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#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++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;


int main(){
 int N;
  cin >>N;
  if (N%1000 == 0){
    cout <<0<<endl;
  }else{
  cout << 1000-(N%1000)<<endl;
  }
}

Measured memory_bytes: 3628
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
 
        //Nから繰り返し7を引き、4で割れる数を探す。
        for(int i = 0; i < N; i++){
            if((N - i * 7) >= 0 && ((N - i * 7) % 4) == 0){
                System.out.println("Yes");
                N = -1;
                break;
            };
        }
        if(N != -1){
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26836
n,m=map(int,input().split())
li=[0]*(n+1)
cn=[0]*(n+1)
ac=wa=0
for _ in range(m):
  x,y=input().split()
  x=int(x)
  if y=="AC":
    if li[x]!=1:
      li[x]=1
      ac+=1
      wa+=cn[x]
  else:
    cn[x]+=1
print(ac,wa)
      

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//end



int main(){
   string s; cin>>s;
   deque<char> deq; bool rev=0;
   rep(i,0,s.size())deq.push_back(s[i]);
   int q; scanf("%d",&q);
   rep(i,0,q){
      int t; scanf("%d",&t);
      if(t==1)rev^=1;
      else{
         int f; char c; cin>>f>>c; f--;
         if(f^rev)deq.push_back(c);
         else deq.push_front(c);
      }
   }
   if(rev)reverse(ALL(deq));
   rep(i,0,deq.size())cout<<deq[i]; puts("");
   return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

const int N = 3030;
const int mod = 1000000007;

int p[N];

int zeros(int l, int r) {
	return p[r] - p[l];
}

char s[N];
int l[N], r[N];
int c[N][N];
int dp[N][N];

void test() {
	int n,m;
	scanf("%d %d %s", &n, &m, s);
	FOR(i,m) {
		scanf("%d%d", &l[i], &r[i]);
		l[i]--;
		if (i>0 && r[i]<r[i-1]) {
			r[i] = r[i-1];
		}
	}
	l[m] = r[m] = n;
	FOR(i,n) p[i+1] = p[i] + (s[i]=='0');
	FOR(i,n+1) FOR(j,i+1) {
		if (i==0 || i==j) c[i][j] = 1;
		else {
			c[i][j] = c[i-1][j] + c[i-1][j-1];
			if (c[i][j] >= mod) c[i][j] -= mod;
		}
	}
	FOR(z,n+1) dp[m][z] = 1;
	for (int i=m-1; i>=0; i--) {
		if (r[i] > l[i+1]) { // overlap
			int d = l[i+1] - l[i];
			FOR(z,n+1) {
				for (int zz = 0; zz <= d; zz++) {
					if (zz>z) break;
					if (d-zz > r[i]-l[i]-z) continue;
					dp[i][z] += 1LL * c[d][zz] * dp[i+1][z-zz+zeros(r[i], r[i+1])] % mod;
					if (dp[i][z] >= mod) dp[i][z] -= mod;
				}
			}
		} else { // no overlap
			FOR(z,n+1) {
				dp[i][z] = 1LL * c[r[i]-l[i]][z] * dp[i+1][zeros(l[i+1], r[i+1])] % mod;
				if (dp[i][z] >= mod) dp[i][z] -= mod;
			}
		}
	}
	printf("%d\n", dp[0][zeros(l[0], r[0])]);
}

int main() {
	int ttn=1;
	//scanf("%d", &ttn);
	while (ttn--) test();
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N,0);
  vector<int> solution(N,0);
  for (int i=0; i<N;i++) {
    cin >> vec[i];
  }

  int counter=0;
  int j=0;
  for (int i=N-1; i>=0; i--) {
    counter=0;
    j=2;
    while (j*(i+1)<=N) {
      counter+=solution[j*(i+1)-1];
      j++;
    }
    counter = counter%2;
    if (counter!=vec[i]) {
      solution[i]=1;
    }
  }
  int balls=0;
  for (int i=0; i<N; i++) {
    balls+=solution[i];
  }
  cout << balls << endl;
  if (balls!=0) {
    for (int i=0; i<N; i++) {
      if (solution[i]==1) {
        cout << i+1 << " ";
      }
    }
  }
}

Measured memory_bytes: 4744
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
int a[2001],c[4001],n;
int main(){
  r(i,1001)r(j,1001)a[i+j]++;
  r(i,2001)r(j,2001)c[i+j]+=a[i]*a[j];
  while(cin>>n)cout<<c[n]<<endl;
}

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

const int NUM = 15;

int main() {
	int wf[NUM][NUM];
	int n;
	while ( cin >> n , n ) {
		for ( int i = 0 ; i < NUM ; i++ ) {
			for ( int j = 0 ; j < NUM ; j++ ) {
				if ( i == j ) {
					wf[i][j] = 0;
				} else {
					wf[i][j] = 1000000;
				}
			}
		}
		
		int m=0;
		
		int a,b,c;
		for ( int i = 0 ; i < n ; i++ ) {
			cin >> a >> b >> c;
			wf[a][b] = wf[b][a] = c;
			if ( a > m ) {
				m = a;
			} if ( b > m ) {
					m = b;
			}
		}
		m++;
		for ( int a = 0 ; a < m ; a++ ) {
			for ( int b = 0 ; b < m ; b++ ) {
				for ( int c = 0 ; c < m ; c++ ) {
					wf[b][c] = min ( wf[b][c] , wf[b][a] + wf[a][c] );
				}
			}
		}
		int loc,sec = 1000000;
		for ( int a = 0 ; a < m ; a++ ) {
			int nsec = 0;
			for ( int b = 0 ; b < m ; b++ ) {
				nsec += wf[a][b];
			}
			if ( nsec < sec ) {
				loc = a;
				sec = nsec;
			}
		}
		cout << loc << " " << sec << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define int long long int
#define ii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
#define output(x) for (auto a:x) cout<<a<<" ";cout<<endl;
#define output2(x) for (auto a:x) cout<<a.fi<<" "<<a.se<<endl;
#define PI 3.14159265
#define all(x) x.begin(),x.end()

// DEBUG TEMPLATE
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
  *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
  
// DEBUG TEMPLATE ENDS

#define MOD 1000000007
int power(int x,int y,int mod = MOD) 
{ 
  int ret = 1;
  x = x % mod;
  while (y){
    if(y&1) ret = (ret*x)%mod;
    y = y>>1;
    x = (x*x)%mod;
    } 
    return ret%mod; 
}

void solve()
{ 
 int n;
 cin>>n;
 map<string,int> cnt;
 for (auto x : {"AC" , "WA" ,"TLE" ,"RE"}) cnt[x] = 0;
 for (int i=0;i<n;i++){
   string s;
   cin>>s;
   cnt[s]++;
 }
 for (auto x : {"AC" , "WA" ,"TLE" ,"RE"}) {
   cout<<x<<" x "<<cnt[x]<<endl;
 }
}


/*
  
*/
signed main(){
  int t = 1;
  // cin>>t;
  while (t--)
  solve();
}
// Check MOD values plox :(


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
#define yn(x) puts((x ? "Yes" : "No"))
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;
int K;

void input() {
  cin >> N >> K;
  ;
  ;
}
const int MAX = 2 * (1e6 + 5);
long long fac[MAX], finv[MAX], inv[MAX];
void com_init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; 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;
}
void solve() {
  int ans = 0;
  com_init();
  rep(i, 0, min(N, K)) {
    ans += com(N, i) * com(N - 1, i);
    ans %= MOD;
  }
  cout << ans << endl;
  ;
  ;
}
signed main() {
  cout << setprecision(12);
  input();
  solve();
  return 0;
}

Measured memory_bytes: 47104
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
typedef long long LL;
const int MaxN = 1e5;
const LL INF = -(1LL << 60);
using namespace std;
LL dp[MaxN + 5];
int a[MaxN + 5] , c[MaxN + 5] , b[MaxN + 5];
int n , m;
int main()
{
	while(~scanf("%d%d" , &n , &m)){
		for(int i = 1;i <= m;i++){
			scanf("%d%d%d" , &a[i] , &b[i] , &c[i]);
		}
		for(int i = 1;i <= 5010;i++) dp[i] = INF;
		dp[1] = 0;
		bool ok = 0;
		for(int i = 1;i <= 5010;i++){
			int t = 0;
			for(int j = 1;j <= m;j++){
				if(dp[a[j]] + c[j] > dp[b[j]]){
					dp[b[j]] = dp[a[j]] + c[j];
					if(b[j] == n) t = 1;
				}
			}
			if(t > 0 && i > 4000) ok = 1;
		}
		if(!ok) printf("%lld\n" , dp[n]);
		else printf("inf\n");
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

ll fc(vector<int> &ld, vector<int> &c, int d){
  ll ret = 0;
  rep(i, 26){
    ret += (ll)c.at(i)*(d - ld.at(i));
  }
  return ret;
}

ll ret(vector<int> &c, vector<vector<int>> &s, vector<int> &ld, int t, int day, bool f, int &tt){
  ll ans = 0;
  tt = ld.at(t);
  ld.at(t) = day;
  ans += s.at(day).at(t);
  ans -= fc(ld, c, day);
  if(f == false)ld.at(t) = tt;
  return ans;
}

int main(){
  int D;
  cin >> D;
  vector<int> ld(26, -1);
  vector<int> c(26);
  rep(i, 26) cin >> c.at(i);
  vector<vector<int>> s(D, vector<int>(26));
  rep(i, D){
    rep(j, 26){
      int in;
      cin >> in;
      s.at(i).at(j) = in;
    }
  }
  int tt, sb, xx;
  rep(i, D){
    ll mx = -9e18;
    int jj = 0;
    if(i < D-3){
      rep(j, 26){
        rep(k, 26){
          rep(l, 26){
            ll r = ret(c, s, ld, j, i, true, tt);
            r += ret(c, s, ld, k, i+1, true, sb);
            r += ret(c, s, ld, l, i+2, false, xx);
            if(r > mx){
              mx = r;
              jj = j;
            }
            ld.at(j) = tt;
            ld.at(k) = sb;
          }
        }
      }
    }else{
      rep(j, 26){
        ll r = ret(c, s, ld, j, i, false, tt);
        if(r > mx){
          mx = r;
          jj = j;
        }
      }
    }
    cout << jj+1 << endl;
    ret(c, s, ld, jj, i, true, xx);
  }
  return 0;
}

Measured memory_bytes: 3696
#include <stdio.h>
#include <stdlib.h>

struct DrinkInfo{
	long long price; 
	long long cnt;
};

struct DrinkInfo dinfo[100000];

int cmp(const void *a, const void *b)
{
	struct DrinkInfo *a_i = (struct DrinkInfo *)a;
	struct DrinkInfo *b_i = (struct DrinkInfo *)b;

	long long cmp_val = a_i->price - b_i->price; 

    if (cmp_val < 0)  return -1;
    if (cmp_val == 0) return 0;
	if (cmp_val > 0)  return 1;	
}

int main(int argc, char *argv[])
{
    long long n, m;
	long long  i;
    scanf ("%lld %lld",  &n, &m);

	for (i = 0; i < n; i++) {
        scanf("%lld %lld", &dinfo[i].price,  &dinfo[i].cnt);
	}

	qsort(dinfo, n, sizeof(struct DrinkInfo), cmp);

	long long  total_price = 0;
	long long  num = m;
	for (i = 0; i < n; i++) {
		if (dinfo[i].cnt >= num) {
			total_price += (num * dinfo[i].price);
			break;
		}
		else {
			total_price += (dinfo[i].cnt * dinfo[i].price);
			num -= dinfo[i].cnt;
		}
	}
	printf("%lld\n", total_price);
	return 0;
}


Measured memory_bytes: 3324
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0;i<n;i++){
            a[i] = sc.nextInt();
        }
        int next = 1;
        for(int i = 0;i<n;i++){
            if(a[i] == next){
                next++;
            }
        }
        if(next==1){
            System.out.println(-1);
        }else{
            System.out.println((n - next + 1));
        }
        sc.close();
    }
}

Measured memory_bytes: 66408
N = int(input())
ans = 0
for i in range(1, N + 1):
    if i % 2 == 0:
        continue
    cnt = 2
    for j in range(2, i):
        if i % j == 0:
            cnt += 1
    if cnt == 8:
        ans += 1
print(ans)

Measured memory_bytes: 9088
N=int(input())
A=list(map(int, input().split()))
A=sorted(A,reverse=True)
if A[N-1] == 0:
  print(0)
  exit(0)

ans = 1
for i in range(N):
  ans*=A[i]
  if(ans>1000000000000000000):
    print(-1)
    exit(0)
print(ans)

Measured memory_bytes: 21772
N = int(input())
A = list(map(int,input().split()))
l = []
for i in range(1,N):
    if (A[i-1] < A[i]):
        l.append("<")
    elif (A[i-1] != A[i]):
        l.append(">")

a = [0]*len(l)

for i in range(len(l)-1):
    if (a[i] == 0):
        if (l[i] != l[i+1]):
            a[i+1] = 1
    
print(sum(a)+1)


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

const int INF =1001001001;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0 ,1};

int main()
{    
   int h,w;
   cin >> h >> w;
   char s[h][w];
   rep(i,h) rep(j,w) cin >> s[i][j];
   int ans =0;
   //BFS(幅優先探索)を使う

   //全ての位置をスタートにする
   rep(i,h) rep(j,w){
      //#だったら飛ばす
      if(s[i][j] == '#') continue;
      //キューと記録用配列を用意
      queue<P> q;
      //全てINFで埋めた記憶用配列
      vector<vector<int>> dist(h,vector<int>(w, INF));
      //INFでなければ更新し、キューに入れる関数
      auto update = [&](int i, int j, int x){
         if(dist[i][j] != INF) return;
         dist[i][j] = x;
         q.emplace(P(i,j));
      };
      //一つ目のキューに今位置を初期位置として入れる
      update(i,j,0);
      //全て移動するとキューが空になる
      while(!q.empty()){
         //キューから取り出す
         int i = q.front().first;
         int j = q.front().second; q.pop();

         //上下左右を順に見る
         rep(dir,4){
            int ni = i + di[dir];
            int nj = j + dj[dir];

            //はみ出た場合を考慮
            if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
            //壁検出
            if(s[ni][nj] == '#') continue;
            //突破したら1足して(移動して)更新
            update(ni,nj,dist[i][j] + 1);
         }
      }

      //最後に今回の位置スタートで一番遠かった位置==移動距離の最大なので今までの最大値と比較する
      rep(i,h) rep(j,w){
         if(dist[i][j] == INF)continue;
         ans = max(ans, dist[i][j]);
      }
   }

   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (){
	int a,b,c,nilai1,nilai2,nilai3;
	scanf ("%d %d %d", &a,&b,&c);
	nilai1=a+b;
	nilai2=a+c;
	nilai3=b+c;
	if (a==b||b==c||a==c){
		printf ("%d\n", a+b);
	}else if (nilai3<nilai2&&nilai3<nilai1){
		printf ("%d\n", nilai3);
	}else if (nilai2<nilai1&&nilai2<nilai3){
		printf ("%d\n", nilai2);
	}else if (nilai1<nilai2&&nilai1<nilai3){
		printf ("%d\n", nilai1);
	}
 return 0;}

Measured memory_bytes: 128
s=gets.chomp.reverse
s.gsub!('CB', 'D')
s = s.split(/[BC]/).compact.reject(&:empty?)
r=0
s.each do |e|
  k=0
  e.each_char do |c|
    if c == 'A'
      r += k
    else
      k += 1
    end
  end
end

p r

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

using ll=long long;
using namespace std;

int main()
{
  int N,M;
  cin >> N >> M;
  vector<ll> x(N),y(N),z(N);
  for( int i=0;i<N;i++ )
    cin >> x[i] >> y[i] >> z[i];

  ll m;
  for( ll s1=-1;s1<3;s1+=2 )
      for( ll s2=-1;s2<3;s2+=2 )
	  for( ll s3=-1;s3<3;s3+=2 )
	    {
	      vector <ll> tmp(N);
	      for( int i=0;i<N;i++ )
		tmp[i] = s1*x[i]+s2*y[i]+s3*z[i];
	      sort(tmp.begin(), tmp.end());
	      ll t = 0;
	      for( int i=N-1;i>=N-M;i-- )
		t += tmp[i];
	      //	      cout << t << endl;
	      m = max(t, m);
	    }

  cout << m << endl;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
from fractions import gcd

class SegmentTree:
    def __init__(self, N, func, I):
        self.sz = N
        self.func = func
        self.I = I
        self.seg = [I]*(N*2)
 
    def assign(self, k, x):
        self.seg[k + self.sz] = x
 
    def build(self):
        for i in range(self.sz - 1, 0, -1):
            self.seg[i] = gcd(self.seg[2 * i], self.seg[2 * i + 1])
 
    def update(self, k, x):
        k += self.sz
        self.seg[k] = x
        while k > 1:
            k //= 2
            self.seg[k] = gcd(self.seg[2 * k], self.seg[2 * k + 1])
 
    def query(self, a, b):
        R = self.I
        a += self.sz
        b += self.sz
        while a < b:
            if a & 1:
                R = gcd(R, self.seg[a])
                a += 1
            if b & 1:
                b -= 1
                R = gcd(self.seg[b], R)
            a >>= 1
            b >>= 1
        return R

def main():
    N = int(readline())
    m = map(int,read().split())
    seg = SegmentTree(N , gcd , 0)
    for i in range(N):
        seg.assign(i , next(m))
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans,gcd(seg.query(0,i) , seg.query(i+1,N)))
    print(ans)

main()


Measured memory_bytes: 81468
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;

#define all(v) (v).begin(),(v).end()
using ll = long long;
constexpr ll INF = 1e18;

int main(void) {
    string S;
    cin >> S;
    if (S[S.size()-1] != 's') cout << S << "s" << endl;
    else cout << S << "es" << endl;
    return 0;
}


Measured memory_bytes: 3128
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include <typeinfo>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;

int main(){


    while(true){
        int n;
        double m, alpha;
        cin >> n;
        if(n==0){
            break;
        }
        vector<int> s(n);
        for(int i=0; i<n; i++){
            cin >> s[i];
        }

        double sum = 0;
        for(int i=0; i<n; i++){
            sum += s[i];
        }
        m = double(sum)/double(s.size());

        double sum_a=0;
        for(int i=0; i<n; i++){
            sum_a += (s[i]-m)*(s[i]-m);
        }
        alpha = sqrt(sum_a/double(n));

        cout << fixed;
        cout << setprecision(8) << alpha << endl;


    }


    return 0;
}



Measured memory_bytes: 3244
#include<cstdio>
#include<cstring> 
using namespace std;
char s[10005];
int main()
{
	scanf("%s", s);
	int len = strlen(s);
	int flag = 0;
	for(int i = 0; i < len; i++)
	{
		if(flag == 1 && s[i] == 'F')
		{
			printf("Yes\n");
			return 0;
		}
		if(s[i] == 'C')
		{
			flag = 1;
			continue;
		}
	}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 128
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;


void Calculate_Depth(vector<vector<int>>&edge, vector<int>&depth, int stnode) {
	depth[stnode] = 0;
	queue<int>Q;
	Q.push(stnode);
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop();
		for (auto i : edge[cn]) {
			if (depth[i] > depth[cn] + 1) {
				depth[i] = depth[cn] + 1;
				Q.push(i);
			}
		}
	}
	return;
}

void Search(vector<vector<int>>&edge, vector<int>&depth, int node, vector<int>&dp) {
	int sum = 0;
	int no = 0;
	for (auto i : edge[node]) {
		if (depth[i] < depth[node])continue;
		Search(edge, depth, i, dp);
		if (dp[i])sum += dp[i];
		else no++;
	}
	dp[node] = sum + max(0, no - 1);
}

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

	cin >> N;
	vector<vector<int>>edge(N);
	for (int i = 1; i < N; i++) {
		cin >> L >> R;
		edge[L].push_back(R);
		edge[R].push_back(L);
	}
	vector<int>depth(N, MOD);
	vector<int>dp(N);
	Calculate_Depth(edge, depth, 0);
	Search(edge, depth, 0, dp);
	for (int i = 1; i < N; i++) {
		if (dp[0] == dp[i]) {
			dp[0]++;
			break;
		}
	}
	dp[0] = max(dp[0], 1);
	cout << dp[0] << endl;
	return 0;
}

Measured memory_bytes: 14208
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

using namespace std;

int main()
{
    long n, m;
    cin >> n >> m;

    long l_max = 0;
    long r_min = n;

    for(int i = 0; i < m ; i++){
        long l, r;
        cin >> l >> r;

        if(l_max < l){
            l_max = l;
        }

        if(r_min > r){
            r_min = r;
        }
    }

    long pass = r_min - l_max + 1;
    if(pass < 0){
        pass = 0;
    }

    cout << pass << endl;

    return 0;
}



Measured memory_bytes: 256
from collections import defaultdict


def main():
    N, x = map(int, input().split())
    a_list = list(map(int, input().split()))
    ans = 0
    for i in range(len(a_list)):
        d = max(0, a_list[i] - x)
        a_list[i] -= d
        ans += d

    for i in range(1, len(a_list)):
        total = a_list[i - 1] + a_list[i]
        if total > x:
            d = total - x
            a_list[i] -= d
            ans += d

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14516
class WeightedUnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0 for i in range(n)]
        # 親ノードとの重み
        self.diff_weight = [0 for i in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        # 親ノードはまだ上書きしない
        root = self.find(self.par[x])
        self.diff_weight[x] += self.diff_weight[self.par[x]]
        self.par[x] = root
        return self.par[x]

    def weight(self, x):
        # xの根に対する重みを返す
        self.find(x)
        return self.diff_weight[x]

    def diff(self, x, y):
        #xの根と yの根の差分をとる
        return self.weight(y) - self.weight(x)

    def unite(self, x, y, w):
        # ノード x の下にノード y をつける。辺の重みは w
        # x の根と y の 根をくっつけるのでwを補正する
        w += self.weight(x)
        w -= self.weight(y)
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            # y の下に x をつけることになるので、重さは反転させる
            self.par[x] = y
            w = -w
            self.diff_weight[x] = w
        elif self.rank[y] < self.rank[x]:
            self.par[y] = x
            self.diff_weight[y] = w
        else:
            self.par[y] = x
            self.rank[x] += 1
            self.diff_weight[y] = w

n, m = map(int, input().split())
wuf = WeightedUnionFind(n)
for i in range(m):
    l, r, d = map(int, input().split())
    l -= 1
    r -= 1
    if wuf.find(l) == wuf.find(r):
        if wuf.diff(l, r) != d:
            print('No')
            exit()
    else:
        wuf.unite(l, r, d)
else:
    print('Yes')

Measured memory_bytes: 10024
#include<bits/stdc++.h>
using namespace std;
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int m,n,a,b,d,x,y,k,c=0;
    string s,t;
    cin>>n>>s;
    for(int i=0;i<n-2;i++){
        if(s[i]=='A'&&s[i+1]=='B'){
          if(s[i+2]=='C'){c++;}
        }
    }
    cout<<c;
}

Measured memory_bytes: 256
N=int(input())
res=N
for i in range(N+1):
  cc=0
  t=i
  while t>0:
    cc+=t%6
    t=t//6
  t=N-i
  while t>0:
    cc+=t%9
    t=t//9
  if res>cc:
    res=cc
import math
print(math.floor(res))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
 
using namespace std; 
#define int         long long int
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define sd(t) 		scanf("%d",&(t))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define ld			long double
const int N = 2e5 + 5;
int arr[N];
pii segtree[4*N];
int n;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("jjj.txt", "w", stdout);
	#endif
} 

void build(int l, int r, int node){
	if(l==r){
		segtree[node] = make_pair(arr[l], l);
		return;
	}

	int mid = l+r >> 1;

	build(l, mid, 2*node+1);
	build(mid+1, r, 2*node + 2);

	segtree[node] = min(segtree[2*node+1], segtree[2*node+2]);
}

pii query(int s, int e, int l, int r, int node){
	if(s <= l and e >= r){
		return segtree[node];
	}

	if(s > r or e < l){
		return {INT_MAX, -1};
	}

	int mid = l+r >> 1;

	pii a = query(s, e, l, mid, 2*node + 1);
	pii b = query(s, e, mid + 1, r, 2*node + 2);

	return min(a, b);
}

int okay(int l, int r){

	if(l > r) return 0;

	pii a = query(l, r, 0, n-1, 0);

	return (a.y-l+1)*a.x*(r-a.y+1) + okay(l, a.y-1) + okay(a.y+1, r);

}

void solve(){
	
	cin >> n;

	rep(i, 0, n){
		cin >> arr[i];
	}

	build(0, n-1, 0);

	cout << okay(0, n-1) << endl;
}

int32_t main(){
	// fast();
    int t = 1;
    // cin>>t;
    while(t--)
    solve();
}

Measured memory_bytes: 18304
#include <iostream>
#include <cmath>
#include <iomanip>
#include <bits/stdc++.h>

using namespace std;

int main() {
  int A, B, H, M; cin >> A >> B >> H >> M;
  double theta = abs(M_PI*(H+M/60.0)/6.0-2.0*M_PI*(M/60.0));
  double result = sqrt(A*A+B*B-A*B*2.0*cos(theta));
  cout << fixed << setprecision(20) << result << endl;
  return 0;
}

Measured memory_bytes: 4140
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    long long n;
    long long a;
    long long b;
    long long c;
    long long d;
    long long e;
    long long m=1000000000000000;
    long long ans=0;
    
    cin >> n;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    cin >> e;
    
    m = min({a, b, c, d, e});
    
    ans = n / m;
    
    if(n%m>=1){
        
        ans += 1;
        
    }
    
    ans += 4;
    
    cout << ans << endl;
    
    return 0;
    
}

Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

LL f(int N,int D){
	if( N == 1 ){
		return D;
	}
	LL odd,even;
	if( N & 1 ){
		odd = N;
		even = N-1;
	}else{
		odd = N-1;
		even = N;
	}
	LL mask = 64;
	LL ans = 0;
	while(mask){
		if( D & mask ){//奇数個作れる
			ans += odd * mask;
		}else{//偶数個作れる
			ans += even * mask;
		}
		mask >>= 1;
	}
	return ans;
}
void solve(){
	int T;
	cin >> T;
	int N,D;
	while(T--){
		cin >> N >> D;
		cout << f(N,D) << endl;
	}
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int r;cin>>r;
    cout<<r*r<<endl;
}

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

template <typename T> struct Edge {
    int to; T cost;
    Edge(int to = -1, T cost = 0) : to(to), cost(cost) {}
};

template <typename T> vector<T> dijkstra(vector<vector<Edge<T>>> &g, int s, T inf = numeric_limits<T>::max()) {
    priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> que;
    vector<T> dis(g.size(), inf);
    que.emplace(0, s);
    dis[s] = 0;
    while (!que.empty()) {
        auto p = que.top(); que.pop();
        if (dis[p.second] < p.first) continue;
        for (auto &e : g[p.second]) if (dis[e.to] > dis[p.second] + e.cost) {
            dis[e.to] = dis[p.second] + e.cost;
            que.emplace(dis[e.to], e.to);
        }
    }
    return dis;
}

int main() {
    int V, E, r;
    cin >> V >> E >> r;
    vector<vector<Edge<int>>> g(V);
    for (int i = 0; i < E; ++i) {
        int s, t, d;
        cin >> s >> t >> d;
        g[s].emplace_back(t, d);
    }
    auto dis = dijkstra(g, r);
    for (auto d : dis) {
        if (d == numeric_limits<int>::max()) cout << "INF" << endl;
        else cout << d << endl;
    }
}


Measured memory_bytes: 12972
import numpy as np

n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [0]*n
for i in range(n):
    a[i] = list(map(int, input().split()))

ans = 0
for i in range(n):
    if np.dot(np.array(a[i]), np.array(b)) + c > 0:
        ans += 1

print(ans)

Measured memory_bytes: 21108
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Contest
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().ToCharArray().Select(x=>x.ToString()).ToList();
            List<string> ls = new List<string>();
            ls.Add("");
            for(int i=0;i<s.Count();i++)
            {
                if (ls.Last() != s[i].ToString())
                    ls.Add(s[i]);
                else
                {
                   if(i+1<s.Count()) ls.Add(s[i] + s[++i]);
                }
            }
            Console.WriteLine(ls.Count() - 1);
        }


    }
}


Measured memory_bytes: 32348
import heapq
x,y,z,k = (int(x) for x in input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
# heap
h = []
g = set()
heapq.heappush(h, (-(a[0]+b[0]+c[0]),0,0,0))
for i in range(k):
    q,ia,ib,ic = heapq.heappop(h)
    print(-q)
    ja,jb,jc = ia+1,ib,ic
    if ja<x and (ja,jb,jc) not in g:
        heapq.heappush(h, (-(a[ja]+b[jb]+c[jc]),ja,jb,jc))
        g.add((ja,jb,jc))
    ja,jb,jc = ia,ib+1,ic
    if jb<y and (ja,jb,jc) not in g:
        heapq.heappush(h, (-(a[ja]+b[jb]+c[jc]),ja,jb,jc))
        g.add((ja,jb,jc))
    ja,jb,jc = ia,ib,ic+1
    if jc<z and (ja,jb,jc) not in g:
        heapq.heappush(h, (-(a[ja]+b[jb]+c[jc]),ja,jb,jc))
        g.add((ja,jb,jc))
    


Measured memory_bytes: 4852
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm> // sort
#include <map>       // pair
#include <vector>
using namespace std;

#define REP(a,b) for(int i =(a);i < (b);i++)
#define FOR(n) for(int i = 0; i<(n); i++)
#define COUT(c)  cout<<(c)<<endl


const int INF = 100100100;
const int MOD = (int)1e9 +7;
const double EPS = 1e-9; 

typedef long long int ll;

//char in[120];
//ex. pair
//pair<pair<string,int>,int> p[110];

int main(){
    int n,d;cin>>n>>d;

    if (n%(2*d+1) == 0) cout << n/(2*d+1) << endl;
    else cout << n/(2*d+1) + 1 <<endl;
    return 0;    
}

Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.trim().split('\n');

while (line = lines.shift()) {
    const numbers = line.split(' ').map(Number);

    // Edit from here
    const a = numbers[0];
    const b = numbers[1];

    if ( a === 0 && b === 0) { break; }

    const output = a < b ? a + ' ' + b : b + ' ' + a;

    console.log(output);

    // to here
}



Measured memory_bytes: 18760
#include<bits/stdc++.h>
#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define per(i,n,j) for(int i=(n);i>=(j);i--)
using ll=long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF=1LL<<60;

int n,k;
vector<int> h(100100);

int main(){
    cin>>n>>k;
    int ans=0;
    rep(i,0,n){
        cin>>h[i];
        if(h[i]>=k) ans++;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define per(i, n, s) for (int i = (n-1); i >= (int)(s); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;

int main(){
    int n,t; cin>>n>>t;
    vector<int> v;
    rep(i,0,n){
        int x,y;
        cin>>x>>y;
        if(y<=t) v.push_back(x);
    }
    if(v.size()==0){
        cout<<"TLE"<<endl;
        return 0;
    }
    sort(all(v));
    cout<<v[0]<<endl;
    return 0;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    int N, M;
    cin >> N >> M;
    string S; cin >> S;

    vector<int> ans;
    int i = N;
    while (i >= 1) {
        int m = M;
        while (i - m <= -1) {
            m--;
        }
        while (S[i - m] == '1') {
            m--;
            if (m == 0) {
                cout << -1 << endl;
                return 0;
            }
        }
        ans.pb(m);
        i = i - m;
    }
    reverse(all(ans));
    rep(i, ans.size()) cout << ans[i] << ' ';
    cout << endl;

    return 0;
}

Measured memory_bytes: 1096
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

    int n;cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a.begin(),a.end());
    ll ma=a[n-1],low,high;
    if(ma%2==0) low=high=ma/2;
    else{
        low=ma/2;
        high=ma/2+1;
    }
    ll dif=ma,idx;
    for(int i=0;i<n-1;i++){
        if(a[i]<=low){
            if(low-a[i]<=dif){
                dif=low-a[i];
                idx=i;
            }
        }
        else{
            if(a[i]-high<=dif){
                dif=a[i]-high;
                idx=i;
            }
        }
    }
    cout<<ma<<" "<<a[idx]<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const double PI  =3.141592653589793238463;
long long mod = 1000000007;

int main()
{

   ios::sync_with_stdio(false);
	cin.tie(0);
	ll t;
	t=1;
	while(t--)
    {
long long n;
cin>>n;
int m = n%10;
if(m==2||m==4||m==5||m==7||m==9) {
    cout<<"hon"<<"\n";
}
else if(m==3) cout<<"bon"<<endl;
else cout<<"pon"<<endl;
    
    }
}









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




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

	int ans;

	int tmp;

	int a[5];
	int b[5];
	for (int i = 1; i <= N / 2; i++)
	{
		a[0] = i / 10000;
		a[1] = i / 1000 - 10 * a[0];
		a[2] = i / 100 - 100 * a[0] - 10 * a[1];
		a[3] = i / 10 - 1000 * a[0] - 100 * a[1] - 10 * a[2];
		a[4] = i % 10;

		b[0] = (N-i) / 10000;
		b[1] = (N-i) / 1000 - 10 * b[0];
		b[2] = (N - i) / 100 - 100 * b[0] - 10 * b[1];
		b[3] = (N - i) / 10 - 1000 * b[0] - 100 * b[1] - 10 * b[2];
		b[4] = (N - i) % 10;

		if (i == 1)
		{
			ans = a[0] + a[1] + a[2] + a[3] + a[4] + b[0] + b[1] + b[2] + b[3] + b[4];
		}
		else
		{
			tmp = a[0] + a[1] + a[2] + a[3] + a[4] + b[0] + b[1] + b[2] + b[3] + b[4];
			if (tmp < ans)
				ans = tmp;
		}
	}
	cout << ans;

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define ll unsigned long long
using namespace std;
ll at(ll a){
    return (a==1)?1:2*at(a/2)+1;
}

int main(){
    ll H;
    cin>>H;
    cout<<at(H)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  R n;
  ll a[n];
  rep(i,n) R a[i];
  map<ll,ll> m[2];
  rep(i,n) m[i%2][a[i]]++;
  ll ans=MAX;
  vector<P> v[2];
  rep(i,2) {
    tr(it,m[i]) v[i].pb(P(it->S,it->F));
  }
  rep(i,2) sort(all(v[i]),greater<P>());
  rep(i,min(2,(int)v[0].size())) {
    rep(j,min(2,(int)v[1].size())) {
      if(v[0][i].S==v[1][j].S) {
        ans=min(ans,n-v[0][i].F);
        ans=min(ans,n-v[1][j].F);
      } else ans=min(ans,n-v[0][i].F-v[1][j].F);
    }
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 8444
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
using namespace std;

int main(){
    int a, b;
    string ans = "Impossible";
    cin >> a >> b;
    if(a%3==0 || b%3==0 || (a+b)%3==0) ans = "Possible";
    cout << ans << endl;
}


Measured memory_bytes: 256