akhauriyash/Code-Regression huggingface dataset:
void main()
{
    long n = rdElem;
    long[] a = rdRow;

    long q = rdElem;
    foreach (i; 0 .. q)
    {
        long p = rdElem;
        long r = a.binSrch!"a <= b"(p);
        if (r != -1 && a[r] == p) 1.writeln;
        else 0.writeln;
    }
}

long binSrch(alias pred = "a < b")(long[] arr, long val)
{
    alias predFun = binaryFun!pred;
    long l = -1, r = arr.length;
    if (!predFun(l, r)) swap(l, r);
    while (abs(r - l) > 1)
    {
        long m = (l + r) / 2;
        if (predFun(arr[m], val)) l = m;
        else r = m;
    }
    return l;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
#define Size(n) (n).size()

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}
//long long int ruizyo(long long int aa, long long int bb){
  //  if(aa==0){
    //    return 1;
    //}
    //else if(aa%2==0){
      //  long long int tt=ruizyo(aa/2,bb);
        //return (tt*tt)%MOD;
    //}
    //else{
      //  return (ruizyo(aa-1,bb)*bb)%MOD;
    //}
//}フェルマ－のア


//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

//visited=vector<vector<bool>>(10,vector<bool>(10,false));アを全部falseに


long long int n,cnt=0,ans=0,a[10000000],b,c,cmp[10000000],cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;

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

       cin >> n;
       rep(i,n){cin>>a[i];
           if(a[i]==0){
               cmp[0]++;
           }
           else{
               cmp[a[i]]++;
               cmp[a[i]-1]++;
               cmp[a[i]+1]++;
           }
       }
       sort(cmp,cmp+10000000);
       reverse(cmp,cmp+10000000);
       Cout(cmp[0]);
       
       
return 0;
}


