akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define eps 1e-9
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n, k, Q;
llint a[2005];

bool check(llint x)
{
	for(int i = 1; i <= n; i++){
		llint l = a[i], r = l+x, ret = 0, cnt = 0, len = 0;
		for(int j = 1; j <= n; j++){
			if(a[j] < l){
				ret += min(max(0LL, len-k+1), cnt);
				len = cnt = 0;
			}
			else{
				len++;
				if(a[j] <= r) cnt++;
			}
		}
		ret += min(max(0LL, len-k+1), cnt);
		if(ret >= Q) return true;
	}
	return false;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> k >> Q;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	llint ub = 1e9+7, lb = -1, mid;
	while(ub-lb>1){
		mid = (ub+lb)/2;
		if(check(mid)) ub = mid;
		else lb = mid;
	}
	cout << ub << endl;
	
	return 0;
}

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

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define sz size()
#define S second
#define F first
#define all(x) x.begin(), x.end()
#define int ll

typedef pair < int, int > pii;
typedef vector < int >  vi;
typedef vector < vector < int > >  vvi;

void solve(){
    int a, b, c,d;
    cin >> a >> b >> c >> d;
    int x =  b * c;
    x = max(x, b * d);
    x = max(x, a * c);
    x = max(x, a * d);
   cout << x;
}

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





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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> t(n);
	int sum = 0;
	for (auto&& ti : t)
	{
		cin >> ti;
		sum += ti;
	}
	int m;
	cin >> m;
	for (int i = 0; i < m; i++)
	{
		int p, x;
		cin >> p >> x;
		cout << sum + x - t[p-1] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    int n;
    cin>>n;
    vi a(n+1);
    int mx=1,mi=1;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[mi]>a[i]) mi=i;
        if(a[mx]<a[i]) mx=i;
    }
    cout<<2*n<<'\n';
    if(abs(a[mx])>abs(a[mi]))
    {
        cout<<mx<<" "<<1<<'\n';
        cout<<mx<<" "<<1<<'\n';
        for(int i=2;i<=n;i++)
            cout<<i-1<<" "<<i<<'\n'<<i-1<<" "<<i<<'\n';
    }
    else{
        cout<<mi<<" "<<n<<'\n'<<mi<<" "<<n<<'\n';
        for(int i=n-1;i>=1;i--)
            cout<<i+1<<" "<<i<<"\n"<<i+1<<" "<<i<<'\n';
    }

}

Measured memory_bytes: 256
#include <stdio.h>

int main (){
	int a,b,c;
	scanf("%d %d %d\n",&a,&b,&c);
	int sum1=a+b;
	int sum2=a+c;
	int sum3=b+c;
	int min=sum1;
	if(sum2<min)min=sum2;
	if(sum3<min)min=sum3;
	printf("%d\n",min);
	
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{   
    int n, m;
    ll k;
    cin >> n >> m >> k;
    vll a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    vll sa(n+1, 0), sb(m+1, 0);
    rep(i, n) sa[i+1] = sa[i] + a[i];
    rep(i, m) sb[i+1] = sb[i] + b[i];
    
    int ans = 0;
    rep(i, n+1) {
        ll sum = sa[i];
        if(sum > k) break;
        auto itr = upper_bound(all(sb), k-sum);
        int cnt = itr - sb.begin() - 1;
        //cout << i << cnt << endl;
        ans = max(ans, i+cnt);
    }
    cout << ans << endl;
        
    return 0;
}


Measured memory_bytes: 9560
import sys


def num_patty(level):
    return 2 ** (level + 1) - 1


def num_all(level):
    return 2 ** (level + 2) - 3


def total_patty(n, x):
    res = 0
    pos = x - 1
    for cur_level in range(n + 1)[::-1]:
        print("L = {}, P = {}, R = {}: ".format(cur_level, pos, res), file=sys.stderr, end="")
        if cur_level == 0:
            print("level zero", file=sys.stderr)
            res += 1
            break
        prev_level_total = num_all(cur_level - 1)
        cur_level_total = num_all(cur_level)
        if pos == 0:
            print("left bread", file=sys.stderr)
            break
        elif 1 <= pos <= prev_level_total:
            print("left block", file = sys.stderr)
            pos -= 1
            continue
        elif pos == prev_level_total + 1:
            print("middle patty", file = sys.stderr)
            res += num_patty(cur_level - 1) + 1
            return res
        elif prev_level_total + 2 <= pos <= cur_level_total - 2:
            print("right block", file = sys.stderr)
            res += num_patty(cur_level - 1) + 1
            pos -= prev_level_total + 2
            continue
        else:
            print("right bread", file = sys.stderr)
            res += num_patty(cur_level)
            break
    return res


def main():
    n, x = (int(z) for z in input().split())
    res = total_patty(n, x)
    print(res)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
  long long n,a,b,u=0;
  cin>>n>>a>>b;
  if(a+b==0)u=0;
  else if(n%(a+b)==0)
    u+=n/(a+b)*a;
  else{
    u+=n/(a+b)*a;
    if(n%(a+b)<=a)
      u+=(n%(a+b));
    else
      u+=a;
  }
  cout<<u<<endl;
  return 0;
}

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

