akhauriyash/Code-Regression huggingface dataset:
#include<map>
#include<queue>
#include<cstdio>
#include<string>

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

using namespace std;

const int INF=1<<29;

pair<int,int> operator-(const pair<int,int> &a){ return make_pair(-a.first,-a.second); }

int main(){
	map<string,int> f;
	int n,T; scanf("%d%d",&n,&T);
	char tmp[16];
	scanf("%s",tmp); if(f.count(tmp)==0) f.insert(make_pair(tmp,f.size()));
	int s=f[tmp];
	scanf("%s",tmp); if(f.count(tmp)==0) f.insert(make_pair(tmp,f.size()));
	int g=f[tmp];

	int N=0;
	static int idx1[100000],idx2[100000]; // vertex id -> どの路線か, 路線の何番目の駅か
	static vector<int> route[50000],t[50000];
	rep(i,n){
		int m; scanf("%d",&m);
		route[i].resize(m);
		t[i].resize(m-1);
		rep(j,m){
			scanf("%s",tmp); if(f.count(tmp)==0) f.insert(make_pair(tmp,f.size()));
			route[i][j]=f[tmp];
			idx1[N]=i;
			idx2[N]=j;
			N++;
		}
		rep(j,m-1){
			scanf("%d",&t[i][j]);
		}
	}

	static vector<int> V[100000]; // V[i] := { u | route[idx1[u]][idx2[u]] == i }
	rep(u,N) V[route[idx1[u]][idx2[u]]].push_back(u);

	static pair<int,int> d[100000][2]; // <time,乗り換え回数>
	rep(u,N) rep(dir,2) d[u][dir].first=INF;

	static bool trans[100000]; // trans[i] := ( 駅 i から乗換えをしたかどうか ) <- これがないと |E|=O(V^2) となり TLE する

	pair<int,int> ans(-1,0);
	priority_queue< pair< pair<int,int>,pair<int,int> > > Q; // <<-time,-乗り換え回数>,<vertex id,順方向か逆方向か>>
	rep(u,N) if(route[idx1[u]][idx2[u]]==s) {
		d[u][0]=d[u][1]=make_pair(0,0);
		Q.push(make_pair(make_pair(0,0),make_pair(u,0)));
		Q.push(make_pair(make_pair(0,0),make_pair(u,1)));
	}
	while(!Q.empty()){
		pair<int,int> d_now=-Q.top().first;
		int u=Q.top().second.first,dir=Q.top().second.second; Q.pop();

		if(d[u][dir]<d_now) continue;

		if(route[idx1[u]][idx2[u]]==g){ ans=d_now; break; }

		// 今の電車に乗り続ける
		if(dir==0){ // 順方向
			if(idx2[u]+1<route[idx1[u]].size()){
				pair<int,int> d_next=d_now;
				d_next.first+=t[idx1[u]][idx2[u]];
				if(d[u+1][dir]>d_next){
					d[u+1][dir]=d_next;
					Q.push(make_pair(-d_next,make_pair(u+1,dir)));
				}
			}
		}
		else{ // 逆方向
			if(idx2[u]-1>=0){
				pair<int,int> d_next=d_now;
				d_next.first+=t[idx1[u]][idx2[u]-1];
				if(d[u-1][dir]>d_next){
					d[u-1][dir]=d_next;
					Q.push(make_pair(-d_next,make_pair(u-1,dir)));
				}
			}
		}

		// 乗り換え
		if(!trans[route[idx1[u]][idx2[u]]]){
			trans[route[idx1[u]][idx2[u]]]=true;

			rep(i,V[route[idx1[u]][idx2[u]]].size()){
				int v=V[route[idx1[u]][idx2[u]]][i];
				pair<int,int> d_next=d_now;
				d_next.first+=T;
				d_next.second++;
				rep(dir2,2){
					if(d[v][dir2]>d_next){
						d[v][dir2]=d_next;
						Q.push(make_pair(-d_next,make_pair(v,dir2)));
					}
				}
			}
		}
	}

	if(ans.first==-1) puts("-1"); else printf("%d %d\n",ans.first,ans.second);

	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

void solve(ll N, ll M, vector<ll> H, vector<ll> A, vector<ll> B) {
  vector<bool> isgood(N,true);

  for (auto i = 0; i!=M; ++i) {
    if(H[A[i]-1] <= H[B[i]-1]) {
      isgood[A[i]-1] = false;
    }
    if(H[A[i]-1] >= H[B[i]-1]) {
      isgood[B[i]-1] = false;
    }
  }
  cout << count(isgood.begin(),isgood.end(),true) << endl;
}

int main() {
  ll N;
  cin >> N;
  ll M;
  cin >> M;
  vector<ll> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  vector<ll> A(M);
  vector<ll> B(M);
  for (int i = 0; i < M; i++) {
    cin >> A[i];
    cin >> B[i];
  }
  solve(N, M, move(H), move(A), move(B));
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  int64_t sum = 0;

  vector<int> vec(1000009, 0);
  for (int i = 0; i < 1000000; i++) {
    if (i % 3 != 0 && i % 5 != 0) {
      vec.at(i) = i;
    }
  }

  for (int i = 0; i < n + 1; i++) {
    sum += vec.at(i);
  }

  cout << sum << endl;

}


Measured memory_bytes: 7216
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e18;
const ll mod = 1e9 + 7;


int main(){
    ll n,m,q;
    cin >> n >> m >> q;
    vector<vector<ll>> v(n + 1,vector<ll>(n + 1,0));
    REP(i, m){
        int l ,r;
        cin >> l >> r;
        v[l][r]++;
    }
    FOR(i,1,n + 1){
        REP(j,n+1)v[i][j] += v[i - 1][j];
    }
    REP(i,n + 1){
        FOR(j, 1, n+1)v[i][j] += v[i][j -1];
    }
    REP(i,q){
        int p,q;cin >> p >> q;
        int ans = v[p - 1][p - 1] + v[q][q] - v[p - 1][q] - v[q][p - 1];
        dump(ans);
    }
    return 0;
}

Measured memory_bytes: 2944
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
   
int top, S[1000];
   
   
void push(int x){
    top++;
    S[top] = x;
}
   
int pop(){
    top--;
    return S[top+1];
}
   
   
int main(void) {
    int a,b;
    top=0;
    char s[100];
    while( scanf("%s",s) != EOF){
        if( s[0]=='+'){
            a = pop();
            b = pop();
            push(a+b);
        } else if( s[0] == '-'){
            b=pop();
            a=pop();
            push(a-b);
        } else if( s[0] == '*'){
            a = pop();
            b= pop();
            push(a *b);
        } else{
            push(atoi(s));
        }
    }
       
    printf("%d\n",pop());
       
    return 0;
}


Measured memory_bytes: 1988
import java.util.*;
import java.util.Map.Entry;

import javax.swing.text.Segment;
import javax.xml.ws.WebEndpoint;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};
    static long mod=1000000007;
    
    public static void main(String[] args) {        
        new Thread(null, new Main(), "", 200 * 1024 * 1024).start();        
    }

    public void run() {
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        int m=sc.nextInt();

        out.println((n+m-1)/m);
     	out.flush();
    }

    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }

    static void ret(long ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x,y; double d;
//	P(int  x, int y, double d) {
//	  this.x=x;
//	  this.y=y;
//	  this.d=d;
//	}
//}


class P implements Comparable<P>{
    int x,y;
    P(int x,int y) {
    	this.x=x;
    	this.y=y;
    }

    public int compareTo(P p){
        return y-p.y;
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString()
    {
        while( st==null || !st.hasMoreTokens() )
			try {
				st = new StringTokenizer(x.readLine());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        return st.nextToken();
    }
    public int nextInt()
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) {
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) {
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() {
        return this.nextString().toCharArray();
    }    
    public long nextLong()
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


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

using namespace std;

int main()
{
	int n;
  cin >> n;
  
  int a[n+1] = {0};
  
  for(int i=0;i<n-1;i++)
  {
		int x;
    cin >> x;
    a[x]++;
  }
  
  for(int i=1;i<=n;i++)
    cout << a[i] << endl;
}

Measured memory_bytes: 4412
#include <iostream>
#include <string.h>
using namespace std;

int main(){
	string t, h;
	int n, taro, hanako;

	taro = 0;
	hanako = 0;

	cin >> n;
	for(int i=0; i<n; i++){
		cin >> t >> h;
		if(t > h){
			taro = taro+3;
		}else if(t < h){
			hanako=hanako+3;
		}else{
			taro=taro+1;
			hanako=hanako+1;
		}
	}
	cout << taro << " " << hanako << endl;
	return 0;
}


Measured memory_bytes: 3148
#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;

const long INF = 1e9 + 1;

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b+c >= 22) cout << "bust" << endl;
  else cout << "win" << endl;
  
}


Measured memory_bytes: 3600
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll					long long
#define MOD					1000000007
#define MAX					1e9
#define MIN                 -1e9
#define PI					acos(-1.0)
#define vi					vector<int>
#define vii					vector<vi>
#define vll					vector<ll>
#define mid(s,e)			(s+(e-s)/2)
#define clz(n)				__builtin_clzll(n))

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
template<typename T>
void printVec(const T &v, char sep=' ') {for (auto &i: v) cout << i << sep;}
template<typename T>
void printVecPair(const T &v, char sep=' ') {for (auto &i: v) cout << i.first <<" " << i.second<< sep;}


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
	int n;
	cin>>n;
	vii dp(2,vi(3));
	for(int i=0;i<n;i++) {
			int c[3];
			for(int j=0;j<3;cin>>c[j++]);
			for(int j=0;j<3;j++) {
					for(int k=0;k<3;k++) {
							if(j!=k) {
									dp[i%2][j] = max(dp[(i+1)%2][k] + c[j],dp[i%2][j]);

							}
					}
			}
			debug(dp);
			
	}
	cout<<max({dp[(n-1)%2][0], dp[(n-1)%2][1], dp[(n-1)%2][2]});
	return 0;
}





Measured memory_bytes: 256
n = int(input())
t, a = [int(_) for _ in input().split()]
h = list(map(int, input().split()))
tmp = 10e9
output = 0

for i in range(n):
    if tmp > abs(a - (t - 0.006 * h[i])):
        tmp = abs(a- (t - 0.006 * h[i]))
        output = i + 1

print(output)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9+5;
const int mod = 998244353;

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

long long fpow(long long a,long long n){
  long long ret=1;
  if(n==1) return a;
  if(n%2==0) {
      ret = fpow(a*a%mod, n/2) %mod ;
  }else {
      ret = (a%mod)*fpow(a*a%mod, n/2) %mod;
  }
  return ret %mod;
}
int comb(int a, int b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    int tmp = ifac[a-b]* ifac[b] % mod;
    return tmp * fac[a] % mod;
}

int dp[3002][3002];
signed main(){
    int k;
    string s;
    cin >> k >> s;
    if(s.length()<=k) {
        cout << s << endl;
        return 0;
    }
    cout << s.substr(0,k)+"..." << endl;

    return 0;
}



Measured memory_bytes: 7820
#include <stdio.h>
#include <math.h>
long long min(long long a,long long b){
  if(a>b) return b;
  else return a;
 }

int main(void){
  long long n,d[5],ans,minmove;
  scanf("%lld",&n);

  for(int i=0;i<5;i++) scanf("%lld",&d[i]);
  minmove=min(d[0],min(d[1],(min(d[2],(min(d[3],d[4]))))));
  ans=(long long)ceil((double)n/minmove)+4;

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

Measured memory_bytes: 2188
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>

using namespace std;

int main() {

string a,b,c;
cin >> a >> b >> c;
char d,e,f;
d=a[0]-32;
e=b[0]-32;
f=c[0]-32;
cout << d << e << f << endl;

  return 0;
}


Measured memory_bytes: 256
import scala.io.{StdIn => in}

object Main extends App {
  val a = Iterator.continually(in.readInt)
    .take(5)
    .toArray
  val k = in.readInt
  val ans = if(Array(0,1,2,3,4).combinations(2).forall(i => (a(i(0)) - a(i(1))).abs <= k)) "Yay!" else ":("
  println(ans)
}

Measured memory_bytes: 25408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
  int a,b,c,d,e;
  cin >> a>> b>> c>> d>> e;
  int n = 5;
  vector<int> yon = {a,b,c,d,e};
  vector<int> times(n);
  int besttime = 99999999;
  for(int i= 0;i<n;i++){
    if(yon[i]%10==0) times[i]=yon[i];
    else times[i]= yon[i]-yon[i]%10+10;
  }
  rep(i,n){
    int ku = 0;
    rep(j,n){
      if(i==j){
         ku+=yon[j];
      }else{
        ku+=times[j];
      }
    }
     besttime = min(besttime,ku);
  }

  cout << besttime << endl;
 return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
p = 10 ** 9 + 7
A.sort(reverse=True)
B.sort(reverse=True)
A.append(0)
B.append(0)
a = 0
b = 0
cnt = 1
for i in range(N * M, 0, -1):
  x = N * M - i
  if A[a] == i and B[b] == i:
    a += 1
    b += 1
  elif A[a] == i:
    a += 1
    cnt *= b
  elif B[b] == i:
    b += 1
    cnt *= a
  else:
    cnt *= a * b - x
  cnt %= p
print(cnt)

Measured memory_bytes: 3188
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;

long long abc[30],pl[30];


int main(){
  long long n,count=0,ans=1;
  cin>>n;
  for(int i=0;i<n;i++){
    char temp;
    cin>>temp;
    abc[temp-'a']++;
  }
  for(int i=0;i<26;i++){
    if(abc[i]!=0) {
      pl[count]=abc[i];
      count++;
    }
  }
  for(int i=0;i<count;i++){
    ans*=(pl[i]+1);
    if(ans>1000000007) ans=ans%1000000007;
  }
  ans=(ans-1)%1000000007;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
a,b = map(int,input().split())
list = []

#当てはまるxがあるかどうか
for x in range(1500):
  if a/0.08 <= x < (a+1)/0.08 and b/0.1<= x < (b+1)/0.1:
#あったらリストに追加する
    list.append(x)
#空集合かどうか確かめる
if len(list) == 0 :
  print(-1)
  
else:
  print(min(list))



Measured memory_bytes: 2940
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        
        int[] v = new int[n];
        for(int i=0; i<n; i++){
            v[i] = Integer.parseInt(sc.next());
        }
        
        PriorityQueue<Integer> q = new PriorityQueue<>();
        int max = 0;
        
        for(int a=0; a<=Math.min(k,n); a++){
            for(int b=0; b<=Math.min(k-a,n-a); b++){
                q.clear();
                q.add(0);
                int sum = 0;
                for(int i=0; i<a; i++){
                    q.add(v[i]);
                    sum += v[i];
                }
                for(int i=0; i<b; i++){
                    q.add(v[n-1-i]);
                    sum += v[n-1-i];
                }
                
                for(int i=0; i<k-(a+b); i++){
                    if(q.peek()==0){
                        break;
                    }
                    sum -= q.poll();
                }
                max = Math.max(max, sum);
            }
        }
        
        System.out.println(max);
    }
}


Measured memory_bytes: 22612
//     THE ONLY WAY IS UP
 
#include<bits/stdc++.h>
 
#define ll              long long int
#define ld              long double
#define f1(i, a, b)     for(ll i = a; i < b; i++)
#define f2(a, b)        for(auto a : b)
#define ar(v, i)        v[i]
#define ar_(v, i, j)    v[i][j]
#define in_(x)          ll x; cin >> x;
#define ino_(type, x)   type x; cin >> x;
#define pb              push_back
#define nl              "\n"
#define tcase(t)        ll t; cin >> t; f1(z, 0, t)
using namespace std;
 
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    in_(n)
    map<ll, ll> map;
    f1(i, 0, n-1){
        in_(x);
        map[x]++;
    }
    ll i = 1;
    f2(x, map){
        while(true){
            if(x.first == i){
                cout << x.second << nl;
                i++;
                break;
            }else{
                cout << "0" << nl;
                i++;
            }
        }
    }
    f1(j, i, n+1)
        cout << "0" << nl;
}


