akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int get_val(vi &v, int k, int l, int r)
{
    int sum = 0;
    vi disposable;
    for (int i = 0; i < l; i++)
    {
        sum += v[i];
        if (v[i] < 0)
        {
            disposable.push_back(v[i]);
        }
    }
    for (int i = 0; i < r; i++)
    {
        int j = v.size() - i - 1;
        sum += v[j];
        if (v[j] < 0)
        {
            disposable.push_back(v[j]);
        }
    }
    sort(disposable.begin(), disposable.end());

    int ret = sum;
    int limit = disposable.size();
    for (int i = 0; i < k - l - r; i++)
    {
        if (i >= limit)
        {
            break;
        }
        ret -= disposable[i];
    }

    return ret;
}

int main()
{
    int n, k;
    cin >> n >> k;
    vi v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }

    int mx = -1e9;
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= n; j++)
        {
            if (i + j > n || i + j > k)
            {
                continue;
            }
            int val = get_val(v, k, i, j);
            if (mx < val)
            {
                mx = val;
            }
        }
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<algorithm>

#define X first
#define Y second
#define rep(i,n) for(int i = 0; i < n; ++i)
using namespace std;


int main(void){
  int a,b,c;
  cin >> a >> b >> c;
  if( a<= c && c <= b){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#define maxn (ll)1e5+10
using namespace std;
typedef long long ll;
int n;
ll k,cnt[maxn],s;
int main() {
	scanf("%d %lld",&n,&k);
	int a; ll b;
	for (int i=1;i<=n;i++) {
		scanf("%d %lld",&a,&b);
		cnt[a]+=b;
	}
	s=0;
	for (int i=1;i<=maxn-10;i++) {
		s+=cnt[i];
		if (s>=k) {
			printf("%d\n",i);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 896
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio
    
    int n,a,b;
    cin >> n >> a >> b;
    int x;
    x=a+b;
    
    int p=n/x;
    int q=n%x;
    int r=0;
    if(q<a)
    r=q;
    else
    r=a;
    
    cout << ((p*a) + r)  << endl;


	return 0;
    
}


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

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t),weight(w){ }
};

typedef pair<int,int> P;
using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}


bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}

