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

const int MOD = 998244353;

int a, b, c, d;
long long dp[3003][3003];

long long solve(int x, int y)
{
    if (x < a || y < b)
        return 0;
    
    if (x == a && y == b)
        return 1;
    
    if (dp[x][y] != -1)
        return dp[x][y];
    
    long long ans = solve(x - 1, y) * y + solve(x, y - 1) * x;
    ans += MOD - solve(x - 1, y - 1) * (x - 1) % MOD * (y - 1) % MOD;

    return dp[x][y] = ans % MOD;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    cin >> a >> b >> c >> d;
    memset(dp, -1, sizeof(dp));

    cout << solve(c, d) << "\n";
    return 0;
}


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

int main(){
  
  int n,m;
  cin >> n >> m;
  vector<pair<int,bool>> dp(n,make_pair(1,0));
  dp[0].second = true;
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a --;
    b --;
    dp[a].first --;
    dp[b].first ++;
    if(dp[a].second) dp[b].second = true;
    if(dp[a].first == 0) dp[a].second = false;
  }
  int ans = 0;
  rep(i,n) ans += dp[i].second;
  //debug
  //rep(i,n) cout << dp[i].first << "," << dp[i].second << endl;
  //debug
  cout << ans << endl;
}

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
const int N=2019;
ll rem[N];
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    string s;
    cin>>s;
    ll n=s.size();
    ll d=1;
    ll num=0;
    rem[0]=1;
    repD(i,n-1,0)
    {
        num=((s[i]-'0')*d+num)%N;
        d=(d*10)%N;
        rem[num]++;
    }
    ll ans=0;
    rep(i,N) ans+=(rem[i]*(rem[i]-1))/2;
    cout<<ans<<'\n';
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


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

using namespace std;
typedef long long ll;

int n,m;

int main()
{
	scanf("%d%d",&n,&m);
	int x = 1,y = n;
	for(int i=m;i >= 1;i--){
		if(i&1) printf("%d %d\n",x,m+2-x) , x++;
		else printf("%d %d\n",n-y+n-m+1,y) , y--;
	}
} 

Measured memory_bytes: 3836
import java.util.*;
 
public class Main
{
    public static void main(String []args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int curr = 7;
        int sum = 0;
        boolean found = false;
        for(int i = 1 ; i <= 1000000 ; i++)
        {
            sum += curr%n;
            sum %= n;
            if(sum == 0)
            {
                found = true;
                System.out.println(i);
                break;
            }
            curr = curr*10%n;
        }
        if(!found)
        System.out.println("-1");
    }
}

Measured memory_bytes: 36076
S = int(input())
import numpy as np
values = list(map(int, input().split()))
values2 = np.array(values)
costs = list(map(int, input().split()))
cost2 = np.array(costs)
tes=values2-cost2
kotae=0
for i in range(S):
  value=tes[i]
  if value >= 0:
    kotae=kotae+tes[i]


print(kotae)
  

Measured memory_bytes: 21536
require 'pp'

num = $stdin.gets.chomp.to_i
items = num.times.map {$stdin.gets.chomp.split(" ").map(&:to_i)}

def valid?(numbers, left, right)
  return [left, right] if numbers.empty?
  number = numbers.shift
  if left.empty? or left[-1] < number then
    ret = valid?(numbers.clone, left + [number], right)
    return ret if ret
  end
  if right.empty? or right[-1] < number then
    ret = valid?(numbers.clone, left, right + [number])
    return ret if ret
  end
  return false
end

items.each do |item|
  puts valid?(item, [], []) ? "YES" : "NO"
end

Measured memory_bytes: 6248
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define N 1000000
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int l[N],r[N];
int main()
{	int n; ll ans=0; scanf("%d",&n);
	for(rint i=1;i<=n;i++) scanf("%d%d",&l[i],&r[i]);
	sort(l,l+n+1); sort(r,r+n+1);
	for(rint i=0;i<=n;i++) ans+=max(0,l[n-i]-r[i]);
	cout<<2*ans;
	return 0;
}


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

