akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    ll n = s.size();
    ll ndx = 0;
    string dream = "maerd";
    string dreamer = "remaerd";
    string erase = "esare";
    string eraser = "resare";
    while (ndx < n){
        if (s[ndx]=='m'){
            rep1(i, 5){
                if (s[ndx+i]!=dream[i]){
                    cout << "NO" << endl;
                    return 0;
                }
            }
            ndx += 5;
        }
        else if (s[ndx]=='e'){
            rep1(i, 5){
                if (s[ndx+i]!=erase[i]){
                    cout << "NO" << endl;
                    return 0;
                }
            }
            ndx += 5;
        }
        else if (s[ndx]=='r'){
            if (s[ndx+2]=='m'){
                rep1(i, 7){
                    if (s[ndx+i]!=dreamer[i]){
                        cout << "NO" << endl;
                        return 0;
                    }
                }
                ndx += 7;
            }
            else if (s[ndx+2]=='s'){
                rep1(i, 6){
                    if (s[ndx+i]!=eraser[i]){
                        cout << "NO" << endl;
                        return 0;
                    }
                }
                ndx += 6;
            }
            else{
                cout << "NO" << endl;
                return 0;
            }
        }
        else {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 3740
#include <iostream>
#include <vector>
#include <boost/range/irange.hpp>
#include <algorithm>
#include <deque>

using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    uint N;
    cin >> N;
    vector<ull> as(N, 0), bs(N, 0), cs(N, 0);
    for (auto &&i: irange(0U, N)) {
        cin >> as.at(i);
    }
    for (auto &&i: irange(0U, N)) {
        cin >> bs.at(i);
    }
    for (auto &&i: irange(0U, N)) {
        cin >> cs.at(i);
    }
    sort(as.begin(), as.end());
    sort(bs.begin(), bs.end());
    sort(cs.begin(), cs.end());


    vector<ull> bs_count(N, 0);
    for (auto &&i: irange(0U, N)) {
        ull current_a_ind;
        if (i == 0) {
            current_a_ind = 0;
        } else {
            current_a_ind = bs_count.at(i - 1);
            bs_count.at(i) = bs_count.at(i - 1);
        }
        while (true) {
            if (current_a_ind >= as.size())break;
            if (as.at(current_a_ind) < bs.at(i)) {
                bs_count.at(i)++;
                current_a_ind++;
            } else break;
        }
    }


    vector<ull> cs_count(N, 0);
    for (auto &&i: irange(0U, N)) {
        ull current_b_ind;
        if (i == 0) {
            current_b_ind = 0;
        } else {
            current_b_ind = cs_count.at(i-1);
            cs_count.at(i) = cs_count.at(i-1);
        }
        while (true){
            if (current_b_ind >= bs.size())break;
            if (bs.at(current_b_ind) < cs.at(i)){
                cs_count.at(i)++;
                current_b_ind++;
            } else break;
        }
    }


    deque<ull> bs_sum(N, 0);
    for (auto &&i: irange(0U, N)) {
        if (i == 0) {
            bs_sum.at(i) = bs_count.at(i);
        } else {
            bs_sum.at(i) = bs_sum.at(i - 1) + bs_count.at(i);
        }
    }
    bs_sum.push_front(0U);
    ull ret{0};
    for (auto &&i: irange(0U, N)) {
        ret += bs_sum.at(cs_count.at(i));
    }
    cout << ret;
    return 0;
}

Measured memory_bytes: 5120
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M, Q;
	cin >> N >> M >> Q;

	vector<vector<int>> bgn_end(N, vector<int>(N));
	int bgn, end;
	for (int i = 0; i < M; i++) {
		cin >> bgn >> end;
		bgn--, end--;
		bgn_end[bgn][end]++;
	}

	for (int row = 0; row < N; row++) {
		for (int col = 1; col < N; col++) {

			bgn_end[row][col] += bgn_end[row][col - 1];

		}
	}

	int ans;
	for (int i = 0; i < Q; i++) {
		ans = 0;
		cin >> bgn >> end;
		bgn--, end--;

		for (int j = bgn; j <= end; j++) {

			ans += bgn_end[j][end];
		}

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

	return 0;
}

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

int main() {
  int n; cin >>n;
  bool ok = false;
  for (int i=0; i<9; i++){
    for (int j=0; j<9; j++){
      if ((i+1)*(j+1)==n){
        ok = true;
      }
    }
  }
  if (ok) cout <<"Yes" <<endl;
  else cout <<"No" <<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define VERTEX_MAX 100000
#define BUF_SIZE 20

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d", a1, a2);
#else
#error
#endif
  return 0;
}

struct range {
    int start;
    int end;
};

int asc_by_start(const void *a1, const void *a2) {
    struct range *ra1 = (struct range*)a1;
    struct range *ra2 = (struct range*)a2;
    return ra1->start - ra2->start;
}

int main(void) {
    int vs, queries;
    get_int2(&vs, &queries);
    struct range ranges[VERTEX_MAX+1];
    int i;
    for(i = 0; i < queries; i++) {
        int s, e;
        get_int2(&s, &e);
        // 1-indexed -> 0-indexed
        s--; e--;
        ranges[i] = (struct range){s, e};
    }
    ranges[queries] = (struct range){VERTEX_MAX+1, VERTEX_MAX+2};
    qsort(ranges, queries, sizeof(struct range), asc_by_start);
    int cnt = 0;
    struct range prev = ranges[0];
    for(i = 1; i < queries+1; i++) {
        struct range cur = ranges[i];
        if(prev.end - 1 >= cur.start) {
            prev.end = min(prev.end, cur.end);
            continue;
        }
#ifdef DEBUG
        printf("cur: [%d, %d], prev: [%d %d]\n",
            cur.start, cur.end,
            prev.start, prev.end
        );
#endif
        cnt++;
        prev = cur;
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 1788
#include<cstdio>
#include<algorithm>
using namespace std;
long long n,f[200000],mod=1000000007,a,b,s[200000];
int main()
{
	scanf("%lld%lld%lld",&n,&a,&b);
	for(int i=1;i<=n;i++)scanf("%lld",s+i);
	if(a>b)swap(a,b);
	for(int i=2;i<n;i++)
		if(s[i+1]-s[i-1]<a){puts("0");return 0;}
	f[0]=1;s[0]=-b;
	long long sum=0,r=0;int u=0;

	for(int i=1;i<=n;i++)
	{
		for(;r<i&&s[i]-s[r]>=b;r++)sum=(sum+f[r])%mod;
		f[i]=sum;
		if(s[i]-s[i-1]<a)sum=0,r=i-1;
	}
	for(int i=r;i<=n;i++)sum=(sum+f[i])%mod;
	printf("%lld\n",sum);
	return 0;
}

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

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

    int d;
    cin >> d;

    vector<int> c(26);
    rep(i, 26) cin >> c[i];
    vector<vector<int>> s(d, vector<int>(26));
    rep(i, d) rep(j, 26) cin >> s[i][j];

    vector<int> t(d);
    // rep(i, d){
    //     cin >> t[i];
    //     --t[i];
    // }

    vector<int> last(26, 0);
    vector<pair<int, int>> sms(d);
    int total = 0;
    rep(i, d){
        int res = -1001001001;
        int mxidx = -1;
        rep(tt, 26){
            int sm = 0;
            sm += s[i][tt];
            vector<int> l = last;
            
            int minus = 0;

            rep(j, 26) ++l[j];
            l[tt] = 0;
            rep(j, 26) minus += c[j] * l[j];

            sm -= minus;
            if(sm > res){
                mxidx = tt;
                res = sm;
            }
        }
        rep(j, 26) ++last[j];
        last[mxidx] = 0;
        t[i] = mxidx;
        sms[i] = make_pair(res, i);
        total += res;
    }

    // rep(i, d) cout << t[i] << endl;

    sort(sms.begin(), sms.end());

    int res = total;
    rep(didx, d){
        //if(didx > 100) break;
        int to = -1;
        rep(kidx, 26){
            vector<int> tt = t;
            tt[sms[didx].second] = kidx;

            vector<int> last(26, 0);
            int res_c = 0;
            rep(i, d){
                res_c += s[i][tt[i]];
                
                int minus = 0;

                rep(j, 26) ++last[j];
                last[tt[i]] = 0;
                rep(j, 26) minus += c[j] * last[j];

                res_c -= minus;
                
            }
            if(res_c > res){
                to = kidx;
                res = res_c;
            }
        }

        if(to != -1) t[sms[didx].second] = to;
    }

    rep(i, d) cout << t[i]+1 << endl;


    return 0;
}

Measured memory_bytes: 3708
#include<iostream>
#include<list>
#include<algorithm>
using namespace std;
int main()
{
    list<int> L;
    int n;
    cin>>n;
    while(n--)
    {
        int t;cin>>t;
        L.push_back(t);
    }
    int q;
    cin>>q;
    while(q--)
    {
        int b,e;
        cin>>b>>e;
        auto begin=L.begin();
        auto end=L.begin();
        for(int i=0;i<b;i++)
        {
            begin++;
        }
         for(int i=0;i<e;i++)
        {
            end++;
        }
        reverse(begin,end);
    }
    auto it=L.begin();
    cout<<*it;
    it++;
    for(auto i=it;i!=L.end();i++)
    {
        cout<<" "<<*i;
    }
    cout<<endl;
    
}


Measured memory_bytes: 3116
inp = []
for i in range(5):
    inp.append(int(input()))
inp2 = sorted(inp, key=lambda x: x%10)
inp3 = [d for d in inp2 if d%10 != 0]
if inp3 != []:

    last = inp3[0]
    inp2.remove(last)
else:
    last = 0

r = 0
for c,z in enumerate(inp2):
    if z%10 == 0:
        r += z
    else:
        r += z//10 * 10 + 10
res = r + last
print(res)

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

// (x^n)%m
ll modpow(ll x, ll n, ll m){
    ll ret = 1;
    while( n != 0 ){
        if( n&1 ){ ret = (ret*x)%m; }
        x = (x*x)%m;
        n >>= 1;
    }
    return ret;
}

// (x^(m-2))%m
ll modinv(ll x, ll m){
    return modpow(x, m-2 , m);
}

vector<ll> modfact;
vector<ll> modfactinv;

ll modcomb(ll n, ll r){
    // n! / (r! * (n-r)!)
    ll denom = 1;
    ll numer = 1;
    numer = modfact[n];
    denom = (modfactinv[r] * modfactinv[n-r])%MOD;
    return (numer * denom)%MOD;
}

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;
    ll K;

    modfact.resize(2*100000+1);
    modfactinv.resize(2*100000+1);
    modfact[0] = 1;
    modfactinv[0] = modinv(1, MOD);
    ll fact = 1;
    for( int i = 1; i <= 2*100000; i++){
        fact = (fact*i)%MOD;
        modfact[i] = fact;
        modfactinv[i] = modinv(fact, MOD);
    }

    cin >> N >> K;
    vector<ll> array(N, 0);

    REP(i, N){ cin >> array[i]; }

    sort(array.begin(), array.end());
    vector<ll> small(N,0);
    vector<ll> big(N,0);
    ll sum1=0;
    ll sum2=0;
    REP(i, N){
        sum1 = (sum1 +array[i])%MOD;
        sum2 = (sum2 + array[array.size()-1-i])%MOD;
        small[i] = sum1;
        big[array.size()-1-i] = sum2;
    }

    ll total = 0;
    for(int i = K-2; i <= N-2; i++){
        //DEBUG("i=%d modcomb=%lld  big[i+1]=%lld small[N-2-i]=%lld", i, modcomb(i,K-2), big[i+1], small[N-2-i]);
        total = (total + modcomb(i, K-2) * (big[i+1] - small[N-2-i])%MOD)%MOD;
    }
    cout << total%MOD << endl;
}


Measured memory_bytes: 5760
import sys

payable = [False] * (10 ** 5 + 1)
payable[0] = True
for i in range(100,106):
    payable[i] = True

for i in range(106, 10 ** 5 + 1):
    payable[i] = any(payable[i-105:i-99])

def main():
    x = int(sys.stdin.readline().rstrip())
    print(payable[x] & 1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	// your code goes here
	long long h, hh;
	cin >> h;
	hh = h;
	long long count = 0;
	while(hh != 1){
		hh /= 2;
		count ++;
	}
	long long ans = pow(2, count) * 2 - 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;
using u64 = LL;
using u128 = LL;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

LL po(LL a, LL n, LL m){
  if(n==0) return 1;
  LL an = po(a,n/2,m);
  an = (an*an)%m;
  if(n&1) return an*a%m;
  return an;
}

bool isprime(LL n, int iter=100) {
    if (n < 4)
        return n == 2 || n == 3;

    for (int i = 0; i < iter; i++) {
        LL a = 2 + rand() % (n - 3);
        if (po(a, n - 1, n) != 1)
            return false;
    }
    return true;
}

bool chk(LL i, LL n){
  while(n%i==0) n/=i;
  if(n==1) return 1;
  if(n%i==1) return 1;
   return 0;
}
int main(){
  fio();
  LL n; cin>>n;
  if(n==2) {
    cout<<1<<endl;
    return 0;
  }
  LL k = n-1;
  set<LL> s;
  for(LL i = 2;i*i<=k;i++){
    if(k%i==0 && chk(i,n)) s.insert(i);
    if(k%i==0 && chk(k/i,n))s.insert(k/i);
  }
  s.insert(k);
  for(LL i=2;i*i<=n;i++){
    if(n%i==0 && chk(i,n)) s.insert(i);
    if(n%i ==0 && chk(n/i,i)) s.insert(n/i);
  }
 // s.insert(2);
  s.insert(n);
//  for(auto i:s) cout<<i<<" ";
  //  cout<<endl;
  cout<<s.size()<<endl;
  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int a,b;
  cin >> a >> b;

  cout << 6-a-b << endl;
  return 0;
}


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


Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define read(arr,n)	for(int i=0;i<n;i++) cin>>arr[i];
#define print(arr,n) for(int i=0;i<n;i++) cout << arr[i]<<' ';cout << endl;
typedef int int32;
#define int ll
#define mod 1000000007

using namespace std;

typedef long long ll;

ll power(ll x, ll y) {
	if (y == 0)	return 1;
	ll val = power(x, y/2) % mod;
	val = val * val % mod;
	if (y & 1)	val = val * x % mod;
	return val;
}

void solve() {
	ll n, k;
	cin >> n >> k;
	
	ll multi[k+1] = {};
	
	for (int i = 1; i <= k; i++) {
		multi[i] = k/i;
	}
	
	ll sum = 0;
	ll p[k+1] = {};
	
	for (int i = k; i >= 1; i--) {
		p[i] = power(multi[i],n);
	
		for (int j = i+i; j <=k; j+=i) {
		 	p[i] = (p[i] - p[j] + mod)%mod;
		}
		sum = (sum + p[i]*i % mod) % mod;
	}
	
	cout << sum << endl;
}

int32 main() {
	int t = 1;
	//cin >> t;
	int c = 0;
	while (c < t) {
		solve();
		c++;	
	}
	return 0;
}


Measured memory_bytes: 5180
import sys
from itertools import accumulate
from collections import Counter
from bisect import bisect as br, bisect_left as bl
class DammyMap:
    #1-indexed
    def __init__(self, A, B, issum = False):
        #Aに初期状態の要素をすべて入れる,Bは値域のリスト
        self.X, self.comp = self.compress(B)
        self.size = len(self.X)
        self.tree = [0] * (self.size + 1)
        self.p = 2**(self.size.bit_length() - 1)
        self.dep = self.size.bit_length()
        
        CA = Counter(A)
        S = [0] + list(accumulate([CA[self.X[i]] for i in range(self.size)]))
        for i in range(1, 1+self.size):
            self.tree[i] = S[i] - S[i - (i&-i)]
        if issum:
            self.sumtree = [0] * (self.size + 1)
            Ssum = [0] + list(accumulate([CA[self.X[i]]*self.X[i] for i in range(self.size)]))
            for i in range(1, 1+self.size):
                self.sumtree[i] = Ssum[i] - Ssum[i - (i&-i)]
    def compress(self, L):
        #座圧
        L2 = list(set(L))
        L2.sort()
        C = {v : k for k, v in enumerate(L2, 1)}
        # 1-indexed
        return L2, C
    
    def leng(self):
        #今入っている個数を取得
        return self.count(self.size)
    
    def count(self, i):
        #i(Bの元)以下の個数を取得
        i = self.comp[i]
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
    
    def less(self, v):
        #v(Bの元である必要はない)未満の個数を取得
        i = bl(self.X, v)
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
    
    def leq(self, v):
        #v(Bの元である必要はない)以下の個数を取得
        i = br(self.X, v)
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        #iをx個入れる,負のxで取り出す,iの個数以上取り出すとエラーを出さずにバグる
        i = self.comp[i]
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
        
        
    def get(self, v):
        # v番目の値を取得
        if v <= 0:
            return -1
        s = 0
        k = self.p
        for _ in range(self.dep):
            if s + k <= self.size and self.tree[s+k] < v:
                s += k
                v -= self.tree[s]
            k //= 2
        return self.X[s]
    
    def addsum(self, i, x):
        #sumを扱いたいときにaddと併用
        x *= i
        i = self.comp[i]
        while i <= self.size:
            self.sumtree[i] += x
            i += i & -i
    
    def countsum(self, i):
        #i(Bの元)以下のsumを取得
        i = self.comp[i]
        s = 0
        while i > 0:
            s += self.sumtree[i]
            i -= i & -i
        return s
    
    def getsum(self, v):
        #v番目までのsumを取得
        x = self.get(v)
        return self.countsum(x) - x*(self.count(x) - v)


N = int(input())
A = list(map(int, input().split()))
B = {v : i for i, v in enumerate(A, 1)}
T = DammyMap([0, N+1], list(range(0, N+2)))
ans = 0
for a in range(1, N+1):
    b = B[a]
    T.add(b, 1)
    i = T.count(b)
    ans += a*(T.get(i+1)-b)*(b-T.get(i-1))
print(ans)


Measured memory_bytes: 122688
import java.util.Scanner;

public class Main {

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

		int radius = scanner.nextInt();

		double circle = radius * 2 * 3.14;
		//double circle = radius * 2 * Math.PI;

		System.out.println(circle);

		scanner.close();
	}

}


Measured memory_bytes: 36048
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<set>
#define MN 50005
using namespace std;
int n,m,k,val[MN],c[MN][2],id[MN],fa[MN],ht[MN],sz[MN],ans=0x3f3f3f3f;bool vis[MN];
bool cmp(int x,int y){return val[x]>val[y];}
multiset<int> s;
multiset<int>::iterator it;
int merge(int x,int y){
	if((!x)||(!y))return x+y;
	if(val[x]>val[y])swap(x,y);
	c[x][1]=merge(c[x][1],y);
	if(ht[c[x][0]]<ht[c[x][1]])swap(c[x][0],c[x][1]);
	ht[x]=ht[c[x][1]]+1;sz[x]=sz[c[x][0]]+sz[c[x][1]]+1;return x;
}
int getfa(int x){return fa[x]==x?x:fa[x]=getfa(fa[x]);}
int main(){
	scanf("%d%d%d",&n,&m,&k);int x,y,tmp;
	for(int i=1;i<=n;i++)scanf("%d",&val[i]),id[i]=fa[i]=i,sz[i]=1,ht[i]=0;sort(id+1,id+n+1,cmp);
	for(int i=1;i<=n;i++){
		vis[id[i]]=1;
		if(vis[id[i]-1]){
			x=getfa(id[i]),y=getfa(id[i]-1);
			if(val[x]>val[y]&&sz[y])swap(x,y);if(sz[y])fa[y]=x;merge(x,y);
		}
		if(vis[id[i]+1]){
			x=getfa(id[i]),y=getfa(id[i]+1);
			if(val[x]>val[y]&&sz[y])swap(x,y);if(sz[y])fa[y]=x;merge(x,y);
		}tmp=getfa(id[i]);
		while(sz[tmp]>=m)s.insert(val[tmp]),x=merge(c[tmp][0],c[tmp][1]),fa[tmp]=x,fa[x]=x,tmp=x;
		while(s.size()>k)it=s.end(),--it,s.erase(it);
		if(s.size()==k)it=s.end(),--it,ans=min(ans,(*it)-val[id[i]]);
	}printf("%d\n",ans);
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

int main(){
	int n,m,x;
	cin>>n>>m>>x;
	int a=0,b=0;
	for(int i=0;i<m;i++){
		int y;
		cin>>y;
		if(y<x){
			a++;
		}else{
			b++;
		}
	}
	cout<<min(a,b)<<endl;
}

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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<vector<pair<int, int>>> t(n + 1, vector<pair<int, int>>());

    int a, b, c;
    for (int i = 0; i < n - 1; i++) {
        cin >> a >> b >> c;
        t[a].push_back(make_pair(b, c));
        t[b].push_back(make_pair(a, c));
    }

    vector<ll> color(n + 1, -1);
    color[1] = 0;

    deque<tuple<int, int, int>> deq;
    for (const auto x : t[1]) {
        deq.emplace_back(x.first, x.second, 0);
    }

    int d;
    while (!deq.empty()) {
        auto x = deq.back(); deq.pop_back();
        d = get<1>(x) % 2 == 0 ? get<2>(x) : (get<2>(x) + 1) % 2;
        color[get<0>(x)] = d;
        for (const auto y : t[get<0>(x)]) {
            if (color[y.first] < 0) {
                deq.emplace_back(y.first, y.second, d);
            }
        }
    }

    for (int i = 1; i <= n; i++) {
        cout << color[i] << endl;
    }
}


Measured memory_bytes: 7168
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
// #include <numeric>
#include <complex>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++i)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;
typedef long long int ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;

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

int main() {
	int x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	int x3=0,y3=0,x4=0,y4=0;

	y3 = y2 + (x2-x1);
	x3 = x2 - (y2-y1);
	x4 = x3 - (x2-x1);
	y4 = y3 - (y2-y1);

	cout << x3 << " " << y3 << " " << x4 << " " << y4 << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  int A, B, C;
  std::cin >> A >> B >> C;

  int answer = 0;

  while (A != B || B != C || A != C) {
    if (A > B) { std::swap(A, B); }
    if (B > C) { std::swap(B, C); }
    if (A > B) { std::swap(A, B); }

    if (A + 2 <= C) {
      A += 2;
    } else {
      A += 1;
      B += 1;
    }

    answer++;
  }

  std::cout << answer << std::endl;
}


Measured memory_bytes: 256
#include <algorithm>  // sort, unique
#include <deque>
#include <iostream>  // テスト
#include <string>
#include <vector>

/**
 * 3 2 2 1
 * sort-> 1 2 2 3
 * unique-> 1 2 3 x
 * erase-> 1 2 3
 */
template <typename T>
std::vector<T> deduplicate(std::vector<T> v) {
    std::sort(v.begin(), v.end());
    v.erase(std::unique(v.begin(), v.end()), v.end());
    return v;
}
/**
 * std::unique は
 * 1. 連続した要素のうち先頭以外の要素を後ろに持っていく
 * 2. 後ろに持っていった要素の値は未規定になる
 * 3. 後ろに持っていった要素の先頭のイテレータを返す
 */
template <typename T>
std::deque<T> deduplicate(std::deque<T> d) {
    std::sort(d.begin(), d.end());
    d.erase(std::unique(d.begin(), d.end()), d.end());
    return d;
}

std::string deduplicate(std::string s) {
    std::sort(s.begin(), s.end());
    s.erase(std::unique(s.begin(), s.end()), s.end());
    return s;
}

// tests----------------------------------------------------------------
void abc098_b();  // stringの重複削除

int main() {
    abc098_b();
    return 0;
}

void abc098_b() {
    using std::string;
    int n;
    std::cin >> n;
    string s;
    std::cin >> s;

    int ans = 0;
    for (int i = 1; i < n - 1; ++i) {
        string f = deduplicate(s.substr(0UL, i));
        string r = deduplicate(s.substr(i));

        int duplications = 0;
        for (char fc : f) {  // 𝑶(n * n/2 * n/2)
            // find は一致する要素を探してイテレータを返す
            if (r.find(fc) != string::npos) duplications++;
        }
        ans = std::max(ans, duplications);
    }

    std::cout << ans << "\n";
    return;
}

Measured memory_bytes: 256
import math
n=int(input())
p=math.sqrt(n)
def x(g):
  a=g
  c=0
  while a>=0:
    a-=1
    c+=1
  return c-1

m=x(p)
for i in range(m):
  if n%(m-i)==0:
    print(m-2-i+(n//(m-i)))
    break



Measured memory_bytes: 3060
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
    char a,b;
    scanf("%c %c",&a,&b);
    if(a=='H') printf("%c\n",b);
    else if(a=='D')
    {
        if(b=='H') printf("D\n");
        else printf("H\n");
    }
    return 0;
}


Measured memory_bytes: 3024
class Dice
	def initialize(array)
		@a = Array.new(array)
	end
	
	def rotate(direction)
		if direction == "N" then
			tmp = @a[0]
			@a[0] = @a[1]
			@a[1] = @a[5]
			@a[5] = @a[4]
			@a[4] = tmp
		elsif direction == "S" then
			tmp = @a[0]
			@a[0] = @a[4]
			@a[4] = @a[5]
			@a[5] = @a[1]
			@a[1] = tmp
		elsif direction == "E" then
			tmp = @a[0]
			@a[0] = @a[3]
			@a[3] = @a[5]
			@a[5] = @a[2]
			@a[2] = tmp
		elsif direction == "W" then
			tmp = @a[0]
			@a[0] = @a[2]
			@a[2] = @a[5]
			@a[5] = @a[3]
			@a[3] = tmp
		end
	end
	
	def get_top
		@a[0]
	end
end

def array_to_i(a)
	0.upto(a.length) {|i|
		a[i] = a[i].to_i
	}
	return a
end

a = STDIN.gets.chop.split(" ")
a = array_to_i(a)
dir = STDIN.gets.chomp

dice = Dice.new(a)

dir.each_char {|d|
	dice.rotate(d)
}

print dice.get_top, "\n"



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

int A[1000];
int ans = 0;

void trace(int A[], int N){
    for (int i = 0; i < N; i++){
        if(i>0){
            printf(" ");
        }
        printf("%d", A[i]);
    }
    printf("\n");
}

void selectionSort(int A[], int N){
    for (int i = 0; i < N; i++){
        int minj = i;
        for (int j = i; j < N; j++){
            if(A[j] < A[minj]){
                minj = j;
            }
        }
        if(A[i] != A[minj]){
            ans++;
            swap(A[i], A[minj]);
        }
    }
    trace(A, N);
}

int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;
    rep(i, N) cin >> A[i];
    selectionSort(A, N);
    cout << ans << endl;
}



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

using ll=long long;

int main(){

  int n,k;
  cin >> n >> k;

  vector<ll> a(n);
  vector<ll> b(n-k);
  ll sum=1;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(i>=k){
      if(a[i]>a[i-(k-1)-1]){
        cout << "Yes" << endl;
      }else{
        cout << "No" << endl;
      }
    }
  }


}