#define INF 1000000000

using namespace std;

int iter(vector<int>& c, vector<int>& t, int idx, int N, int T, int res)
{
  if (idx >= N) return res;
  if (t[idx] <= T) return iter(c, t, idx + 1, N, T, min(res, c[idx]));
  else return iter(c, t, idx + 1, N, T, res);
}

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

  int res = iter(c, t, 0, N, T, INF);
  if (res != INF) cout << res << endl;
  else cout << "TLE" << endl;


  return 0;
}


Measured memory_bytes: 256
def bfs(v):
  distance=[-1]*n
  distance[v]=0
  next=connection[v]
  next2=set()
  visited=[-1]*n
  visited[v]=1
  visitct=1
  ct=0
  while visitct!=n:
    ct+=1
    for i in range(len(next)):
      distance[next[i]]=ct
      visited[next[i]]=1
      visitct+=1
      for j in range(len(connection[next[i]])):
        if visited[connection[next[i]][j]]==-1:
          next2.add(connection[next[i]][j])
    next=list(next2)
    next2=set()
    
  return distance

import sys
input = sys.stdin.readline
n=int(input())
l=[list(map(int,input().split())) for i in range(n-1)]
connection=[[] for i in range(n)]
for i in range(n-1):
  connection[l[i][0]-1].append(l[i][1]-1)
  connection[l[i][1]-1].append(l[i][0]-1)

f=bfs(0);s=bfs(n-1)
ctf=0;cts=0
for i in range(n):
  if f[i]<=s[i]:
    ctf+=1
  else:
    cts+=1

if ctf>cts:
  print('Fennec')
else:
  print('Snuke')

Measured memory_bytes: 77656
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m,a,i,s=0,p;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>a;
        s=s+a;
    }
    if(s>n)
    {
        printf("-1");

    }
    else
    {
        p=n-s;
        printf("%lld",p);
    }
}


Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

ll h,w;
ll dy[4] = {1,0,-1,0};
ll dx[4] = {0,1,0,-1};

bool in(ll y, ll x){
    return 0 <= y && y < h && 0 <= x && x < w;
}

int main(){
    cin >> h >> w;
    vvl a(h,vl(w,0));
    queue<P> q;
    ll sum = 0;
    rep(i,h){
        rep(j,w){
            char c; cin >> c;
            if(c=='#'){
                q.emplace(i,j);
                a[i][j] = 1;
                sum++;
            }
        }
    }
    ll n = q.size();
    ll ans = 0;
    while(!q.empty()){
        P p = q.front(); q.pop();
        ll y = p.first;
        ll x = p.second;
        rep(i,4){
            ll ny = y + dy[i];
            ll nx = x + dx[i];
            if(in(ny,nx)&&a[ny][nx]==0){
                a[ny][nx] = 1;
                q.emplace(ny,nx);
                //cout << ny << nx << endl;
            }
        }
        n--;
        if(n==0){
            ans++;
            n = q.size();
        }
    }
    cout << ans-1 << endl;
}


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

int main() {
  string A, B, C;
  cin >> A >> B >> C;
  
  if (A[A.size()-1] == B[0] && B[B.size()-1] == C[0])  cout << "YES"; 
  else cout << "NO";
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  string S;
  cin >> S;

  if(S == "ABC"){
    print("ARC");
  } else {
    print("ABC");
  }

}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define f(i,x,n) for(ll i=x;i<n;i++)
#define fl(i,x,n) for(ll i=n;i>=x;i--)
#define mod (ll)1e9+7
#define print(x) cout<<x<<endl
#define vec vector<ll>
#define pai pair<ll, ll>
#define itr(it) :: iterator it
#define MAX (ll)1e16
#define MIN (ll)-1e16
#define X first
#define Y second
#define up upper_bound
#define lo lower_bound
using namespace std;
       ///////////   ///     ///   ///      ///   ////////////  ///      ///
       ///           ///     ///   ///      ///   ///      ///  ///      ///
       ///           ///     ///   ///      ///   ///      ///  ///      ///
       ///////////   ///////////   ///      ///   ////////////  ////////////
               ///   ///     ///   ///      ///   ///      ///  ///      ///
               ///   ///     ///   ///      ///   ///      ///  ///      ///
       ///////////   ///     ///   ////////////   ////////////  ///      ///