Measured memory_bytes: 16116
//
// Created by Yoshiki Shino on 2018/07/01.
//

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

class Request{
public:
    int begin;
    int end;
    int size;
};

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

    vector<Request> requests;
    for (int i = 0; i < M; ++i) {
        int begin;
        int end;
        int size;
        cin >> begin >> end;
        size = end - begin;
        Request request = {begin-1, end-1, size};
        requests.push_back(request);
    }

    sort(requests.begin(), requests.end(),
         [](const Request& lhs, const Request& rhs){ return lhs.end < rhs.end; });

    vector<bool> bridges(N-1, false);

    for (Request request: requests) {
        auto alreadySolved = find_if(bridges.begin() + request.begin, bridges.begin() + request.end, [](bool bridge) { return bridge; });
        if (alreadySolved == bridges.begin() + request.end) {
            bridges[request.end-1] = true;
        } else {
            continue;
        }
    }

    cout << count(bridges.begin(), bridges.end(), true) << endl;

    return 0;
}

Measured memory_bytes: 1912
/*
 NOTE:
*/
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <queue>
#include <vector>
#include <map>
#include <stack>
#include <set>
#define MP make_pair
#define F first
#define S second
#define TIME (double)clock()/CLOCKS_PER_SEC
using namespace std;
typedef long long ll;

