akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, x);

  int b = 0, p = 0;
  for (int i = 2; i < x; ++i) {
    int mmax = 0;
    int idx = 0;
    for (int j = 2; (int)pow(i, j) <= x; ++j) {
      if ((int)pow(i, j) > mmax) {
        mmax = i;
        idx = j;
      }
    }
    if ((int)pow(b, p) < (int)pow(mmax, idx)) {
      b = mmax;
      p = idx;
    }
  }

  cout << (int)pow(b, p) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int tuki[13]={0,0,31,60,91,121,152,182,213,244,274,305,335};
  string cal[400];
  cal[1]="Thursday";cal[2]="Friday";cal[3]="Saturday";cal[4]="Sunday";
  cal[5]="Monday";cal[6]="Tuesday";cal[7]="Wednesday";
  for(int i=1;i<=366;i++)
    cal[i+7]=cal[i];
  int a,b;
  while(cin>>a>>b,a+b)
    cout<<cal[tuki[a]+b]<<endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i=0; i<N; i++) {
    cin >> L.at(i);
  }
  sort(L.begin(), L.end());
  int sum = 0;
  for (int i=0; i<N-1; i++) {
    sum += L.at(i);
  }
  string answer;
  if (L.at(N-1) < sum) {
    answer = "Yes";
  }
  else {
    answer = "No";
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ctype.h>
# define pb push_back
#define fst first
#define sec second
#define For(i,a,b) for(int i=a;i<b;i++)
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
#define fo(i,n) for(ll i=0;i<n;i++)
#define endl "\n"
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define boolsize 1000001
#define pi pair<ll,ll>
#define vi vector<ll>
#define vii vector<pi>
using namespace std;
template<typename T>
void showvector(vector <T> v)
{
    for(T x:v)
        cout<<x<<" ";
    cout<<endl;

}
template<typename T>
void showvector1(vector <T> v)
{
    ll n=v.size();
    fo1(i,n-1)
        cout<<v[i]<<endl;

}
template<typename T>
void showset(set <T> s)
{
    for(T x: s)
        cout<<x<<" ";
    cout<<endl;
}
template<class T>
void showvectorpair(vector<T> v)
{
    for(auto it=v.begin();it!=v.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T,typename P>
void showmap(map <T,P> m)
{
    for(auto it=m.begin();it!=m.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T>
bool comp(T a,T b)
{
    return (a>b);
}
template<class T>
bool comppair(T a,T b)
{
    if(a.first==b.first)
        return(a.second>b.second);
    return (a.first>b.first);
}
bool sameparity(ll a,ll b)
{
    return (a%2==b%2);
}
bool difparity(ll a,ll b)
{
    return !(a%2==b%2);
}
bool isprime(ll x)
{   if(x<=1)
     return false;
    for(ll i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
bool iseven(ll x)
{
    return !(x%2);
}
bool isodd(ll x)
{
    return (x%2);
}
//vector <bool> prime(boolsize,1);
//void seive()
//{
//    ll n=boolsize;
//    prime[0]=prime[1]=0;
//    for(ll i=2;i<=sqrt(boolsize);i++)
//    {
//        if(prime[i]==1)
//        {
//            for(ll j=i*i;j<=n;j+=i)
//            {
//                prime[j]=0;
//            }
//        }
//    }
//}

/// check for test case before submitting
void vfun()
{
    ll h,w;
    cin>>h>>w;
    vector <string> v(h);
    fo(i,h)
        cin>>v[i];

    w+=2;
    fo(i,w)
    cout<<"#";
    cout<<endl;
    fo(i,h)
    cout<<"#"<<v[i]<<"#\n";
    fo(i,w)
    cout<<"#";

}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0); ///cant use scanf, printf
    cin.tie(0);cout.tie(0); /// no longer auto flush cout before each cin, remove for interactive
    //cout << fixed << setprecision(11); /// no scientific output
    ll test=1;
    //cin>>test;
    while(test--)
    {

        //fun();
        vfun();
//         if(vfun())
//            cout<<"YES\n";
//         else
//            cout<<"NO\n";
    }
}
///before sub
/// check for value of zero and single input in array
///loop vars,1LL in mult, equal, one, bounds, int v ll, endl, finish taking inputs
/// check whether test cases are given or not




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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

const int INF = 1999999999;

template<typename T>
T vec_max(V<T> v){return *max_element(ALL(v));}

int main(){
    int N,X,Y;
    cin>>N>>X>>Y;

    Vi cnt(N);
    REP(i,N){
        REP2(j,i,N){
            int dist = min(abs(i-j),abs(i-(X-1))+1+abs((Y-1)-j));
            cnt[dist]++;
        }
    }

    REP(i,N-1){
        cout<<cnt[i+1]<<endl;
    }

    return 0;
}

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

int main(){
  int n,k;cin >> n >> k;
  int p[n];rep(i,n)cin >> p[i];
  sort(p,p+n);
  int ans = 0;
  rep(i,k){
    ans += p[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>

int main(){
 int n;
 scanf("%d\n",&n);
 for(int x = 0;x < n;x++){
  char A[101],B[101];
  scanf("%s\n%s\n",A,B);
  
  int l_a,l_b;
  if((l_a = strlen(A)) > 80 || (l_b = strlen(B)) > 80){
   printf("overflow\n");
   continue;
  }
  int val[100];
  memset(val,-1,sizeof(val));
  for(int i = 0;i < l_a || i < l_b;i++){
   val[i] = 0;
   if(l_a - i > 0) val[i] += A[l_a - i - 1] - '0';
   if(l_b - i > 0) val[i] += B[l_b - i - 1] - '0';
  }
  bool flg = false;
  int max;
  for(int j = 0;val[j] != -1;j++){
   max = j;
   if(val[j] >= 10){
    if(j + 1 >= 80) flg = true;
    else{
        val[j] -= 10;
        if(val[j+1] == -1) val[j+1] = 0;
        val[j + 1]++;
        max = j + 1;
    }
   }
  }
  if(flg || max >= 80){
   printf("overflow\n");
  }else{
   for(;max >= 0;max--){
    printf("%d",val[max]);
   }
   printf("\n");
  }
 }
 return 0;
}

Measured memory_bytes: 2748
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007

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

int main() {
	ll D, G; cin >> D >> G;
	vector<pair<ll, ll>> pro(D);
	for (int i = 0; i < D; i++)
		cin >> pro[i].first >> pro[i].second;
	ll ans = 1e5;
	ll twos = pow(2, D);
	for (int i = 0; i < twos; i++) {
		ll temp = i, scr = 0, kari = 0;
		vector<int> bit(D);
		for (int j = 0; temp > 0; j++) {
			bit[j] = temp % 2;
			temp /= 2;
		}
		for (int j = 0; j < D; j++) {
			if (bit[j]==1) {
				scr += 100 * (j + 1) * pro[j].first + pro[j].second;
				kari += pro[j].first;
			}
			
		}
		if (scr < G) {
			for (int j = D - 1; j >= 0; j--) {
				if (bit[j]==0) {
					int rem = (G - scr + 100 * (j + 1) - 1) / (100 * (j + 1));
					//cout << "i=" << i << " ";
					//cout << "j=" << j << " rem=" << rem << " G-scr=" << G - scr << endl;
					if (rem < pro[j].first) kari += rem, scr += rem * 100*(j + 1);
					break;
				}
			}
		}
		//cout << "i=" << i;
		//cout << " scr=" << scr  ;
		//cout << " kari=" << kari << endl;
		if (scr >= G) {
			
			ans = min(ans, kari);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 4032
while True:
    h, w= list(map(int,input().split()))
    if h!=0 or w!=0:
        line_e=[]
        line_d=[]
        for i in range(w):
            if i %2 ==0:
                line_e.append("#")
                line_d.append(".")
            else:
                line_e.append(".")
                line_d.append("#")
                
        e_line="".join(line_e)
        d_line="".join(line_d)
    
        for i in range(h):
            if i%2==0:
                print(e_line)
            else:
                print(d_line)
        
        print()
        
    else:
        break

Measured memory_bytes: 7612
#include<stdio.h>
#include<algorithm>
using namespace std;
int dat[100][100];
int a,b;
int solve(int row,int col){
	int ret=0;
	dat[row][col]=0;
	if(row>0&&dat[row-1][col]==1){
		ret=max(ret,solve(row-1,col));
	}
	if(col>0&&dat[row][col-1]==1){
		ret=max(ret,solve(row,col-1));
	}
	if(row<b-1&&dat[row+1][col]==1){
		ret=max(ret,solve(row+1,col));
	}
	if(col<a-1&&dat[row][col+1]==1){
		ret=max(ret,solve(row,col+1));
	}
	dat[row][col]=1;
	return ret+1;
}
int main(){
	while(1){
		scanf("%d%d",&a,&b);
		if(a+b==0)return 0;
		for(int i=0;i<b;i++){
			for(int j=0;j<a;j++){
				scanf("%d",&dat[i][j]);
			}
		}
		int ret=0;
		for(int i=0;i<b;i++){
			for(int j=0;j<a;j++){
				if(dat[i][j])ret=max(ret,solve(i,j));
			}
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <utility>
using namespace std;

int main(){
    int n;
    cin >> n;
    for(int k=0;k<n;k++){
        int mat,point[16][16]={};
        pair<int,int> goal;
        bool vert[16][16]={},horiz[16][16]={};
        cin >> goal.first >> goal.second >> mat;
        for(int i=0;i<mat;i++){
            int rx1,rx2,ry1,ry2;
            cin >> rx1 >> ry1 >> rx2 >> ry2;
            if(rx1!=rx2)horiz[max(rx1,rx2)][ry1]=true;
            else vert[rx1][max(ry1,ry2)]=true;
        }
        point[0][0]=1;
        for(int i=1;i<=goal.first;i++){
            if(!horiz[i][0]){
                point[i][0]+=point[i-1][0];
            }
        }
        for(int l=1;l<=goal.second;l++){
            if(!vert[0][l]){
                point[0][l]+=point[0][l-1];
            }
        }
        for(int i=1;i<=goal.first;i++){
            for(int l=1;l<=goal.second;l++){
                if(!horiz[i][l]){
                    point[i][l]+=point[i-1][l];
                }
                if(!vert[i][l]){
                    point[i][l]+=point[i][l-1];
                }
            }
        }
        if(!point[goal.first][goal.second]) cout << "Miserable Hokusai!" << endl;
            else cout << point[goal.first][goal.second] << endl;
    }
}

Measured memory_bytes: 3016
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
int main() {
	int N;
	scanf("%d", &N);
	long long A[N], ans = 0;
	for (int i = 0; i < N; ++i) scanf("%lld", &A[i]);
	priority_queue<long long> best;
	sort(A, A + N);
	best.push(A[N - 1]);
	for (int i = N - 2; i >= 0; --i) {
		ans += best.top();
		best.pop();
		best.push(A[i]);
		best.push(A[i]);
	}
	printf("%lld", ans);
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << 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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

int main(){

  ll n;cin>>n;
  ll x[n];rep(i,0,n)cin>>x[i];

  ll mi=INF;
  rep(i,1,101){
    ll sum=0;
    rep(j,0,n){
      sum+=(i-x[j])*(i-x[j]);
    }
    chmin(mi,sum);
  }

  out(mi);
  // ll num=0;
  // if(n%2==0){
  //   num=(x[n/2]+x[(n-1)/2])/2;
  // }else{
  //   num=x[n/2];
  // }
  // // rep(i,0,n){
  // //   sum+=x[i];
  // // }
  // // ll avg=sum/n;

  // ll ans=0;
  // rep(i,0,n){
  //   ans+=(num-x[i])*(num-x[i]);
  // }

  // out(ans);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n-1); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define scout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main() {
	int h,w;
	cin >> h >> w;
	char s[h][w];
	rep(i,h)rep(j,w) cin >> s[i][j];
	bool ok=true;
	for(int i=1;i<h-1;i++) {
		for(int j=1;j<w-1;j++) {
			if(s[i][j]=='#') {
				if(s[i-1][j]=='.'&&s[i][j-1]=='.'&&s[i+1][j]=='.'&&s[i][j+1]=='.') ok = false;
			}
		}
	}
	if(ok) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h> 
#define REP(i,n) for(int i=0; i< (n); ++i)
#define FOR(i,s,n) for(int i=s; i< (n); ++i)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
 
    cout << fixed << setprecision(30);
 
    while (true){
        int N, M; cin >> N >> M;
        if (N == 0) break;
        int r; cin >> r;
 
        vvi students(M, vi(1262, 0));
 
        REP(i, r){
            int t, n, m, s;
            cin >> t >> n >> m >> s; m--;
            if (s == 1){
                students[m][t]++;
            } else {
                students[m][t]--;
            }
        }
 
        REP(i, M) FOR(j, 1, 1262) students[i][j] += students[i][j - 1];
 
        int q; cin >> q;
        REP(i, q){
            int ts, te, m;
            cin >> ts >> te >> m; m--;
            int cnt = 0;
            FOR(j, ts, te) if (students[m][j] >= 1) cnt++;
            cout << cnt << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 50836
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
typedef pair<int,int> P;
#define mod 1000000007


int main(){
    string s;
    cin >> s;
    int a=(s[0]-'0')*10+s[1]-'0';
    int b=(s[2]-'0')*10+s[3]-'0';
    if((1<=a&&a<=12)){
        if(1<=b&&b<=12) cout << "AMBIGUOUS" << endl;
        else cout << "MMYY" << endl;
    }
    else{
        if(1<=b&&b<=12) cout <<"YYMM" <<endl;
        else cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
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)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int a, b;
    cin >> a >> b;
    if (a < 6) cout << 0 << endl;
    else if (a < 13) cout << b / 2 << endl;
    else cout << b << endl;

    return 0;
}


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

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

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

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

 
int main() {
    const ll b = 1e9 + 7;
    ll n, m;
    string s;
    
    cin >> n >> m >> s;
    
    vector<ll> hash(n + 1, 0), p(n + 1, 0);
    hash[0] = 1;
    p[0] = 1;
    for(int i = 1; i <= n; i++){
        hash[i] = hash[i - 1] * b + s[i - 1];
        p[i] = p[i - 1] * b;
    }
    
    int l = 0, r = 0;
    set<ll> st;
    REP(i, m){
        string t;
        cin >> t;
        
        if(t == "L++")l++;
        if(t == "L--")l--;
        if(t == "R++")r++;
        if(t == "R--")r--;
        
        st.insert(hash[r + 1] - hash[l] * p[r - l + 1]);
    }
    
    cout << st.size() << endl;
}


Measured memory_bytes: 21816
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define RFOR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))

using namespace std;

static const double EPS = 1e-9;
typedef long long ll;
typedef pair<int, int> paii;

int h, w, n;
int ma[2000][2000];
int dp[2000][2000];

paii solve()
{
	paii res = paii(0, 0);
	CLR(dp);
	
	dp[0][0] = n-1;
	
	FOR(j, 0, h)
		FOR(i, 0, w)
		{
			if(dp[j][i]%2==0)
			{
				dp[j+1][i] += dp[j][i]/2;
				dp[j][i+1] += dp[j][i]/2;
			}
			else
			{
				if( ma[j][i] == 0 )
				{
					dp[j+1][i] += (dp[j][i]+1)/2;
					dp[j][i+1] += (dp[j][i]-1)/2;
				}
				else
				{
					dp[j+1][i] += (dp[j][i]-1)/2;
					dp[j][i+1] += (dp[j][i]+1)/2;
				}
			}
		}
		
	FOR(j, 0, h)
		FOR(i, 0, w)
		{
			if(dp[j][i]%2 != 0)
				ma[j][i] = !ma[j][i];
		}
	
	while( res.first >= 0 && res.first < w && res.second >= 0 && res.second < h )
	{	
		if( ma[res.second][res.first] == 1)//east
		{
			res.first++;
		}
		else//south
		{
			res.second++;
		}
	}
	
	res.first++;
	res.second++;
	
	return res;
}

int main()
{
	while(cin >> h >> w >> n, (h||w||n))
	{
		FOR(j, 0, h)
			FOR(i, 0, w)
			{
				cin >> ma[j][i];
			}
		
		paii p = solve();
		
		cout << p.second << " " << p.first << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 25740
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int n,sum=0,s;
	cin >> n;
	vector<int>b(n-1);
	vector<int>a(n);
	for (int i = 0; i < n-1; i++) {
		cin >> b[i];
	}
	a[0] = b[0];
	for (int i = 1; i < n-1; i++) {
		a[i] = min(b[i-1], b[i]);
		sum += a[i];
	}
	sum += b[0];
	sum += b[n - 2];
	cout << sum << endl;

}

Measured memory_bytes: 256
import java.util.*;
import java.util.Map.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
        while (n-- > 0) {
            int num = sc.nextInt();
            if (!map.containsKey(num)) {
                map.put(num, 1);
            } else {
                int v = map.get(num);
                map.put(num, v + 1);
            }
        }
        
        int s = map.size();
        
        int[] array = new int[s];
        int index = 0;
        for (Entry<Integer, Integer> entry : map.entrySet()) {
            array[index] = entry.getValue();
            index++;
        }
        
        Arrays.sort(array);
        
        int count = 0;
        for (int i = 0; i < s - k; i++) {
            count += array[i];
        }
        
        System.out.println(count);
    }
}


Measured memory_bytes: 99964
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
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)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

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

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define fo(i,n) for(int i=0;i<n;i++)
    #define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
    int main(){
        int a;cin >>a;
        cout << a + a*a +a*a*a;
      	return 0;
    }

Measured memory_bytes: 3356
N, Q = map(int, input().split())
S = list(input())
cnt = [0] * (N)

for i in range(1, N):
    if S[i - 1] + S[i] == 'AC':
        cnt[i] = cnt[i - 1] + 1
    else:
        cnt[i] = cnt[i - 1]

for _ in range(Q):
    l, r = map(int, input().split())
    ans = cnt[r - 1] - cnt[l - 1]
    print(ans)


Measured memory_bytes: 6872
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 2e5 + 20 ;
int n , X , x[N] , d[N] ;
ll part[N] ;

inline ll get (int k) {
	ll ans = 1ll * n * X + 1ll * k * X ;

	for (int i = 1 , p = n ; p > 0 ; i ++ , p -= k)
		ans += (part[p] - part[max(0 , p - k)]) * d[i] ; 
	
	return ans ;
}

int32_t main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;

	cin >> n >> X ;

	for (int i = 0 ; i < n ; i ++) cin >> x[i] ;

	sort(x , x + n) ;

	for (int i = 0 ; i < n ; i ++) part[i + 1] = part[i] + x[i] ;

	d[1] = 5 ;
	for (int i = 2 ; i <= n ; i ++) d[i] = 2 * i + 1 ;

	int low = 1 , high = n + 1 ;
	while (high - low > 1) {
		int mid = (low + high) >> 1 ;
		if (get(mid) < get(mid - 1)) low = mid ;
		else high = mid ;
	}
 
	cout << get(low) << '\n' ;
}

Measured memory_bytes: 3328
#include <functional>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int l, k;
    cin >> l >> k;

    vector<vector<long>> dp(l + 2, vector<long>(k + 1, 0));
    dp[1][1] = 1;
    dp[1][k] = 1;
    for (int h = 1; h <= l; ++h) {
        for (int i = 0; i < k; ++i) {
            dp[h + 1][i] += dp[h][i + 1];
        }
        if (dp[h][0] > 0) {
            dp[h + 1][1] += dp[h][0];
            dp[h + 1][k] += dp[h][0];
        }
    }

    long sum_ = 0;
    for (int h = 1; h <= l; ++h) {
        sum_ += dp[h][1];
    }
    cout << sum_ << endl;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int n;
ll a[222222];
ll b[222222];

int main() {
   cin >> n;
   rep (i, n) {
      cin >> a[i];
      b[i+1] = a[i];
      b[i+1] += b[i];
   }

   ll ans = 0;
   map<ll, ll> mp;
   rep (i, n+1) {
      mp[b[i]]++;
   }

   for (auto x : mp) {
      ll t = x.second;
      ans += t * (t-1) / 2;
   }

   cout << ans << endl;


   return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1e9+7
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> pii;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};


using namespace std;

int main() {
    int n;cin>>n;
    vector<int> v(n);
    rep(i,0,n)cin>>v[i];
    Sort(v);
    reverse(all(v));
    int a=0,b=0;
    rep(i,0,n){
        if(i%2==0)a+=v[i];
        else b+=v[i];
    }
    cout<<a-b<<endl;
    
    return 0;
}


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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int res = 0;
  for (int a = 0; a <= A; ++a) {
    for (int b = 0; b <= B; ++b) {
      for (int c = 0; c <= C; ++c) {
        int total = 500*a + 100*b + 50*c; // 合計金額
        if (total == X) ++res; // 合計金額が X に一致したら答えをインクリメント
      }
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 3576
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;

int main()
{
	int N,a;
	map<int,int> m;
	int ans=0;
	
	cin >> N;
	for(int i=0;i<N;i++)
	{
		cin >> a;
		m[a]++;
	}
	
	for(auto&& i:m)
	{
		if(i.second>i.first)
			ans+=i.second-i.first;
		else if(i.second<i.first)ans+=i.second;
	}
	
	cout << ans << endl;
	return 0;
}


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

int main()
{
	int n, k, d, l, f;
	int h[10] = {0};
	cin >> n >> k;
	for (int i = 0; i < k; i++)
	{
		cin >> d;
		h[d] = 1;
	}
	string s;
	for (int i = n; i < 100000; i++)
	{
		s = to_string(i);
		l = s.length();
		f = 0;
		for (int j = 0; j < l; j++)
		{
			if (h[s[j] - '0'])
			{
				f = 1;
				break;
			}
		}
		if (!f)
		{
			cout << i ; break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
(stdin => {
  // Define Function
  // Declare Variable
  const inputs = stdin.toString().trim().split(' ')
  const a = parseInt(inputs[0], 10)
  const b = parseInt(inputs[1], 10)
  const Comp = function (a, b) {
    if (a < b) {
      return 'a < b'
    } else if (a > b) {
      return 'a > b'
    } else {
      return 'a == b'
    }
  }
  console.log(Comp(a, b))
})(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 15112
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define pii pair<int,int>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
using namespace std; 

int main(){
	int n,m;
	cin>>n>>m;
	int mi=min(n,m),ma=max(n,m);

	string s="";
	for(int i=0;i<ma;i++)
		s+=to_string(mi);

	cout<<s<<endl;

}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map(String::toInt)

    if (N == 1) {
        println(K)
        return
    }

    (2..N).fold(K.toLong()) { acc, elm ->
        acc * (K - 1)
    }.let(::println)

}



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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n;
	cin >> n;
	int mn = INF;
	int ans = 0;
	while(n--)
	{
		int x;
		cin >> x;
		setmin(mn, x);
		ans += x <= mn;
	}
	
	cout << ans;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



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

int main(){
	int n;
	while(cin >> n){
		int cnt = 0;
		for(int i=0;i<10;i++){
        	for(int j=0;j<10;j++){
            	for(int k=0;k<10;k++){
                	for(int l=0;l<10;l++){
                    	if(i+j+k+l==n)
                    		cnt++;
                	}
            	}
        	}
    	}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////
ll vs;
ll cal(ll i){
    if(i<0)return 0;
    if(i>vs)return vs;
    return i;
}
int main(){fastio
    ll n,k;cin>>n>>k;
    string s;cin>>s;
    vector<ll>v;
    ll pos=0;
    while(pos<=n-1){
        ll c=1;
        while(pos<=n-2&&s[pos]==s[pos+1]){
            c++;
            pos++;
        }
        v.pb(c);
        pos++;
    }
    //for(auto x:v)cout<<x<<" ";cout<<endl;
    vs=v.size();
    ll sum[vs+1];
    sum[0]=0;
    rep(i,0,vs-1)sum[i+1]=sum[i]+v[i];
//rep(i,0,vs)cout<<sum[i]<<" ";cout<<endl;
    ll ans=0;
    if(s[0]=='0'){
        for(ll i=-4;i<=vs+4;i+=2){
            ll p=sum[cal(i)]-sum[cal(i-2*k-1)];
            Max(ans,p);
  //          cout<<p<<" ";
        }
    }else{
        for(ll i=-5;i<=vs+4;i+=2){
            ll p=sum[cal(i)]-sum[cal(i-2*k-1)];
            Max(ans,p);
   //         cout<<p<<" ";
        }
    }
    /*
    ll co=0;
    if(s[0]=='0')co--;
    if(s[n-1]=='0')co--;
    if(vs<=2*k+1+co){
        cout<<n;return 0;
    }
    if(vs==1&&k>=1){
        cout<<n;return 0;
    }
    */
    cout<<ans<<endl;
    
    
    return 0;
}



Measured memory_bytes: 2116
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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;}

const ll mod=1e9+7;

int main()
{
    ll n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    ll cnt=1;
    ll ans=0;
    rep(i,n){
        if(i==0){
            continue;
        }
        if(s[i]!=s[i-1]){
            cnt++;
        }
        else{
            ans++;
        }
    }
    if(cnt==1){
        cout << ans << endl;
        return 0;
    }
    if(cnt%2==0){
        if(k<=cnt/2-1){
            ans+=k*2;
            cout << ans << endl;
        }
        else{
            ans+=2*(cnt/2-1)+min(k-(cnt/2-1),1LL);
            cout << ans << endl;
        }
    }
    else{
        if(k<=cnt/2){
            ans+=k*2;
            cout << ans << endl;
        }
        else{
            ans+=2*(cnt/2);
            cout << ans << endl;
        }
    }
    
    return 0;
} 

Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>

using namespace std;

int main(void) {

	int a[5], time = 0, minn = 9;

	bool all0 = true;

	for (int i = 0; i < 5; i++)
	{
		cin >> a[i];
		if (a[i] % 10 != 0) {
			minn = min(minn, a[i] % 10);
			all0 = false;
		}
	}

	if (all0)minn = 0;

	for (int i = 0; i < 5; i++)
	{
		time += (((a[i] - 1) / 10) + 1) * 10;
	}

	if(all0==false)time = time - (10 - minn);

	cout << time << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<climits>
using namespace std;
int main(){
  long long int n,a,b,mini;cin>>n;
  mini=n-1;
  for(long long int i=2;i<=n/i;i++){
      if(n%i==0){
        a=i;b=n/i;
        if(a+b-2 < mini)mini=a+b-2;
      }
  }
   cout<<mini;
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
	int M;
	cin >> M;
	cout << 24 + (24 - M) << endl;
	return 0;
}

Measured memory_bytes: 256
import math
#map(int,input().split())
#int(x) for x in input().split()
#for _ in range(int(input())):
n=int(input())
s=''
while n>0:
	x=n//26
	d=n-x*26
	if d==0:
		s+='z'
		n=(n-26)//26
		continue
	else:
		s+=chr(96+int(d))
	if n%26==0 and x==1:
		break
	n=x
print(s[::-1])













Measured memory_bytes: 62044
#include <iostream>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(void){
    int H,W;
    cin >> H >> W;
    char C[H][W];
    rep(i,H)rep(j,W)cin >> C[i][j];
    for(int i=0;i < H*2;i++){
        for(int j=0;j<W;j++){
            cout << C[i/2][j];
        }
        cout << endl;
    }
}


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

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

	vector<int> p(n);

	for (int i = 0; i < n; i++) { cin >> p[i]; }

	int ans = 0;
	for (int i = 0; i < n - 2; i++) {

		if (p[i] < p[i + 1] && p[i + 1] < p[i + 2]) {
			ans++;
		}
		else if (p[i + 2] < p[i + 1] && p[i + 1] < p[i]) {
			ans++;
		}

	}
	
	cout << ans << endl;

	return 0;
}

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

int main(){

        int a,b,c,t;

        cin >> a;
        cin >> b;
        cin >> c;

        if(a > b){

                t = a;
                a = b;
                b = t;

        }

        if(b > c){

                t = b;
                b = c;
                c = t;

        }

        if(a > b){

                t = a;
                a = b;
                b = t;

        }

        cout << a << " " << b << " " << c << endl;

        return 0;
}




Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define N 100005
using namespace std;
int a[103][103],cnt[10003];
void sprint(int m, int n){
    int i, k = 0, l = 0,z=0;
    while (k < m && l < n){
        for (i = l; i < n; ++i){
            a[k][i]=z+1;
            cnt[z]--;
            if(cnt[z]<=0)
                z++;
        }
        k++;
        for (i = k; i < m; ++i)
        {
            a[i][n-1]=z+1;
            cnt[z]--;
            if(cnt[z]<=0)
                z++;
        }
        n--;
        if ( k < m){
            for (i = n-1; i >= l; --i){
                a[m-1][i]=z+1;
                cnt[z]--;
                if(cnt[z]<=0)
                    z++;
            }
            m--;
        }
        if (l < n){
            for (i = m-1; i >= k; --i){
                a[i][l]=z+1;
                cnt[z]--;
                if(cnt[z]<=0)
                    z++;
            }
            l++;    
        }
    }
}
 
int main(){
    int h,w;
    cin>>h>>w;
    int n;
    cin>>n;
    memset(a,0,sizeof(a));
    for(int i=0;i<n;i++){
        cin>>cnt[i];
    }
    sprint(h,w);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<a[i][j]<<" ";
        }
        cout<<"\n";
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

// O(N log mod)
template<long long MOD=1000000007ll>
struct ModCombination{
    vector<long long> f,fi;
    ModCombination(){}
    ModCombination(int N){
        init(N);
    }

    // x^-1
    long long invp(long long x){
        return mod_pow(x,MOD-2);
    }

    long long mod_pow(long long x,long long n){
        long long res=1;
        while(n){
            if(n&1) res=(res*x)%MOD;
            x=(x*x)%MOD;
            n>>=1;
        }
        return res;
    }

    void init(int N){
        f.resize(N+1);
        fi.resize(N+1);
        f[0]=1;
        for(int i=1;i<N+1;i++) f[i]=(f[i-1]*i)%MOD;
        for(int i=0;i<N+1;i++) fi[i]=invp(f[i]);
    }

    // nCr
    long long get(long long n,long long r){
        long long ret=f[n];
        ret=(ret*fi[r])%MOD;
        ret=(ret*fi[n-r])%MOD;
        return ret;
    }
};

int main(){
    ll h,w,a,b;
    cin >> h >> w >> a >> b;

    ModCombination<> cmb(h+w+2);

    ll ans=0;
    rep(i,w-b){
        int x=i+b; 
        int y=h-a-1;
        ll s=cmb.get(x+y,x);
        x=a-1;
        y=w-b-1-i;
        ll t=cmb.get(x+y,x);
        ans += s*t%mod;
        ans %= mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
import java.util.Scanner;

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

        int number = scn.nextInt();
        int [] box;
        box = new int[number];
        for(int i = 0; i < number; i++) box[i] = scn.nextInt();

        int count = scn.nextInt();
        int answer = 0;
        for(int j = 0; j < count; j++){
            int check = scn.nextInt();
            if(solve(check,number,box)) answer++;
        }
        System.out.println(answer);
    }
    static boolean solve(int check, int max,int[] box){
        int right = max;
        int left = 0;
        int mid = 0;
        while(left < right){
            mid = (left + right)/2;
            if(box[mid] == check) return true;
            else if(box[mid] < check) left = mid + 1;
            else if(box[mid] > check) right = mid;
        }
        return false;
    }
}


Measured memory_bytes: 69332
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    s64 n, k;
    cin >> n >> k;

    s64 ans = 0;
    for (s64 b = k + 1; b <= n; ++b)
    {
        ans += (b - k) * ((n - b + 1) / b + 1) + MAX(0, n - k - b * ((n - b + 1) / b + 1) + 1);
    }
    ans -= (k == 0 ? n - k : 0);

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll ,ll>;
const ll INF = 1LL<<61LL;
const ll MOD = 1e9+7;

int main(){
	ll N;
	cin >> N;
	vector<ll> s(N);
	for(int i=0;i<N;i++)
		cin >> s[i];
	for(int i=0;i<N/2;i++)
		s[i] += s[N-1-i];
	ll ans = 0;
	vector<bool> visited(N, false);
	for(ll step = 1;step<N;step++){
		ll now = 0;
		ll sum = 0;
		while(now + step < N-1){
			now += step;
			ll idx = min(now, N-1-now);
			if(visited[idx] || N-1-now-step <= 0 || (N % 2 && now == N / 2))
				break;
			visited[idx] = true;
			sum += s[idx];
			ans = max(ans, sum);
		}
		now = 0;
    while(now + step < N-1){
      now += step;
      ll idx = min(now, N-1-now);
      visited[idx] = false;
    }
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))[::-1]
l,r=10**12+1,-1
while l-r>1:
    t=(l+r)//2
    s=k
    for i,j in zip(a,b):
        if t<i*j:s-=i-t//j
    if s<0:r=t
    else:l=t
print(l)

Measured memory_bytes: 122572
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	int n; cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	int ans=0;
	for(int i=1;i<n-1;i++)
	{
	    if( (a[i]>a[i+1] && a[i]<a[i-1])||(a[i]<a[i+1]&&a[i]>a[i-1]) ) ans++;
	    
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <cassert>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <numeric>
#define ALL(c) (c).begin(), (c).end()

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdi = pair<double, int>;
using pdd = pair<double, double>;

int B, A, N;
vector<int> P;

int main() {
	cin >> N >> A >> B;
	for (int i = 0; i < N; i++)
	{
		int tmpP;
		cin >> tmpP;
		P.push_back(tmpP);
	}

	vector<int> n(3);
	for (const auto &tmpP : P)
	{
		if (tmpP <= A) {
			n[0]++;
		}
		else if (tmpP <= B) {
			n[1]++;
		}
		else {
			n[2]++;
		}
	}

	int ans = *min_element(ALL(n));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import math
n = int(input())
mod = 10**9 + 7
cou = 0
pdic = {}
kan = []
betu = [0,0,0]

for i in range(n):
    a , b = map(int,input().split())
    if a*b != 0:
        g = math.gcd(abs(a),abs(b))
        if a*b > 0:
            m = 1
        elif a*b < 0:
            m = -1
        p = (m*abs(a)//g,abs(b)//g)
        q = ((-m)*abs(b)//g,abs(a)//g)
        if pdic.get(q,-1) != -1:
            kan[pdic[q]][1] += 1
        elif pdic.get(p,-1) == -1:
            pdic[p] = cou
            kan.append([1,0])
            cou += 1
        elif pdic.get(p,-1) != -1:
            kan[pdic[p]][0] += 1
    elif a*b == 0:
        if a == 0 and b == 0:
            betu[2] += 1
        elif a == 0:
            betu[0] += 1
        elif b == 0:
            betu[1] += 1
        
        
ans = 1
for i in range(len(kan)):
    ans *= (pow(2,kan[i][0],mod) + pow(2,kan[i][1],mod) - 1) % mod
    ans %= mod
ans *= (pow(2,betu[0],mod) + pow(2,betu[1],mod) - 1) % mod
print((ans-1+betu[2])%mod)

Measured memory_bytes: 69220
#include<iostream>
#define mod 1000000007
using namespace std;
long long dp[8001][8001],a[200001],b[200001],ans,jc[8001],invjc[8001];
long long C(int a,int b)
{
  return jc[b]*invjc[a]%mod*invjc[b-a]%mod;
}
long long fast_pow(long long a,int b)
{
  if (b==0)
    return 1;
  if (b&1)
    return fast_pow(a*a%mod,b/2)*a%mod;
  else
    return fast_pow(a*a%mod,b/2);
}
int main()
{
  int n;
  cin>>n;
  for (int i=1;i<=n;++i)
    cin>>a[i]>>b[i];
  for (int i=1;i<=n;++i)
    dp[2010-a[i]][2010-b[i]]++;
  for (int i=1;i<=4010;++i)
    for (int j=1;j<=4010;++j)
      dp[i][j]=(dp[i][j]+dp[i-1][j]+dp[i][j-1])%mod;
  for (int i=1;i<=n;++i)
    ans=(ans+dp[a[i]+2010][b[i]+2010])%mod;
  jc[0]=1;
  for (int i=1;i<=8000;++i)
    jc[i]=jc[i-1]*i%mod;
  invjc[8000]=fast_pow(jc[8000],mod-2);
  for (int i=7999;i>=0;--i)
    invjc[i]=invjc[i+1]*(i+1)%mod;
  for (int i=1;i<=n;++i)
    ans=(ans-C(2*a[i],2*a[i]+2*b[i])+mod)%mod;
  cout<<ans*fast_pow(2,mod-2)%mod<<endl;
  return 0;
}

Measured memory_bytes: 254208
#include <atcoder/fenwicktree>
#include "bits/stdc++.h"
using namespace std;
using namespace atcoder;

const int N=2e5+20;

int n,q,t,u,v;

int main()
{
	scanf("%d%d",&n,&q);
	auto dsa=fenwick_tree<long long>(n);
  	for(int i=0;i<n;i++) scanf("%d",&u),dsa.add(i,u);

	while(q--)
	{
		scanf("%d%d%d",&t,&u,&v);
		if(t==0) dsa.add(u,v);
		else printf("%lld\n",dsa.sum(u,v));
	}
}

Measured memory_bytes: 8220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1 << 30;
ll ans = INF;
bool ch[100100]={};

int main()
{
ll n;
cin >> n;
deque<pair<int,int>> v; 
v.push_front({1,1});

ch[1]=true;
while(true){
    pair<int,int> p;
    p=v.front();
    v.pop_front();
    if(p.first==0){
        ans=p.second;
        break;
    }
    if(!ch[p.first*10%n]){
        v.push_front({(p.first*10)%n,p.second});
        ch[p.first*10%n]=true;
    }
    v.push_back({(p.first+1)%n,p.second+1});
}

cout << ans << endl;
return 0;
}

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

int main(void){
  int n;
  cin >> n;
  int next = 1;
  int res = 0;
  for(int i = 0;i < n;++i){
    int a;
    cin >> a;
    if(a == next){
      ++next;
    } else {
      ++res;
    }
  }
  cout << (res == n ? -1 : res) << endl;
  return 0;
}


Measured memory_bytes: 256