ll minn( ll a , ll b) 
{
    if(a>b)
        return b;
    return a;
}
ll maxx2( ll a , ll b)
{
    if(a>b)
        return a;
    return b;
}
ll maxx(ll a,ll b,ll c)
{
  return maxx2(a,maxx2(b,c));
}
ll gcdd(ll a, ll b)
{
    if(b==0)
        return a;
    else
        return gcdd(b,a%b);
}
ll dsum(ll n)
{
    ll sum=0;
    while(n>0)
    {
        sum+=n%10;
        n/=10;
    }
    return sum;
}
ll poww(ll a,ll b)
{
    if(b<=0)
        return 1;
    if(b==1)
        return a;
    else
        return poww(a,b/2)*poww(a,b/2)*poww(a,b%2);
}
ll sumsq(ll x,ll y,ll z)
{
    return (x-y)*(x-y)+(y-z)*(y-z)+(z-x)*(z-x);
}
ll n,k,a[200001],dp[200001]={0};
ll solve(ll i)
{
    if(dp[i]!=1000000000)
        return dp[i];
    if(i<=0)
    {
        return 0;
    }
    f(j,1,k+1)
    {
        if((i-j)>=0)
        {
            dp[i]=minn(dp[i],solve(i-j)+abs(a[i]-a[i-j]));
        }
    }
    return dp[i];
}
signed main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    IOS;

    cin>>n>>k;
    f(i,0,n)
    {
        cin>>a[i];
    }
    f(i,0,n)
    {
        dp[i]=1000000000;
    }
    ll ans=solve(n-1);
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main()
{
    string D;
    cin>>D;
    vector<int> vec;
    if(D=="25"){
        cout<<"Christmas"<<endl;
   }else if(D=="24"){
        cout<<"Christmas Eve"<<endl;
   }else if(D=="23"){
        cout<<"Christmas Eve Eve"<<endl;
   }else if(D=="22"){
        cout<<"Christmas Eve Eve Eve"<<endl;}
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define fi first
#define se second
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 200009
#define M 1e6+9
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
#define int long long
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}

// ll n,k,a,b,c,d,x,y,z,m,l;
// ll ans;
// vecl arr(N);
// ll dp[509][509];
// ll pre[N];

int c[10][10];

void test_case() {
	
   
     int n;
    cin >> n;
    for (int k = 0; k <= 6; k++) {
        int b = pow(10, k);
        for (int i = b; i < min(n + 1, 10 * b); i++) {
            c[i / b][i % 10]++;
        }
    }
   ll cnt = 0;
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            cnt += c[i][j] * c[j][i];
        }
    }
   cout << cnt << endl;


   
   


    



}


signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


    int t = 1;
    // cin >> t;
    while(t--)
    {   
        test_case();
    }
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
#define me0(a) memset(a,0,sizeof(a))
#define me1(a) memset(a,-1,sizeof(a))
#define op freopen("in.txt", "r", stdin)
#define pii pair<int,int>
#define mp(x,y) make_pair(x,y)
using namespace std;
const int INF = 0x3f3f3f3f;
typedef long long LL;
void read(int& val) { int x = 0; int bz = 1; char c; for (c = getchar(); (c<'0' || c>'9') && c != '-'; c = getchar()); if (c == '-') { bz = -1; c = getchar(); }for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - 48; val = x * bz; }
const int mod=998244353;
const int maxn = 2e6+7;

int n,m,a[maxn];
int main(){
    read(n);
    m=0;
    fo(i,1,n) read(a[i]),m^=a[i];
    fo(i,1,n){
        printf("%d ",m^a[i]);
    }
    puts("");
    return 0;
}


Measured memory_bytes: 4544
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
 
using namespace std;
 
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


const int INF = 1e9;

double EPS = 1e-10;

pii d[100100];

int main(){
	int n, t, ans;
	while(cin>>n && n){
		d[0].fi=-1;
		d[0].se = 0;
		for(int i = 1; i <= n; i++) {
			cin>>t;
			d[i].fi=t;
			if(i%2==1){
				if(d[i].fi!=d[i-1].fi) d[i].se = 1;
				else d[i].se = d[i-1].se+1;
			}
			else{
				if(d[i].fi==d[i-1].fi) d[i].se = d[i-1].se+1;
				else d[i].se = d[i-1].se+d[i-1-d[i-1].se].se+1;
			}
		}
		ans = 0;
		int idx = n;
		while(idx > 0){
			if(d[idx].fi==0) ans += d[idx].se;
			idx -= d[idx].se;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1940
//この方のようなコードを。
#include <bits/stdc++.h>

using namespace std; 

int main() {

	int a[5]; 
	int totalTime = 0, maxRemainder = 0; 

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

		int remainder = a[i]%10;

		if(remainder == 0) {
			totalTime += a[i]; 
		} 
		else {
			maxRemainder = max(maxRemainder, 10 - remainder); 
			totalTime += a[i] + 10 - remainder; 
		}
	}
	cout << totalTime - maxRemainder << endl; 

	return 0; 
}


Measured memory_bytes: 256
from collections import deque

def main():
    m = int(input())
    c = 0
    dq = deque()
    for _ in range(m):
        q = list(map(int,input().split()))
        if q[0] == 0:dq.appendleft(q[1])
        elif q[0] == 1:
            dq.rotate(-q[1])
            c+=q[1]
        else :dq.popleft()
    dq.rotate(c)
    for e in dq:print(e)

if __name__ == '__main__':
    main()




Measured memory_bytes: 21676
#include "bits/stdc++.h"

using namespace std;

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

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

	int n; cin >> n;
	vector<int> a(n),res(100010,0);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] > 0) res[a[i] - 1]++;
		res[a[i]]++;
		res[a[i]+1]++;
	}
	int ans = 0;
	for (int i = 0; i <= 100000; i++) ans = max(ans, res[i]);
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 5;