ll n;
bool a[200020][20];

int flag[20];

ll fans = 0;

bool more()
{
	for (int i = 0; i < 20; i ++)
		if (flag[i] > 1)
			return 1;
	return 0;
}

int main()
{
//	freopen("test.in", "r", stdin);
//	freopen("test.out", "w", stdout);
 	ios::sync_with_stdio(false);
 	ll cur = 1;
	cin >> n;
	for (ll i = 1; i <= n; i ++) {
		int v;
		cin >> v;
		for (int j = 0; j < 20; j ++) {
			a[i][j] = v % 2;
			flag[j] += v % 2;
			v /= 2;
		}
		while (more()) {
			for (int j = 0; j < 20; j ++)
				if (a[cur][j])
					flag[j] --;
			cur ++;
		}
		fans += i - cur + 1;
	}
	cout << fans << endl;
	return 0;
}
/*
*/



Measured memory_bytes: 4224
using System;

namespace ABC069D
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] bufs = Console.ReadLine().Split(' ');
            int H = int.Parse(bufs[0]);
            int W = int.Parse(bufs[1]);
            int N = int.Parse(Console.ReadLine());

            bufs = Console.ReadLine().Split(' ');
            int[] a = new int[N];

            for (int i = 0; i < N; i++)
            {
                a[i] = int.Parse(bufs[i]);
            }

            int cur = 0;
            string[] line = new string[W];

            for (int h = 0; h < H; h++)
            {
                if (h % 2 == 0)
                {
                    for (int i = 0; i < W; i++)
                    {
                        if (a[cur] == 0) { cur++; }
                        line[i] = (cur + 1).ToString();
                        a[cur]--;
                    }
                } 
                else
                {
                    for (int i = W - 1; i >= 0; i--)
                    {
                        if (a[cur] == 0) { cur++; }
                        line[i] = (cur + 1).ToString();
                        a[cur]--;
                    }
                }

                for (int i = 0; i < W; i++)
                {
                    if (i != 0) { Console.Write(' '); }
                    Console.Write(line[i]);
                }
                Console.WriteLine();
            }

        }
    }
}