int main(){
    int t[4],n[4];
    for(int i=0;i<4;i++){
        cin>>t[i]>>n[i];
        if(t[i]==1) cout<<6000*n[i]<<endl;
        else if(t[i]==2) cout<<4000*n[i]<<endl;
        else if(t[i]==3) cout<<3000*n[i]<<endl;
        else cout<<2000*n[i]<<endl;
    }
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define pb push_back
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ll long long
using namespace std;
int main(){
  int a, b, t;
  cin >> a >> b >> t;
  int ans = t / a * b;
  cout << ans << endl;
  return 0;
}


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

int main() {
  int n;cin>>n;
  vector<int> a(n+1);
  vector<pair<int,int>> p(n+1);
  for(int i=1;i<=n;i++){
    cin>>a[i];
  p[i]=make_pair(a[i],i);
  }
  sort(all(p));
  for(int i=1;i<=n;i++)cout<<p[i].second<<" ";
  cout<<endl;
}

Measured memory_bytes: 4508
#include<stdio.h>
#include<string.h>
#include<stdbool.h>

int main()
{
  int n;
  
  scanf("%d",&n);
  
  int t[n+1],x[n+1],y[n+1];
  int i;
  bool b=true;
  
  t[0]=0,x[0]=0,y[0]=0;
  
  for(i=0;i<n;i++)
  {
    scanf("%d%d%d",&t[i+1],&x[i+1],&y[i+1]);
  }
  
  for(i=0;i<n;i++)
  {
    int tmpx=x[i+1]-x[i];
    int tmpy=y[i+1]-y[i];
    int time=t[i+1]-t[i];
    
    if(time>=abs(tmpx)&&time>=abs(tmpy))
    {
      if((abs(tmpx)+abs(tmpy))%2!=time%2)
      {
        b=false;
      }
    }
    else
    {   
      b=false;
      printf("No\n");
      return 0;
    }
  }
  
  if(b==true)
  {
    printf("Yes\n");
  }
  else
  {
    printf("No\n");
  }
  
  return 0;
}

Measured memory_bytes: 1280
A, B, C, D = gets.split.take(4).map(&:to_i)
N = gets.to_i
_2 = [A * 8, B * 4, C * 2, D].min
_1 = [A * 4, B * 2, C].min
p N / 2 * _2 + N % 2 * _1

Measured memory_bytes: 1788
aka,midori,ao=map(int,input().split())
K = int(input())
count = 1
while count <= K-1:
    if aka>=midori:
        midori = midori*2
        count = count+1
    else:
        break
while count <= K:
    if midori>=ao:
        ao = ao*2
        count = count+1
    else:
        break
if aka<midori:
    if midori<ao:
        print("Yes")
    else:
        print("No")
else:
    print("No")



Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define mid (l+r)/2
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ll long long
using namespace std;
int q,k=0,tot=0,s=0;
const int maxn=2e5+5;
ll f[maxn*4],va[maxn*4];
ll res1,res2,ans,f1,f2,sum1,sum2;
int op[maxn],x[maxn],y[maxn],t[maxn];
ll kth(int l,int r,int rt)
{
    if(l==r)
    {
        res1=t[l];
        //printf("%lld\n",f1*t[l]-f2*t[l]-sum1+sum2);
        return f1*t[l]-f2*t[l]-sum1+sum2;
    }
    else
    {
        if(f2+f[rt<<1|1]<=s/2)
        {
            f2+=f[rt*2+1];
            sum2+=va[rt<<1|1];
            return kth(lson);
        }
        else
        {
            f1+=f[rt<<1];
            sum1+=va[rt<<1];
            return kth(rson);
        }
    }
}
void add(int l,int r,int rt,int x)
{
    if(l==r)
    {
        va[rt]+=t[l];
        f[rt]++;
        return ;
    }
    if(x<=mid)
        add(lson,x);
    else
        add(rson,x);
    f[rt]=f[rt*2]+f[rt*2+1];
    va[rt]=va[rt*2]+va[rt*2+1];
}
int main()
{
    scanf("%d",&q);
    for(int i=1; i<=q; i++)
    {
        scanf("%d",&op[i]);
        if(op[i]==1)
            scanf("%d%d",&x[i],&y[i]),t[++tot]=x[i];
    }
    sort(t+1,t+1+tot);
    for(int i=1; i<=q; i++)
    {
        if(op[i]==1)
        {
            s++;
            int a=lower_bound(t+1,t+1+tot,x[i])-t;
            add(1,tot,1,a);
            ans+=y[i];
        }
        else
        {
            f1=f2=sum1=sum2=0;
            res2=kth(1,tot,1);
            printf("%lld %lld\n",res1,res2+ans);
        }
    }
    return 0;
}


Measured memory_bytes: 12672
#include <iostream>
#include <cstring>
#include <cstdio>
#include<cstdint>
#include<utility>
#include<algorithm>
#include<map>
#include<cmath>
#include<vector>
#include<string>
#include<list>
#include<deque>
#include<stack>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define rep(i, n) for (int i = 0; i < n; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
const int MOD = 1e9+7;
#define NIL -1
const int INF = 1 << 29;
ll n;
ll k;
ll cnt[MAX];

int main(){
    ll a,b;
    memset(cnt,0,sizeof(cnt));
    cin>>n>>k;
    rep(i,n){
        cin>>a>>b;
        cnt[a]+=b;
    }
    ll count=0;
    ll i;
    for(i=1;i<=MAX;i++){
        count+=cnt[i];
        if(count>=k){
            cout<<i<<endl;
            break;
        }
        
    }
    return 0;
}

Measured memory_bytes: 1024
h,w = map(int,input().split())
a = []
mod = 10**9 + 7
for i in range(h):
  a.append([s  for s in input()])
dp = [[0]*w for i in range(h)]
dp[0][0] = 1
for i in range(h):
  for j in range(w):
    tasu = 0
    if j >0 and a[i][j-1] == ".":
      tasu += dp[i][j-1]
    if i>0 and a[i-1][j] == ".":
      tasu += dp[i-1][j]
    dp[i][j] = tasu%mod+dp[i][j]
print(dp[h-1][w-1]%mod)

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

int main(){
  int n;
  cin >> n;
  int m = n%10;
   if(m==3) cout << "bon" << endl;
  else if(m==0||m==1||m==6||m==8) cout << "pon" << endl;
  else cout << "hon" << endl;
  
 return 0; 
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N[3];
	for (int i = 0; i < 3; i++)
	{
		cin >> N[i];
	}

	sort(N, N + 3);

	cout << N[2] * 10 + N[1] + N[0] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    if(e-a<=k)cout << "Yay!";
    else cout << ":(";
    


}

/*



 */


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = (1LL<<31)-1;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
template <typename T,typename E>
struct SegmentTree{
  typedef function<T(T,T)> F;
  typedef function<T(T,E)> G;
  typedef function<E(E,E)> H;
  typedef function<E(E,ll)> P;
  ll n;
  F f;
  G g;
  H h;
  P p;
  T d1;
  E d0;
  vector<T> dat;
  vector<E> laz;
  SegmentTree(ll n_,F f,G g,H h,T d1,E d0,
	      vector<T> v=vector<T>(),P p=[](E a,ll b){return a;}):
    f(f),g(g),h(h),d1(d1),d0(d0),p(p){
    init(n_);
    if(n_==(ll)v.size()) build(n_,v);
  }
  void init(ll n_){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(2*n-1,d1);
    laz.clear();
    laz.resize(2*n-1,d0);
  }
  void build(ll n_, vector<T> v){
    for(ll i=0;i<n_;i++) dat[i+n-1]=v[i];
    for(ll i=n-2;i>=0;i--)
      dat[i]=f(dat[i*2+1],dat[i*2+2]);
  }
  inline void eval(ll len,ll k){
    if(laz[k]==d0) return;
    if(k*2+1<n*2-1){
      laz[k*2+1]=h(laz[k*2+1],laz[k]);
      laz[k*2+2]=h(laz[k*2+2],laz[k]);
    }
    dat[k]=g(dat[k],p(laz[k],len));
    laz[k]=d0;
  }
  T update(ll a,ll b,E x,ll k,ll l,ll r){
    eval(r-l,k);
    if(r<=a||b<=l) return dat[k];
    if(a<=l&&r<=b){
      laz[k]=h(laz[k],x);
      return g(dat[k],p(laz[k],r-l));
    }
    return dat[k]=f(update(a,b,x,k*2+1,l,(l+r)/2),
		    update(a,b,x,k*2+2,(l+r)/2,r));
  }
  T update(ll a,ll b,E x){
    return update(a,b,x,0,0,n);
  }
  T query(ll a,ll b,ll k,ll l,ll r){
    eval(r-l,k);
    if(r<=a||b<=l) return d1;
    if(a<=l&&r<=b) return dat[k];
    T vl=query(a,b,k*2+1,l,(l+r)/2);
    T vr=query(a,b,k*2+2,(l+r)/2,r);
    return f(vl,vr);
  }
  T query(ll a,ll b){
    return query(a,b,0,0,n);
  }
};
    auto F = [](ll a, ll b){return min(a,b);};
    auto G = [](ll a, ll b){return b==INF?a:b;};
    auto H = G;
    auto P = [](ll a, ll b){return a;};
    SegmentTree<ll,ll> seg(MAX_N, F, G, H, INF, INF,vl(MAX_N,INF));
int main() { cin >> n >> q; 
while(q--){
    cin >> x;
    if(x==0){
        cin >> a >> b >> c;
        seg.update(a, b + 1, c);
    }
    else{
        cin >> a >> b;
        cout << seg.query(a, b + 1)<<endl;
    }
}}



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

int n,x;
map<int,int>f;
long long ans;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x;
		ans+=f[x-i];
		f[-i-x]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 20584
S = int(input())
slist = input().split()

for i,a in enumerate(slist):
  slist[i] = int(a)

new_list = sorted(slist)
d_count = 0
for i,j in zip(slist,new_list):
  if i != j:
    d_count += 1
    
if d_count <= 2:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    long long ans = 1LL, tmp = ans;
    for (int i = 0; i < n; i++) {
        ans *= a[i];
        if (ans > 1000000000000000000LL || ans < 0 || tmp > ans)  {
            ans = -1;
            break;
        }
        tmp = ans;
    }
    for (int i = 0; i < n; i++) {
        if (a[i] == 0) {
            ans = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3964
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var sx = int.Parse(line[0]);
        var sy = int.Parse(line[1]);
        var tx = int.Parse(line[2]);
        var ty = int.Parse(line[3]);
        var x = tx - sx;
        var y = ty - sy;
        writeAns(x, y);
    }
    public static void writeAns(int x, int y)
    {
        var ans = "";
        ans += new string('U', y);
        ans += new string('R', x);
        ans += new string('D', y);
        ans += new string('L', x);
        ans += "D";
        ans += new string('R', x + 1);
        ans += new string('U', y + 1);
        ans += "L";
        ans += "U";
        ans += new string('L', x + 1);
        ans += new string('D', y + 1);
        ans += "R";
        Console.WriteLine(ans);
    }
}

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

#define F first
#define S second
typedef double db;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll gcd(ll x,ll y){
return y? gcd(y,x%y):x;
}

int main(){
  ll n,sum=0;
  cin>>n;
  vector<ll> v(n);
  rep(i,n)cin>>v[i];
  map<ll,ll> mp;
  rep(i,n){
  ll a=v[i];
  mp[a]++;
  }
  for(int i=1;i<=n;++i){
  ll b=mp[i]*(mp[i]>0? mp[i]-1:0)/2;
  sum+=b;
  }
  rep(i,n){
  ll c=v[i];
  cout<<sum-mp[c]+1<<endl;
  }
return 0;
}

Measured memory_bytes: 16640
import java.util.Scanner;

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

		int num = scanner.nextInt();
		scanner.close();
		
		
		int a[] = {1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,24,25,27,28,30,
				32,35,36,40,42,45,48,49,54,56,63,64,72,81};
		boolean flg = false;
		for(int i = 0; i < a.length; i++) {
			if(a[i] == num) {
				System.out.println("Yes");
				flg = true;
				break;
			}
		}
		
		if(!flg) {
			System.out.println("No");
		}
	}

}



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