int main()
{
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;    
  }
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 * Main
 */
public class Main {

    public static void main(String[] args) {
        FastScanner scan = new FastScanner(System.in);
        final int N = scan.nextInt();
        final int K = scan.nextInt();
        int count = 0;
        for (int i = 0; i < N; i++) {
            if (scan.nextInt() >= K) {
                count++;
            }
        }
        System.out.println(count);
    }

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
             return Double.parseDouble(next());
         }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        } 
    }
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define pr(a,b) cout << a << " " << b << endl
#define pr1(a,b,c) cout << a << " " << b << " "<< c << endl
#define int long long
#define M 998244353

int fact[4001];
int facti[4001];

int pw(int x, int p)
{
	if(p==0)
		return 1;
	int t=pw(x,p/2);
	if(p%2==0) return (t*t)%M;
	else	   return (((t*t)%M)*x)%M;
}
int mult(int x,int y)
{
	return (x*y)%M;
}

int nCk(int n, int k)
{
	if(n<k)
		return 0;
	return mult(fact[n],mult(facti[k],facti[n-k]));
}

int32_t main()
{
	fastio;
	int n,k;
	cin >> k >> n;
	int i,j,x;
	
	fact[0] = 1;
	facti[0] = 1;
	for(i=1;i<=4000;i++){
		fact[i] = (fact[i-1]*i)%M;
		facti[i] = pw(fact[i],M-2);
	}

	int pairs, ans, fre;
	for(i=2;i<=2*k;i++)
	{
		// Restricted Set  && Unrestricted Set
		// Find number of restricted pairs
		pairs = 0;
		ans = 0;
		for(j=1;j<=k;j++)
		{
			if(i-j>j && i-j<=k)
				pairs++;
		}
		fre = k-2*pairs;
		// pr(fre, pairs);
		if(i%2==0)
		{
			for(j=0;j<=pairs;j++)
			{
				// j positions reserved;
				ans = (ans + mult(mult(nCk(pairs,j), pw(2,j)),(nCk(n+fre-2,fre+j-2) + nCk(n+fre-3,fre+j-2))%M))%M;
			}
		}
		else
		{
			for(j=0;j<=pairs;j++)
			{
				ans = (ans + mult(mult(nCk(pairs,j), pw(2,j)),nCk(n+fre-1,fre+j-1)))%M;
			}
		}
		cout << ans << endl;
	}

	return 0;
}

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

using namespace std;

typedef long long int ll;

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int main() {

    fastio();

    int x;
    cin >> x;

    if(x >= 30) cout << "Yes\n";
    else cout << "No\n"; 

    return 0;
}

Measured memory_bytes: 3648
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

template<class T>
inline bool chmin(T& a, const T b) { return a > b && (a = b, true); }

inline int popcount(lint n) {
	n = (n & 0x5555555555555555) + (n >> 1 & 0x5555555555555555);
	n = (n & 0x3333333333333333) + (n >> 2 & 0x3333333333333333);
	n = (n & 0x0f0f0f0f0f0f0f0f) + (n >> 4 & 0x0f0f0f0f0f0f0f0f);
	n = (n & 0x00ff00ff00ff00ff) + (n >> 8 & 0x00ff00ff00ff00ff);
	n = (n & 0x0000ffff0000ffff) + (n >> 16 & 0x0000ffff0000ffff);
	n = (n & 0x00000000ffffffff) + (n >> 32 & 0x00000000ffffffff);
	return n;
}

int main() {

	int N;
	cin >> N;

	vector<lint> X(N), Y(N), P(N);
	for (int i = 0; i < N; i++) cin >> X[i] >> Y[i] >> P[i];

	vector<vector<lint>> xmin(1 << N, vector<lint>(N));
	vector<vector<lint>> ymin(1 << N, vector<lint>(N));
	for (int i = 0; i < (1 << N); i++) {
		for (int j = 0; j < N; j++) {
			xmin[i][j] = abs(X[j]);
			ymin[i][j] = abs(Y[j]);
			for (int k = 0; k < N; k++) {
				if ((i >> k) & 1) {
					chmin(xmin[i][j], abs(X[j] - X[k]));
					chmin(ymin[i][j], abs(Y[j] - Y[k]));
				}
			}
		}
	}

	vector<lint> ans(N + 1, LINF);
	for (int i = 0; i < (1 << N); i++) {
		for (int j = i; j >= 0; j--) {
			j &= i;
			long long cost = 0;
			for (int k = 0; k < N; k++) {
				if (!((i >> k) & 1)) {
					cost += min(xmin[j][k], ymin[i - j][k]) * P[k];
				}
			}
			chmin(ans[popcount(i)], cost);
		}
	}

	for (const auto& e : ans) {
		if (e == LINF) cout << "SAFE" << "\n";
		else cout << e << "\n";
	}

	return 0;
}