Measured memory_bytes: 11220
#include 	<ext/pb_ds/assoc_container.hpp> 
#include 	<ext/pb_ds/tree_policy.hpp> 
#include 	<iostream>
#include 	<queue>
#include 	<tuple>
#include 	<vector>
#include	<bits/stdc++.h>
#include	<algorithm>
#include 	<cmath>
#include 	<map>
#include 	<string>
#include 	<iomanip> 
#include 	<ctype.h>
#define 	ll  long long int
#define		read(a) long long int a; cin>>a;
#define 	readstr(s) string s; cin>>s;
#define 	readc(c) char c; cin>>c;
#define 	readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define 	loop(i,a,b) for(ll i=a;i<b;i++)
#define 	rloop(i,a,b) for(ll i=a;i>b;i--)
#define 	loopchar() for(char c='a';c<='z';c++)
#define 	printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define		printv(v) for (int i: v) cout << i << " "; cout << endl;
#define 	loopitr(vec) for(auto itr=vec.begin();itr!=vec.end();itr++)
#define 	ff first
#define 	ss second
#define 	readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define 	all(a) a.begin(), a.end()
#define 	yes cout <<"YES"<<endl;
#define 	no cout <<"NO"<<endl;
#define 	sc(x) cout << (#x) << " is " << (x) << endl;
#define 	fast ios_base::sync_with_stdio(false);cin.tie(0);
#define 	pb(p) push_back(p)
#define 	mp make_pair
#define 	fsort(vec) sort(vec.begin(),vec.end())
#define 	rsort(vec) sort(vec.begin(),vec.end(),compare)
#define 	Endl endl
#define 	ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define 	roundoff std::cout << std::setprecision(15)
#define 	inf 9223372036854775807
#define 	infn -9223372036854775807
#define 	pi 3.14159265358979323846
const 		int mod = 1e9+7; 
#define 	intsize ll size = trunc(log10(num)) + 1
#define 	REVERSE(vec) reverse(vec.begin(),vec.end())
using 		namespace __gnu_pbds; 
using 		namespace std;