using namespace std;

#pragma GCC optimize("O3")
static const auto __ = [] {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  return nullptr;
}();

int solve(int N) {
  int A[N];
  for (int& a : A) {
    cin >> a;
  }
  int DP[N];
  DP[0] = 0;
  DP[1] = abs(A[1] - A[0]);
  for (int i {2}; i < N; ++i) {
    DP[i] = min(DP[i - 1] + abs(A[i - 1] - A[i]),
                DP[i - 2] + abs(A[i - 2] - A[i]));
  }
  return DP[N - 1];
}

int main(int argc, char* argv[]) {
  int N;
  cin >> N;
  cout << solve(N) << '\n';
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <algorithm>
 
using namespace std;
 
#define rep(i, n) for(int i = 0; i < n ; i++)
#define For(i, a, b) for(int i = (a) ; i < (b); i++)
 
int main(void){
    int N, M;
    int L, R;
 
    scanf("%d %d", &N, &M);
 
    int L_max = 0;
    int R_min = N;
  
    rep(i, M){
        int L, R;
     	scanf("%d %d", &L, &R);
    	L_max = max(L, L_max);
        R_min = min(R, R_min);
    }
 
    cout << max(0, R_min - L_max + 1) << endl;
 
    return 0;
 
    }

Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))

    # print(N)
    # print(A)
    d = {i:0 for i in range(1,N+1)}
    d2 = {}
    d3 = {}
    # print(d)
    # return


    for i in A:
        d[i] += 1

    # print(d)
    sum = 0
    for i in range(1,N+1):
        d2[i] = int(d[i] * (d[i]-1) / 2)
        sum += d2[i]

    # print(d2)

    for i in range(1, N+1):
        if d[i] == 0: d3[i] = 0
        else: d3[i] = int((d[i]-1) * (d[i]-2) / 2)

    # print(d3)


    for i in A:
        print(sum - d2[i] + d3[i])