Measured memory_bytes: 12924
#ABC125B-Resale.py

from sys import stdin

input = stdin.readline

N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

X_Y = []

for i in range(N):
    X_Y.append(V[i] - C[i])

X_Y.sort(reverse=True)

result = 0

for x_y in X_Y:
    if x_y >= 0:
        result += x_y
    else:
        break

print(result)


Measured memory_bytes: 3060
str = gets.chomp.split("")
str_left = str[0..1].join
str_right = str[2..3].join

yymm_flag = false
mmyy_flag = false
(1..12).each do |i|
  if i < 10
    i = i.to_s
    s = '0'+ i
    mmyy_flag = true if s == str_left
    yymm_flag = true if s == str_right
  else
    s = i.to_s
    mmyy_flag = true if s == str_left
    yymm_flag = true if s == str_right
  end
end

if yymm_flag && mmyy_flag
  puts 'AMBIGUOUS'
else
  puts 'YYMM' if yymm_flag
  puts 'MMYY' if mmyy_flag
  puts 'NA' if !yymm_flag && !mmyy_flag
end

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

const int MOD = 1e9+7;
int n, k, visited[100005];
vector<int> graph[100005];

long long dfs(int u) {
    visited[u] = 1;
    // printf("looking at %d\n", u);
    long long product = 1;
    int childCnt = 0;
    for (auto v : graph[u]) {
        if (!visited[v]) {
            if (u==1) product = (product * (k - 1 - childCnt))%MOD;
            else product = (product * (k - 2 - childCnt))%MOD;
            // printf("product is now %d\n", product);
            childCnt++;
            product = (product * dfs(v))%MOD;
        }
    }

    return product%MOD;
}

int main() {
    cin>>n>>k;
    int u, v;

    for (int i=0;i<n-1;i++) {
        cin>>u>>v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    for (int i=0;i<100005;i++) visited[i] = 0;
    cout<<(dfs(1)*k)%MOD;
}

Measured memory_bytes: 10752
if __name__ == '__main__':
    n, k = map(int, input().split())
    num = [0] * (n + 1)
    for i in range(1, n + 1):
        num[i] = num[i - 1] + i
    num.append(num[-1])
    ans = 0
    for i in range(k, n + 2):
        max_num = num[n] - num[max(0, n - i)]
        min_num = num[i - 1]
        ans += max_num - min_num + 1
        ans %= (10 ** 9 + 7)
    print(ans)


Measured memory_bytes: 19404
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#define MY_DEBUG(s)      s
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#define MY_DEBUG(s)      
#endif

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

#define EPS (1e-7)
#define IINF ((int)1e9)


MY_NAMESPACE(testbed)
bool ABC167F_order(pll const& lhs, pll const& rhs)
{
	// first:  open
	// second: close

	bool retval;

	int lhs_sign = 0;
	if (lhs.first > lhs.second)
		lhs_sign = 1;  // more open
	else if (lhs.first < lhs.second)
		lhs_sign = -1;  // more close

	int rhs_sign = 0;
	if (rhs.first > rhs.second)
		rhs_sign = 1;
	else if (rhs.first < rhs.second)
		rhs_sign = -1;

	if (lhs_sign != rhs_sign)
		retval = lhs_sign > rhs_sign;
	else
	{
		if (lhs_sign >= 0)
		{
			if (lhs.second != rhs.second)
				retval = lhs.second < rhs.second;
			else
				retval = lhs.first > rhs.first;
		}
		else
		{
			//if (lhs.second != rhs.second)
			//	retval = lhs.second > rhs.second;
			//else
				retval = lhs.first > rhs.first;
		}
	}

	return retval;
}

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

	int n;
	cin >> n;
	vector<pll> num_live_open_and_close(n);
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		for (auto it = s.begin(); it != s.end(); it++)
		{
			if (*it == '(')
			{
				num_live_open_and_close[i].first++;
			}
			else  // *it==')'
			{
				if (num_live_open_and_close[i].first > 0)
					num_live_open_and_close[i].first--;
				else
					num_live_open_and_close[i].second++;
			}
		}
	}

	sort(num_live_open_and_close.begin(), num_live_open_and_close.end(), ABC167F_order);

	ll level = 0;
	for (auto it = num_live_open_and_close.begin(); it != num_live_open_and_close.end(); it++)
	{
		level -= it->second;
		if (level < 0)
		{
			cout << "No" << "\n";
			return 0;
		}
		level += it->first;
	}
	if (level == 0)
		cout << "Yes" << "\n";
	else
		cout << "No" << "\n";
	return 0;
}
MY_NAMESPACE_