ll gcd (ll a, ll b) { return b ? gcd (b, a % b) : a; }
ll lcm (ll a, ll b) { return a / gcd(a, b) * b; }

//code start from here 

int main() {
	fast;
	#ifndef ONLINE_JUDGE
 	 	freopen("input.txt","r",stdin);
	  	freopen("output.txt","w",stdout);
	#endif
	read(a)
	loop(j,-125,125){
		loop(i,-125,125){
			ll p=i*i*i*i*i;
			ll l=j*j*j*j*j;
			ll sum=p-l;
			if(sum==a){
				cout<<i<<" "<<j<<endl;
				return 0;
			}
		}
	}
	return 0;
}

//ends here 

Measured memory_bytes: 3632
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#include<bitset>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	map<pair<string,string>,ll> pattern;
	string Skari;
	string S;
	ll ans=0;
	scan(N);scan(Skari);
	rep(i,N) S[i]=Skari[i];
	for(int i=N;i<2*N;i++) S[i]=Skari[3*N-i-1];
	ll bitmax=(1LL<<N);
	rep(i,bitmax){
		string s="";
		string t="";
		rep(j,N){
			if(((i>>j)&1)){
				s+=S[j];
			}
			else{
				t+=S[j];
			}
		}
		pattern[mp(s,t)]++;
	}
	rep(i,bitmax){
		string s="";
		string t="";
		rep(j,N){
			if(((i>>j)&1)){
				s+=S[j+N];
			}
			else{
				t+=S[j+N];
			}
		}
		ans+=pattern[mp(s,t)];
	}
	prin(ans);
	return 0;
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  string s;cin>>s;
  int time=0;
  char now='A';
  int nowi=0;
  while(nowi<s.size())
  {
    now=(char)(now+1);
    if(now>'Z')now='A';
    if(now=='A')time++;
    if(now==s[nowi])nowi++;
  }
  cout<<time<<endl;
}



Measured memory_bytes: 3212
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  vector<int> a(5); REP(i, 5) cin >> a[i];
  int k; cin >> k;
  cout << (a[4] - a[0] > k ? ":(" : "Yay!") << '\n';
  return 0;
}


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

int main() {
    string n;
    int k, d[5] = {}, e[5] = {0, 1};
    cin >> n >> k;
    for(auto c : n) {
        for(int i = k; i >= 0; i--) {
            d[i + 1] += d[i] * 9;
            if(c != '0')
                d[i + 1] += e[i + 1] + e[i] * (c - '1'), e[i + 1] = e[i];
        }
    }
    cout << d[k + 1] + e[k + 1] << endl;
    return 0;
}


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

using namespace std;

#ifdef LOCAL
#define err cerr
#else
#define err if (false) cerr
#endif

typedef long long ll;

const int MAXN = 55;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
   int n; string s1, s2;
    cin >> n >> s1 >> s2;
    for (int i = 0; i < n; i++)
    {
        cout << s1[i] << s2[i];
    }
}


Measured memory_bytes: 256
N = int(input())

ARR = []

for i in range(N):
    ARR.append(int(input()))


dict = {}


for ar in ARR:
    if dict.get(ar) == None:
        dict.__setitem__(ar,True)
    else:
        dict.__setitem__(ar,not dict.get(ar))

print(sum(dict.values()))

Measured memory_bytes: 16268
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef pair<Int,Int> P;

int main(){
    vector<int> X(5);
    rep(i,5){
        cin >> X[i];
        if(X[i] == 0){
            cout << i+1 << endl;
            return 0;
        }
    }

}

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

int main() {
  int N;
  cin >> N;
  vector<int> bukanum(N);
  for (int i=0; i<N-1; i++){
    int joshiID;
    cin>> joshiID;
    bukanum.at(joshiID-1)++;
  }
  for (int i=0; i<N; i++){
    cout << bukanum.at(i) << endl;
  }
  
}

Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define debug(x) cerr << #x << " " << x << endl;
#define debug_p(x) cerr << #x << " [" << x.fi << " " << x.se << "]"<<endl;
#define debug_v(x) {cerr << #x << " "; for (auto ioi : x) cerr << ioi << " "; cerr << endl;}
#define debug_vp(x) {cerr << #x << " "; for (auto ioi : x) cerr << '[' << ioi.fi << " " << ioi.se << ']'; cerr << endl;}
#define debug_v_v(x) {cerr << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cerr << ioi2 << " "; cerr << '\n';} cerr << "*/" << #x << endl;}
#define gen_clock(x) ll x = clock(); cerr << "Clock " << #x << " created" << endl;
#define check_clock(x) cerr << "Time spent in " << #x << ": " << (double)(clock() - x)/CLOCKS_PER_SEC << endl; x = clock();
#define reset_clock(x) x = clock()
 
const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
 