Measured memory_bytes: 6352
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
  string s;
  
  cin >> s;
  replace(s.begin(),s.end(),',',' ');
  cout << s << endl;

  return 0;
}

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

int main(void){
	int h1,m1,h2,m2,k;
	scanf("%d%d%d%d%d",&h1,&m1,&h2,&m2,&k);
	int len=h2*60+m2-h1*60-m1;
	printf("%d\n",len-k);
	return 0;
}


Measured memory_bytes: 3816
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        char[] c=fsc.next().toCharArray();
        fsc.close();
        int l=c.length;
        long uc=0, dc=0;
        long ans=0;
        for(int i=0;i<l;i++){
            if(c[i]=='<'&&(i==l-1||c[i+1]=='>')){
                uc++;
                ans+=(uc*(uc+1))/2;
            }
            else if(c[i]=='>'&&(i==l-1||c[i+1]=='<')){
                dc++;
                ans+=(dc*(dc-1))/2;
                if(dc>uc) ans+=dc-uc;
                uc=0;
                dc=0;
            }
            else if(c[i]=='<') uc++;
            else if(c[i]=='>') dc++;
        }
        System.out.println(ans);
    }
    static class FastScanner{
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}

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

int main() {
    int N; cin >> N;
    int a[N];
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        sum ^= a[i];
    }
    for (int i = 0; i < N; i++) {
        int ans = sum^a[i];
        if (i) cout << " ";
        cout << ans;
    }
    cout << endl;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,k,a,b,counter=0,ans;cin>>n>>k;
  map<ll,ll> m;rep(i,n) {cin>>a>>b;m[a]+=b;}
  for (auto i=m.begin();i!=m.end(); ++i) {
    counter+=(i->second);if (counter >= k) {ans+=(i->first);break;}
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <stdio.h>
using namespace std;

int n, k;
string s;

int main() {

	cin >> n >> k >> s;

	if (s[k - 1] == 'A') s[k - 1] = 'a';
	else if (s[k - 1] == 'B') s[k - 1] = 'b';
	else s[k - 1] = 'c';

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
class Array
	def accum
		ac = Array.new(size + 1)
		ac[0] = 0
		(1..size).each do |i|
			ac[i] = ac[i-1] + self[i-1]
		end
		ac
	end

	def accum!
		(1..size-1).each{|i|
			self[i] += self[i-1]
		}
		self.unshift(0)
	end

	def accum_2d
		ac = map{|r| r.accum}
		(1..size-1).each{|i|
			(1..ac[0].size-1).each{|j|
				ac[i][j] += ac[i-1][j]
			}
		}
		ac.unshift([0] * ac[0].size)
		ac
	end

	def accum_2d!
		each{|r| r.accum!}
		(1..size-1).each{|i|
			(1..self[0].size-1).each{|j|
				self[i][j] += self[i-1][j]
			}
		}
		unshift([0] * self[0].size)
	end
		
	def bsearch_first_index(l = 0, r = size - 1, &pred)
		return nil if l > r
		c = (l + r) / 2 
		if pred[self[c]]
			bsearch_first_index(l, c-1, &pred) || c
		else
			bsearch_first_index(c+1, r, &pred)
		end
	end

	def bsearch_first_item(l = 0, r = size - 1, &pred)
		i = bsearch_first_index(l, r, &pred)
		i ? self[i] : nil
	end

	def bsearch_last_index(l = 0, r = size - 1, &pred)
		return nil if l > r
		c = (l + r) / 2 
		if pred[self[c]]
			bsearch_last_index(c+1, r, &pred) || c
		else
			bsearch_last_index(l, c-1, &pred)
		end
	end

	def bsearch_last_item(l = 0, r = size - 1, &pred)
		i = bsearch_last_index(l, r, &pred)
		i ? self[i] : nil
	end
end

n, m, a, b, q, r = gets.split.map(&:to_i)

if a == 1 && b == 1
	k = m / (q + r)
	if k < n
		p [m - k * (q + r), (k + 1) * (q + r) - m].min
	else 
		p m - n * (q + r)
	end
	exit
end

steps = []
(0..n-1).each do |k|
	s = q*a**k + r*b**k
	steps << s
	break if s >= m
end

min = m
if steps[-1] > m
	x = steps.pop
	min = x - m if x && x - m < min
end

half1, half2 = steps.partition.with_index{|x, i| i < steps.size / 2}

subset_sums1 = [0]
(1..2**half1.size-1).each do |x|
	i = ((x - 1) ^ x).to_s(2).size - 1
	y = x - (1 << i)
	subset_sums1[x] = subset_sums1[y] + half1[i]
end
subset_sums1.uniq!
subset_sums1.sort!

subset_sums2 = [0]
(1..2**half2.size-1).each do |x|
	i = ((x - 1) ^ x).to_s(2).size - 1
	y = x - (1 << i)
	subset_sums2[x] = subset_sums2[y] + half2[i]
end

subset_sums2.each do |ss2|
	if ss2 >= m
		min = ss2 - m if ss2 - m < min
		next
	end

	i = subset_sums1.bsearch_last_index {|ss1| ss2 + ss1 <= m}
	x = subset_sums1[i] + ss2
	min = m - x if m - x < min
	if i < subset_sums1.size - 1
		x = subset_sums1[i+1] + ss2
		min = x - m if x - m < min
	end
end
p min

Measured memory_bytes: 67552
import bisect, copy, heapq, math
from math import inf
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
a=[int(input()) for i in range(n)]

now=n
lst=[-1]*n

for i in range(n):
    tmp=bisect.bisect_left(lst,a[i])
    if tmp==now:
        lst[tmp-1]=a[i]
        now-=1
    else:
        lst[tmp-1]=a[i]
# print(lst)
print(n-now)

Measured memory_bytes: 14300
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B;
    
    cin>>A>>B;
    
    if(A==B){
            cout<<"Draw"<<endl;
    }
    
    else if(A==1){
            cout<<"Alice"<<endl;
    }
    
    else if(B==1){
            cout<<"Bob"<<endl;
    }
    
    else if(A>B){
            cout<<"Alice"<<endl;
    }
    
    else if(A<B){
            cout<<"Bob"<<endl;
    }
    
    else{
            cout<<"Bob"<<endl;
    }
}


Measured memory_bytes: 3592
N, K = map(int, input().split())
V = [int(x) for x in input().split()]
L = [[] for i in range(K + 1)]
R = [[] for i in range(K + 1)]
for i in range(1, K + 1):
  L[i] = sorted(V[:i])
  R[i] = sorted(V[-i:], reverse=True)
ans = 0
for l in range(min(N, K) + 1):
  for r in range(min(N, K) + 1 - l):
    LR = L[l] + R[r]
    k = K - l - r
    while k > 0:
      if len(LR) and LR[0] <= LR[-1] and LR[0] < 0:
        LR.pop(0)
      elif len(LR) and LR[-1] <= LR[0] and LR[-1] < 0:
        LR.pop(len(LR) - 1)
      k -= 1
    ans = max(sum(LR), ans)
print(ans)

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

int main(){
    bool is_prime[1000000];

    is_prime[0]=is_prime[1]=false;
    for(int i=2;i<1000000;i++){
        is_prime[i]=true;
    }

    for(int i=2;i*i<1000000;i++){
        if(is_prime[i]){
            for(int j=i*i;j<1000000;j+=i){
                is_prime[j]=false;
            }
        }
    }

    
    while(true){
        int n;
        cin>>n;

        if(n==0) break;
        
        int cnt=0;
        for(int i=2;i<=n;i++){
            if(is_prime[i]==false) continue;
            int ans=0;
            for(int j=i;j<=n;j++){
                if(is_prime[j]) ans+=j;
                if(ans>=n) break;
            }
            if(n==ans) cnt++;
        }
        cout<<cnt<<endl;
    }

    return 0;
}


Measured memory_bytes: 4068
#include <iostream>

using namespace std;

int main(void){
  int n, x[100000];
  int i, c = 0;
  
  cin >> n >> x[0];
  for(i = 1; i < n; i++){
    cin >> x[i];
    if(x[i-1] < x[i]){
      x[i]--;
    }
    else if(x[i-1] == x[i]){
    }
    else{
      c = 1;
      break;
    }
  }
  if(c == 0){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
  return 0;
}

Measured memory_bytes: 640
import java.util.List;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);
	    //String s=gs();
	    //String t=gs();
	    int c=gi();

	   
	    System.out.print(c*c*c);

//        if (a>=3200) {
//        	System.out.print(s);
//        }else {
//        	System.out.print("red");
//        }


	}
	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int a, b; cin >> a >> b;
  cout << (max(a, b) + max(max(a, b)-1, min(a, b)));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll i;
	string s;
	cin>>s;
	for(i=0;i<s.length();i++)
	{
		cout<<"x";
	}
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int ans=0;
  long long a;
  long long b=0;
  for(int i=0;i<n;i++){
    cin >> a;
    b |= a;
  }
  for(int i=0;1;i++){
    if(b&(1<<i)){
      cout << i << endl;
      return 0;
    }
  }


  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int N,i,j,time,n;
    int num[100];
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&num[i]);
    }
    for(i=0,n=N;i<N;i++,n--){
        for(j=1;j<n;j++){
            if(num[j-1] > num[j]){
                int temp=num[j];
                num[j] = num[j-1];
                num[j-1] = temp;
                time++;
            }
        }
    }
    for(i=0;i<N;i++){
        printf("%d",num[i]);
        if(i<N-1){
            printf(" ");
        }
    }
    printf("\n%d\n",time);
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= b; j++) {
      if (i * (b - j) + j * (a - i) == c) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    long ans = 0;
    if(A+B >= 2*C){
        ans = min(X, Y)*2*C;
    }
    else ans = min(X, Y)*(A+B);

    if(X > Y){
        if(A > 2*C)ans += 2*C*(X -Y);
        else ans += A*(X - Y);
    }
    else if(Y > X){
        if(B > 2*C)ans += 2*C*(Y - X);
        else ans += B*(Y - X);
    }
    else ans = ans;
    cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>

int main (){
	int N,donuts,cake,pin=0;
	scanf("%d",&N);

	for(donuts=0;donuts*7<=N;donuts++){
		for(cake=0;cake*4+donuts*7<=N;cake++){
			if(cake*4+donuts*7==N) {
				printf("Yes\n");
				return 0;
			}
		}
		if(pin==1)break;
	}
	if(pin==0)printf("No\n");
	return 0;
}



Measured memory_bytes: 128
n,k = map(int,input().split())

a = [0]
a.extend(list(map(int,input().split())))
l = [None]*(n+1)

now = 1
step = 0
l[now] = 0
while k:
    now = a[now]
    step += 1
    k -= 1
    if l[now] is not None:
        looplen = (step - l[now])
        k = k%looplen
    else:
        l[now] = step
print(now)

Measured memory_bytes: 32348
n = input()
src = input()
h = src.split()
out = 0
out_m = 0
prev = 0
for el in h:
  #print(el)
  if int(el) <= int(prev):
    out += 1
  else:
    if out > out_m:
      out_m = out
    out = 0
  prev = el
  #print(out)
if out > out_m:
  out_m = out
print(out_m)


Measured memory_bytes: 11132
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,M;
int A[100010];
int B[100010];
vector<int> v;
P p[100010];
priority_queue<int> Q;

signed main(){
	cin>>N>>M;
	REP(i,N){
		cin>>A[i]>>B[i];
		p[i]={A[i],B[i]};
	}
	sort(p,p+N);
	int T=0;
	int pos=0;
	int ans=0;
	REP(i,M){
		int D=i+1;
		while(p[pos].first<=D&&pos<N){
			Q.push(p[pos].second);
			pos++;
		}
		if(!Q.empty()){
			ans+=Q.top();
			Q.pop();
		}
		DEB(pos)DEB(Q.size())DEB(ans)END
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4472