Measured memory_bytes: 18728
#include <bits/stdc++.h>
using namespace std;
vector < long long > checkprime(long long N) {
        vector < long long > v;
        for( long long i = 1;i * i <=N;++i ) {
             if( N % i == 0) {
                 if( i * i == N )
                         v.push_back(i);
                 else   
                {
                 v.push_back(i);
                 v.push_back(N/i);
                }
              }
        }
    sort(v.begin(),v.end());
    return v;
    }
int main() 
{
    long long n,i;
    cin>>n;
    vector < long long > v,w;
    v=checkprime(n);
    if(v.size()%2==0)
    {
        for(i=0;i<v.size()/2;i++)
        {
            w.push_back(v[i]+v[v.size()-i-1]-2);
        }
    }
    else
    {
        for(i=0;i<=v.size()/2;i++)
        {
            w.push_back(v[i]+v[v.size()-i-1]-2);
        }

    }
    cout<<*min_element(w.begin(),w.end());
	return 0;
}

Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = 0;
		int B = 0;
		Integer[] card = new Integer[N];
		for (int i = 0; i < N; i++) {
			card[i] = sc.nextInt();
		}
		Arrays.sort(card, Collections.reverseOrder());
		for (int i = 0; i < card.length; i++) {
			if (i%2 == 0) A += card[i];
			else B += card[i];
		}
		System.out.println(A-B);
	}	
}

Measured memory_bytes: 21716
N = int(input())
S = input()
# n, *a = map(int, open(0))
# M, D = map(int, input().split())
# A = list(map(int, input().split()))
# S = input()
cnt = 0
new = "-"
for c in S:
    if c == new[-1]:
        continue
    new += c
print(len(new) - 1)

Measured memory_bytes: 3316
n,l = map(int,input().split())
apple = [0]*n

for i in range(n):
  apple[i] = l+i
eat = apple[i]
for i in range(n):
  eat = min(abs(apple[i]),abs(eat))

if eat in apple:
  apple.remove(eat)
else:
  apple.remove(-1*eat)

print(sum(apple))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  string A, B; cin >> A >> B;

  bool res = true;
  if (A == "H") {
    res = B == "H";
  } else {
    res = B == "D";
  }
  auto ans = res;
  cout << (ans ? "H" : "D") << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define invp(a,p)pom(a,p-2,p)


int n;
char s[5010];
ll atai[5010];
int idx[5010];
int c(const void*p,const void*q){
	if(atai[*(int*)p]<atai[*(int*)q])return -1;
	if(atai[*(int*)p]>atai[*(int*)q])return 1;
	if(*(int*)p<*(int*)q)return -1;
	return 1;
}

int f(int m,int g,int MOD){
	ll ue=pom(g,m,MOD);
	ll has=0;
	rep(i,0,m)has=(has*g+s[i])%MOD;
	rep(i,m,n+1){
		atai[i-m]=has;
		has=(has*g+s[i])%MOD;
		has=((has-s[i-m]*ue)%MOD+MOD)%MOD;
	}
	
	rep(i,0,n-m+1)idx[i]=i;
	qsort(idx,n-m+1,sizeof(int),c);
//	printf("%d:",m);
//	rep(i,0,n-m+1)printf("%d ",atai[idx[i]]);puts("");
		
	int flag=0;

	rep(i,0,n-m+1){
		int t=i;
		while(t+1<n-m+1&&atai[idx[i]]==atai[idx[t+1]])t++;
		if(idx[i]+m<=idx[t]){
			flag=1;
			break;
		}
		i=t;
	}
	return flag;
}

int main(){
	scanf("%d %s",&n,s);
	int l=0,r=n;//lはok,rはng
	while(r-l>1){
		int m=(l+r)/2;
		if(f(m,1234,1000000007)&&f(m,4567,1000000009)&&f(m,7890,1000000021))l=m;
		else r=m;
	}
	printf("%d",l);
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
#include <atcoder/all>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) for(int sz=0;sz<int(vec.size());sz++) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

using modi = atcoder::modint1000000007;
// using modi = atcoder::modint998244353;

using PI = P<int, int>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    V<PI> xy(n);
    for (int i = 0; i < n; i++) cin >> xy[i].first >> xy[i].second;
    V<int> ord(n); iota(ALL(ord), 0);
    sort(ALL(ord), [&](int i, int j) {
        return xy[i] < xy[j];
    });

    atcoder::dsu dsu(n);
    set<PI> yi;
    for (int i: ord) {
        int y = xy[i].second;
        int ymin = y;
        while (!yi.empty() && yi.begin()->first < y) {
            PI it = *yi.begin();
            yi.erase(yi.begin());
            dsu.merge(xy[i].first - 1, it.second);
            chmin(ymin, it.first);
        }
        yi.insert(PI(ymin, xy[i].first - 1));
    }

    for (int i = 0; i < n; i++) {
        cout << dsu.size(xy[i].first - 1) << '\n';
    }
    return 0;
}