if __name__ == '__main__':
    main()


Measured memory_bytes: 117960
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define L_T_S_K ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);  
const int mod = 1e9 + 7;
const int N = 1e6 + 9;
int fact[N];

int binpower(int a , int b){
	a%=mod;
	int res = 1;
	while(b > 0){
		if(b&1){
			res = res * a % mod;
		}
		a = a * a % mod;
		b>>=1;
	}
	return res;
}
void pre(){
	fact[0] = fact[1] = 1;
	for(int i = 2 ; i < N ;i++){
		fact[i] = fact[i - 1] * i %mod;
	}
}
int mul(int x , int y){
	return ((x % mod) * (y % mod))%mod;
}
int inver(int x){
	return binpower(x , mod - 2);
}
int32_t main(){
 L_T_S_K;
 pre();
 int x , y;
 cin >> x >> y;
 if((x + y)%3 != 0){
 	cout << 0 << "\n";
 	return 0;
 }
 int n = (2 * y - x)/3;
 int m = (2 * x - y)/3;
 if(n < 0 || m < 0){
 	cout << 0 ;
 	return 0;
 }
 cout << mul(fact[n + m] , inver( mul(fact[n] , fact[m]))); 
 return 0;		
} 


Measured memory_bytes: 8064
class Node
  attr_accessor :left, :right, :parent, :value

  def initialize(value)
    @value = value
  end

  def remove
    case children_count
    when 0
      replace_parent_pointer
    when 1
      replace_node = left ? left : right
      replace_parent_pointer(replace_node)
    when 2
      replace_node = next_section_point

      replace_node.left = left
      left.parent = replace_node

      if replace_node.value != right.value
        replace_node.right = right
        right.parent = replace_node
      end
      
      replace_node.replace_parent_pointer

      replace_parent_pointer(replace_node)
    end

    self.parent = nil
    self.left = nil
    self.right = nil
  end

  def replace_parent_pointer(replace_node = nil)
    replace_node.parent = parent if replace_node

    return if parent.nil?

    if parent&.left&.value == value
      parent.left = replace_node
    else
      parent.right = replace_node
    end
  end

  def children_count
    return 2 if left && right
    return 1 if left || right
    0
  end

  private

  def next_section_point
    node = right
    node = node.left until node.left.nil?
    node
  end
