akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> ans, used(n, 0);
  for (int i = 0; i < n; i++) {
    int k = 1, num = 0, id = 0;
    for (int j = 0; j < n; j++) {
      if (used[j]) continue;
      if (a[j] == k) num = k, id = j;
      k++;
    }
    if (num == 0) {
      cout << -1 << endl;
      return 0;
    }
    used[id] = 1;
    ans.emplace_back(num);
  }
  reverse(ans.begin(), ans.end());
  for (auto &v : ans) {
    cout << v << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
int main() {
    int N;
    cin >> N;
    vector<P>AB(N);
    rep(i, 0, N){
        cin >> AB[i].first >> AB[i].second;
    }
    sort(AB.begin(), AB.end(), [](const P& x , const P& y) { return x.second < y.second;});
    ll d = 0;
    bool isok = true;
    rep(i, 0, N){
        d+=AB[i].first;
       
        if(d>AB[i].second){
            isok = false;
        }
    }
    if(isok){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>

int main(void) {
  int l, r, d;
  scanf("%d %d %d", &l, &r, &d);
  int max = r / d;
  int min = l / d;
  if (l % d != 0) {
    printf("%d\n", max - min);
  } else {
    printf("%d", max - min + 1);
  }
  return 0;
}

Measured memory_bytes: 1708
#include <iostream>

char M[300][300];
int X[300][300];
int row[300];

int main()
{
    std::ios_base::sync_with_stdio(0);
    int h,w,k;
    std::cin >> h >> w >> k;
    for (int i=0;i<h;++i) {
        for (int j=0;j<w;++j) {
            std::cin >> M[i][j];
            row[i] += M[i][j] == '#' ? 1 : 0;
        }
    }
    int kk = 0;
    for (int i=0;i<h;++i) {
        if (row[i] > 0) {
            ++kk;
            bool first = true;
            for (int j=0;j<w;++j) {
                if (M[i][j] == '#')
                {
                    if (first) first = false;
                    else ++kk;
                }
                X[i][j] = kk;
            }
        } else if (kk > 0) {
            for (int j=0;j<w;++j) X[i][j] = X[i-1][j];
        }
    }

    for (int i=h-1;i>=0;--i) {
        for (int j=0;j<w;++j) {
            if (X[i][j] == 0)
                X[i][j] = X[i+1][j];
        }
    }
    for (int i=0;i<h;++i) {
        for (int j=0;j<w;++j) {
            std::cout << " " << X[i][j];
        }
        std::cout << std::endl;
    }
    
    return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long A, long long B){
    REP1(i, 10000000) {
        if((LL)(i*0.08) == A && (LL)(i*0.1) == B) {
            cout << i << endl;
            return;
        }
    }

    cout << "-1" << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int digsum(int n) {
int res = 0;
while(n > 0) {
res += n%10;
n /= 10;
}
return res;
}

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    ll cnt =0;

    for(int i=1; i<=n; i++){
        int c = digsum(i);
        if(c>= a && c<=b) cnt += i;
    }
    cout << cnt << endl;
    
}

Measured memory_bytes: 256
import collections
n = int(input())
a = list(map(int, input().split()))

a_mod = list(map(lambda x:x%4, a))
c = collections.Counter(a_mod)

if c[2] == 0 and c[0] +1 == c[1] + c[3]:
  print("Yes")
elif c[0] >= c[1] + c[3]:
  print("Yes")
else:
  print("No")


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

int main() {
    int k;
    scanf("%d", &k);
    int o = 0, e = 0;
    for(int i = 1; i < k+1; i++){
        if(i % 2 == 0) e++;
        else o++;
    }
    printf("%d\n", e*o);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int read()
{
    char c=getchar();int f=1,sum=0;
    while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0' && c<='9'){sum=sum*10+c-'0';c=getchar();}
    return sum*f;
}
int n,m,q;
char s[2005][2005];bool mp[2005][2005];
int sum[2005][2005],sumh[2005][2005],suml[2005][2005];
int main()
{
	n=read();m=read();q=read();
	for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	{
		mp[i][j]=s[i][j]-'0';
		sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+mp[i][j];
		sumh[i][j]=sumh[i-1][j]+sumh[i][j-1]-sumh[i-1][j-1];
		suml[i][j]=suml[i-1][j]+suml[i][j-1]-suml[i-1][j-1];
		if(!mp[i][j]) continue;
		sumh[i][j]+=(mp[i][j]==mp[i-1][j]);
		suml[i][j]+=(mp[i][j]==mp[i][j-1]);
	}
	while(q--)
	{
		int a=read(),b=read(),c=read(),d=read();
        int ansh=sumh[c][d]-sumh[a][d]-sumh[c][b-1]+sumh[a][b-1];
        int ansl=suml[c][d]-suml[a-1][d]-suml[c][b]+suml[a-1][b];
        int ans=sum[c][d]-sum[a-1][d]-sum[c][b-1]+sum[a-1][b-1];
		printf("%d\n",ans-ansh-ansl);
	}
	return 0;
}


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

using namespace std;
using ll = long long;

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

int main() {
  int n;
  cin >> n;
  vector<pair<string, pair<int, int>>> v(n);
  rep(i, n) {
    cin >> v[i].first >> v[i].second.first;
    v[i].second.first *= -1;
    v[i].second.second = i + 1;
  }
  sort(v.begin(), v.end());
  rep(i, n) cout << v[i].second.second << endl;
  return 0;
}


Measured memory_bytes: 3580
#![allow(unused_imports)]
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::collections::BinaryHeap;

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_end().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}
impl<T: Iterator> IteratorExt for T {}

fn main() {
    let n = read!(usize);
    let a = read!([usize]);

    let mut sum = 0;
    for &e in &a {
        sum ^= e;
    }

    for &e in &a {
        print!("{} ", e^sum);
    }
    print!("\n");
}



Measured memory_bytes: 6304
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
LL dp[SIZE];
int main(){
    int n,k;
    R(n,k);
    REP(i,k){
        int x;
        R(x);
        dp[x]=-1;
    }
    dp[0]=1;
    FOR(i,1,n){
        if(dp[i]==-1)continue;
        if(dp[i-1]!=-1)ADD(dp[i],dp[i-1]);
        if(i>1&&dp[i-2]!=-1)ADD(dp[i],dp[i-2]);
    }
    W(dp[n]);
    return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define mm(a,b) memset(a,b,sizeof(a))
#define ACCELERATE (ios::sync_with_stdio(false),cin.tie(0))
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<long long,long long>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define pf(x) printf("%d\n",x)
#define pf2(x,y) printf("%d %d\n",x,y)
#define pf3(x,y,z) printf("%d %d %d\n",x,y,z)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
#define E exp(1.0)
#define db double
#define ll long long
#define ld long double
#define ull unsigned long long
//#define io
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
//#define gc getchar
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
//inline int read()
//{
//    int ret=0,f=0;char c=gc();
//    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
//    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
//    if(f)return -ret;return ret;
//}
char s[500];
int main()
{
    #ifdef io
    freopen("in.txt","r",stdin);
    #endif
    scanf("%s",s);
    printf("%s\n",s[0]=='S'?"Cloudy":(s[0]=='C'?"Rainy":"Sunny"));
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		long K=sc.nextLong();
		int A[]=new int[N];
		for(int i=0;i<N;i++) {
			A[i]=sc.nextInt();
		}
		if(A[0]==1) {
			System.out.println(1);
			System.exit(0);
		}
		int B[]=new int[N];
		int next=0;
		long loop=0;
		for(int i=0;i<K;i++) {
			if(B[next]==0) {
			B[next]=i+1;
			next=A[next]-1;
			K--;
					}else {
						loop=i+1-B[next];
						K%=loop;
						break;
					}

		}
		for(int i=0;i<K;i++) {
			next=A[next]-1;
		}
		System.out.println(next+1);

}
}


Measured memory_bytes: 59992
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  int n, m;
  cin >> n;
  unordered_map<string, int> mp;
  vector<string> s(n);
  REP(i,n){
    cin >> s[i];
    mp[s[i]] ++;
  }
  cin >> m;
  vector<string> t(m);
  REP(i,m){
    cin >> t[i];
    mp[t[i]] --;
  }
  //
  int ans = 0;
  for(auto itr = mp.begin();itr!= mp.end();++itr){
    if(itr->second > 0){
      ans = max(ans, itr->second);
    }
  }
  cout << ans << endl;
}


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

using namespace std;

int sumDigits(int n)
{
	int sum = 0;
	while (n > 0)
	{
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

int main()
{
	int ansCount = 0;
	int N, A, B;

	cin >> N >> A >> B;
	
	for (int i = 1; i <= N; ++i)
	{
		int sum = sumDigits(i);
		if (A <= sum && sum <= B)
		{
			ansCount += i;
		}
	}
	
	cout << ansCount << endl;


	return 0;
}

Measured memory_bytes: 256
def ecount(X):
  c,ans=1,[[],[]]
  for i in range(len(X)-1):
    if X[i]==X[i+1]:c+=1
    else:
      ans[1].append(c);c=1;ans[0].append(X[i])
  ans[1].append(c)
  ans[0].append(X[-1])
  return ans
n=int(input())
a=ecount(sorted(list(map(int,input().split()))))
ans=0
for i in range(len(a[0])):
  if a[0][i]<=a[1][i]:ans+=a[1][i]-a[0][i]
  else:ans+=a[1][i]
print(ans)

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

int main(){
  string s; cin>>s;
  int len = s.size();
  ll ans = 0;
  rep(bit, 1<<len-1){
    ll tmp = 0;
    rep(i,len-1){
      tmp *= 10;
      tmp += s[i] - '0';
      if (bit & (1<<i)) ans += tmp, tmp = 0;
    }
    tmp *= 10;
    tmp += s.back() - '0';
    ans += tmp;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3612
using System;
class Program{
  static void Main(string[] args){
    int Max, Min;
    while (true){
      int n = int.Parse(Console.ReadLine());
      if(n == 0)break;
      
      int[] numbers = new int[n];
      for (int i = 0 ; i < n ; i ++ ){
        numbers[i] =  int.Parse(Console.ReadLine());
      }
      Max = Min = numbers[0];
      
      for (int i = 0 ; i < n ; i ++ ){
        if(Max < numbers[i] )Max = numbers[i];
        if(Min > numbers[i] )Min = numbers[i];
      }
      
      int output =0;
      
      for (int i = 0 ; i < n ; i ++ ){
        output += numbers[i];
      }
      output = (output - Min - Max )/ (n-2);
      Console.WriteLine(output);
    }
  } 
}

Measured memory_bytes: 5656
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;


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

    vector<pair<pair<string, int>, int>> book(N);
    for (int i = 0; i < N; i++)
    {
        cin >> book[i].first.first >> book[i].first.second;
        
        book[i].first.second *= -1;
        book[i].second = i + 1;
    }

    sort(book.begin(), book.end());    //string は辞書順、intは点数を負にしたから絶対値大きい順にならぶ

    for (int i = 0; i < N; i++)
    {
        cout << book[i].second << endl;
    }
    
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
  map<pair<char,int>,int> ma;
  char c[4]={'S','H','C','D'};
  int n;
  cin>>n;
  rep(i,n){
    char t;
    int tt;
    cin>>t>>tt;
    ma[mkp(t,tt)]=1;
  }
  rep(i,4){
    rep(j,13){
      if(ma[mkp(c[i],j+1)]==0) cout<<c[i]<<" "<<j+1<<endl;
    }
  }
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1196
d = int(input())
c = list(map(int,input().split()))
s = []
for i in range(d):
  si = list(map(int,input().split()))
  s.append(si)
lastd = [-1 for _ in range(26)]
ans = 0
t = [0 for _ in range(d)]
for i in range(d):
  di = int(input())
  t[i] = di-1
  lastd[di-1] = i
  ans += s[i][di-1]
  for j in range(26):
    ans -= (i-lastd[j])*c[j]
m = int(input())
for _ in range(m):
  da,qa = map(int,input().split())
  da -= 1
  qa -= 1
  qb = t[da]
  t[da] = qa
  qb1 = -1
  qa1 = -1
  ans -= s[da][qb] 
  ans += s[da][qa]
  for i in range(da-1,-1,-1):
    if t[i] == qb:
      qb1 = i
      break
  for i in range(da-1,-1,-1):
    if t[i] == qa:
      qa1 = i
      break
  qb2 = d
  qa2 = d
  for i in range(da+1,d):
    if t[i] == qb:
      qb2 = i
      break
  for i in range(da+1,d):
    if t[i] == qa:
      qa2 = i
      break
  ans -= c[qb]*(qb2-da)*(da-qb1)
  ans += c[qa]*(qa2-da)*(da-qa1)
  print(ans)

Measured memory_bytes: 72540
#!/usr/bin/env python3
import sys
from itertools import chain


def solve(N: int, K: int, H: "List[int]"):
    H = sorted(H, reverse=True)
    return sum(H[K:])


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    answer = solve(N, K, H)
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 34524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define se second
#define fi first
#define pb push_back
const int N=1e5 + 5;
int a[N],b[N];

int main(){

//	freopen("in.txt","r",stdin);

	int n;
	scanf("%d",&n);
	for(int i=0;i < n;i++)
		scanf("%d",a + i);
	for(int i=0;i < n;i++)
		scanf("%d",b + i);
	ll sum1=0,sum2=0;
	for(int i=0;i < n;i++){
		if(b[i] > a[i]) sum1+=(b[i] - a[i] + 1) / 2;
		sum2+=b[i] - a[i];
	}
	if(sum2 >= sum1) puts("Yes");
	else puts("No");

	return 0;

}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
typedef long long LL;
const int MAXN = 1e4 + 8;

LL a[MAXN], b[MAXN];

int main()
{
    #ifdef LOCAL
    freopen("b.txt", "r", stdin);
    //freopen("b.out", "w", stdout);
    int T = 4;
    while(T--){
    #endif // LOCAL
    ios::sync_with_stdio(false); cin.tie(0);

    LL n, i, cnta = 0, cntb = 0, ans;
    cin >> n;
    for(i = 0; i < n; i++){
        cin >> a[i];
    }
    for(i = 0; i < n; i++){
        cin >> b[i];
    }
    for(i = 0; i < n; i++){
        if(a[i] < b[i]){
            if((b[i]-a[i]) & 1){
                cnta += (b[i]-a[i]+1)/2;
                cntb ++;
            }
            else{
                cnta += (b[i]-a[i])/2;
            }
        }
        else{
            cntb += a[i] - b[i];
        }
    }
    if(cnta < cntb){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }

    #ifdef LOCAL
    cout << endl;
    }
    #endif // LOCAL
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

bool intime(int n)
{
	return 1730<=n && n<=1930;
}

pii getinfo(int src,int dst)
{
	int table[7][7]={
		{   0, 300, 500, 600, 700,1350,1650},
		{   6,   0, 350, 450, 600,1150,1500},
		{  13,   7,   0, 250, 400,1000,1350},
		{  18,  12,   5,   0, 250, 850,1300},
		{  23,  17,  10,   5,   0, 600,1150},
		{  43,  37,  30,  25,  20,   0, 500},
		{  58,  52,  45,  40,  35,  15,   0},
	};
	src--;dst--;
	if(src>dst) swap(src,dst);
	return mp(table[dst][src],table[src][dst]);
}

int main()
{
	
	for(int n1,h1,m1,n2,h2,m2;cin>>n1,n1;){
		cin>>h1>>m1>>n2>>h2>>m2;
		int t1=h1*100+m1,t2=h2*100+m2;
		pii info=getinfo(n1,n2);
		bool harf=(intime(t1)||intime(t2))&&info.first<=40;
		if(harf){
			info.second/=2;
			info.second=(info.second+49)/50*50;
		}
		cout<<info.second<<endl;
	}
	
	return 0;
}

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

namespace ConsoleApplication
{
    class Program
    {
        static void Main()
        {
            new Solution().answer();
        }
    }

    class Solution
    {
        string N, M, T;
        int x, a, b,d1,d2;
        public Solution()
        {
            N = Console.ReadLine();
            //M = Console.ReadLine();
            //int j = Convert.ToInt32(N);
            string[] M_split = new string[3];
            //string[] M_split_full = new string[j * 3];

            M_split = N.Split(' ');
            x=Convert.ToInt32(M_split[0]);
            a=Convert.ToInt32(M_split[1]);
            b=Convert.ToInt32(M_split[2]);

            d1=Math.Abs(a-x);
            d2=Math.Abs(b-x);

            if (d1 > d2) { T = "B"; } else { T = "A"; }

            //int a;
            //for (a = 0; a < j; a++)
            //{
            //    M_split_full[a] = M_split[a];
            //    M_split_full[j + a] = (Convert.ToInt32(M_split[a]) - 1).ToString();
            //    M_split_full[(2 * j) + a] = (Convert.ToInt32(M_split[a]) + 1).ToString();
            //}

            //var count =(from item in M_split_full
            //            group item by item into g
            //            select g.Count()).ToList();

            //var ans = (from item in count
            //           group item by item into g
            //           select g.Max()).ToList();

            //ans.Sort();
            //T = ans[ans.Count() - 1].ToString();                          
        }

        public void answer()
        {
            Console.WriteLine(T);
        }
    }
}


Measured memory_bytes: 13396
n,k,q=map(int,input().split())
a=[int(input()) for i in range(q)]

m=[0]*n

for i in range(q):
  m[a[i]-1]+=1

for j in range(n):
  m[j]=k+m[j]-q

ans=['No']*n

for h in range(n):
  if m[h]>0:
    ans[h]='Yes'

print('\n'.join(ans))

Measured memory_bytes: 18420
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)


int main()
{
	int n, m, a, b;
	string ans[1005];

	cin >> n >> m >> a >> b;

	REP(i, n) {
		REP(j, m) {
			ans[i] += ".";
		}
	}

	if (m % 2 == 1) {
		for (int i = 1; i < n; i += 2) {
			if (b > 0) {
				b--;
				ans[i - 1][0] = '^';
				ans[i][0] = 'v';
			}
			else {
				break;
			}
		}

		for (int i = 1; i < n; i += 2) {
			for (int j = 1; j < m; j += 2) {
				if (b >= 2) {
					b -= 2;
					ans[i][j] = 'v';
					ans[i - 1][j] = '^';
					ans[i][j + 1] = 'v';
					ans[i - 1][j + 1] = '^';
				}
				else {
					break;
				}
			}
		}

		for (int i = n - 1; i > 0; i -= 2) {
			for (int j = m - 1; j >= 0; j--) {
				if (b > 0) {
					if (ans[i][j] == '.' && ans[i - 1][j] == '.') {
						b--;
						ans[i][j] = 'v';
						ans[i - 1][j] = '^';
					}
				}
				else {
					break;
				}
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m - 1; j++) {
				if (a > 0) {
					if (ans[i][j] == '.' && ans[i][j + 1] == '.') {
						ans[i][j] = '<';
						ans[i][j + 1] = '>';
						a--;
					}
				}
				else {
					break;
				}
			}
		}

		if (a == 0 && b == 0) {
			cout << "YES" << endl;
			REP(i, n) {
				REP(j, m) {
					cout << ans[i][j];
				}
				cout << endl;
			}
		}
		else {
			cout << "NO" << endl;
		}
	}
	else {
		for (int i = 1; i < n; i += 2) {
			for (int j = 0; j < m; j += 2) {
				if (b >= 2) {
					b -= 2;
					ans[i][j] = 'v';
					ans[i - 1][j] = '^';
					ans[i][j + 1] = 'v';
					ans[i - 1][j + 1] = '^';
				}
				else if (b == 1) {
					b--;
					ans[i][j] = 'v';
					ans[i - 1][j] = '^';
					break;
				}
				else {
					break;
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m - 1; j++) {
				if (a > 0) {
					if (ans[i][j] == '.' && ans[i][j + 1] == '.') {
						ans[i][j] = '<';
						ans[i][j + 1] = '>';
						a--;
					}
				}
				else {
					break;
				}
			}
		}

		if (a == 0 && b == 0) {
			cout << "YES" << endl;
			REP(i, n) {
				REP(j, m) {
					cout << ans[i][j];
				}
				cout << endl;
			}
		}
		else {
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 2304
# n = 2*10**5
# X = "10"*10**5
n = int(input())
X = input()
c = 0
cnt = 0
for i,x in enumerate(X):
    c += (1<<(n-i-1))*int(x)
    cnt += int(x)

amari_cnt_p = c % (cnt+1)
if cnt != 1:
    amari_cnt_m = c % (cnt-1)

dp = []
for d in range(n):
    if X[d] == "0":
        amari = (amari_cnt_p + pow(2,n-d-1,cnt+1))%(cnt+1)
    else:
        if cnt != 1:
            amari = (amari_cnt_m - pow(2,n-d-1,cnt-1))%(cnt-1)
        else:
            amari = -1
    dp.append(amari)

memo = [-1]*(2*10**5+10)
memo[0] = 1
def calc(n):
    if n == -1:
        return 0
    if n == 0:
        return 1
    if memo[n] != -1:
        return memo[n]
    cnt = 1
    while n > 0:
        c = bin(n).count("1")
        n %= c
        cnt += 1
    memo[n] = cnt
    return cnt

for d in dp:
    ans = calc(d)
    print(ans)


Measured memory_bytes: 113720
using System;

using System.Collections.Generic;
using System.Linq;


namespace C_Breadth_First_Search
{
  class Program
  {
    static void Main(string[] args)
    {
      int size = int.Parse(Console.ReadLine());
      arraysize = size;
      ansarr = new int[size+1];
      int[,] ans = new int[size + 1, size + 1];
      for (int nth = 1; nth < size + 1; nth++)
      {
        String[] input = Console.ReadLine().Split(' ');
        for (int n = 0, index = 2; n < int.Parse(input[1]); n++, index++)
        {
          ans[int.Parse(input[0]), int.Parse(input[index])] = 1;
        }
      }
    
      bfs(1, ans);
      for(int n = 1; n <= size; n++)
      {
        if (ansarr[n] == 0)
        {
          if(n==1) Console.WriteLine(n + " " + ansarr[n] );
          else Console.WriteLine(n + " -1");
        }
        else
        {
          Console.WriteLine(n + " " + ansarr[n] );
        }
       
        
      }

    }
    public static int arraysize;
    public static int[] ansarr;
    static void bfs(int s, int[,] arr)
    {
      Queue<int> q = new Queue<int>();
      q.Enqueue(s);
      ansarr[s] = 0;
      while (true)
      {
        int num = q.Dequeue();
        for(int n = 1; n <= arraysize ; n++)
        {
          if (arr[num, n] == 0) continue;
          if (ansarr[n]==0&&n!=1  || ansarr[n] > ansarr[num]+1) { 
          ansarr[n] = ansarr[num] + 1;
          }
          else
          {
            continue;
          }
          int[] check = q.ToArray<int>();
          Boolean test = true;
          foreach(int c in check)
          {
            if (c == n) { test = false; break; }
          }
          if(test) q.Enqueue(n);
        }
        if (q.Count == 0) break;
      }
    }
  }
}



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

typedef struct _Node {
  int key;
  struct _Node *next, *prev;
} Node;

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next;
  while(cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

void init(void) {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(void) {
  Node *cur = nil->next;
  int isf = 0;
  while(1) {
    if(cur == nil) break;
    if(isf++>0) printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if(t==nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(void) {
  deleteNode(nil->next);
}

void deleteLast(void) {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(void) {
  int key, n, i;
  int size = 0;
  int np = 0, nd = 0;
  char com[20];
  scanf("%d", &n);
  init();
  for(i=0;i<n;i++) {
    scanf("%s%d",com, &key);
    if (com[0] == 'i') {
      insert(key);
      np++;
      size++;
    } else if(com[0] == 'd') {
      if(strlen(com) > 6) {
        if(com[6] == 'F')
          deleteFirst();
        else if(com[6] == 'L')
          deleteLast();
      } else {
        deleteKey(key);
        nd++;
      }
      size--;
    }
  }
  printList();
  return 0;
}


Measured memory_bytes: 33044
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <climits>
#include <set>
using namespace std;
#define repn(i,s,n) for (int i=int(s); i < int(n); i++)
#define rep(i,n) repn(i,0,n)
#define repd(i,n) for (int i=int(n)-1; i >= 0; i--)

typedef vector<int> VI;
typedef vector<VI> VVI;


struct UnionFind {
  vector<int> p; 
  UnionFind(int n) : p(n, -1) { };
  void unite(int u, int v) {
    if ((u = find(u)) == (v = find(v))) return;
    if (p[u] > p[v]) swap(u, v);
    p[u] += p[v]; p[v] = u;
  }
  bool same(int u, int v) { return find(u) == find(v); }
  int find(int u) { return p[u] < 0 ? u : p[u] = find(p[u]); }
  int size(int u) { return -p[find(u)]; }
};


int n, m;
VI h;
const int H_MAX = 1000010;

struct Edge
{
  int a, b, cost;

  int getSinkTime() const {
    return min(h[a], h[b]);
  }

  bool operator<(const Edge& o) const {
    int sinkTime = getSinkTime();
    int oSinkTime = o.getSinkTime();
    if (sinkTime != oSinkTime) return sinkTime > oSinkTime;  // 最後に沈むのを先に
    return cost < o.cost;
  }
};

void solve() {
  vector<Edge> es;
  h = VI(n);
  VI numSunk(H_MAX);
  rep(i, n) {
    cin >> h[i];
    numSunk[h[i]]++;
  }
  rep(i, H_MAX-1) numSunk[i+1] += numSunk[i];
  rep(i, m) {
    Edge e;
    cin >> e.a >> e.b >> e.cost;
    e.a--;
    e.b--;
    es.push_back(e);
  }

  // 最初に非連結になる時間を得る
  sort(es.begin(), es.end());
  UnionFind uf(n);
  int count = 1;
  int first_unconnected_h = H_MAX-1;
  for (int ei = 0; ei < m; ei++) {
    Edge& e = es[ei];
    int numV = n - numSunk[e.getSinkTime()];
    if (numV > count) first_unconnected_h = e.getSinkTime();
    if (!uf.same(e.a, e.b)) {
      count++;
      uf.unite(e.a, e.b);
    }
  }
  if (count < n) {
    cout << 0 << endl;
    return;
  }

  // 非連結になる時間に全部同時に沈むようにする
  rep(i, n) {
    h[i] = min(h[i], first_unconnected_h);
  }

  sort(es.begin(), es.end());
  uf = UnionFind(n);
  int min_cost = 0;

  rep(ei, es.size()) {
    Edge& e = es[ei];
    if (!uf.same(e.a, e.b)) {
      min_cost += e.cost;
      uf.unite(e.a, e.b);
    }
  }

  cout << min_cost << endl;
}

int main() {
  while (cin >> n >> m, n||m) solve();
  return 0;
}

Measured memory_bytes: 5756
#include <bits/stdc++.h>
#define maxn 2005
#define maxl 1000000000

using namespace std;

#define st first
#define nd second
#define ALL(x) (x).begin(), (x).end()

template <class T>
void mini(T& l, T r) {
  l = min(l, r);
}
template <class T>
void maxi(T& l, T r) {
  l = max(l, r);
}

using LL = long long;
using LD = long double;
using ULL = unsigned long long;
const int dx[] = {0, -1, 1, 0, -1, -1, 1, 1},
          dy[] = {-1, 0, 0, 1, -1, 1, -1, 1};
const int INF = 1e9;
const LL MOD = 1e9 + 7;

int t, T;

void Solve() {
  // TODO
  int n, k;
  cin >> n >> k;
  string p;
  cin >> p;
  int cnt = 0;
  for (int i = 1; i < n; i++) {
    if (p[i] == p[i - 1]) cnt++;
  }
  cout << min(n - 1, cnt + k * 2) << '\n';
  return;
}

void Prepare() {
  // TODO
  return;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  // Prepare();
  // cin >> T;
  // for (t = 1; t <= T; t++) {
  //   printf("Case #%d: ", t);
  Solve();
  // }
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}


int main()
{
    int a, b;
    string s;
    cin >> a >> b >> s;

    string ans = "Yes";
    if (s[a] != '-')
        ans = "No";
    rep(i,s.length()) {
        if (i == a) {
            continue;
        }
        if(s[i] == '-')
            ans = "No";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	1000000007

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

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

	ll modinv(ll a)
	{
		ll b = max, u = 1, v = 0;
		while (b)
		{
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= max;
		if (u < 0)
			u += max;
		return u;
	}

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

int func(int a, int b)
{
	if (a < b)
		return func(b, a);
	int r;
	while (r = a % b)
	{
		a = b;
		b = r;
	}
	return b;
}

int main()
{
	ll x;
	cin >> x;

	ll now = 100;
	ll r = 0;

	while (now < x)
	{
		now *= 1.01;
		r++;
	}

	printf("%lld", r);

	return 0;
}

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

using namespace std;

const int N = 2e5;
int used[N];
int cnt[N];

void solve() {
    int n, m;
    cin >> n >> m;
    int correctans = 0, penalties = 0;
    for (int i = 0; i < m; i++) {
        int p; string s; cin >> p >> s;
        if (s == "AC") {
            if (used[p] == 0) {
                correctans++;
                penalties += cnt[p];
            }
            used[p] = 1;
        }
        else cnt[p]++;
    }
    cout << correctans << ' ' << penalties;
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
}


Measured memory_bytes: 1024
import Control.Monad
import Data.List
import Control.Applicative

main = do
  [n,a,b] <- map read . words <$> getLine
  putStr $ show $ aandb  n a b
  putStr " "
  putStrLn $ show $ axorb  n a b

aandb :: Int -> Int -> Int -> Int
aandb n a b
  |a > b = b
  |otherwise = a

axorb :: Int -> Int -> Int -> Int
axorb n a b
  |a + b - n > 0 = a + b - n
  |otherwise = 0

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m; cin>>n>>m;
    vector <int> (100010);
    vector <bool> tokubetu(100010);
    int big =1e9;
    int small = 0;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        small = max(small, a);
        big = min(big,b);
    }
    //cout<<big<<endl;
    cout<<max(0, big-small+1)<<endl;
}


Measured memory_bytes: 640
#include <stdio.h>

int main (void){
    int days;
    int first_price_days;
    int first_price;
    int over_price;
    scanf ("%d",&days);
    scanf("%d",&first_price_days);
    scanf("%d",&first_price);
    scanf("%d",&over_price);
    if(days > first_price_days){
        printf("%d\n",first_price * first_price_days + over_price *(days - first_price_days));
    }else{
        printf("%d\n",first_price * days);
    }
    return 0;
}

Measured memory_bytes: 128
from collections import defaultdict
import bisect
s = input()
t = input()
dicta = defaultdict(list)
for a,b in enumerate(s):
    dicta[b] += [a]
snow = -1
count = 0
flag = True
for i in t:
    if i not in s:
        flag = False
        break
    nowt = dicta[i]
    snowind = bisect.bisect_right(nowt,snow)
    if snowind == len(nowt):
        count += 1
        snow = nowt[0]
    else:
        snow = nowt[snowind]
if flag:
    print(len(s)*count+snow +1)
else:
    print(-1)
        

Measured memory_bytes: 8052
#include<iostream>
#include<algorithm>
using namespace std;
int N,K,H[2<<17];
main()
{
	cin>>N>>K;
	for(int i=0;i<N;i++)cin>>H[i];
	sort(H,H+N);
	long ans=0;
	for(int i=0;i<N-K;i++)ans+=H[i];
	cout<<ans<<endl;
}


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

int tax(int x, int p)
{
  return p * (100+x) / 100;
}

int solve(int x, int y, int s)
{
  int maximum = 0;
  for(int i=1;i<s;i++)
    for(int j=i;j<s;j++)
      if(tax(x, i) + tax(x, j) == s)
	maximum = max(maximum, tax(y, i) + tax(y, j));
  return maximum;
}


int main()
{
  int X, Y, S;

  while(cin >> X >> Y >> S && X>0)
    {
      cout << solve(X, Y, S) << endl;
    }
}



Measured memory_bytes: 3048
N,x=map(int,input().split())
A=list(map(int,input().split()))
ans=0
pre=0
for i in range(N-1):
    s=A[i]+A[i+1]-pre
    ans+=max(0,s-x)
    pre=min(max(0,s-x),A[i+1])
print(ans)

Measured memory_bytes: 14052
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+10;
pair<int,int> a[N];
int main() {
	int n;
	scanf("%d",&n);
	for (int i=0;i<n;i++) {
		int x;
		scanf("%d",&x);
		a[i] = {x,i};
	}
	sort(a,a+n);
	int ans = 0;
	for (int i=0;i<n;i++) if ((a[i].second^i)&1) ans++;
	printf("%d\n",ans/2);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){

	int N;
	int K;
	long long int sum = 0;
	long long int chk1,chk2;
	int c1,c2;
	cin >> N >> K;

	chk1 = 0;
	for(int i = 1; i <K ; i++)
	{
		chk1 +=i;
		c1 = i;
	}
	chk2 = 0;
	for(int i = N; i > N - K; i-- ){
		chk2 += i;
		c2 = i;
	}

	while( K <= N +1 ){
		
		sum += (chk2+1 - chk1);
		c1++;
		c2--;
		chk2+=c2;
		chk1+=c1;
		K++;
	}

	cout << sum % (1000000000+7)<< endl;


	return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i = 0; i < (n); i++)
const int mod = 1e9 + 7;
int n;
struct Matrix {
    vector<vector<int>> a = vector<vector<int>>(n, vector<int>(n));
    Matrix operator *(const Matrix& other) {
        Matrix product;
        vector<vector<long long>> tmp(n, vector<long long>(n));
        REP(i, n)REP(j, n)REP(k, n) {
            tmp[i][k] += (long long) a[i][j] * other.a[j][k];
            tmp[i][k] %= mod;

            // product.a[i][k] = (product.a[i][k] + (long long) a[i][j] * other.a[j][k]) % mod;
        }
        REP(i, n)REP(j, n) product.a[i][j] = tmp[i][j] % mod;
        return product;
    }
};
Matrix expo_power(Matrix a, long long k) {
    Matrix product;
    REP(i, n) product.a[i][i] = 1;
    while (k > 0) {
        if (k % 2) {
            product = product * a;
        }
        a = a * a;
        k /= 2;
    }
    return product;
}



void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int main() {
    // D. Count Paths

    c_p_c();

    long long k;
    cin >> n >> k;
    Matrix single;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            cin >> single.a[i][j];


    Matrix total = expo_power(single, k);
    int answer = 0;
    REP(i, n) REP(j, n) {
        answer = (answer + total.a[i][j]) % mod;
    }
    cout << answer << endl;
}

Measured memory_bytes: 3656
#include<iostream>
#include<cmath>

int main(){
	int n;
	std::cin>>n;
	int cnt=0,x;
	for(int i=0;i<n;i++){
		int flag=0;
		std::cin>>x;
		for(int i=2;i<=(int)std::sqrt(x);i++){
			if(x%i==0){
				flag=1;
				break;
			}
		}
		if(!flag) cnt++;
	}
	std::cout<<cnt<<'\n';
	return 0;
}



Measured memory_bytes: 3088
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <string>
#include <stack>
#include <set>
#include <vector>

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef pair<int,int> pii;

const int INF = 1 << 29;
const double EPS = 1e-10;


int main() {
  for (int N, M, P; cin >> N >> M >> P, (N | M | P) != 0;) {
    M--;

    int x[100];
    int sum = 0;
    rep(i, N) {
      cin >> x[i];
      sum += x[i];
    }

    if (x[M] == 0) cout << 0 << endl;
    else cout << (int)(sum * (100 - P) / x[M]) << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;
vector<vector<ll>>w(110000);
priority_queue<ll> que;
int main(){
    ll n,m,ans=0;
    cin>>n>>m;
    rep(i,0,n){ll a,b;cin>>a>>b;w[a].push_back(b);}
    rep(i,1,m+1){
        rep(j,0,w[i].size()) que.push(w[i][j]);
        if(que.size()!=0){ans+=que.top();que.pop();}
        
    }
    cout<<ans<<endl;
}

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

int main()
{
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    int sum = a1+a2+a3;
    if (sum >= 22) cout << "bust" <<endl;
    else cout << "win" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main(void){
  int N;
  cin >> N;
  if(N % 2 == 0){
    cout << 0.5;
  } else {
    cout << (N / 2.0 + 0.5) / N;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int tmp;
int ans;
char s;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		if(s=='I')tmp++;
		else tmp--;
		ans=max(tmp,ans);
	}
	cout<<ans<<endl;
	return 0;
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define PII pair<int,int>
#define f first
#define s second
#define VI vector<int>
#define LL long long
#define MP make_pair
#define LD long double
#define PB push_back
#define PLL pair <LL, LL>
#define ALL(V) V.begin(),V.end()
#define abs(x) max((x),-(x))
#define PDD pair<LD,LD> 
#define VPII vector< PII > 
#define siz(V) ((int)V.size())
#define FOR(x, b, e)  for(int x=b;x<=(e);x++)
#define FORD(x, b, e) for(int x=b;x>=(e);x--)
#define REP(x, n)     for(int x=0;x<(n);x++)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#ifdef DEB
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define debug2(...) cerr << __VA_ARGS__
#else
#define debug(...)
#define debug2(...)
#endif
const int N = 6;
int a[N], b[N];
LD res = 0;
void add(LD p) {
	LD curr = 0;
	for (int i = 0; i < N; ++i)
		curr += min(a[i] * p, b[i] * (1 - p));
	maxi(res, curr);
}
int main() {
	for (int i = 0; i < N; ++i)
		scanf("%d", a + i);
	for (int i = 0; i < N; ++i)
		scanf("%d", b + i);
	for (int i = 0; i < N; ++i)
		if (a[i] + b[i])
			add(b[i] / ((LD)a[i] + b[i]));
	add(0);
	add(1);
	printf("%.10Lf\n", 1 - res / 100);
}

Measured memory_bytes: 384
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xs = readLine()!!.split(" ").map(String::toInt)

    if (xs.toSet().size == 1) {
        println(n / 2)
        return
    }

    val oddNumList = xs.withIndex().filter { it.index % 2 == 0 }.map { it.value }
    val evenNumList = xs.withIndex().filter { it.index % 2 != 0 }.map { it.value }

    val groupby1 = oddNumList.groupBy { it }.map { it.value }.sortedByDescending { it.size }
    val groupby2 = evenNumList.groupBy { it }.map { it.value }.sortedByDescending { it.size }

    val listOfMax1 = groupby1.first()
    val listOfMax2 = groupby2.first()

    if (listOfMax1.first() != listOfMax2.first()) {

        val freq1 = listOfMax1.first()
        val freq2 = listOfMax2.first()

        val count1 = groupby1.filter { it[0] != freq1 }.sumBy { it.size }
        val count2 = groupby2.filter { it[0] != freq2 }.sumBy { it.size }

        println(count1 + count2)
        return
    }


    val freq1 = listOfMax1.first()
    val freq2 = groupby2[1].first()
    val count1 = groupby1.filter { it[0] != freq1 }.sumBy { it.size }
    val count2 = groupby2.filter { it[0] != freq2 }.sumBy { it.size }
    val ans1 = count1 + count2

    val freq3 = groupby1[1].first()
    val freq4 = listOfMax2.first()
    val count3 = groupby1.filter { it[0] != freq3 }.sumBy { it.size }
    val count4 = groupby2.filter { it[0] != freq4 }.sumBy { it.size }
    val ans2 = count3 + count4

    if (ans1 < ans2) {
        println(ans1)
    } else {
        println(ans2)
    }
}


Measured memory_bytes: 79852
n,m=map(int,input().split())
w,u=3*m,n-1
o,f,i=998244353,[1],1
while i<w+n:f+=[f[-1]*i%o];i+=1
c=lambda n,k:f[n]*pow(f[n-k],o-2,o)*pow(f[k],o-2,o)
a=c(w+u,u)-n*c(n+m-2,u)
while n>-~m<w:m+=2;a-=c(n,m)*c(2*u+w-m>>1,u)
print(a%o)

Measured memory_bytes: 115556