Measured memory_bytes: 11024
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;

int main()
{ 
    fast;
  
  ll n;
  cin>>n;

  ll ans=0;
  if(n<9)
  {
    cout<<n<<endl;
    return 0;
  }
  ans+=9;
  if(n<100)
    {cout<<ans<<endl;
      return 0;}

      if(n<1000)
      {
        ans+=(n-99);
        cout<<ans<<endl;
      return 0;

      }
      ans+=900;
      if(n<10000)
      {
        cout<<ans<<endl;
      return 0;
      }

      else if(n<100000)
        {
          ans+=(n-9999);
          cout<<ans<<endl;
      return 0;
        }
        ans+=(100000-10000);
        cout<<ans<<endl;
  }

Measured memory_bytes: 256
n, m = map(int, input().split())
mod = pow(10, 9) + 7
x = 0
y = m - n + 1
u, v = n, 1
c, p = 1, 1
for i in range(n, 0, -1):
    if i % 2 == 1:
        x += ((c * p) % mod)
    else:
        x -= ((c * p) % mod)
    x %= mod
    p *= y
    p %= mod
    y += 1
    c = (c * u * pow(v, mod - 2, mod)) % mod
    u -= 1
    v += 1
p = 1
for i in range(n):
    p *= (m - i)
    p %= mod
ans = (pow(p, 2, mod) - (p * x)) % mod
print(ans)

Measured memory_bytes: 73560
// {{{ Boilerplate Code <--------------------------------------------------
// vim:filetype=cpp:foldmethod=marker:foldmarker={{{,}}}

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define ALL(A)     (A).begin(), (A).end()

using namespace std;

// }}}

int main(){
	long long N,K;
	vector<long long> a;
	cin>>N>>K;

	long long currentsum=0;

	a.push_back(0);
	FOR(i,0,N){
		long long tmp;
		cin>>tmp;
		tmp-=K;
		currentsum+=tmp;
		a.push_back(currentsum);
	}

	vector<long long> sorted;
	vector<long long> tmp;

	long long freq=sqrt(N)*2;

	long long ret=0;

	FOR(i,0,N+1){
		long long t=0;

		FOR(j,0,tmp.size()){
			if(tmp[j]<=a[i]){
				t++;
			}
		}
		tmp.push_back(a[i]);

		long long upper=sorted.size();
		long long lower=0;

		while(lower<upper){
			long long mid=(lower+upper)/2;

			if(sorted[mid]<=a[i]){
				lower=mid+1;
			}else{
				upper=mid;
			}
		}


		ret+=t+lower;

		if(i%freq==0){
			FOR(j,0,tmp.size()){
				sorted.push_back(tmp[j]);
			}
			tmp.clear();
			sort(ALL(sorted));
		}
	}

	cout<<ret<<endl;
}


Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000