end

class Tree
  def initialize
    @root = nil
  end

  def insert(node)
    parent = nil
    x = @root
    until x.nil?
      parent = x
      if node.value < x.value
        x = x.left
      else
        x = x.right
      end
    end

    node.parent = parent
    if parent.nil?
      @root = node
    elsif node.value < parent.value
      parent.left = node
    else
      parent.right = node
    end
  end

  def in_order(node = @root, arr = [])
    in_order(node.left, arr) if node.left
    arr << node.value
    in_order(node.right, arr) if node.right
    arr
  end

  def pre_order(node = @root, arr = [])
    arr << node.value
    pre_order(node.left, arr) if node.left
    pre_order(node.right, arr) if node.right
    arr
  end

  def find(value)
    x = @root
    until x.nil?
      return x if x.value == value

      if x.value > value
        x = x.left
        next
      end

      x = x.right if x.value < value
    end
    false
  end

  def delete(value)
    node = find(value)
    return unless node
    node.remove
  end
end


tree = Tree.new
gets.to_i.times do
  command, value = gets.split

  case command
  when 'insert'
    tree.insert(Node.new(value.to_i))
  when 'find'
    puts tree.find(value.to_i) ? 'yes' : 'no'
  when 'delete'
    tree.delete(value.to_i)
  when 'print'
    puts "\s" + tree.in_order.join("\s")
    puts "\s" + tree.pre_order.join("\s")
  end
end



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

cart =[]

for _ in range(n):
    p = int(input())

    cart.append(p)

p_m = max(cart)

index = cart.index(p_m)

total =0
for i in range(n):
    if i != index:
        total +=cart[i]
    else:
        total +=cart[i]/2

print(int(total))

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
  int i;
  int n;
  int max;
  int min;
  long long int sum = 0;

  scanf("%d", &n);
  int a[n];

  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    sum += a[i];
  }

  min = a[0];
  max = a[0];

  for (i = 0; i < n; i++) {
    if (a[i] < min) min = a[i];
    if (a[i] > max) max = a[i];
    //sum += a[i];
  }

  printf("%d %d %lld\n", min, max, sum);

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
const ll INF=1e18L+5;
int main()
{
    ll n,W,sum=0;
    cin>>n>>W;


    vector<ll> wt(n+1),v(n+1);
    for(ll i=1;i<=n;i++){
            cin>>wt[i]>>v[i];
            sum+=v[i];
    }
    vector<ll>dp(sum+1,INF);
    dp[0]=0;
    for(ll i=1;i<=n;i++){
        for(ll j=sum;j>=v[i];j--){
            dp[j]=min(dp[j],wt[i]+dp[j-v[i]]);
        }
    }
   ll ans=0;
   ll i;
    for( i=sum;i>=0;i--){
            if(dp[i]<=W){
                cout<<i<<endl;
                    break;
            }
    }


}


Measured memory_bytes: 1024
use std::io;