bool palin(string S){//回文判定
  int n = S.size();
  bool flag = true;
  if(n%2 == 0){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  else if(n%2 == 1){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  return flag;
}
int main(){
  string S;
  cin >> S;
  bool flag = false;
  for(int i = 0; i < 3; i++) {
    if(S[i] == '7'){
      flag = true;
      break;
    }
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl; 
 }


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

const int MAX_N = 10010;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> Array;
typedef vector<Array> Graph;
typedef pair<double, double> pdd;
const ull mod = 1000000000 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)
const ll INF = LLONG_MAX/3;
struct Edge{ll s,t,cost;};

int main(){
    ll V,E;
    cin >> V >> E;

    vector<Edge> G;
    for (int i=0;i<E;i++){
        Edge e;
        cin >> e.s >> e.t >> e.cost;
        e.s--;
        e.t--;
        G.push_back(e);
    }

    vector<ll> d(V,-INF);
    d[0]=0;

    ll d1, d2;
    for(int i=0;i<2*V;i++){
        for (int j=0;j<E;j++){
            Edge e = G[j];
            if(d[e.s] != -INF && d[e.t] < d[e.s] + e.cost){
                d[e.t] = d[e.s] + e.cost;
            }
        }
        if(i==V-1){
            d1 = d[V-1];
        }
        if(i==2*V-1){
            d2 = d[V-1];
        }
    }
    if(d1==d2) cout << d[V-1] << endl;
    else cout << "inf" << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
 
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a;
    map<int,int> mp;
    bool is=false;
    for(int i = 0 ; i < 3 ; i++){
        cin>>a;
        mp[a]++;
        if(mp[a] == 2)
            is = true;
        if(mp[a] == 3)
            is = false;
    }  
    if(is)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int h = tx - sx;
	int v = ty - sy;
	for(int i = 0; i < h; i++) {
		cout << 'R' << flush;
	}
	for(int i = 0; i < v; i++) {
		cout << 'U' << flush;
	}
	for(int i = 0; i < h; i++) {
		cout << 'L' << flush;
	}
	for(int i = 0; i < v + 1; i++) {
		cout << 'D' << flush;
	}
	for(int i = 0; i < h + 1; i++) {
		cout << 'R' << flush;
	}
	for(int i = 0; i < v + 1; i++) {
		cout << 'U' << flush;
	}
	cout << "LU" << flush;
	for(int i = 0; i < h + 1; i++) {
		cout << 'L' << flush;
	}
	for(int i = 0; i < v + 1; i++) {
		cout << 'D' << flush;
	}
	cout << 'R' << endl;

	return 0;
}



Measured memory_bytes: 256
n, ma, mb = map(int, input().split())
ls = [list(map(int, input().split())) for _ in range(n)]
MAX_N = 10 * n + 1
dp = [[[float('inf')] * MAX_N for _ in range(MAX_N)] for _ in range(n + 1)]
dp[0][0][0] = 0

for k, (a, b, c) in enumerate(ls):
    for i in range(MAX_N):
        for j in range(MAX_N):
            dp[k + 1][i][j] = min(dp[k + 1][i][j], dp[k][i][j])
            if i + a < MAX_N and j + b < MAX_N:
                dp[k + 1][i + a][j + b] = min(dp[k][i][j] + c,
                                              dp[k][i + a][j + b])
p = min([
    dp[n][ma * i][mb * i] for i in range(1, MAX_N)
    if ma * i < MAX_N and mb * i < MAX_N
])
if p < float('inf'):
    print(p)
else:
    print(-1)

Measured memory_bytes: 139612
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod=1000000007;
vector<int>G[100005];
int dp[2][100005];
int dis[100005];

void dfs(int now,int par){
    for(int e:G[now]){
        if(e==par)continue;
        dis[e]=dis[now]+1;
        dfs(e,now);
    }
}

int memo(int c,int now){
    if(dp[c][now])return dp[c][now];
    int res=1;
    for(int e:G[now]){
        if(dis[now]<dis[e]){
            if(c)res*=memo(0,e);
            else res*=(memo(0,e)+memo(1,e));
            res%=mod;
        }
    }
    return dp[c][now]=res;
}
signed main(){
    int n;cin>>n;
    rep(i,n-1){
        int x,y;cin>>x>>y;
        x--;y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    dfs(0,-1);
    int ans=memo(0,0)+memo(1,0);
    cout<<ans%mod<<endl;
 //   rep(i,n)cout<<dp[0][i]<<" "<<dp[1][i]<<endl;
}


Measured memory_bytes: 14976
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,*p,*dp;
    cin>>n;
    p=new int[n];
    for(int y=0;y<n;y++){
        cin>>p[y];
    }
    dp=new int[n];
    dp[0]=0;
    dp[1]=abs(p[1]-p[0]);
    for(int i=2;i<n;i++){
       dp[i]=min(dp[i-1]+abs(p[i]-p[i-1]),dp[i-2]+abs(p[i]-p[i-2]));}
    cout<<dp[n-1];
    
    delete[]p;
    delete[]dp;
    
    return 0;
}

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

int main() {
    int a;
    cin >> a;
    int c = 0;
    int d = 0;
    if(a < 82){
        for (int i = 1;i < 10;i++){
            for(int j = 1;j < 10;j++){
                if((i * j) == a){
                    d++;
                    break;
                }else{
                    c++;
                    continue;
                }
            }
        }
        if(d > 0){
            cout << "Yes" << endl;
        }else if(c == 81){
            cout << "No" << endl;
        }
    }else{
        cout << "No" << endl;
    }

    
  return 0;
}


Measured memory_bytes: 256
def solve():
    X, Y = map(int,input().split())
    
    for crane in range(X+1):
        for turtle in range(X+1):
            if crane + turtle != X:
                continue

            if crane * 2 + turtle * 4 == Y:
                print('Yes')
                return
    else:
        print('No')

if __name__ == '__main__':
    solve()

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


typedef long long ll;
typedef long double ld;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;


#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define asd cout << "ok" << endl;


#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define trav(it, m) for(auto it = m.begin(); it!= m.end(); it++)

const int MOD = 1e9 + 7;
const ll INF = 1e19;
const ld PI = acos((ld)-1);
const int MX = 2e5 +5;
const char nl = '\n';


int main(){

  int n; cin >> n;
  for(int i = 0; i < 100; i++){
    for(int j = 0; j < 100; j++){
      if(i*4 + j*7 == n)
      {
        cout <<  "Yes" << nl;
        return 0;
      }
    }
  }
  cout << "No" << nl;

  return 0;
}


Measured memory_bytes: 3632
def resolve():
    '''
    code here
    '''
    N, K = [int(item) for item in input().split()]
    
    data = [input() for _ in range(2*K)]

    sunuke = [0 for _ in range(N)]

    for i in range(K):
        d = data[i*2]
        okashi = data[i*2 + 1].split()
        for j in okashi:
            sunuke[int(j)-1] += 1


    cnt = 0
    for k in sunuke:
        if k == 0:
            cnt += 1

    print(cnt)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007LL
#define PI 3.1415926

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int n, a[100000], b[100000], c[100000];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	ll ans = 0;
	sort(a, a+n); sort(c, c+n);
	for (int i = 0; i < n; i++) {
		auto k = lower_bound(a, a+n, b[i]);
		auto l = upper_bound(c, c+n, b[i]);
		ans += (ll)(k-a) * (ll)(c+n-l);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1408
(str_len,cng_cnt) = input().split(" ")
str_input = list(input())

str_len= int(str_len)
cng_cnt= int(cng_cnt)
tmp1=""
cnt=0
cnt2=0
for st in str_input:
    if(tmp1 == st ):
      cnt = cnt+1
    else:
      cnt2= cnt2 + 1
      
    tmp1=st

if (cng_cnt < cnt2-1 ):
	c_up = cng_cnt * 2 
else:
	c_up= (cnt2 * 2) + (cng_cnt - cnt2)
ans =cnt + c_up

if(ans >= str_len):
  ans =str_len-1

print(ans)

Measured memory_bytes: 9872
def wczytaj_liste():
    ciag = input()
    rozdzielona_lista = ciag.split()
    odp = []
    for wyraz in rozdzielona_lista:
        liczba = int(wyraz)
        odp.append(liczba)
    return odp

def D():
    H = wczytaj_liste()[0]
    wykladnik = 0
    while 2**wykladnik <= H:
        wykladnik += 1
    odp = 2**wykladnik - 1
    print(odp)

D()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define ll long long
#define M 998244353
#define all(v) (v).begin(),(v).end()
#define fr first
#define sc second
#define sz(x) (ll)((x).size())
#define endl "\n"
#define vc vector
#define pb push_back
#define pii pair<ll,ll>
#define psi pair<string,ll>
#define msi map<string,ll>
#define mii map<ll,ll>
#define mp  make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265
#define mem(x,val) memset(x,val,sizeof(x))
#define r0 return 
const long long INF=1e18;
template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}
#define dbgv(container) {cerr << #container << " : \n"; int cnt = 0; for (auto& x: container) cerr << #container << "[" << cnt++ << "] = " << x << '\n';} 
#define dbgvv(container) {cerr << #container << " : \n"; int c1=0,c2=0; for (auto& x : container){c2 = 0; for (auto& y : x) {cerr << #container << "[" << c1 << "][" << c2++ << "] = " << y << '\n';}c1++;}}
#define dbg(...)__f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

//code begins here
ll dp[100005],h[100005],n;
ll calc(ll i)
{
	if(i>=n+1) return INF;
	if(i==n) return 0;
	if(dp[i]!=-1) return dp[i];
	dp[i]=min(calc(i+1)+abs(h[i+1]-h[i]),calc(i+2)+abs(h[i+2]-h[i]));
	return dp[i];
}
void solve()
{
 	cin>>n;
 	mem(dp,-1);
 	rep(i,1,n+1) cin>>h[i];
 	cout<<calc(1);
}
signed main()
{
	fast
	ll t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <queue>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
using namespace std;
#define sL(i) i << 1
#define sR(i) i << 1 | 1
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<int, pair<int,int>> ppi;
const int MOD = 1e9 + 7;
const int INF = 2e9 + 5;

int n, x, t;
int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> x >> t;
    cout << ((n * t + x - 1) / x + t - 1) / t * t;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> P;
#define INF 10000000000000
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
#define repN_1(i, n) for(ll i = 0; i < (ll)(n - 1); i++)
#define repM(i, n) for(ll i = (ll)(n - 1); i >= 0; i--)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main()
{
	ll n;
	ll h[100005];
	ll cost[100005];
	memset(h, 0, sizeof(h));
	memset(cost, 0, sizeof(cost));

	cin >> n;
	rep1(i, n + 1)
		cin >> h[i];

	cost[2] = abs(h[1] - h[2]);

	for (ll i = 3; i <= n; i++)
	{
		cost[i] = min(cost[i - 2] + abs(h[i] - h[i - 2]), cost[i - 1] + abs(h[i] - h[i - 1]));
	}

	cout << cost[n] << endl;

	return 0;
}

Measured memory_bytes: 1792
// and it belongs to the other side

#include <bits/stdc++.h>
#include <vector>

#define s second
#define f first
#define pb push_back
#define int ll
#define D(x) cout<<#x<<": "<<x<<endl
#define D2(x) cout<<#x<<": "<<x<<' '

using namespace std;

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

const long long MAX=2e3,mod=1e9+7,INF=1e15;

int n,m;

main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    cout << (n-1)*(m-1);
    return -0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long GCM(long x, long y)
        {
            var s = x;
            var t = y;
            if (x < y) GCM(y, x);
            while (y != 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return s / x * t;
        }



        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var s = Console.ReadLine();
            var i = 0;
            bool f = true;
            while (i < s.Length)
            {
                bool f1 = i + 4 < s.Length && s[i] == 'd' && s[i + 1] == 'r' && s[i + 2] == 'e' && s[i + 3] == 'a' && s[i + 4] == 'm';

                bool f3 = i + 4 < s.Length && s[i] == 'e' && s[i + 1] == 'r' && s[i + 2] == 'a' && s[i + 3] == 's' && s[i + 4] == 'e';
               
                bool f5 = i + 9 < s.Length && s[i + 5] == 'e' && s[i + 6] == 'r' && s[i + 7] == 'a' && s[i + 8] == 's' && s[i + 9] == 'e';
                bool f6 = i + 6 < s.Length && s[i + 5] == 'e' && s[i + 6] == 'r';
                bool f7 = i + 5 < s.Length && s[i + 5] == 'r';
                if (f1)
                {
                    if (f6)
                    {
                        if (f5) i += 5;
                        else i += 7;
                    }
                    else i += 5;
                }
                else if (f3)
                {
                    if (f7) i += 6;
                    else i += 5;
                }
                else { f = false; break; }
            }
            Console.WriteLine(f ? "YES" : "NO");

            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 13116
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = b - a;
		int bhight = 0;
		for (int i = 1; i <= c; i++) {
			bhight += i;
		}
		System.out.println(bhight - b);
	}
}


Measured memory_bytes: 21844
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		String a = sc.next(), b = sc.next(), c = sc.next();
		System.out.println((a.charAt(a.length()-1)==b.charAt(0) && b.charAt(b.length()-1)==c.charAt(0)) ? "YES" : "NO");
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 35504
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>

// https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
const int MAX = 1'000'000;
const int MOD = 1'000'000'000 + 7;
long long int fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long int COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int f(int x, int y) {
    const int aTimesThree = -1 * x + 2 * y;
    const int bTimesThree = 2 * x - y;

    if (aTimesThree % 3 != 0) return 0;
    if (bTimesThree % 3 != 0) return 0;

    const int a = aTimesThree / 3;
    const int b = bTimesThree / 3;

    return COM(a + b, a);
}

int main() {

    COMinit();

    int X, Y; // the target coordinate
    std::cin >> X >> Y;

    std::cout << f(X, Y) << std::endl;

    return 0;

}


Measured memory_bytes: 27112
def ceildiv(a, b):
    return -(-a // b)

h, w = map(int, input().split())

if (h==1 or w==1):
    print(1)
else:
    r0 = ceildiv(w,2)
    r1 = w//2
    r0s = ceildiv(h,2)
    r1s = h//2
    print(r0*r0s + r1*r1s)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define F(i,start,end) for(int i=start;i<end;++i)
const int MOD=1e9+7;

int main(){
    long n;
    string s;
    cin >> n >> s;
    long cnt=0;
    F(i,0,10){
        int a=s.find(i+'0');
        if(a>=0 && a<n){
            F(j,0,10){
                int b=s.find(j+'0',a+1);
                if(b>=0 && b<n){
                    F(k,0,10){
                        int c=s.find(k+'0',b+1);
                        if(c>=0 && c<n){
                            ++cnt;
                        }
                    }
                }
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from collections import Counter
def resolve():
    N=list(input())
    a=sum(map(int,N))
    for n in range(1,len(N)):
        t=(N[:n]+[9]*(len(N)-n))
        a=max(a,sum(map(int,t))-1)
    print(a)
        
#%%submit!
resolve()

Measured memory_bytes: 38256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return len(divisors)

n = int(input())
cnt = 0
for i in range(1, n + 1, 2):
    if make_divisors(i) == 8:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;

const int INF = (int)1e9;
int X[1005], dp2[1005][5005], dp3[1005][5005];
pii dp[1005][2];
vector<int> G[1005];

void chmin(int &a, int b){
    a = min(a, b);
}

void dfs(int s){
    vector<pii> vec1, vec2;
    for(auto u : G[s]){
        dfs(u);
        vec1.push_back(dp[u][0]);
        vec2.push_back(dp[u][1]);
    }
    for(int i=0;i<=vec1.size();i++) for(int j=0;j<=5000;j++) dp2[i][j] = dp3[i][j] = INF;
    dp2[0][0] = dp3[0][0] = 0;
    for(int i=0;i<vec1.size();i++){
        pii p1 = vec1[i], p2 = vec2[i];
        for(int j=0;j<=X[s];j++){
            if(dp2[i][j]==INF) continue;
            chmin(dp2[i+1][min(j+p1.first, 5004)], dp2[i][j]+p1.second);
            chmin(dp2[i+1][min(j+p2.first, 5004)], dp2[i][j]+p2.second);
            chmin(dp3[i+1][min(j+p1.second, 5004)], dp3[i][j]+p1.first);
            chmin(dp3[i+1][min(j+p2.second, 5004)], dp3[i][j]+p2.first);
        }
    }
    int t1 = INF, t2 = INF;
    for(int i=0;i<=X[s];i++) chmin(t1, dp2[vec1.size()][i]), chmin(t2, dp3[vec2.size()][i]);
    dp[s][0] = {X[s], t1}, dp[s][1] = {t2, X[s]};
}

int main(){
    int N;
    cin>>N;
    for(int i=1;i<N;i++){
        int p;
        cin>>p;
        G[p-1].push_back(i);
    }
    for(int i=0;i<N;i++)cin>>X[i];
    dfs(0);
    if(min(dp[0][0].second, dp[0][1].first)<INF) cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

Measured memory_bytes: 39552
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  int n;
  cin >>n;
 
  cout << fixed << setprecision (20);
  
  long double bunbo = 0;
  vector<long double> p(n);
  rep(i,n) {
  cin >> p[i];
  bunbo+=1/p[i];
  }
  
  cout << (long double)1/bunbo << endl;
  
}


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

#define LL long long
#define ULL unsigned long long int
LL INF=10000000000000001;
#define mx 100005
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define READ 	freopen("in.txt","r",stdin)
#define WRITE  	freopen("out.txt","w",stdout)
#define BOOST	ios_base::sync_with_stdio(false)


#define sf 	scanf
#define pf 	printf
#define F  	first
#define S  	second
#define pb 	push_back
#define NL	pf("\n")
#define si(x)		sf("%d",&x);
#define sii(x,y)	sf("%d%d",&x,&y);
#define siii(x,y,z)	sf("%d%d%d",&x,&y,&z);
#define sl(x)		sf("%lld",&x);
#define sll(x,y)	sf("%lld%lld",&x,&y);
#define slll(x,y,z)	sf("%lld%lld%lld",&x,&y,&z);
#define clr(x,y) 	memset(x,y,sizeof (x) )
#define ch 			printf("Came Here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n")
#define SV(v)		sort(v.begin(),v.end())
#define SVR(v,cmp)	sort(v.begin(),v.end(),cmp)
#define ALL(v)		v.begin(),v.end()
#define FOR(i,n)	for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define rev(i,s,n)	for(int i=n;i>=s;i--)
// graph direction array [4]
//LL X[4]={0,0,1,-1};
//LL Y[4]={1,-1,0,0};
// graph direction array [8]
//int X[8]={0,0,1,-1,-1,1,1,-1};
//int Y[8]={1,-1,0,0,-1,-1,1,1};
// Knight Direction Array
//int X[8] = {1,1,2,2,-1,-1,-2,-2};
//int Y[8] = {2,-2,1,-1,2,-2,1,-1};

// comparison function for sort
//bool asc(LL a,LL b){
//    return a<b;
//}
//bool desc(LL a,LL b){
//    return a>b;
//}
//
//LL mod =1000000007;
//LL powerMod(LL a,LL b){
//	if(b==0)return 1%mod;
//	LL x=powerMod(a,b/2);
//	x = (x%mod*x%mod)%mod;
////	if(x>=mod)x%=mod;
//	if(b%2==1){
//		x = (x%mod*a%mod)%mod;
////		if(x>=mod)x%=mod;
//	}
//	return x%mod;
//}
//LL modMul(LL a, LL b){
//
//    LL ans = 0;
//    a = a % mod;
//    while (b > 0){
//        if ( b % 2 )
//            ans = (ans%mod+ a%mod) % mod;
//        a = (a%mod * 2%mod) % mod;
//        b /= 2;
//    }
//    return ans % mod;
//}
// ----------------------------------------------
// ----------------------------------------------

int n,m,a,k,b;

int main(){
//	READ;
//	WRITE;
//	BOOST;
//	int t;

    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{

            cout<<"Bob"<<endl;
        }
    }

//    main();

    return 0;
}


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

#define rep(i,a,n) for(int i=a;i<n;++i)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

const int N=2e5+5;
const int inf=2e9;
int a[2][N];
int pos[N];
int f[2][N][32];
struct node{
    int val,l,r;
    bool friend operator<(node a,node b){
        return a.val>b.val;
    }
};

void rmq_init(int v,int n){
    for(int i=0;i<n;++i) {
        f[v][i][0]=a[v][i];
    }
    for(int j=1;(1<<j)<=n;++j){
        for(int i=0;i+(1<<j)-1<n;++i){
            f[v][i][j]=min(f[v][i][j-1],f[v][i+(1<<(j-1))][j-1]);
        }
    }
}
int query(int v,int l,int r){
    int k=0;
    while(1<<(k+1)<=(r-l+1)) ++k;
    return min(f[v][l][k],f[v][r-(1<<k)+1][k]);
}
int main(){
    ios::sync_with_stdio(0);
    int n,t;
    cin>>n;
    rep(i,0,n){
        cin>>t;
        pos[t]=i;
        a[i&1][i]=t;
        a[(i&1)^1][i]=inf;
    }
    rmq_init(0,n);
    rmq_init(1,n);

    priority_queue<node>q;
    t=query(0,0,n-1);
    q.push({t,0,n-1});
    while(!q.empty()){
        node t=q.top();
        int v1=t.val;
        q.pop();
        int v2=query((pos[v1]&1)^1,pos[v1]+1,t.r);
        cout<<v1<<' '<<v2<<' ';
        v1=pos[v1];
        v2=pos[v2];
        if(v1!=t.l){
            q.push({query(t.l&1,t.l,v1-1),t.l,v1-1});
        }
        if(v1+1!=v2){
            q.push({query((v1+1)&1,v1+1,v2-1),v1+1,v2-1});
        }
        if(v2!=t.r){
            q.push({query((v2+1)&1,v2+1,t.r),v2+1,t.r});
        }
    }
    return 0;

}


Measured memory_bytes: 54520
#include<cmath>
#include<cstdio>
#include<algorithm>
#define maxn 200005
using namespace std;
const int MX=1e8;
const double pi=acos(-1.0);
double ans;
int n,sx,sy,tx,ty,top,que[maxn];
struct chj{
	int x,y;
	bool operator <(const chj b)const{return x<b.x;}
}a[maxn];
inline char nc(){
	static char buf[100000],*L=buf,*R=buf;
	return L==R&&(R=(L=buf)+fread(buf,1,100000,stdin),L==R)?EOF:*L++;
}
inline int read(){
	int ret=0,f=1;char ch=nc();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=nc();}
	while (ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=nc();
	return ret*f;
}
int main(){
	sx=read();sy=read();tx=read();ty=read();n=read();
	for (int i=1;i<=n;i++) a[i]=(chj){read(),read()};
	if (sx>tx){sx=MX-sx;tx=MX-tx;for (int i=1;i<=n;i++) a[i].x=MX-a[i].x;}
	if (sy>ty){sy=MX-sy;ty=MX-ty;for (int i=1;i<=n;i++) a[i].y=MX-a[i].y;}
	sort(a+1,a+n+1);
	for (int i=1;i<=n;i++)
	if (sx<=a[i].x&&a[i].x<=tx&&sy<=a[i].y&&a[i].y<=ty){
		if (!top||a[i].y>que[top]){que[++top]=a[i].y;continue;}
		int L=1,R=top,ret=0;
		while (L<=R){
			int mid=(L+R)>>1;
			if (que[mid]>a[i].y) ret=mid,R=mid-1;else L=mid+1;
		}
		if (ret) que[ret]=a[i].y;
	}
	ans=(double)(tx-sx+ty-sy)*100-(20-5*pi)*top;
	if (top==min(tx-sx,ty-sy)+1) ans+=pi*5;
	printf("%.12lf\n",ans);
	return 0;
}

Measured memory_bytes: 2560
s = input()

ans = ''
idx = -1
for i, c in enumerate(s):
    if c == 'A' and idx == -1:
        idx = i
        break
for i, c in enumerate(reversed(s)):
    if c == 'Z':
        ans = s[idx:len(s)-i]
        break
print(len(ans))


Measured memory_bytes: 3512
n = int(input())
a = list(map(int, input().split()))

l, r = 0, 0
sum = 0
ans = 0
while r < n:
    # 右端を進める
    if sum ^ a[r] == sum+a[r]:
        sum += a[r]
        r += 1
        ans += r - l
    # 右端と左端を進める
    elif l == r:
        l += 1
        r += 1
    # 左端を進める
    else:
        sum -= a[l]
        l += 1
    # print('l={}, r={}, size={}, ans={}, {}'.format(l, r, r - l, ans, a[l:r]))
print(ans)

Measured memory_bytes: 24840
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <iomanip>
#include <cmath>
#include <boost/multiprecision/cpp_int.hpp>
#include <map>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;

int main()
{
    // 整数の入力
    ll X;
    cin >> X;
    if (400 <= X && X < 600){
        cout << 8 << endl;
    }else if (600 <= X && X < 800){
        cout << 7 << endl;

    }else if (800 <= X && X < 1000){
        cout << 6 << endl;

    }else if (1000 <= X && X < 1200){
        cout << 5 << endl;

    }else if (1200 <= X && X < 1400){
        cout << 4 << endl;

    }else if (1400 <= X && X < 1600){
        cout << 3 << endl;
    }else if (1600 <= X && X < 1800){
        cout << 2 << endl;

    }else if (1800 <= X && X < 2000){
        cout << 1 << endl;
    }
    return 0;
}

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

int A[1000000],n;

int binarySearch(int key){
    int left=0;
    int right=n;
    int mid;
    while(left<right){
        mid=(left+right)/2;
        if(key==A[mid])return 1;
        if(key>A[mid])left=mid+1;
        else if(key<A[mid])right=mid;
    }
    return 0;
}
int search(int B[],int m,int key){
    int i=0;
    B[m]=key;
    while(B[i]!=key)i++;
    return i!=m;
}

int main(){
    int i,q,k,sum=0;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>A[i];
    }
    cin>>q;
    for(i=0;i<q;i++){
        cin>>k;
        //if(search(A,n,k))sum++;
        if(binarySearch(k))sum++;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3476
#include<bits/stdc++.h>
#include<map>
#include<queue>
#include<cmath>
#include<cassert>
#include<vector>
#include<iostream>
using namespace std;

vector<int> bits;
vector<int> after;

void print(vector<int> v){
  for(auto i:v){
    //cerr<<i<<" ";
  }//cerr<<endl;
}

void init(){
  bits.clear();
  after.clear();
}

bool input(){
  int n,m;
  cin>>n>>m;
  for(int i=0;i<n;i++){
    int tmp;
    cin>>tmp;
    bits.push_back(tmp);
  }
  for(int i=0;i<m;i++){
    int tmp;
    cin>>tmp;
    after.push_back(tmp);
  }
  return true;
}


int make_ans(vector<int> pre,vector<int> a,vector<int> b){
  queue<pair<int,vector<int>>> q;
  map<vector<int>,int> dp;
  q.push(make_pair(0,pre));
  while(!q.empty()){
    pair<int,vector<int>> now = q.front();q.pop();
    const vector<int> v = now.second;
    const int cost = now.first;
    if(v==a)return cost;
    if(v==b)return cost;
    if(dp.count(v)!=0)continue;
    dp[v]=cost;
    for(int i=0;i+1<v.size();i++){
      vector<int> next= v;
      swap(next[i],next[i+1]);
      q.push(make_pair(cost+1,next));
    }
  }
  return INT_MAX;
}

int solve(){
  vector<int> b;
  bool jj = false;
  for(int i=0;i<after.size();i++){
    for(int j=0;j<after[i];j++){
      b.push_back(jj);
    }
    jj = (!jj);
  }
  print(bits);
  print(b);
  vector<int> a = b;
  for(int i=0;i<b.size();i++){
    a[i] = (!a[i]);
  }
  print(b);
  int ans = make_ans(bits,a,b);
  return ans;
}

int main(){
  init();input();
  cout<<solve()<<endl;
}

Measured memory_bytes: 2800
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e9;

bool is_prime[ 1000002 ];
vector<int> P;
void Eratosthenes( const int N )
{
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;//初期化
    }    
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
}

//最大公約数
ll yaku(ll a, ll b){
    if(a>b) return yaku(b,a);
    else{
        if(b%a==0) return a;
        else return yaku(b%a,a);
    }
}

int main(){
    ll A,B,ans=1;
    cin>>A>>B;
    ll N=yaku(A,B);
    Eratosthenes(1000001);
    //cout<<P.size();
    if(N==1) ans=1;
    else{
        int i=0;
        
        while(true){ 
            int m=P.at(i);
            bool kari=false;
            while(N%m==0){
                kari=true;
                N/=m;
            }
            if(kari) ans++;
            
            if(m*m>N) break;
            i++; 
            if(i==P.size()) break;
        }
        if(N!=1) ans++;
    }
    cout<<ans<<endl;
}


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


int main() {

    int n, m;
    cin >> n >> m;
    cout << (n-1)*(m-1) << endl;
    return 0;
}

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
    int n; cin >> n;
    if(n == 1){cout << "Hello World" << endl; }
    else{
    	int a, b; cin >> a >> b;
        int ans = a + b;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
// Ring.cc
// 図のようなリング状の文字列 sの任意の位置から、時計回りに連続した文字をいくつか選んで、
// 文字列 pが作れるかを判定するプログラムを作成してください。
// 【入力】
// １行目に文字列 sが与えられます。
// ２行目に文字列 pが与えられます。
// 【出力】
// pが作れる場合は Yes と、作れない場合は No と１行に出力してください。
// 【制約】
// ・1 ≤ pの長さ ≤s の長さ ≤100
// ・文字列は英小文字からなる
// 【例】
// 入力：
// vanceknowledgetoad
// advance
// 出力：
// Yes
// 入力：
// vanceknowledgetoad
// advanced
// 出力：
// No
#include<iostream>
#include<cstring>
using namespace std;

int main( void) {
  char s[101];
  char ss[201];
  char p[101];

  cin >> s >> p;

  strcpy( ss, s);
  strcat( ss, s);

  if ( strstr( ss, p) == NULL) cout << "No";
  else cout << "Yes";

  cout << endl;

  return 0;
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n;
ll tac[15][15];
ll res;
int main()
{
	cin >>n;
	for (int i=1;i<=n;i++)
	{
		int x=i%10,t=i;
		while (t)
		{
			if (t<10)
			{
				tac[t][x]++;
				break;
			}
			else t/=10;
		}
	}
	for (int i=1;i<10;i++)
		for (int j=1;j<10;j++)
			res+=tac[i][j]*tac[j][i];
	cout <<res;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
static const int fast_io = [](){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);return 0;}();
static const int precise_doubles = [](){cout<<fixed<<setprecision(20);return 0;}();
typedef pair<int, int> PII;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(k) - iterator to kth largest, order_of_key(k) - #things < k
typedef long double LD;
typedef long long LL;
#define EVAL(x) x
#define NEWL EVAL({cout << '\n';})
#define SPA(x) EVAL({cout << #x" = " << x << ' ';})
#define SPAR(a, b) EVAL({cout<<#a" = ";for(auto it=a;it!=b;)cout<<*(it++)<<" ";cout<<'\n';})
#define SPAV(v) EVAL({cout<<#v" = ";for(auto it=v.begin();it!=v.end();)cout<<*(it++)<<" ";cout<<'\n';})
const int INF = 0x3f3f3f3f; // 1.0e9
const LL LINF = 0x3f3f3f3f3f3f3f3fll; // 4.5e18
const LD eps = 1e-20;
const int mod = 1e9 + 7;
inline int msum(int x, int y) {return (x+y<mod ? x+y : x+y-mod);}
inline int mdif(int x, int y) {return (x>=y ? x-y : x-y+mod);}
inline int mprod(int x, int y) { return (1ll*x*y) % mod; }
inline int mpow(int x, LL y) {LL r=1;while(y){if(y&1)r=mprod(r,x);x=mprod(x,x);y>>=1;}return r;}
inline int minv(int x) { return mpow(x, mod-2); }
//------------------------------------------------------------------------------------------------------

int main() {
    int n; cin >> n;
    vector<int> p(n+5);
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (p[i] != i) {
            continue;
        }
        int j = i;
        while (j+1 <= n and p[j+1] == j+1) {
            j++;
        }
        int l = j-i+1;
        ans += l/2;
        if (l & 1) {
            ans++;
        }
        i = j+1;
    }
    cout << ans << '\n';
}






























Measured memory_bytes: 640
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, m, c = map(int, input().split())
b = list(map(int, input().split()))

ans = 0
for _ in range(n):
    a = list(map(int, input().split()))
    tmp = 0
    for i in range(m):
        tmp += a[i] * b[i]
    tmp += c
    if tmp > 0:
        ans += 1

print(ans)


Measured memory_bytes: 62120
#include <cstdio>
#include <cstdlib>

int N;
int a[110];
int num[110];
long long res=0;
long long tr;
long long ss[110];
long long tr2;
long long r1, r2;
long long ss2[110];

void srch(int dep)
{
	int i, j;
	if(dep==(N+2)/2){
		long long sum = 0;
		/*for(i=1; i<dep; i++){
			if(num[i]==0)
				sum += a[i];
		}
		for(; i<N; i++){
			if(num[i]==0 && a[i]>0)
				sum += a[i];
		}*/
		sum = tr+ss[dep]-r2;
		if(sum > res)
			res = sum;
		return ;
	}
	if(num[dep]==0)
		tr += a[dep];
	if(tr+ss[dep+1]-r2 <= res){
	}
	else
		srch(dep+1);
	if(num[dep]==0)
		tr -= a[dep];
	if(num[dep]==1)
		return ;
	if(tr+ss[dep+1]-r2 <= res)
		return ;
	int ta[110], taL=0;
	for(i=1; i*dep<=N; i++){
		j = i*dep;
		if(num[j]==0){
			num[j] = 1;
			ta[taL] = j;
			taL ++;
			if(j >= (N+2)/2 && a[j]>0)
				r2 += a[j];
			//tr2 += a[j];
		}
	}
	srch(dep+1);
	for(i=0; i<taL; i++){
		num[ta[i]] = 0;
		if(ta[i] >= (N+2)/2 && a[ta[i]]>0)
			r2 -= a[ta[i]];
		//tr2 -= a[ta[i]];
	}
}

void solve()
{
	int i;
	ss[N+1] = 0;
	ss2[N+1] = 0;
	for(i=N; i>=1; i--){
		if(a[i] > 0)
			ss[i] = ss[i+1] + a[i];
		else
			ss[i] = ss[i+1];
		ss2[i] = ss2[i+1] + a[i];
	}
	for(i=1; i<=N; i++)
		num[i] = 0;
	res = 0;
	tr = tr2 = 0;
	r1 = r2 = 0;
	srch(1);
	printf("%lld\n", res);
}

int res2;
void solve2()
{
	int i, j, k, l;
	res2 = 0;
	for(i=0; i<(1<<N)-1; i++){
		int num2[20];
		for(j=1; j<=N; j++)
			num2[j] = 0;
		k = i;
		l = 1;
		while(k>0){
			if(k%2==1){
				for(j=1; j*l<=N; j++){
					num2[j*l] = 1;
				}
			}
			k /= 2;
			l ++;
		}
		int sum2 = 0;
		for(j=1; j<=N; j++){
			if(num2[j]==0)
				sum2 += a[j];
		}
		if(sum2 > res2)
			res2 = sum2;
	}
	printf("%d\n", res2);
}

void test1()
{
	int i;
	N = 100;
	for(i=0; i<N; i++){
		a[i+1] = rand() % 1000 - 500;
	}
	solve();
	//solve2();
	//if(res != res2)
	//	printf("Wrong\n");
}

void test()
{
	int i;
	for(i=0; i<100; i++)
		test1();
}

int main()
{
	//test();
	//freopen("in.txt", "r", stdin);
	int i;
	scanf("%d", &N);
	for(i=1; i<=N; i++)
		scanf("%d", &a[i]);
	solve();
	//solve2();
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,sum=0;
  cin>>n;
  for(int i=1;i<=n;i++)
  {
   if((i%3==0 and i%5==0) || (i%3==0 || i%5==0))
      continue;
  else
    sum+=i;
  }
  cout<<sum<<endl;
  
}

Measured memory_bytes: 3584
import java.util.*;

public class Main {
	double EPS = 10.e-08;
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int [] data = new int[n];
			for(int i = 0; i < n; i++) {
				data[i] = sc.nextInt();
			}
			data[0]--;
			
			boolean flg = true;
			for(int i = 1; i < n; i++){
				if(data[i-1] < data[i]){
					data[i]--;
					continue;
				}
				if(data[i-1] == data[i]) {
					continue;
				}
				else {
					flg = false;
					break;
				}
			}
			System.out.println(flg ? "Yes" : "No");
			
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


Measured memory_bytes: 50168
from collections import defaultdict
def main():
  N, K = map(int,input().split())
  D = defaultdict(int)
  for _ in range(N):
    a, b = map(int,input().split())
    D[a]+=b
  D = sorted(D.items())
  ans, total = D[0]
  for i in range(1,len(D)):
    if K <= total:
      print(ans)
      return
    else:
      c, d = D[i]
      ans = c
      total+=d
  print(ans)
  return

main()

Measured memory_bytes: 82516
N = int( input())

X = list( map( int, input().split() ))

m = min( X )
M = max( X )

v_min = 10 ** 18
for i in range( m, M + 1 ):
  v = 0
  for x in X:
    v += ( i - x ) ** 2
  v_min = min( v, v_min )
print( v_min )

Measured memory_bytes: 3064
N = int(input())
ans = ''
for i in range(1,99):
    if N <= 26 **i:
        N -= 1
        for j in range(i):
            ans += chr(ord('a')+N%26)
            N //= 26
        break
    else:
        N -=26**i
print(ans[::-1])


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

#define endl             '\n' 
#define pii              pair <int,int>
#define pll              pair <long long,long long>
#define sc               scanf
#define pf               printf
#define Pi               2*acos(0.0)
#define ms(a,b)          memset(a, b, sizeof(a))
#define pb(a)            push_back(a)
#define MP               make_pair
#define db               double
#define ll               long long
#define EPS              1E-5
#define ff               first
#define ss               second
#define sqr(x)           (x)*(x)
#define D(x)             cout<<#x " = "<<(x)<<endl
#define VI               vector <int>
#define DBG              pf("Hi\n")
#define MOD              1000000007
#define CIN              ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define SZ(a)            (int)a.size()
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define REP(i,a,b)       for(int i=a;i<b;i++)
#define TEST_CASE(t)     for(int z=1;z<=t;z++)
#define all(a)           a.begin(),a.end()
#define intlim           2147483648
#define infinity         (1<<28)
#define ull              unsigned long long
#define gcd(a, b)        __gcd(a, b)
#define lcm(a, b)        ((a)*((b)/gcd(a,b)))
 
using namespace std;
 
 
const int fx[]= {+1,-1,+0,+0};
const int fy[]= {+0,+0,+1,-1};
// const int N = 1e5 + 5;
#define piii pair<int, pair<int,int> >

const int N = 2e5 + 5;
ll c=0;
ll f(ll n){
  if(n==1ll)return 1;
  ll aux = f(n/2)*2  + 1;  
  return aux;
}
int main(){
  // CIN;
  int n,m;
  ll x;
  while(cin >> x)
  {
    cout << f(x) << endl;

  }
}

Measured memory_bytes: 256
N = int(input())
array1 = list(map(int,input().split()))
array2 = list(map(int,input().split()))
array = [array1,array2]
candy = [0]*N
for i in range(N):
    candy[i] = sum(array[0][0:i+1])+array[1][i]+sum(array[1][i+1:N])
print(max(candy))

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

const ll MOD = 1000000007;
const ll MAX = 200010;
ll fac[MAX], finv[MAX];



ll mmul(ll a, ll b) {
    return ((a%MOD)*(b%MOD))%MOD;
}

ll mpow(ll a, ll b) {
    ll res = 1LL;
    while(b) {
        if(b & 1LL) res = (res*a) % MOD;
        b >>= 1;
        a = (a*a) % MOD;
    }
    return res;
}

ll mdiv(ll a, ll b) {
    return (a * mpow(b, MOD-2)) % MOD;
}

ll mcomb(ll n, ll k) {
    if(n<k || k<0) return 0;
    else return mmul(mmul(fac[n], finv[k]), finv[n-k]);
}

inline void INIT_F(){
    fac[0] = finv[0] = 1;
    for(ll i=1; i<MAX-1; i++) {
        fac[i] = (fac[i-1]*i) % MOD;
        finv[i] = mdiv(finv[i-1], i);
    }
}

int main() {
    ll N, M;
    cin >> N >> M;
    INIT_F();

    ll res = 1;
    for(ll i=2; i*i <= M; i++) {
        if(M%i) continue;
        ll tcnt = 0;
        while(M%i == 0) {
            M /= i;
            tcnt++;
        }
        res *= mcomb(N-1+tcnt, tcnt) % MOD;
        res %= MOD;
    }
    if(M > 1) res = (res * N) % MOD;

    cout << res << endl;
    return 0;

}




Measured memory_bytes: 3328