int main(){
	
	string S;
	cin>>S;
	
	int ans = 0;
	
	for(int i=0;i<3;i++){
		for(int j=i;j<3;j++){
			if(S[j]=='R'){
				ans = max(ans,j-i+1);
			}
			else break;
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>
int main(void) {
	int flag = 1, i, j, n, v, changes = 0, a[100];
	scanf("%d", &n); /*1 <= n <= 100*/
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	while (flag) {
		flag = 0;
		for (j = n - 1; j > 0; j--) {
			if (a[j] < a[j - 1]) {
				v = a[j];
				a[j] = a[j - 1];
				a[j - 1] = v;
				flag = 1;
				changes++;
			}
		}
	}
	for (j = 0; j < n - 1; j++)
		printf("%d ", a[j]);
	printf("%d\n", a[n - 1]);
	printf("%d\n", changes);
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
using namespace std;
int main(){
 int W,H,x,y,r;
 cin >> W >> H >> x >> y>>r;
 bool can = true;
 if(x<r || W<x+r) can = false;
 if(y<r || H<y+r) can = false;
 if(can) cout << "Yes" << endl;
 else cout << "No" <<endl;
}


Measured memory_bytes: 3136
import java.util.Scanner;

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

		int n = sc.nextInt();
		int[] a = new int[n + 1];

		for (int i = 1; i < a.length; i++) {
			a[i] = sc.nextInt();
		}

		int cnt = 0;
		for (int i = 1; i < a.length; i++) {
			if (i == a[a[i]])
				cnt++;
		}

		int pair = cnt / 2;
		System.out.println(pair);

		sc.close();
	}

}


Measured memory_bytes: 52372
#include <stdio.h>
int A[100000], n;

int binarySearch(int key){
  int left = 0;
  int right = n;
  int mid;
  while (left < right){
    mid = (left + right) / 2;
    if (A[mid] == key)
	  return (1);
    else if (key < A[mid]){
      right = mid;
    }
    else {
      left = mid + 1;
    }
  }
  return (0);
}

int main(void){
  int i, q, k, sum = 0;
  scanf("%d", &n);
  for( i = 0; i < n; i++ ){
    scanf("%d", &A[i]);
  }

  scanf("%d", &q);
  for (i = 0; i < q; i++){
    scanf("%d", &k);
    if (binarySearch(k)) sum++;
  }

  printf("%d\n", sum);
  return (0);
}



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

int main() {
  int N, l, r, sum;
  cin >> N;
  sum = 0;
  for (int i=0; i<N; i++){
    cin >> l >> r;
    sum += r-l+1;
  }
  cout << sum << endl;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define vi vector<int>
#define vl vector<long long>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPD(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORD(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define INF 1e18
#define INFTY 1e9
#define MOD 1e9+7
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

template<class T> bool chmax(T &a, const T & b) {
    if (a<b) {
        a = b;
        return true;
    }
    return false;
}

template<class T> bool chmin(T &a, const T & b) {
    if (a>b) {
        a = b;
        return true;
    }
    return false;
}

struct edge {int to, cost;};
vector< vector<edge> > es;
const int MAX_N = 100010;
const int MAX_M = 10010;
int n, m;
vi a, b, c;

int main() {
    cin >> n;
    a.resize(n);
    b.resize(n);
    c.resize(n);
    REP(i, n) cin >> a[i];
    REP(i, n) cin >> b[i];
    REP(i, n) cin >> c[i];

    sort(a.begin(), a.end());
    sort(c.begin(), c.end());
    ll ans = 0;
    REP(i, n) {
        auto p = lower_bound(a.begin(), a.end(), b[i]);
        ll cnt1 = p - a.begin();
        auto q = upper_bound(c.begin(), c.end(), b[i]);
        ll cnt2 = c.end() - q;
        //cout << p << ' ' << n-q << endl;
        ans += cnt1*cnt2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

signed main() {
    int N, K;
    cin >> N >> K;

    int V[N];
    REP(i, N) cin >> V[i];

    int ans = 0;
    REP2(A, 0, K) {
        int L = min(N, K) - A;
        REP2(B, 0, L) {
            vi v;
            if (A > 0) REP(i, A) v.pb(V[i]);
            if (B > 0) REP(i, B) v.pb(V[N-1-i]);

            sort(v.begin(), v.end());
            int M = K - A - B;
            int sum = 0;
            REP(i, v.size()) {
                if (M > 0 && v[i] < 0) {
                    M--; continue;
                }
                sum += v[i];
            }
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
		int N, A, B;
		cin >> N >> A >> B;
		if (A > B || (N == 1 && A != B))
			cout << 0 << endl;
		else if (A == B)
		{
			cout << 1 << endl;
		}
		else
		{
			int min = A + B + (N - 2)*A;
			int max = A + B + (N - 2)*B;
			int num = max - min + 1;
			printf("%lld\n", (long long)(B - A)*(N - 2) + 1);
		}
		//system("pause");
		return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
vector<ll> dp[5050][2];
int sz[5050];
vector<int> v[5050];
ll calc[5050];


void dfs(int x,int p=-1){
    sz[x]=1;
    for(auto to:v[x]){
        if(to==p)continue;
        dfs(to,x);
    }
    rep(i,2)dp[x][i].resize(sz[x]+1);
    dp[x][0][1]=1;
    int s=2;
    for(auto to:v[x]){
        if(to==p)continue;
        int m=dp[to][0].size();
        vector<ll> dpp[2];
        rep(i,2)dpp[i].resize(m+s);
        rep(i,m)rep(j,s){
            dpp[0][i+j]+=(dp[x][0][j]*dp[to][0][i]+dp[x][1][j]*dp[to][1][i])%mod;
            dpp[1][i+j]+=(dp[x][0][j]*dp[to][1][i]+dp[x][1][j]*dp[to][0][i])%mod;
        }
        s+=m-1;
        rep(i,s){
            dp[x][0][i]=dpp[0][i]%mod;
            dp[x][1][i]=dpp[1][i]%mod;
        }
    }
    rep(i,s-1){
        dp[x][0][0]+=dp[x][1][i+1]*calc[i+1]%mod;
        dp[x][1][0]+=dp[x][0][i+1]*calc[i+1]%mod;
    }
    dp[x][0][0]%=mod;
    dp[x][1][0]%=mod;
    if(p!=-1)sz[p]+=sz[x];
}


int main(){
    int n;cin>>n;
    rep(i,n-1){
        int x,y;cin>>x>>y;
        --x;--y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    calc[0]=1;
    rep(i,n)calc[i+2]=calc[i]*(i+1)%mod;
    dfs(0);
    ll ans=(mod+dp[0][1][0]-dp[0][0][0])%mod;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 138496