Measured memory_bytes: 80128
#include <iostream>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
const ll MAX_N=100,MOD=1e9+7;
//dpで解く。n番目の文字を決めるにあたって重要なのはそれより前の3文字分の情報だけである
//dp[n][m]=長さnで問題の条件を満たすもので最後の3文字がm(A,C,G,Tをそれぞれ0,1,2,3とみなし、文字列を4進数の整数にエンコードしたもの)となる文字列の個数
//と定義する
ll N,dp[MAX_N+1][4*4*4],agc[3]={0,2,1};
bool isagc(ll *ary){
    //aryはある文字列のACGTを数字で置き換えた配列
    //部分文字列にAGCを含みか判定する
    REP(i,2){
        bool flg=true;
        REP(j,3){
            if(ary[i+j]!=agc[j]){
                flg=false;
            }
        }
        if(flg)
            return true;
    }
    return false;
}
bool chk(ll m){
    //mは長さ4文字の文字列をエンコードしたもの
    //mが条件を満たしているか判定する
    ll ary[4];  //mをデコードする
    REP(i,4){
        ary[3-i]=m%4;
        m/=4;
    }
    //AGCを含むか判定する
    if(isagc(ary)){
        return false;
    }
    ll ary2[4];
    //swapしてもAGCを含まないか判定する
    REP(i,3){
        REP(j,4){
            ary2[j]=ary[j];
        }
        swap(ary2[i],ary2[i+1]);
        if(isagc(ary2)){
            return false;
        }
    }
    return true;
}
int main(){
    cin>>N;
    ll pw4=4*4*4;
    //dpテーブル初期化
    REP(i,4*4*4){
        if(i==0*16+2*4+1 || i==0*16+1*4+2 || i==2*16+0*4+1)continue;    //条件を満たさない文字列
        dp[3][i]=1;
    }
    //配るdp
    FOR(i,3,N){
        REP(j,4*4*4){
            //dp[i][j]からの遷移を考える
            REP(k,4){
                //k=i+1番目の文字
                if(chk(j*4+k)){
                    //kをi+1番目の文字にしてもokなら
                    ll j2=(j*4+k)%pw4;    //遷移先の状態
                    dp[i+1][j2]+=dp[i][j];
                    dp[i+1][j2]%=MOD;
                }
            }
        }
    }
    ll ans=0;
    REP(i,4*4*4){
        ans+=dp[N][i];
        ans%=MOD;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<functional>
#include<algorithm>
#include<stack>
#include<queue>
#include<iomanip>
#include<set>
#include<map>
#include<utility>
#include<string>
#include<vector>

using namespace std;

#define LL long long
const int dx[4] = { 1,-1,0,0 };
const int dy[4] = { 0,0,1,-1 };
bool OOA(int x, int y, int H, int W) { return (0 <= x && x<H) && (0 <= y && y<W); }

int k;
int Q[8];
pair<int,int>fq[8];

int main() {
	cin>>k;
	for(int i=0;i<8;i++)Q[i]=-1;
	for(int i=0;i<k;i++){
		int r,c;
		cin>>r>>c;
		fq[i].first=r;
		fq[i].second=c;
		Q[r]=c;
	}
	int rc[8]={0,1,2,3,4,5,6,7};
	while(next_permutation(rc,rc+8)){
		bool flg=false;
		for(int i=0;i<k;i++){
			flg|=(rc[fq[i].first]!=fq[i].second);
			if(flg)break;
		}
		if(flg)continue;
		set<int>dd,ud;
		for(int i=0;i<8;i++){
			dd.insert(i-rc[i]);
			ud.insert(i+rc[i]);
		}
		if(dd.size()+ud.size()!=16)continue;
		for(int i=0;i<8;i++){
			for(int j=0;j<8;j++){
				if(rc[i]==j)cout<<'Q';
				else cout<<'.';
			}
			cout<<endl;
		}
		break;
	}

	return 0;
}



Measured memory_bytes: 3116
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;

const ll MAXN = (ll)2e3+10;
const ll DIV = (ll)1e9+7;


int main(void) {
   ll N;
   cin>>N;
   string S;
   cin>>S;
   vector<int> ar(2*N);
   if (S[0]=='W' || S[2*N-1]=='W') {
      cout<<0<<endl;
      return 0;
   }
   ar[0] = 1;
   ar[2*N-1] = -1;
   rep(i,1,2*N) {
      if (S[i] == S[i-1]) {
         if (ar[i-1]==1) ar[i]=-1;
         else ar[i]=1;
      } else {
         if (ar[i-1]==1) ar[i] = 1;
         else ar[i] = -1;
      }
   }
   // rep(i,0,2*N) cout<<ar[i]<<endl;

   ll sum = 0;
   rep(i,0,2*N) sum+=ar[i];
   if (sum!=0) {
      cout<<0<<endl;
      return 0;
   }
   ll ans = 1;
   ll tmp = 0;
   for(int i = 2*N-1;i>=0;i--) {
      if (ar[i]==-1) {
         tmp++;
      } else {
         ans *= tmp;
         ans = ans%DIV;
         tmp--;
      }
   }
   // cout<<ans<<endl;
   rep(i,1,N+1) {
      ans *= i;
      ans = ans%DIV;
   }
   cout<<ans<<endl;

   return 0;
}

Measured memory_bytes: 1412
N = int( input())
S = input()
C = [0]*(N+1)
for i in range(N):
    if S[i] == ".":
        C[i+1] = C[i]
    else:
        C[i+1] = C[i] + 1
b = C[N]
w = N - b
ans = w
for i in range(N):
    if C[i+1] + N - i - 1 -b + C[i+1] < ans:
        ans = C[i+1] + N - i - 1 -b + C[i+1]
print(ans)


Measured memory_bytes: 11144
//13, 04, 2019, 09:03:00 Rafaelcs cpp
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

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

    string s;

    cin >> s;

    int cnt1 = 0, cnt2 = 0;

    for(int i = 0 ; i < s.length() ; i++){
        if(s[i] == '1' && (i & 1)){
            cnt1++;
        }else if(s[i] == '0' && !(i & 1)){
            cnt1++;
        }
    }

    for(int i = 0 ; i < s.length() ; i++){
        if(s[i] == '1' && !(i & 1)){
            cnt2++;
        }else if(s[i] == '0' && (i & 1)){
            cnt2++;
        }
    }

    cout << min(cnt1, cnt2) << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
#define rep(i , m , n) for(int i=m;i<n;++i)
	
int main(){
	rep(i , 1 , 10){
		rep(j , 1 , 10){
			cout << i << 'x' << j << '=' << i*j << endl;
		}
	}
	return 0; 
}

Measured memory_bytes: 1120
#include <stdio.h>

int main() {
	int a, b, c;
	
	scanf("%d %d %d", &a, &b, &c);

	int d = a - b;
	int e = a - c;
	
	if(d < 0) {		
		d *= -1;
	}
	
	if(e < 0) {
		e *= -1;	
	}

	
	if(d < e) {
		printf("A\n");
	}
	else if (e < d) {
		printf("B\n");
	}
	return 0;
}

Measured memory_bytes: 1604
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <queue>
#define ll long long
using namespace std;

int main(){
    ll X;
    cin>>X;
    if(X>=30) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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


int main(){
	
	int n,k;
	cin>>n>>k;
	vector<long long> hel(n);
	for(int i=0;i<n;i++){
		cin>>hel[i];
	}
	sort(hel.begin(),hel.end());
	
	long long sum=0;
	int go = 0;
	while(go<(n-k)){
		sum += hel[go++];
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long 
#define all(v) v.begin() , v.end()
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define tr(con) for(auto it = con.begin(); it!= con.end() ; it++)
#define INF 1e9+7   // 1 * 10^9+ 7
using namespace std;

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n ; cin >> n ;
	int p[n] ;
	for(int i=0;i<n;i++) cin >> p[i];
	int ans =0;
	for(int i=1;i<=n-2;i++){
		if((p[i] > p[i-1] && p[i]<p[i+1])  || (p[i]<p[i-1] && p[i]>p[i+1])) ans++;
	}	
	cout<< ans;
	return 0;
}


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



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s;
    cin >> s;
    long long ans = 0;
    int cur = 0;
    for(int i = 0; i < (int)s.size(); i++){
        if(s[i] == 'W'){
            ans += i - cur;
            cur += 1;
        }
    }
    cout << ans;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF = 0x1fffffffffffffff;
int main(){
    ll n;
    cin>>n;
    ll a[n][3];
    for(ll i=0;i<n;i++)cin>>a[i][0]>>a[i][1]>>a[i][2];
    vector<vector<ll>> dp(n,vector<ll>(3,INF));
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for(ll i=1;i<n;i++){
        for(ll j=0;j<3;j++){
            if(j==0){
                dp[i][j]=max(dp[i-1][1]+a[i][j],dp[i-1][2]+a[i][j]);
            }else if(j==1){
                dp[i][j]=max(dp[i-1][0]+a[i][j],dp[i-1][2]+a[i][j]);
            }else{
                dp[i][j]=max(dp[i-1][1]+a[i][j],dp[i-1][0]+a[i][j]);
            }
        }
    }
    ll ans;
    ans=max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
    cout<<ans<<endl;
}

Measured memory_bytes: 8064
fun main(args: Array<String>) = abc157c()

fun abc157c() {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val scList = (1..m).map { readLine()!!.split(' ').map { it.toInt() }.let { Pair(it[0], it[1]) } }

    val number = IntArray(n) { -1 }

    for (sc in scList) {
        val (s, c) = sc
        if (number[s - 1] != -1 && number[s - 1] != c) return println(-1)
        number[s - 1] = c
    }

    if (n >= 2 && number[0] == 0) return println(-1)

    if (n >= 2 && number[0] == -1) number[0] = 1

    val answer = number.joinToString("") { (if (it == -1) 0 else it).toString() }

    println(answer)
}


Measured memory_bytes: 36512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  rep(i, 10000000){
    if((b*i+c)%a == 0){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3636
n, m = gets.split.map(&:to_i)
bulbs = {}
m.times do |i|
  tmp = gets.split.map(&:to_i)
  tmp.shift
  bulbs[i+1] = { switches: tmp }
end
ps = gets.split.map(&:to_i)

ps.each.with_index(1) do |p, i|
  bulbs[i][:p] = p
end

sw = {}
n.times do |i|
  sw[i+1] = false
end

ans = 0
(0..("1" * n).to_i(2)).each do |i|
  bit = i.to_s(2).rjust(n, '0')
  on_off = bit.chars.map{|j| j == '1' }

  on_off.each.with_index(1) do |bool, i|
    sw[i] = bool
  end

  flg = true
  m.times do |j|
    on_count = bulbs[j+1][:switches].count{|s| sw[s]}
    if on_count % 2 != bulbs[j+1][:p]
      flg = false
    end
  end

  ans += 1 if flg
end

puts ans


Measured memory_bytes: 14296
nn,m=map(int,input().split())
sc=[list(map(int,input().split()))for _ in range(m)]
def check(n):
  ss=str(n)
  if len(ss)!=nn:return False
  for s,c in sc:
    if ss[s-1]!=str(c):return False
  return True
for i in range(1000):
  if check(i):print(i);exit()
print(-1)

Measured memory_bytes: 3060
parseInt(x) = parse(Int, x)
parseBig(x) = parse(BigInt, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
parseMapB(x::Array{SubString{String},1}) = map(parseBig, x)

const MOD=1000000007
function modcmb(n,r)
    res::BigInt=1
    d::Int=min(r,n-r)
    for i in 0:d-1
        res=res*(n-i)*powermod(d-i,MOD-2,MOD)%MOD
    end
    return res%MOD
end

function main()
    n,a,b=parseMapB(split(readline()))
    ans::BigInt=mod(powermod(2,n,MOD)-1-modcmb(n,a)-modcmb(n,b),MOD)
    println(ans%MOD)
end
main()

Measured memory_bytes: 298280
#include <bits/stdc++.h>
#define debug(x) cout << #x << ": " << x << endl;
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;
typedef long long ll;
//ll power_mod(ll a, ll k){ll ans = 1;a %= MOD;while(k){if(k % 2) ans *= a;a = (a * a) % MOD;k /= 2;ans %= MOD;}return ans;}
//ll power(ll a, ll k){ll ans = 1;while(k){if(k % 2)ans *= a;a = a * a;k /= 2;}return ans;}
//ll CalcAppNum(ll n){ll ans = 0;for(ll i=1,j; i<=n; i=j+1) {j = min(n, n / (n/i));ans += (j - i + 1) *(n/i);}return ans;}    //计算1-n约束个数和
template<class T>inline void read(T &res) {char c;T flag=1;while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;}
template<class T>inline void prin(T x) {if(x>9)prin(x/10);putchar(x%10+'0');}
const int MOD = 2333;
const int MAX = 1e7;
const int MAXN = 1e7+10;
const int inf = 2e5 + 100;
long double PI =3.14159265358979323846;
//INT_MAX

int main()
{
    int n;
    string ch1, ch2;
    cin >> n;
    cin >> ch1 >> ch2;
    for(int i=0; i<n; i++) cout << ch1[i] << ch2[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

  
s=int(input())
n=int(s/3)
g=0
for i in range(n):
  if i==0:
    g=g+1
  else:
    S=s-3*(i+1)
    x=i
    y=S+x
    g=g+cmb(y,x)
  
g=g%1000000007
print(g)

Measured memory_bytes: 9612
import math
A, B = map(int, input().split())
Al = math.ceil(A / 0.08)
Au = int((A + 0.99) // 0.08) + 1
Bl = math.ceil(B / 0.1)
Bu = int((B + 0.9) // 0.1) + 1
Ar = [x for x in range(Al, Au)]
Br = [y for y in range(Bl, Bu)]
X = set(Ar) & set(Br)
print(-1 if list(X) == [] else min(X))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000000LL;
const int MAX=100001;
const double EPS=1e-10;
int main(){
    int n;
    cin>>n;
    int a[100010];
    int ans=0;
    a[0]=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        ans+=abs(a[i]-a[i-1]);
    }
    a[n+1]=0;
    ans+=abs(a[n+1]-a[n]);
    for(int i=1;i<=n;i++){
        int s=ans;
        ans+=abs(a[i+1]-a[i-1]);
        ans-=abs(a[i-1]-a[i]);
        ans-=abs(a[i+1]-a[i]);
        cout<<ans<<endl;
        ans=s;
    }
    
    
}


Measured memory_bytes: 1664
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    cin >> N;
    write((double)((N + 1) / 2) / N);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back 
#define lb lower_bound 
#define lowbit(x) (x)&(-x)   
#define forup(i,a,b) for(int i=(a);i<=(b);i++)  
#define fordown(i,a,b) for(int i=(a);i>=(b);i--)  
#define maxn 1000005
#define INF 107000000 
#define mod 997
using namespace std;  
typedef long long ll;  
typedef unsigned long long ull;  
    
template<class T> inline  void read(T& num){   num = 0; bool f = true;char ch = getchar();   while(ch < '0' || ch > '9') { if(ch == '-') f = false;ch = getchar();}   while(ch >= '0' && ch <= '9') {num = num * 10 + ch - '0';ch = getchar();}   num = f ? num: -num;  } 
int out[100]; 
template<class T> inline
void write(T x,char ch){  if (x==0) {putchar('0'); putchar(ch); return;}  if (x<0) {putchar('-'); x=-x;} int num=0; while (x){ out[num++]=(x%10); x=x/10;} fordown(i,num-1,0) putchar(out[i]+'0'); putchar(ch); } 
/*=======================================================*/
int cnt[maxn];
int n,q;
int main()
{ cin>>n>>q;
 forup(i,1,q)
  { int x,y; read(x);read(y);
   cnt[x]++;cnt[y]++;
  }
  forup(i,1,n)
  { if(cnt[i]&1) { puts("NO");return 0;}} 
 puts("YES");
return 0;	
} 

Measured memory_bytes: 640
#include <iostream>
using namespace std ;
int main() {
  int h,n,i,s ;
  int arr[200000] ;
  cin>> h>> n;
  s=0;
  for(i=1;i<=n;i++){
    cin>> arr[i];
    s=s+arr[i] ;
  }
  if (s>=h){
    cout<<"Yes" ;
  }
  else{
    cout<< "No" ;
  }
}

Measured memory_bytes: 640
n,t=map(int,input().split())
l=[]
for i in range(n):
    l.append([j for j in map(int,input().split())])
    
a=1001
for i in l:
    if i[1] <= t and i[0] < a:a=i[0]
if a > 1000:
    a = 'TLE'
print(a)

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

int main(){
  int sets, sum = 0;
  cin >> sets;
  
  int start, end;
  rep(i, sets){
    cin >> start >> end;
    sum += end - start + 1;
  }
  
  cout << sum << endl;
}
    
    

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

using namespace std;

const int NMAX = 1e5;

int N;
int h[NMAX + 5], dp[NMAX + 5];

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

    dp[1] = 0;
    dp[2] = abs(h[1] - h[2]);
    for(int i = 3; i <= N; i++)
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i - 2] - h[i]));
    
    cout << dp[N];

    exit(0);
}

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

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

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;


int main(){
  double d,t,s;
  cin >> d >> t >> s;
  
  if(d/s<=t) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vi vector<ll>
#define pb push_back
#define F first
#define S second
#define all(v) (v).begin(),(v).end()
#define pii pair<ll,ll>
#define vii vector<pii>
#define MOD 1000000007LL
#define calc_fact(n) tgamma(n+1)


signed main()
{
    FIO;
    ll n;
    cin>>n;
    ll ans=n+(n*n)+(n*n*n);
    cout<<ans;
}

Measured memory_bytes: 3636
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include "bits/stdc++.h"
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 5010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int a, b;
    cin >> a >> b;
    cout << 6 - a - b;
    return 0;
}

Measured memory_bytes: 892
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;
typedef pair<ll,int> P;

int main(){
  int S,up,down,hup,hdown;
  cin>>S;
  up=S/100;
  down=S%100;
  hup=up<=12&&1<=up;
  hdown=down<=12&&1<=down;
  if(hdown!=0 && hup!=0) cout<<"AMBIGUOUS"<<endl;
  else if(hdown!=0) cout<<"YYMM"<<endl;
  else if(hup!=0) cout<<"MMYY"<<endl;
  else cout<<"NA"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;


int main(void) {
	int n, m, i, a[100003] = {};
	map<int, int> am;

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

	for (i = 1; i <= n; i++) {
		a[i] = (a[i - 1] + a[i]) % m;
	}

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

	ll ans = 0;
	map<int, int>::iterator ite;

	for (ite = am.begin(); ite != am.end(); ite++) {
		ans += (ll)(ite->second) * (ite->second - 1) / 2;
	}

	cout << ans << endl;

	return 0;
}

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


int main() {
  int n,p;
  cin >> n>>p;
  vector<int>a(n);
  rep(i,n){
    cin>>a.at(i);
  }
  vector<long>g(n);
  vector<long>k(n);
   
    rep(i,n){
      if(i==0){
        
        if(a.at(i)%2==0){
          k.at(i)=0;
          g.at(i)=2;
        }
        else{
          k.at(i)=1;
          g.at(i)=1;
        }
      }
      else  if(a.at(i)%2==0){
        g.at(i)=2LL*g.at(i-1);
        k.at(i)=2LL*k.at(i-1);
      }
      else if(a.at(i)%2!=0){
        g.at(i)=g.at(i-1)+k.at(i-1);
        k.at(i)=k.at(i-1)+g.at(i-1);
      }
      
    }
  if(p==0){
    cout<<g.at(n-1)<<endl;
  }
  else{
    cout<<k.at(n-1)<<endl;
  }
  
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
using namespace std;


int main(int argc, const char * argv[]) {
    int a = 0;
    int b = 0;
    bool flag = false;
    cin >> a >> b;

    
    for(int i = 1; i <= 1000; i++){
        int atax = i * 8 / 100;
        int btax = i * 0.1f;

        if(atax == a && btax == b){
            cout << i << endl;
            flag = true;
            break;
        }
    }

    if(!flag)cout << -1 << endl;

    return 0;
}


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

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

	int x = 0;
	char a[100];

	for (int i = 0; i < n; i++) {
		if (s[i] == 'I')x++;
		if (s[i] == 'D')x--;

		a[i] = x;
	}

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

	cout << b << endl;

	return 0;
}

Measured memory_bytes: 384
s = list(input())
t = list(input())

s.sort()
t.sort()
t.reverse()

for i in range(min(len(s),len(t))):
    if s[i] < t[i]:
        print("Yes")
        break
    elif s[i] == t[i]:
        if i == min(len(s),len(t))-1:
            if len(s) >= len(t):
                print("No")
            else:
                print("Yes")
    else:
        print("No")
        break


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(){
	int n;
	while(cin >> n, n){
		bool t[30][40];
		for(int i=0; i < 30; i++) for(int j=0; j< 40; j++) t[i][j] = false;

		vector<pair<int, string>> ret(n);
		for(int i=0; i < n; i++){
			cin >> ret[i].second;
			int m, d;
			cin >> m;
			for(int j=0; j < m; j++){cin >> d; t[i][d] = true;}
		}
		for(int i=0; i< 40; i++){
			int count = 0;
			vector<int> v;
			for(int j=0; j< n; j++) if(t[j][i]){count++; v.push_back(j);}
			for(int j=0; j< v.size(); j++) ret[v[j]].first += n-count+1;
		}
		sort(ret.begin(), ret.end());
		cout << ret[0].first << " " << ret[0].second << endl;
	}
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
#define out(x) cout<<x<<"\n";
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
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;
}


ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}
 
ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}

using namespace std;


void solve(){
  string s;
  cin>>s;
  vector<ll>sum(2e5+5);
	int n = s.size();
	int p = 2019;
	map<ll, ll> mp;
	ll mul=1;
  rep(i,n){
    sum[i+1]=sum[i]+mul*(ll)(s[n-1-i]-'0');
    sum[i+1]%=p;
    mp[sum[i+1]]++;
    mul*=10;
    mul%=p;
  }
  ll ans=mp[0];
  rep(i,n){
    ans+=mp[sum[n-i]]-1;
    mp[sum[n-i]]--;
  }
  cout<<ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 5032
#include <bits/stdc++.h>
using namespace std; 
int main(){
	long long A, B, K; 
	cin >> A >> B >> K;
	long long ans1, ans2;  
	if(K > A + B){
		ans1 = 0; ans2 = 0; 
	}
	else if(K > A){
		ans1 = 0; ans2 = B - (K-A); 
	}
	else{
		ans1 = A - K, ans2 = B; 
	}
	cout << ans1 << " " << ans2 << endl; 
}

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

string str;
int num[1080000];
int wp[1080000];
bool able(int x){
  int last = x * 9;
  for(int i = 0;i < str.size();i++)wp[i] = num[i];  
  for(int i = 0;i < str.size();i++){
    int num = wp[i];
    if(last < num)return false;
    int borrow = (last - num) / 10;
    last = num + borrow * 10;
    //if(x == 1)cout << last << " " << num << endl;
    for(int j = i+1;borrow && j < str.size() + 2;j++){
      int dig = borrow % 10;
      if(dig <= wp[j]){
	wp[j] -= dig;
	borrow /= 10;
	continue;
      }
      else{
	wp[j] = wp[j] + 10 - dig;
	borrow /= 10;
	borrow++;
      }
      if(j == str.size() + 1)return true;
    }
  }
  return true;
}

int main(){
  cin >> str;
  for(int i = 0;i < str.size();i++){
    num[str.size() - i - 1] = str[i] - '0';
  }
  int bottom = 0, top = 1080000;
  while(top - bottom > 1){
    int mid = (top + bottom) / 2;
    if(able(mid))top = mid;
    else bottom = mid;
  }
  cout << top<< endl;
  return 0;
}

Measured memory_bytes: 6916
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
using ll = long long;

using namespace std;
int main()
{/*三日目*/
//少数も使いたい割り算はしない方がいい(三日目）
// 数値の大きさ
	int h, n; cin >> h >> n;
	int ssum = 0;
	for (int i = 0;i < n;i++) {
		int sum;	cin >> sum;
		ssum += sum;
	}if (ssum >= h)
		cout << "Yes";
	else
		cout << "No";

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

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

    REP(S,1<<3){
        int result=s[0]-'0';
        REP(i,3){
            if(S>>i&1) result+=s[i+1]-'0';
            else result-=s[i+1]-'0';
        }
        if(result==7){
            string ans; ans+=s[0];
            REP(i,3){
                if(S>>i&1){
                    ans+='+';
                    ans+=s[i+1];
                }
                else{
                    ans+='-';
                    ans+=s[i+1];
                }
            }
            cout<<ans<<"=7"<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
n, x = map(int, input().split())
arr = map(int, input().split())
count = 0
for m in sorted(arr):
    x -= m 
    if x == 0:
        count += 1
        break
    elif x < 0:
        break
    else:
        count += 1
print(count - 1 if x > 0 else count)

Measured memory_bytes: 3060
<?php
  fscanf(STDIN, "%d %d", $a, $b);
  $c = $a;
  $bool = false;
  for ($i=0;$i<$a;$i++) {
      $sum = $i*2 + $c*4;
      if ($sum == $b) {
          $bool = true;
          break;
      }
      $c--;
  }
  $sum = $a*2 + 0*4;
  if ($sum == $b){
      $bool = true;
  }
  if ($bool) {
    echo 'Yes';
  } else {
    echo 'No';
  }
?>

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

ll w,h,p,num[2],ans;
vector<pair<ll,bool>>vec;

int main(){
    cin>>w>>h;
    num[0]=h+1;
    num[1]=w+1;
    rep(i,w+h){
        cin>>p;
        vec.push_back({p,i<w});
    }
    sort(vec.begin(),vec.end());
    rep(i,w+h){
        ll cost=vec[i].first;
        bool b=vec[i].second;
        ans+=num[!b]*cost;
        num[b]--;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6512
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {

    int w, h, n, sum, x, y, nx, ny, diffh;
    scanf("%d %d %d", &w, &h, &n);
    sum = 0;
    scanf("%d %d", &x, &y);
    for (int i = 1; i < n; i++) {
        scanf("%d %d", &nx, &ny);
        if (ny >= y && nx >= x) {
            diffh = ny-y;
            if (nx <= x + diffh) sum+=diffh;
            else sum+=diffh+nx-(x+diffh);
        }
        else if (ny <= y && nx <= x) {
            diffh = y-ny;
            if (nx >= x-diffh) sum+=diffh;
            else sum+=diffh+(x-diffh-nx);
        }
        else {
            sum+= abs(x-nx)+abs(y-ny);
        }
        x = nx, y = ny;
    }
    printf("%d\n", sum);
    return 0;
}



Measured memory_bytes: 2736
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mod 1000000007 
int main()
{  
	ll x;
	cin>>x;
	ll sum[100000];
	memset(sum,0,sizeof(sum));
	ll i;
	sum[0]=100;
	for(i=1;i<=100000;i++)
	{
		sum[i]=sum[i-1]+sum[i-1]/100;
		if(sum[i]>=x)
			break;
	}
	cout<<i;
}

Measured memory_bytes: 4416
n = int(input())
pt,px,py = 0, 0, 0

for _ in range(n):
  ct,cx,cy = map(int,input().split())
  t = ct - pt
  d = abs(cx-px) + abs(cy-py)
  if t < d or (t%2) != (d%2):
    print('No')
    break
  pt,px,py = ct,cx,cy
else:
  print('Yes')

Measured memory_bytes: 9120
#include <iostream>
#include <string>

using namespace std;

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

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

    RPT(i, 26) {
        RPT(j, 15) {
            if (4*i + 7*j > 100) break;
            if (4*i + 7*j == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

const ll mod = 1000000007;

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

    int N;
    cin >> N;
    ll A[N], B[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }

    sort(A, A+N);
    sort(B, B+N);

    ll ans = 1LL, a = 0, b = 0;
    for (int i = 0; i < 2 * N; i++) {
        // cout << a << " " << b << " " << ans << endl;
        if ((b == N) || (a < N && A[a] < B[b])) {
            if (a < b) {
                ans = ans * (b - a) % mod;
            }
            a++;
        } else {
            if (b < a) {
                ans = ans * (a - b) % mod;
            }
            b++;
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	static int APoints = 0;
	static int BPoints = 0;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String strA;
		String strB;

		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			strA = sc.next();
			strB = sc.next();
			calcPoints(strA, strB);
		}
		System.out.println(APoints + " " + BPoints);

	}

	static void calcPoints(String strA, String strB) {
		boolean isBiggerA = false;
		boolean isBiggerB = false;
		boolean isEqual = false;
		int length;
		if (strA.length() > strB.length()) {
			length = strB.length();
		} else {
			length = strA.length();
		}
		for (int i = 0; i < length; i++) {
			if (strA.charAt(i) > strB.charAt(i)) {
				isBiggerA = true;
				break;
			} else if (strA.charAt(i) < strB.charAt(i)) {
				isBiggerB = true;
				break;
			}

		}
		if ((isBiggerA == false) && (isBiggerB == false)) {
			if (strA.length() > strB.length()) {
				isBiggerA = true;
			} else if (strA.length() < strB.length()) {
				isBiggerB = true;
			} else {
				isEqual = true;
			}
		}

		if (isBiggerA) {
			APoints += 3;
		} else if (isBiggerB) {
			BPoints += 3;
		} else if (isEqual) {
			APoints++;
			BPoints++;
		}
	}
}

Measured memory_bytes: 30344
#include <iostream>
#include <string>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
//typedef long long unsigned int ll;
typedef long long ll;
typedef pair<ll, ll> edge;
typedef tuple<ll, ll, ll> tp;

int main() {
  ll n;
  cin >> n;
  ll a[n];
  for (int i=0; i<n; i++) cin >> a[i];
  
  ll mx = a[0];
  for (int i=1; i<n; i++){
    mx = max(a[i], mx);
    if (mx - a[i] >= 2){
      cout << "No" << endl;
      exit(0);
    }
  }
    
  cout << "Yes" << endl;
}

Measured memory_bytes: 1024
N = int(input())
F = [tuple(map(int,input().split())) for i in range(N)]
P = [tuple(map(int,input().split())) for i in range(N)]

ans = -10**18
for b in range(1,2**10):
    tmp = 0
    for i in range(N):
        c = 0
        for k in range(10):
            if b&(1<<k) and F[i][k]:
                c += 1
        tmp += P[i][c]
    ans = max(ans,tmp)
print(ans)

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


struct UnionFind {
    std::vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

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

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

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

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


int main() {
    using namespace std;

    int N, M, K;
    cin >> N >> M >> K;

    UnionFind graph(N);

    vector<int> follow_count(N);
    vector<vector<int>> block(N);

    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        follow_count[a]++;
        follow_count[b]++;

        graph.unite(a, b);
    }
    for (int i = 0; i < K; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        block[a].push_back(b);
        block[b].push_back(a);
    }

    vector<int> size(N, 0);
    for (const auto p : graph.par) {
        size[graph.root(p)]++;
    }

    for (int i = 0; i < N; i++) {
        int connected_size = size[graph.root(i)];
        int ans = connected_size - follow_count[i] - 1;
        for (const auto b : block[i]) {
            if (graph.same(i, b)) ans--;
        }

        cout << ans << " ";
    }

    return 0;
}


Measured memory_bytes: 7552
s = input()
n = len(s)
A = [0]*(n+1)

for i in range(n):
    if s[i] == '<':
        A[i+1] = A[i]+1
for i in reversed(range(n)):
    if s[i] == '>':
        A[i] = max(A[i+1]+1, A[i])
print(sum(A))

Measured memory_bytes: 23336
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
typedef long long lint;

namespace utils{
	template <class T> inline void apn(T &x,const T y){x>y?x=y:0;}
	template <class T> inline void apx(T &x,const T y){x<y?x=y:0;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

int main(){
	int n=nxi(),lim=nxi(),lst=nxi();
	lint ans=std::max(0,lst-lim);
	apn(lst,lim);
	for(int i=2; i<=n; ++i){
		int x=nxi();
		if(x+lst>lim){
			ans+=x+lst-lim;
			lst=lim-lst;
		}
		else lst=x;
	}
	printf("%lld\n",ans);
	return 0;
}


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

int main(void){
  int A, B, C;
  cin >> A >> B >> C;
  if(A == B && A == 5 && C == 7)
    cout << "YES" << "\n";
  else if(A == C && A == 5 && B == 7)
    cout << "YES" << "\n";
  else if(B == C && B == 5 && A == 7)
    cout << "YES" << "\n";
  else
    cout << "NO" << "\n";
  return 0;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;};
void qmod(ll &a,ll b){a=(a*b)%MOD;};
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j,o;
  ll result=0,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll x,y,z;cin>>x>>y>>z;
  x-=z;
  result+=x/(y+z);
  cout<<result<<endl;



  return 0;
}

Measured memory_bytes: 256
import copy

L=[]

def check(M,p,tmp):
  n_ok=0
  for i in range(len(L)):
    sum=0
    for l in L[i]:
      sum+= 1 if tmp[l-1]==1 else 0
    if sum%2==p[i]:
      n_ok+=1
      
  if n_ok==M:
    return 1
  else:
    return 0

def rc(N,M,p,i,tmp):
  if i==N-1:
    return check(M,p,tmp)
  else:
    t1=copy.copy(tmp)
    t2=copy.copy(tmp)
    t1.append(0)
    t2.append(1)
    return rc(N,M,p,i+1,t1)+rc(N,M,p,i+1,t2)

N, M = map(int, input().split())
for _ in range(M):
    tmp = list(map(int,input().split()))
    L.append(tmp[1:])
p=list(map(int,input().split()))
S=[0 for _ in range(N)]

print(rc(N,M,p,-1,[]))

Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
#define intt long long

int main() {
	intt N; std::cin >> N;
	std::vector<intt> a(N);
	for (auto& r : a) std::cin >> r;
	/*std::sort(a.begin(), a.end());
	a.erase(std::unique(a.begin(), a.end()), a.end());*/
	intt ans = 0;
	for (auto& r : a)
		ans += r - 1;
	std::cout << ans << std::endl;
}


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

int main(void){
	int n, X;
	int m = 1e9;
	cin >> n >> X;
	for(int i = 0; i<n; i++){
		int t;
		cin >> t;
		m = min(m,t);
		X -= t;
	}
	cout << n+floor(X/m) <<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define sd(x) scanf("%d", &x)
    #define slld(x) scanf("%lld", &x)
    #define all(x) x.begin(), x.end()
    #define For(i, s, e) for (ll i = s; i < e; i++)
    #define Forr(i, s, e) for (ll i = s; i > e; i--)
    #define pb push_back
    #define ll long long
    #define mp make_pair
    double dp[300 + 1][300 + 1][300 + 1];

    double sushi(ll a, ll b, ll c, ll n)
    {
        if (a < 0 || b < 0 || c < 0)
            return 0;
        if (a == 0 && b == 0 && c == 0)
            return 0;
        if (dp[a][b][c] >= 0)
            return dp[a][b][c];
        ll sum = a + b + c;
        double xd = n + (a) * (sushi(a - 1, b, c, n)) + (b) * (sushi(a + 1, b - 1, c, n)) + (c) * (sushi(a, b + 1, c - 1, n));
        dp[a][b][c] = xd / sum;
        return dp[a][b][c];
    }
    int main()
    {
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
        srand(chrono::high_resolution_clock::now().time_since_epoch().count());
        cout << fixed << setprecision(8);
        ll n;
        cin >> n;
        For(i, 0, 300 + 1)
            For(j, 0, 300 + 1)
                For(k, 0, 300 + 1) dp[i][j][k] = -1;
        ll o = 0, t = 0, th = 0;
        For(i, 0, n)
        {
            ll temp;
            cin >> temp;
            if (temp == 1)
                o++;
            if (temp == 3)
                th++;
            if (temp == 2)
                t++;
        }
        cout << sushi(o, t, th, n) << endl;
        return 0;
    }

Measured memory_bytes: 216924
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;

#define MOD 1e9+7
#define INF 1e9+7
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;

#define MAX_N 10000
#define MAX_V 100
#define MAX_E 100

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

//--------------------------

int div2(int n);

int N;
int a[MAX_N];

int main() {

  int cnt = 0;

  cin >> N;

  rep(i, N) {
    cin >> a[i];
    cnt += div2(a[i]);
  }

  cout << cnt << endl;

  return 0;
}

int div2(int n) {

  int c = 0;

  while(true) {
    if(n==0||n%2==1) return c;
    n/=2;
    ++c;
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int n, time[100] = {0}, i, tmp = 0, max[100] = {0};
	while (cin >> n && !cin.eof())
		time[n-1]++;
	for (i = 0; i < 100; i++)
		if (time[i] > tmp)
			tmp = time[i];
	for (i = 0; i < 100; i++)
		if (time[i] == tmp)
			cout << i+1 << endl;
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,cnt=0,ans=0;
  cin >> n;
  for(int i=1; i<=n; i+=2) {
    cnt=0;
    for(int j=1; j<=i; j++) {
      if(i%j==0) {
        cnt++;
        if(cnt==8) {
          ans++;
        }
      }
    }
  }
    cout << ans << endl;
}

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

using namespace std;
using ll=long long;

const ll m = 1000000007;

int main() {
  ll n, p = 1;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    p = (p * i) % m;
  }
  cout << p << endl;
  return 0;
}

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


using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main(void)
{
    ll n;
    cin>>n;
    string ans;
    while(n){
        n--;
        ans=char('a'+(n%26))+ans;
        n/=26;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3496
#include<bits/stdc++.h>
using namespace std;
int main()
{
  double n,m;
  cin>>n>>m;
  double a[(int)n];
  double s=0;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    s=s+a[i];
  }
  double z=s/(4*m);
  int flag=0;
  for(int i=0;i<n;i++)
  {
    if(a[i]>=z)
    {
      flag++;;
    }
  }
  if(flag>=m)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256