void solve()
{
	ll n;
	cin>>n;
	ll x=1000;
	ll a[n];
	ll t=0,m=0;
	for(ll i=0;i<n;i++)
	cin>>a[i];
	for(ll i=0;i<n-1;i++)
	{
		if(t==0)
		{
			if(a[i]<=a[i+1])
			{
				t=1;
				m=x/a[i];
				x-=m*a[i];
			}
		}
		if(t==1)
		{
			if(a[i]>=a[i+1])
			{
				t=0;
				x+=m*a[i];
				m=0;
			}
		}
	}
	if(t==1)
	{
		t=0;
		x+=m*a[n-1];
		m=0;
	}
	cout<<x;
	
	
	
	
}
 
int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main(){
  int n;
  while(cin >>n){
    int ans = 0;
    for(int i=0; i<10; i++){
      for(int j=0; j<10; j++){
	for(int l=0; l<10; l++){
	  for(int m=0; m<10; m++){
	    if(i+j+l+m == n){ans++;}
	  }
	}
      }
    }
    cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import string
import collections

N = int(input())
count = 0

s = []

for i in range(0,N):
  s.append(''.join(sorted(input())))

  
c = collections.Counter(s)
go = c.most_common()

for i in range(len(go)):
  k = go[i][1]
  count+=k*(k-1)//2
  
print(count)

Measured memory_bytes: 24760
#include<cstdio>
#include<algorithm>
#include<cstring>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
const int N=1e5+5;
typedef long long ll;
ll n;
ll a[5],b[5];
int main()
{
	scanf("%lld%lld%lld%lld",&b[1],&b[2],&b[3],&b[4]);
	scanf("%lld",&n);
	a[1]=1,a[2]=2,a[3]=4,a[4]=8;
	n*=4;
	ll ans=0;
	while (n>0)
	{
		ll m=0,s=0;
		fd(i,4,1)
		if (n>=a[i])
		{
			m=n%a[i];
			s=n/a[i];
			n=m;
			ll tmp=s*b[i],j=i;
			while (j>1)tmp=min(tmp,(s*=2)*b[j-1]),j--;
			ans+=tmp;
		}
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 128
import sys
from collections import deque
sys.setrecursionlimit(10 ** 5)
input = sys.stdin.readline
N, u, v = [int(x) for x in input().strip().split()]

m = [[] for n in range(N)]
f_aokikun = [False for n in range(N)]
f_takahashikun = [False for n in range(N)]
aokikun = [0 for n in range(N)]
takahashikun = [0 for n in range(N)]
takahashikun_enable = [1 for n in range(N)]
for n in range(N-1):
    a, b = [int(x) for x in input().strip().split()]
    m[a-1].append(b)
    m[b-1].append(a)

def aokifunc(c, f, p, cost):
    c[p-1] = cost
    f[p-1] = True
    for p_next in m[p-1]:
        if f[p_next-1]:
            continue
        aokifunc(c, f, p_next, cost+1)

def takahashifunc(c, f, p, cost, aokikun, takahashikun_enable):
    if aokikun[p-1] <= cost:
        takahashikun_enable[p-1] = 0
    c[p-1] = 0
    f[p-1] = True
    for p_next in m[p-1]:
        if f[p_next-1]:
            continue
        takahashifunc(c, f, p_next, cost+1, aokikun, takahashikun_enable)

aokifunc(aokikun, f_aokikun, v, 0)
takahashifunc(takahashikun, f_takahashikun, u, 0, aokikun, takahashikun_enable)
print(max([i * j for i, j in zip(aokikun, takahashikun_enable)])-1)

Measured memory_bytes: 136140
N=[]
T=[]
while True:
    n = input().split()
    for e in n:
        N += [int(e)]
    if len(n) == 1 and N[-1] == 0:
        break

T += [N.pop(0)]
while T[-1] != 0:
    T += [N.pop(sum(T)*2)]

for t in T:
    if t == 0:
        break
    A = 0
    B = 0
    f = N[:t*2]
    del N[:t*2]
    for n in range(t):
        g = 2*n
        if f[g] > f[g+1]:
            A += f[g]+f[g+1]
        elif f[g] < f[g+1]:
            B += f[g]+f[g+1]
        else:
            A += f[g]
            B += f[g+1]
    print (A,B)



Measured memory_bytes: 6136
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
#define F first
#define S second
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<ll> s(n+1);
  rep(i,n){
    s[i+1]=s[i]+a[i];
  }
  map<ll,ll> mp;
  rep(i,n+1){
    mp[s[i]]++;
  }
  ll ans = 0;
  for(auto p:mp){
    ll b = p.second;
    ans += b*(b-1)/2;
  }
  cout << ans << endl;
}



Measured memory_bytes: 17844
import java.util.Scanner;
class Main {
    public   static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        String text = sc.next();
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            String op = sc.next();
            if (op.equals("replace")) {
                int a = sc.nextInt() ;
                int b = sc.nextInt() ;
                String p = sc.next();
                String newText = "";
                newText = text.substring(0,a);
                 newText += p;
                 newText += text.substring(b+1,text.length());
                text = newText;
            }else if(op.equals("reverse")){
                String p = "";
                String newText = "";
                int a = sc.nextInt();
                int b = sc.nextInt();
                for (int j = b; j >= a; j--) {
                    p += text.charAt(j);
                }
                newText = text.substring(0,a);
                newText += p;
                newText += text.substring(b+1,text.length());
                text = newText;
            }else if(op.equals("print")){
                int a = sc.nextInt(); int b = sc.nextInt();
                for (int j = a; j <= b; j++) {
                    System.out.print(text.charAt(j));
                }
                System.out.println();
            }
        }
                
    }

}


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



int main(){
	
	int x; cin>>x;
	const int  s = 1e3;
	vector<ll> b(s*2+1);
	for(int i=0; i<=2*s; i++){
		b.at(i) = pow(i-s,5);
	}
	for(ll i=s*-1; i<=s; i++){
		ll y = pow(i,5)+x;
		//cout << y << endl;
		auto it1 = lower_bound(b.begin(),b.end(),y);
		auto it2 = upper_bound(b.begin(),b.end(),y);
		if(it1!=b.end()&&it1+1==it2){
			cout << it1-b.begin()-s<<' '<<i<<endl;
			return 0;
		}
		
		
	}
}

Measured memory_bytes: 4104
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;
 
int N;
ll A,B,h[Nmax]={};
ll mac=0,cnt,ans=0;
 
bool judge(ll imid){ //imid:answer候補
  	cnt=0;
	REP(i,N) cnt+=max((ll)0,(ll)ceil((double)(h[i]-imid*B)/(A-B)));
	if(cnt<=imid) return true;
	else return false;
}
ll b_search(ll imin, ll imax){
	if(imax < imin){
		return -1;
	}else if(imax-imin<=1) return imax;
     else{
		ll imid = ceil((double)(imax+imin)/2);
        //ll imid = (imax+imin)/2;
		if(judge(imid)){
			return b_search(imin,imid);
		}else return b_search(imid,imax);
	}
}
 
int main() {
	cin >> N >> A >> B;
	REP(i,N){
		cin >> h[i];
		mac=max(mac,h[i]);
	}
	ans=b_search(0,ceil((double)mac/B));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
MOD = 1000003

def mypow(a,m)
#	return a**m % MOD if m < 4
	c ,res = a, 1
	while(m>0);res = res * c % MOD if m.odd?;c, m = c * c % MOD, m >> 1;end
	return res
end

def modinv(a) mypow(a, MOD-2) end
	
r = 1 ;fac = 1.upto(MOD).map { |x| r = r * x % MOD }.unshift(1)
finv = []; finv[MOD-1] = MOD - 1;
(MOD-2).downto(0) { |i| finv[i] = finv[i+1] * (i+1) % MOD}

gets
$<.read.split.map(&:to_i).each_slice(3) do |x,d,n|
	if d.zero?
		p mypow(x,n)
	elsif MOD <= n - 1 + a = modinv(d) * x % MOD or x.zero? 
		p 0
	else
		p fac[a+n-1] * finv[a] % MOD * x % MOD * mypow(d,n-1) % MOD
	end
end




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

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

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint fact(int n){
	static vector<mint> memo={1};
	if(memo.size()<=n){
		int k=memo.size();
		memo.resize(n+1);
		for(;k<=n;k++) memo[k]=memo[k-1]*k;
	}
	return memo[n];
}

int main(){
	int n; scanf("%d",&n);
	vector<int> x(n);
	rep(i,n) scanf("%d",&x[i]);

	mint ans=0,sum=0;
	rep(i,n-1){
		sum+=fact(n-1)/(i+1);
		ans+=sum*(x[i+1]-x[i]);
	}
	printf("%d\n",ans.to_int());

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>

int main(){

    int W,H,x,y,r;

    std::cin >> W >> H >> x >> y >> r;

    if( ((x-r) >= 0) && ((x+r) <= W) && ((y-r) >= 0) && ((y+r) <= H) ){
        std::cout << "Yes" << std::endl;
    }
    else{
        std::cout << "No" << std::endl;
    }

}


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

namespace AOJ
{
  class Program
  {
    public static void Main(string[] args)
    {
      foreach (var h in ReadNumbers(10).OrderBy(x => x).Reverse().Take(3))
        Console.WriteLine(h);
    }

    static IEnumerable<int> ReadNumbers(int n)
    {
      foreach (var i in Enumerable.Range(0, n))
        yield return int.Parse(Console.ReadLine());
    }
  }
}

Measured memory_bytes: 6404
#include <bits/stdc++.h>
template<typename T1, typename T2>
inline bool cmn (T1& a, T2 b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<typename T1, typename T2>
inline bool cmx (T1& a, T2 b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int h, w, n;
  std::cin >> h >> w >> n;
  std::vector<int> obj(h, w);
  for (int i = 0; i < n; i++) {
    int x, y; std::cin >> x >> y;
    x--; y--;
    cmn(obj.at(x), y);
  }
  int ret = h, right = 1;
  for (int i = 1; i < h; i++) {
    if (obj.at(i) < right) {
      ret = i;
      break;
    }
    if (right < obj.at(i)) {
      right++;
    }
  }
  std::cout << ret << std::endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>

int main()
{
	int w,n;

	char c;

	std::cin >> w >> n;

	std::vector<int> a(n);

	std::vector<int> b(n);

	std::vector<int> x(w);

	for(int i=0;i<n;++i)
	{
		std::cin >> a[i] >> c >> b[i];
	}

	for(int i=0;i<w;++i)
	{
		x[i]=i+1;
	}

	for(int i=0;i<n;++i)
	{
		int temp = x[a[i]-1];

		x[a[i]-1]=x[b[i]-1];

		x[b[i]-1]=temp;
	}

	for(int i=0;i<w;++i)
	{
		std::cout << x[i] << '\n';
	}
}

Measured memory_bytes: 1192
#include<iostream>
using namespace std;
int main(){
	long long int n,m,sum=0;
	cin>>n>>m;
	if(n*2<=m){
		sum+=n;
		m-=n*2;
		sum+=m/4;
	}else{
		sum=m/2;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define mid (tl+tr)/2
#define mod 1000000007
#define fain(arr) for(int i=0;i<n;i++)cin>>arr[i];
#define all(x) x.begin(),x.end()
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bugv(n1) if(DEBUG)cout<<#n1<<" is "<<n1<<'\n';
#define buga(A) cout<<#A<<" is :"<<endl ; for(auto x:A)cout<<x<<" "; cout<<endl;
#define FILE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define endl '\n'
#define ll long long 
#define pii pair<int,int>
#define pll pair<long long ,long long >
#define pi acos(-1)
#define sz(x) ((int)x.size())
#define clr(x) memset(x, 0, sizeof(x))
#define init(x, a) memset(x, a, sizeof(x))
#define DEBUG true
using namespace std;

int main(){
	// FILE;
	SPEED;
	int n,m;
	cin>>n>>m;

	cout<<(n*(n-1)/2)+(m*(m-1)/2)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <deque>

using namespace std;

int main()
{
    int t[5];
    for (int i=0;i<5;++i) {
        cin >> t[i];
    }

    sort(t, t+5, [](int l,int r){ return (10 - l%10)%10 < (10 - r%10)%10;});

    int sum = 0;
    for (int i=0;i<4;++i) {
        sum += (t[i] + 9) / 10 * 10;
    }
    sum += t[4];
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

vector<LL> A;

LL final(LL c) {
	FOR (i, A.sz)
		c -= c % A[i];

	return c;
}

int main() {
	int N;
	cin >> N;
	int x;
	FOR (i, N) {
		cin >> x;
		A.pb(x);
	}
	
	LL s = 2LL, e = 1000000000000000001LL, mid;
	LL retMin = -1, retMax = -1;
	while (s <= e) {
		mid = (s + e) >> 1;
		LL c = final(mid);
		if (c < 2)
			s = mid + 1LL;
		else if (c > 2) {
			e = mid - 1LL;
		}
		else {
			retMin = mid;
			e = mid - 1LL;
		}
	}
	

	s = 2LL, e = 1000000000000000001LL;
	while (s <= e) {
		mid = (s + e) >> 1;
		LL c = final(mid);
		if (c < 2)
			s = mid + 1LL;
		else if (c > 2) {
			e = mid - 1LL;
		}
		else {
			retMax = mid;
			s = mid + 1LL;
		}
	}

	if (retMin != -1)
		cout << retMin << " " << retMax << endl;
	else
		cout << -1 << endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int res = 0;
  for (int i = 0; i < 10; i++) {
    if (pow(2, i) <= N) {
      res = pow(2, i);
    }
    else break;
  }
  
  cout << res << endl;
}


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

int MOD=1000000007;
int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}

auto factor(int n){
  map<int,int>res;
  for(int i=2;i*i<=n;i++){
      for(; n%i==0;n/=i) res[i]++;
  }
  if(n>1)res[n]++;
  return res;
}
////////////////////////////////////////////////////////////

signed main() {
  int n;
  cin>>n;
  vector<vector<int>>v(n,vector<int>(0));

  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }

  vector<int>ds(n,-1);
  ds[0]=0;
  queue<int>q;
  q.push(0);
  while(!q.empty()){
    int t=q.front();
    q.pop();
    rep(i,v[t].size()){
      if(ds[v[t][i]]==-1){
        q.push(v[t][i]);
        ds[v[t][i]]=ds[t]+1;
      }
    }
  }
  vector<int>dg(n,-1);
  dg[n-1]=0;
  q.push(n-1);
  while(!q.empty()){
    int t=q.front();
    q.pop();
    rep(i,v[t].size()){
      if(dg[v[t][i]]==-1){
        q.push(v[t][i]);
        dg[v[t][i]]=dg[t]+1;
      }
    }
  }
  int sunuke=0,fennec=0;
rep(i,n){
  if(dg[i]>=ds[i]) fennec++;
  else sunuke++;
}
if(sunuke>=fennec)cout<<"Snuke"<<endl;
else cout<<"Fennec"<<endl;
}


Measured memory_bytes: 10816
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int n;cin>>n;
    ll sum = 0;
    int a[n];rep(i,n){int tmp;cin>>tmp;sum+=tmp-1;}
    co(sum);
}

Measured memory_bytes: 256
/*Made by Shivam Solanki*/
#include<bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define ll long long int
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<pii> vp;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef set<int> sii;
typedef set<ll> sll;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
#define rep(i,k,n) for (int i = k; i < n; ++i) 
#define repr(i,k,n) for (int i = n; i>=k; --i)
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define repll(i,k,n) for (ll i = k; i < n; ++i) 
#define pb push_back
#define mp make_pair
#define __gcd gcd
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int INF = 1e9+5;
const int MOD = 1e9+7;

void solve(){
    int a,b;
    cin>>a>>b;
    int res=a-(2*b);
    cout<<(res<0?0:res);
}

int main(){
    // #ifndef ONLINE_JUDGE  
        // freopen("input.txt", "r", stdin); 
        // freopen("output.txt", "w", stdout); 
    // #endif 
    // fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 256