/// https://beta.atcoder.jp/contests/abc049/tasks/abc049_b
fn main() {
    let (h, _) = {
        let i = read::<isize>();
        (i[0], i[1])
    };

    let mut vec = Vec::new();

    for _ in 0..h {
        let i = read_one::<String>();
        let j = i.clone();
        vec.push(i);
        vec.push(j);
    }

    let mut vec = vec.into_iter().rev().collect::<Vec<String>>();

    while let Some(s) = vec.pop() {
        println!("{}", s);
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

int main() {
    int32_t n;
    int64_t a, b;
    cin >> n >> a >> b;
    int32_t x[n];
    for(int32_t i = 0; i < n; i++) {
        cin >> x[i];
    }

    int64_t answer = 0;
    for (int32_t i = 0; i < n - 1; i++) {
        answer += min(a * (x[i + 1] - x[i]), b);
    }
    cout << answer << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<ctime>
#include<complex>
#include<functional>
#include<climits>
#include<cassert>
#include<iterator>
#include<unordered_set>
#include<unordered_map>

using namespace std;

double a;
/*
long long int ppow(long long int i, long long int j){
long long int res = 1;
while (j){
if (j & 1LL){
res *= i;
}
}
}
*/
int main(){
	long long int n;
	long long int m;
	long long int d;
	cin >> n >> m >> d;
	double lef = d + 1;
	double rig = n - d;
	vector<double> v;
	v.push_back(0);
	v.push_back(lef - 1);
	v.push_back(lef + 1);
	v.push_back(lef);
	v.push_back(rig);
	v.push_back(rig + 1);
	v.push_back(rig - 1);
	v.push_back(n);
	sort(v.begin(), v.end());
	double z = 0.0;
	v.erase(unique(v.begin(), v.end()), v.end());
	for (int i = 0; i + 1 < v.size(); i++){
		if (v[i] >= n)break;
		double R = v[i + 1];
		double L = v[i] + 1;
		double way = 0;
		if (lef <= L){
			way += 1.0;
		}
		if (R <= rig){
			way += 1.0;
		}
		if (d == 0){
			way -= 1.0;
		}
		z += way*(v[i + 1] - v[i]);
	}
	double all = (double)(n)*(double)(n);
	z /= all;
	z *= (m - 1);
	printf("%.16f\n", z);
	return 0;
}

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

namespace atcoder_問題
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = Convert.ToInt32(input[0]);
            int b = Convert.ToInt32(input[1]);
            int sum = 0;
            for (int i = 0; i <= 1; ++i)
            {
                if (a <= b)
                {
                    sum += b;
                    b -= 1;
                 }
                else
                {
                    sum += a;
                    a -= 1;
                }
            }
            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
using namespace std;

int main() {
	int n, a = 1, b, ans = 0;
	vector<int>v;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int t;
		cin >> t;
		v.push_back(t);
	}
	a = v[a - 1];
	++ans;
	while (a > 2) {
		b = v[a - 1];
		v[a - 1] = 1;
		a = b;
		++ans;
	}
	if (a == 1) {
		ans = -1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 892
N = int(input())
A = list(map(int, input().split()))

steps = 0
steps_list = []
for i in range(1,N):
	if A[i] < A[i-1]:
		steps_list.append(A[i-1] - A[i])
		A[i] += A[i-1] - A[i]
print(sum(steps_list))


Measured memory_bytes: 105332
n=int(input())
siritori=[input() for i in range(n)]
tale=siritori[0][:1]
answer='Yes'
for i in range(n):
    if tale!=siritori[i][:1]:
        answer='No'
        break
    if siritori.index(siritori[i])!=i:
        answer='No'
        break
    tale=siritori[i][-1:]
print(answer)

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n;
// string s;

int main() {
    cin >> n;
    std::cout << (n+1)/2 << '\n';

    return 0;
}


Measured memory_bytes: 256
n=int(input())
s=input()
ans=n+1
l=[0]*(n+1)
for i in range(n):
  if s[i]=='E':
    l[i+1]=l[i]+1
  else:
    l[i+1]=l[i]
ans=n+1
for i in range(n):
  ans=min(ans,i-l[i]+l[n]-l[i+1])
print(ans)


Measured memory_bytes: 15160
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <unordered_set>
#include <bitset>
#include <queue>
#include <unordered_map>
using namespace std;
typedef long long ll;
int main(){
    ll N;
    cin >> N;
    ll sum=0;
    for(ll i=1;i<=N;i++){
        if((i%3)!=0&&(i%5)!=0) sum += i;
    }
    printf("%lld\n", sum);
    return 0;
}

Measured memory_bytes: 3728
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
long nCr(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

signed main() {
	string s;
	cin >> s;
	int ans = 0;
	rep(i, s.size()/2) {
		if (s[i] != s[s.size() - 1 - i])ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double EPS=1e-9;
const int MOD=1e9+7;
int main(){
    int h,w;cin>>h>>w;swap(h,w);
    int n;cin>>n;
    if(n==0){
        cout<<w<<endl;
        return 0;
    }
    vector<P> v;
    for(int i=0;i<n;i++){
        int x,y;cin>>x>>y;x--;y--;
        v.push_back(P(y,x));
    }
    sort(all(v));
    ll ans=w;
    int co=0;
    for(int i=0;i<n;i++){
        ll y=v[i].first,x=v[i].second;
        if(x<y+co)continue;
        if(x==y+co){
            co++;continue;
        }
        ans=min(ans,x);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int T,A,X,B,Y,C,D;
vector<pair<int,int> > s;
int _gcd(int a,int b){
	if(b==0)return a;
	return _gcd(b,a%b);
}
void init(){
	int g=_gcd(A,B);
	A/=g,B/=g,C/=_gcd(g,C);
	g=_gcd(A,C),A/=g,C/=g,Y/=g;
	g=_gcd(B,C),B/=g,C/=g,X/=g;
}
void exgcd(int a,int b,int &x,int &y){
	if(b==0){
		x=1,y=0;
		return;
	}
	exgcd(b,a%b,x,y);
	int t=x;
	x=y;
	y=t-a/b*y;
}
int Inv(int a,int mod){
	int x,y;
	exgcd(a,mod,x,y);
	return (x+mod)%mod;
}
int Get(int x){
	return !x?C:(C-1LL*x*D%C)%C;
}
void Get_seg(){
	D=1LL*A*Inv(B,C)%C;
	s.clear();
	int W=C,H=D,now=0,invD=Inv(D,C);
	while("MAK AK IOI!"){
		s.emplace_back(W/H,(int)(1LL*now*invD%C));
		now+=W/H*H;
		if(!(W%=H))break;
		if(!(H%=W))H=W;
	}
	s.emplace_back(0,C);
}
int main(){
	T=read();
	while(T--){
		A=read(),X=read(),B=read(),Y=read(),C=read();
		init();
		if(C==1){
			printf("%d\n",X+Y);
			continue;
		}
		Get_seg();
		ll mx=0;
		for(int i=0;i<(int)s.size()-1;++i){
			int lx=s[i].second,rx=s[i+1].second;
			int ly=Get(lx),ry=Get(rx);
			int dx=(rx-lx)/s[i].first,dy=(ly-ry)/s[i].first;
			auto check=[=](ll k) -> bool{
				if(X-k*lx<0||Y-k*ry<0)return false;
				int a=(X-k*lx)/dx,b=(Y-k*ry)/dy;
				return a+b>=k*s[i].first;
			};
			ll l=0,r=X+Y+1,ans=0;
			while(l<r){
				ll mid=(l+r)>>1;
				if(check(mid)){
					ans=mid;
					l=mid+1;
				}
				else{
					r=mid;
				}
			}
			mx=max(mx,ans);
		}
		printf("%lld\n",mx);
	}
	return 0;
}



Measured memory_bytes: 3736
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, digitDP, treeDP//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vll flag, D; vll path;
//***********//
ll binarySearch(vl V, ll key) {
	ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	ll right = V.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は V.size()
	while (right - left > 1) {
		ll mid = left + (right - left) / 2;
		if (V[mid] >= key) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
int main() {
	ll A, B;
	cin >> N >> A >> B;
	vl H(N);
	for (i = 0; i < N; i++) cin >> H[i];
	ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	ll right = 1000000000; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は V.size()
	while (right - left > 1) {
		ll mid = left + (right - left) / 2;
		ll key = 0;
		for (i = 0; i < N; i++) {
			if (H[i] - B * mid > 0) key += (H[i] - B * mid - 1) / (A-B) + 1;
		}
		if (key <= mid) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	co(right);
}

Measured memory_bytes: 4040
def main():
    X,Y = [int(x) for x in input().split()]
    tsuru = 2
    kame = 4
    for i in range(X+1):
        if Y == (X-i)*kame + i*tsuru:
            print('Yes')
            return
    print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 61644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll t;
ll ret = 0;
ll A = 0, B = 0, C = 0;
string s;


void input() {
  char c;
  IN(c);
  c += 1;
  PRINT(c);
}

void solve() {

}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
<?php
    fscanf(STDIN,"%d%d",$N,$K);
    
    $h = array_map('intval',explode(" ",trim(fgets(STDIN))));
    
    $count=0;
    for($i=0;$i<$N;$i++){
        if($h[$i]>=$K){
            $count++;
        }
    }
    echo $count;

?>

Measured memory_bytes: 25540
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

const MOD: usize = 1e+9 as usize + 7;

fn main() {
    let n = read::<usize>();
    let mut seq = vec![0; n];
    let mut cnts = vec![0; 70];
    for i in 0..n {
        seq[i] = read::<usize>();
        for j in 0..60 {
            cnts[j] += (seq[i] >> j) & 1;
        }
    }
    let mut ans = 0;
    for i in 0..60 {
        ans += (1 << i) % MOD * cnts[i] % MOD * (n - cnts[i]) % MOD;
        ans %= MOD;
    }
    println!("{}", ans);
}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


void Main()
{
    int n;cin>>n;

    REP(i,3){
        if(n%10 == 7){
            cout<<"Yes"<<endl;
            return;
        }
        n/=10;
    }
    cout<<"No"<<endl;

	return;
}

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

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  string ST;
  
  for(int i=0; i<N; i++) cin >> S.at(i);
 
  sort(S.begin(), S.end());
  
  for(int i=0; i<N; i++) ST += S.at(i);
  
  cout << ST << endl;
}

Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif
 
#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
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 RangeAddQuery {
    int n;
    vector<int>d;
    RangeAddQuery(int m) {
        for (n = 1; n < m; n <<= 1);
        d.assign(2 * n, 0);
    }
    void add(int a, int b, int x = -1, int k = 1, int l = 0, int r = -1) {
        if (r == -1)r = n;
 
        if (r <= a || b <= l)return;
        if (a <= l&&r <= b) {
            if (x >= 0)d[k] += (r - l)*x;
            return;
        }
        else {
            if (d[k] != 0) {
                d[2 * k] += d[k] / 2;
                d[2 * k + 1] += d[k] / 2;
                d[k] = 0;
            }
            add(a, b, x, 2 * k, l, (l + r) / 2);
            add(a, b, x, 2 * k + 1, (l + r) / 2, r);
        }
    }
    int get(int i) {
        add(i, i + 1);
        return d[n + i];
    }
};
signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q; cin >> n >> q;
    RangeAddQuery raq(n);
    rep(z, 0, q) {
        int com; cin >> com;
        if (com) {
            int i; cin >> i;
            cout << raq.get(i-1) << endl;
        }
        else {
            int s, t, x; cin >> s >> t >> x;
            raq.add(s - 1, t, x);
        }
    }
    return 0;
}

Measured memory_bytes: 4920
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int p = 0;
		int q = 0;
		int r = 0;
		int ans = 0;
		while(n-- > 0) {
				p = sc.nextInt();
				q = sc.nextInt();
				r = q - p + 1;
				ans += r;
		}
		System.out.println(ans);
	}

}


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

int main() {
	string S;
	cin >> S;
	rep(i, 7) {
		if (S.substr(0, i) + S.substr(S.size() - 7 + i, 7 - i) == "keyence") {
			puts("YES");
			return 0;
		}
	}
	puts("NO");
	return 0;
}

Measured memory_bytes: 256
////////////////////////////////////////////
///                                      ///
///         Template ver. 1 rapel        ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define endl '\n'
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 2e5;
int nx[N + 5];
int first[N + 5];
int arr[N + 5];
int curr[N + 5];

vector<int> vec, res;

void print() {
	for(int i = 0;i < res.size();i++) {
		if(i) cout<<" ";
		cout<<res[i];
	}
	cout<<endl;
}

void hora(int tc) {
	int n;
	LL k;
	cin>>n>>k;
	memset(first, -1, sizeof first);
	memset(curr, -1, sizeof curr);
	for(int i = 0;i < n;i++) {
		cin>>arr[i];
		if(first[arr[i]] == -1) first[arr[i]] = i;
		if(curr[arr[i]] != -1) nx[curr[arr[i]]] = i;
		curr[arr[i]] = i;
	}
	for(int i = 0;i <= N;i++) if(curr[arr[i]] != -1) nx[curr[arr[i]]] = first[arr[i]];
	LL cycle = 0;
	int pos_now = 0;
	do{
		vec.PB(pos_now);
		int nxt = nx[pos_now];
		int diff = nxt - pos_now;
		if(diff <= 0) diff += n;
		cycle += diff + 1;
		pos_now = (nxt + 1) % n;
	}while(pos_now != 0);
	k *= n;
	k--;
	k %= cycle;
	for(int i = 0;i < vec.size();i++) {
		int pos_now = vec[i];
		int nxt = nx[pos_now];
		int diff = nxt - pos_now;
		if(diff <= 0) diff += n;
		diff += 1;
		if(k >= diff) k -= diff;
		else {
			memset(curr, 0, sizeof curr);
			for(int j = 0;j < diff;j++) {
				int val = arr[(j + pos_now) % n];
				if(curr[val] == 0) {
					res.PB(val);
					curr[val] = 1;
				}
				else {
					while(res.back() != val) {
						curr[res.back()] = 0;
						res.POB();
					}
					curr[res.back()] = 0;
					res.POB();
				}
				if(k == 0) {
					print();
					return ;
				}
				k--;
			}
		}
	}
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}




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

typedef long long lint;
#define fint register int
#define flint register lint

inline int ty()
{
	fint a=0,b=1,c=getchar();
	while(!isdigit(c))b^=c=='-',c=getchar();
	while(isdigit(c))a=a*10+c-48,c=getchar();
	return b?a:-a;
}

const int _ = 200007 , inf = 0x3f3f3f3f;
const lint linf = 0x3f3f3f3f3f3f3f3f;

struct node
{
	lint a,b;
	node(lint _a=0,lint _b=0){a=min(_a,_b),b=max(_a,_b);}
	inline friend int operator < (node a,node b)
	{
		return a.a<b.a;
	}
};

node p[_];
int n;
lint ans;

int main()
{
	n=ty();
	flint mia=linf,mxa=-linf,mib=linf,mxb=-linf;
	for(fint i=1;i<=n;i++)
	{
		flint a=ty(),b=ty();
		if(a>b)swap(a,b);
		p[i]=node(a,b);
		mia=min(mia,a),mxa=max(mxa,a);
		mib=min(mib,b),mxb=max(mxb,b);
	}
	
	flint distan=mxb-mia;
	ans=(mxa-mia)*(mxb-mib);
	sort(p+1,p+n+1),mib=mxb=p[1].b;
	
	for(fint i=2;i<n;i++)
	{
		mib=min(mib,p[i].b),mxb=max(mxb,p[i].b);
		ans=min(ans,((max(mxb,p[n].a)-min(mib,p[i+1].a))*distan));
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 3328