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

int main() {
    int A, B;
    cin >> A >> B;
    if (A == B) {
        cout << "Draw" << endl;
    }
    else if (A == 1 || B == 1) {
        if (A == 1) {
            cout << "Alice" << endl;
        }
        else {
            cout << "Bob" << endl;
        }
    }
    else if (A < B){
        cout << "Bob" << endl;
    }
    else {
        cout << "Alice" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FILEIN freopen("input.txt", "r", stdin)
using namespace std;

#define ll long long
#define endl "\n"

int main(){
    // FILEIN;
    int n, l; cin>>n>>l;
    vector<string> s(n);
    for(auto &i : s){
        cin>>i;
    }
    sort(s.begin(), s.end());
    for(auto i:s){
        cout<<i;
    }
    cout<<endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i > b; i--)
#define repll(i, a, b) for (ll i = a; i < b; i++)

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

  int r;
  cin >> r;
  cout << 2 * M_PI * r << endl;

  return 0;
}


Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
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 pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) solve();
}

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  a[0]--;
  rep3(i, 1, n) {
    if (a[i] == a[i - 1]) continue;
    else if (a[i] > a[i - 1]) {
      a[i]--;
    } else {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 640
s = int(input())

#modありのコンビネーション計算
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9 + 7
N = s*2 #必要な数
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans = 0
for i in range(1,s//3+1):
    must = 3*i
    amari = s - must
    ans += cmb(amari+i-1,i-1,mod)
    ans %= mod
print(ans)

Measured memory_bytes: 9540
#include<stdio.h>
#define N 100
int main(){
  int n,p[N+1],m[N+1][N+1],i,l,j,k;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d %d",&p[i-1],&p[i]);
    //cin>>p[i-1]>>p[i];
  }
  for(i=1;i<=n;i++)m[i][i]=0;
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=(1 << 21);
      for(k=i;k<=j-1;k++){
        m[i][j]=m[i][j]<m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j] ? m[i][j]:m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
      }
    }
  }
  printf("%d\n",m[1][n]);
  return 0;
}



Measured memory_bytes: 2048
S = input()
N = len(S)
K = int(input())

if len(set(S)) == 1 or len(S) == 1:
    ans = K * len(S) // 2
    print(ans)
    exit()

left = 0
right = 1

while left < N and S[left] == S[0]:
    left += 1
while right <= N and S[-right] == S[-1]:
    right += 1
right -= 1

change = 0
isChanged = False
T = list(S[left: N - right])

for i, t in enumerate(T[1:], start=1):
    if t == T[i - 1]:
        if not isChanged:
            change += 1
            isChanged = True
            continue
    isChanged = False

ans = change * K
if S[0] == S[-1]:
    ans += left // 2 + (left + right) // 2 * (K - 1) + right // 2
else:
    ans += (left // 2 + right // 2) * K

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPD(i,n) for(int i=(n)-1;i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=(b);--i)
#define TLE() cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms.\n";
const ll MOD = 1E9+7;
const ll IINF = 1E18;
const int INF = 1e9;
const double EPS = 1E-9;
const double PI = atan(1.0) * 4.0;
template<class T> T getbit(T s, int i) {return s>>i&1;}
template<class T> void flipbit(T& s, int i) {s^=(1LL<<i);}
constexpr int cntbit(ll x) {return __builtin_popcountll(x);}
constexpr int lg2(ll x) {return __lg(x);} // return int(log2(x))
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 
ll fpow(ll a,ll p){ll res=1LL;while(p){if(p&1LL) res=res*a%MOD;a=a*a%MOD;p>>=1LL;} return res;}

const int N=1e5+5;
int n;
string s;
ll f[N][2];

ll dp(int i,bool ok){
	if(i==n) return 1LL;
	ll& res=f[i][ok];
	if(~res) return res;
	res=0;
	if(ok) res=dp(i+1,ok)*3LL%MOD;
	else{
		if(s[i]=='1'){
			(res+=dp(i+1,false)*2LL%MOD)%=MOD;
			(res+=dp(i+1,true))%=MOD;
		}
		else res=dp(i+1,false)%MOD;
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>s;
	n=sz(s);
	memset(f,-1,sizeof f);
	cout<<dp(0,false)<<'\n';
}



Measured memory_bytes: 11512
#include<cstdio>
#include<algorithm>
typedef std::pair <long long,long long> gpair;
int n,num[300050];
long long sum[300050];
gpair work(int L,int R){
	int l=L,r=R-1,ret=L;
	if(l==r) return std::make_pair(std::min(num[l],num[l+1]),std::max(num[l],num[l+1]));
	while(l<=r){
		int mid=(l+r>>1);
		long long ls=sum[mid]-sum[L-1],rs=sum[R]-sum[mid];
		//printf("%d :%d %d\n",mid,ls,rs);
		if(ls==rs){return std::make_pair(ls,rs);}
		if(ls>rs){
			if(ls-num[mid]<rs+num[mid]){
				long long a=rs-ls+2*num[mid],b=ls-rs;
				return a>b?(std::make_pair(rs,ls)):(std::make_pair(ls-num[mid],rs+num[mid]));
			}
			r=mid-1;ret=mid;
		}
		else{
			if(ls+num[mid+1]>rs-num[mid+1]){
				int a=ls-rs+2*num[mid+1],b=rs-ls;
				return a>b?(std::make_pair(ls,rs)):(std::make_pair(rs-num[mid+1],ls+num[mid+1]));
			}
			l=mid+1;ret=mid;
		}
	}
	return std::make_pair(std::min(sum[ret]-sum[L-1],sum[R]-sum[ret]),std::max(sum[ret]-sum[L-1],sum[R]-sum[ret]));
}
int main(){
	int n;
	long long ans=1e14;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&num[i]);
		sum[i]=sum[i-1]+num[i];
	}
	for(int i=2;i<=n-2;i++){
		gpair p1=work(1,i);
		gpair p2=work(i+1,n);
		ans=std::min(ans,1ll*(std::max(p1.second,p2.second)-std::min(p1.first,p2.first)));
		//printf("*%d :%d\n",i,ans);
		//printf("%d %d %d %d\n",p1.first,p1.second,p2.first,p2.second);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int left=a+b;
  int right=c+d;
  if(left>right){
    cout<<"Left"<<endl;
  }else if(left==right){
    cout<<"Balanced"<<endl;
  }else{
    cout<<"Right"<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#define endl '\n'
typedef long long ll;
using namespace std;
//ll d[10000001];
int main()
{
	ll n;
	cin>>n;
	vector<ll> v(n);
	for(ll i = 0; i<n; i++)
		cin>>v[i];
	sort(v.begin(),v.end());
	ll m  = v.size();
	ll ans = v[m/2]-v[( m/2 )-1];
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
int main(){
   string s;
   cin>>s;
   int count;
   count=0;
   for(int i=0;i<s.length()/2;i++){
     if(s[i]!=s[s.length()-i-1]){
       count++;
     }
   }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a = a + a[:-1]

da = [a[i] ^ a[i+1] for i in range(len(a) - 1)]
db = [b[i] ^ b[i+1] for i in range(len(b) - 1)]


fail = [0 for i in range(len(da))]
fail[0] = -1
p = 0
for q in range(2, len(da)):
    while p >= 0 and da[q-1] != da[p]:
        p = fail[p]
    p += 1
    fail[q] = p

p = 0
q = 0
while p + q < len(da):
    if db[q] == da[p+q]:
        if q == len(db) - 1:
            print(p, a[p] ^ b[0])
            p += q - fail[q]
            q = fail[q]
        else:
            q += 1
    else:
        p += q - fail[q]
        if q > 0:
            q = fail[q]


Measured memory_bytes: 128080
#include<stdio.h>
int main()
{
	int n,r;
    scanf("%d",&n);
    r=n%10;
    if(r==2 || r==4 || r==5 || r==7 || r==9)
    {
    	printf("hon\n");
    }
    else if(r==0 || r==1 || r==6 || r==8)
    {
    	printf("pon\n");
    }
    else if(r==3)
    {
    	printf("bon\n");
    }
    return 0;
}

Measured memory_bytes: 1652
N, D = map(int,input().split())
X = []
Y = []
for i in range(N):
    x, y = map(int,input().split())
    X.append(x)
    Y.append(y)
x = 0
D = D**2
for i in range(N):
    if D >= X[i]**2 + Y[i]**2:
        x += 1
print(x)


Measured memory_bytes: 24792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
  int a,b;
  cin >> a >> b;
  cout << (a <= 5? 0:(a <= 12? b/2:b)) << endl;
}

int main(int argc, char *argv[]){
  int testcase = 1;
  int multicase = 0;
  if (argc > 1 && stoi(argv[1])) cin >> testcase;
  REP(case_no, testcase) {
    cerr << "case " << case_no + 1 << endl;
    solve();
  }
  return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
use ascii::AsciiChar;
use ascii::AsciiStr;
use itertools::Itertools as _;
use permutohedron::LexicalPermutation as _;
use petgraph::algo::dijkstra;
use petgraph::algo::min_spanning_tree;
use petgraph::data::FromElements;
use petgraph::graph::NodeIndex;
use petgraph::graph::UnGraph;
use petgraph::unionfind::UnionFind;
use proconio::fastout;
use proconio::input;
use proconio::marker::Chars;
use proconio::marker::Usize1;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;
use superslice::Ext as _;

#[fastout]
fn main() {
    input! {
        N: usize,
    }

    // 前処理はO(N)まで許されている
    // エラトステネスの篩により、O(NloglogN)で素数は求まる
    // あー思い出した、最初にそれやっちゃうと考えが固定化されてハマるんだった。本番がそう。

    // 必ず1とその数では割れるのでデフォルト値は2
    let mut divisor_cnt = vec![2i64; N + 1];
    divisor_cnt[0] = 0;
    divisor_cnt[1] = 1;

    // エラトステネスの篩の変種を使う。数字を消す代わりにカウントを増やす
    // debugビルドだと17秒だったがreleaseビルドだと1.8秒で間に合った。まじ?
    for n in 2..=N {
        // for i in (n..=N).step_by(n).skip(1) {
        let mut i = n * 2;
        while i <= N {
            // dbg!(i);
            divisor_cnt[i] += 1;
            i += n;
        }
    }

    // dbg!(&divisor_cnt);

    let mut ans: i64 = 0;

    for k in 1..=N {
        // forループ内をO(1)で求めたい
        let item = k as i64 * divisor_cnt[k];
        ans += item;
    }
    println!("{}", ans);
}


Measured memory_bytes: 80164
#include <bits/stdc++.h>
using namespace std;
const int64_t INF=9999999999999999;

int main() {
   int A,B,X;
   cin>>A>>B>>X;
   if(X>=A&&X<=A+B){cout<<"YES"<<endl;}
   else{cout<<"NO"<<endl;}
return 0;}

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

ll gc(ll a, ll b){
	if(a==0 || b==0){
		return a+b;
	}
	return gc(b%a,a);
}
ll lc(ll a, ll b){
	return a*b/gc(a,b);
}
int main(){
	ll n, m;
	cin >> n >> m;
	string s, t;
	cin >> s >> t;
	ll sz = lc(n,m);
	ll x = sz/n;
	ll y = sz/m;
	ll maxi = lc(x,y);
	bool ok = true;
	for(ll i = 0; i<sz; i+=maxi){
		ok &= s[(int)(i/x)]==t[(int)(i/y)];
	}
	cout << (ok?sz:-1) << endl;
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <list>
#include <map>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define fi first
#define se second
#define pb push_back
//#define mp make_pair
#define rep(i,n) for(register int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
const int INF=0x3f3f3f3f;
const int dx[]={0,1,-1,0},dy[]={1,0,0,-1};
//const int MOD=998244353;
const int N=1e5+10;

inline int read(){
	int ww=1,xx=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-') ww=-ww;ch=getchar();}
	while(isdigit(ch)){xx=(xx<<1)+(xx<<3)+(ch^48);ch=getchar();}
	return ww*xx;
}

int n,h[N],f[N],ans;

signed main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read();
	for(int i=1;i<=n;i++) h[i]=read();
	h[n+1]=2147483647;
	for(int i=n;i>=1;i--) if(h[i+1]<=h[i]) f[i]=f[i+1]+1;
	for(int i=1;i<=n;i++) ans=max(ans,f[i]);
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << ":" << #x << " = " << (x) << endl;
#else
#define dbg
#endif

#pragma endregion Macros

int main()
{
    ll D,T,S;
    cin >> D >> T >> S;

    string ans;
    if (D <= T * S){
        ans = "Yes";
    }else{
        ans = "No";
    }

    cout << ans << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

int n;
int a[111];

int main(){
	cin>>n;
  int res=0;
  rep(i,n)cin>>a[i];
  rep(i,n){
    rep(j,n-1){
      if(a[j]>a[j+1]){
        swap(a[j],a[j+1]);
        res++;
      }
    }
  }
  cout<<a[0];
  repl(i,1,n)cout<<" "<<a[i];
  cout<<endl;
  cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 3088
import numpy as np 
N = int(input())

n = int(np.sqrt(N)) 
ans_list = []
for i in range(1, n + 1):
    if N % i == 0:
        k = int(i + (N / i) - 2) 
        ans_list.append(k) 
    else:
        pass

print(min(ans_list)) 


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


count=len(str(n))
ans=''
if count%2==0:
    for i in range(count-1):
        if i%2==0:
            ans+='9'
        else:
            ans+='0'
else:
    ans=(count//2)*'90'
    try:
        ans=n-int(ans)
    except:
        ans=n
print(int(ans))


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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if (a == 7 && b == 5 && c == 5 || a == 5 && b == 7 && c == 5 || a == 5 && b == 5 && c == 7) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
using namespace std;
typedef long long ll;

int main() {
	ll i, j;
	ll A, B;
	cin >> A >> B;
	if ((A + B) % 2 == 1)
		cout << "IMPOSSIBLE" << endl;
	else
	{
		ll ans = abs(A + B) / 2;
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
h, w, a, b = gets.strip.split.map(&:to_i)
MOD = 10**9+7

def power(x, n)
  return 1 if n.zero?

  if n.even?
    return power(x*x, n/2) % MOD
  else
    return x*power(x, n/2)**2 % MOD
  end
end

$fac = []
$fac[0] = $fac[1] = 1
2.upto(h+w) do |num|
  $fac[num] = num * $fac[num-1] % MOD
end

$ifac = []
$ifac[0] = $ifac[1] = 1
$ifac[h+w-2] = power($fac[h+w-2], (MOD-2)) % MOD
(h+w-3).downto(2) do |num|
  $ifac[num] = $ifac[num+1] * (num+1) % MOD
end

def comb(n,k)
  return 0 if n<k || n<0 || k<0
  $fac[n] * ($ifac[n-k] * $ifac[k] % MOD) % MOD
end

sum = 0
(b+1).upto(w) do |num|
  c1 = comb(h-a-1+num-1, num-1)
  c2 = comb(a-1+w-num+1-1, a-1)

  sum += c1*c2 % MOD
end

p sum%MOD

#p $fac
#p $ifac


Measured memory_bytes: 6276
use std::cmp::min;
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let n:usize = read();
    let mut m:usize = read();
    let mut v:Vec<(usize, usize)> = (0..n).map(|_| (read(), read())).collect();
    v.sort();
    let mut cnt = 0;
    for (value, num) in v {
        if m == 0 {
            break;
        }
        let mini = min(num, m);
        cnt += mini * value;
        m -= mini;
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4104
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 100010
char s[N];
int main(){
	scanf("%s",s+1);
	int len=strlen(s+1);
	int pd=0;
	if(s[1]!='A'){puts("WA");return 0;}
	for(int i=3;i<=len-1;i++){
		if(s[i]<'a'||s[i]>'z'){
			if(s[i]=='C'){
				if(!pd)pd=1;
				else return puts("WA"),0;
			}else {
				return puts("WA"),0;
			}
		}
	}
	if(!pd)return puts("WA"),0;
	if(s[len]>'z'||s[len]<'a')return puts("WA"),0;
	if(s[2]>'z'||s[2]<'a')return puts("WA"),0;
	printf("AC\n");
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	if (N % K > 0)
	{
		cout << 1 << endl;
	}
	else
	{
		cout << 0 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    map<int,int>mp;
    for(int i=0;i<n;i++)
    {
        int temp;
        cin>>temp;
        mp[temp]=i+1;

    }

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




}



Measured memory_bytes: 8288
#include <bits/stdc++.h>
#define FIXED_FLOAT(x) std::fixed <<std::setprecision(2)<<(x)
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define inf std::numeric_limits<int>::max();
#define highest_2_pow(n)  __builtin_clzll((long long)0)- __builtin_clzll((long long)n) - 1
//-----------------------------------------------------------------------------------------------------
#define lli long long int 
#define int long long
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define vi vector<int>
#define vlli vector<long long int>
#define si set<int>
#define slli set<long long int>
#define mt make_tuple
#define mp make_pair
#define eb emplace_back
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll
//---------------------------------------------------
using namespace std;
// GCD and LCM are available
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
err(++it, args...);
}

void faster(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}
void solve(){
    int n,k;
    cin>>n>>k;
    vi v(n);
    rep(i,0,n) cin>>v[i];
    vi dp(n,1e10);
    dp[0] = 0;
    rep(i,1,n){
        rep(j,1,k+1){
            if((i-j)<0) break;
            dp[i] = min(dp[i],dp[i-j] + abs(v[i]-v[i-j]));
        }
    }
    cout<<dp[n-1]<<endl;
}
signed main()
{
    faster();
    int t=1;
    //cin>>t;
    while(t--) solve();
}

Measured memory_bytes: 4768
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N, H[112345];

int main() {

	scanf("%d", &N);
	rep(i, N) scanf("%d", &H[i]);

	int ans = 0;
	int cur = 0;
	rep(i, N-1) {
		if (H[i] >= H[i + 1]) cur++;
		else {
			ans = max(ans, cur);
			cur = 0;
		}
	}
			ans = max(ans, cur);

	printf("%d\n", ans);

	return 0;
}


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

const int mx = 1234567;
const double exp1 = 1e-6;
const int md = 1e9+7;
typedef long long ll;

int ar[mx],xar[mx],uses[mx];
ll arr[mx];
string st[1000];

int main(){

    int tk=1,n,m=0;
//    freopen("in.txt","r", stdin);
//    freopen("out.txt","w", stdout);
    string s;
    while(cin>>s){
        scanf("%d",&n);
        int l = (int)s.size();
        for(int i = 0; i < l; i+=n){
            cout<<s[i];
        }cout<<endl;


    }
    return 0;
}


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

int main(void) {
    ll N; cin >> N;
    int K; cin >> K;
    int count = 0;

    for(int i=0; N-pow(K,i)>=0; i++) count++;
    cout << count << endl;
}

Measured memory_bytes: 4016
//Code by 27.
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>  
#include<memory.h> 
#include<sstream>
#include<time.h>
#include<iomanip>
using namespace std;
const unsigned long long BIGEST=1000000000000000000+1000000000000000000;
const long long BIGER=1000000000000000000;
const int BIG=1000000000;
const int MOD=1000000007;
const long long LMOD=1000000007;
#define lll long long
lll f[2][100005];
lll n,m;
int main()
{
	lll w,v;
	scanf("%lld%lld",&n,&m);
	lll mx=0;
	for(int i=0;i<100005;i++)
	{
		f[0][i]=BIGEST;
		f[1][i]=BIGEST;
		
	}
	f[0][0]=0;
	f[1][0]=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&w,&v);
		for(lll j=0;j<v;j++)
		{
			f[i%2][j]=f[(i+1)%2][j];
			if(f[i%2][j]<=m)mx=max(mx,j);
			//cout<<f[i%2][j]<<" ";
		}
		for(lll j=v;j<=100000;j++)
		{
			f[i%2][j]=min(f[(i+1)%2][j],f[(i+1)%2][j-v]+w);
			if(f[i%2][j]<=m)mx=max(mx,j);
			//cout<<f[i%2][j]<<" ";
		}
		//cout<<mx<<endl;
	}
	cout<<mx;
	return 0;
}

Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Scanner;

class Main{
    public static void main(final String[] args) {

        new Main().sort();

    }

    void sort() {

        int N;
        int[] arr;

        //input
        final Scanner sc = new Scanner(System.in);
        N = Integer.parseInt(sc.next());
        arr = new int[N];
        for (int i=0; i<N; i++){
            arr[i] = Integer.parseInt(sc.next());
        }
        sc.close();

        for (int l=0; l<N; l++){
            if (l == N-1){
                System.out.println(arr[l]);
            }
            else{
                System.out.print(arr[l] + " ");
            }
        }

        // sort
        int key;

        for (int i=1; i<N; i++){
            key = arr[i]; 

            int j = i - 1;
            while (j>=0 && arr[j] > key) {
                arr[j+1] = arr[j];
                j--;                
            }
            arr[j+1] = key;

            for (int l=0; l<N; l++){
                if (l == N-1){
                    System.out.println(arr[l]);
                }
                else{
                    System.out.print(arr[l] + " ");
                }
            }
        }
    }
}


Measured memory_bytes: 31380
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long[] arr = new long[n + 1];
        long[] sums = new long[n + 1];
        for (int i = 1; i <= n; i++) {
            int x = sc.nextInt();
            arr[i] = x + arr[i - 1];
            sums[i] = sums[i - 1];
            if (x > 0) {
                sums[i] += x;
            }
        }
        long max = Integer.MIN_VALUE;
        for (int i = k; i <= n; i++) {
            max = Math.max(max, sums[n] - (sums[i] - sums[i - k]) + arr[i] - arr[i - k]);
            max = Math.max(max, sums[n] - (sums[i] - sums[i - k]));
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 63688
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, m, res = 1, pa[120120][120];

// メモ化再帰(パスカルの三角形)でnCrを求める O(NR)
int comb(int n, int r) {
	if (r<0 || r>n) return 0;
	else if (r==0) return 1;
	else if (pa[n][r]) return pa[n][r];
	else return pa[n][r] = (comb(n-1, r-1) + comb(n-1, r)) %mod;
}

// 素因数分解 O(√N)
map<ll, int> pf(ll n) {
	map<ll, int> res;
	for (ll i = 2; i*i <= n; i++)
		while (n%i==0) ++res[i], n /= i;
	if (n!=1) res[n]++;
	return res;
}

signed main() {
	cin >> n >> m;
	map<ll,int> p = pf(m);
	each(i,p) (res *= comb(n+i.second-1,i.second)) %= mod;
	cout << res << endl;
}

Measured memory_bytes: 99200
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a;
  cin >> a;
  if (a.at(0) == a.at(1)&&a.at(2) == a.at(3)) {
    if (a.at(0) == a.at(2)) {
      cout << "No" << endl;
    }
    else {
      cout << "Yes" << endl;
    }
  }
  else if (a.at(0) == a.at(2)&&a.at(1) == a.at(3)) {
    if (a.at(0) == a.at(1)) {
      cout << "No" << endl;
    }
    else {
      cout << "Yes" << endl;
    }
  }
  else if (a.at(0) == a.at(3)&&a.at(1) == a.at(2)) {
    if (a.at(0) == a.at(1)) {
      cout << "No" << endl;
    }
    else {
      cout << "Yes" << endl;
    }
  }
  else {
    cout << "No" << endl;
  }
}

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

int main() {
  string a,b;
  cin >> a >> b;
  
  if(a.size() > b.size()){
    cout << "GREATER" <<endl;
  }
  else if(a.size() < b.size()){
    cout << "LESS" <<endl;
  }
  else{
    for (int i=0; i<a.size(); i++){
      if (a.at(i)> b.at(i)){
        cout << "GREATER" <<endl;
        break;
      }
      else if(a.at(i)<b.at(i)){
        cout << "LESS" << endl;
        break;
      }
      else if (i == a.size()-1){
        cout << "EQUAL" <<endl;
      }
    }
  }
}


Measured memory_bytes: 3636
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N = I()
S = LS2()

ANS = [0]
for i in range(N):
    if S[i] == 'I':
        ANS.append(ANS[-1]+1)
    else:
        ANS.append(ANS[-1]-1)

print(max(ANS))

Measured memory_bytes: 61832
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramB
    {
        static void Main()
        {
            int n = NextInt, l = NextInt;
            int min = Enumerable.Range(l, n).Min(i => Math.Abs(i));
            System.Console.WriteLine(Enumerable.Range(l, n).Sum() - Enumerable.Range(l, n).First(i => Math.Abs(i) == min));
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


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

int main() {
    int N, i, cost, cost_sum = 0, max_cost = 0;
    cin >> N;
    
    for (i=0; i < N; i++) {
        cin >> cost;
        cost_sum += cost;
        if (max_cost < cost) {
            max_cost = cost;
        }
        // cout << endl << cost_sum << endl;
    }
    max_cost = max_cost / 2;
    cost_sum -= max_cost;

    cout << cost_sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n,k;
    cin >> n >> k;
    Vi a(n);
    rp(i,n) cin >> a.at(i);
    repi(i,k,n){
        Yes(a[i]>a[i-k]);
    }
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 4748
#include<bits/stdc++.h>
#define ll long long int
#define db long double
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
#define Nmax 1000005
#define INF 1000000000
#define MOD 1000000007
#define MAXN 1000005
 
using namespace std;

char matrix[1002][1002];
ll dp[1002][1002];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int tests=1,t=1;
    // cin>>tests;
    while(tests--)
    {	
    	ll i,j,h,w;
    	cin>>h>>w;
    	rep(i,1,h)
    	{
    		rep(j,1,w)
    		cin>>matrix[i][j];
    	}
    	dp[h][w]=1;
    	for(i=h;i>=1;i--)
    	{
    		for(j=w;j>=1;j--)
    		{
    			if(matrix[i][j]=='#') continue;
    			dp[i][j]+=dp[i+1][j]+dp[i][j+1];
    			dp[i][j]%=MOD;
    		}
    	}
    	cout<<dp[1][1];


    }
    	return 0;
    
}

Measured memory_bytes: 12440
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000

int main() {
	int x, y, z;
	int s, ans;
	scanf("%d", &y);
	f(i, 1000000) {
		x = i;
		x = x * 108;
		x = x / 100;
		if (x == y) {
			printf("%d\n", i);
			return 0;
		}
}
	printf(":(\n");

	return 0;
}


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


#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)		idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)	for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)		idp p2((x).F, (x).S)
#define dump(x,n)	idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)	idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)	idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)	idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)	rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)	rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li child[100100];
vector<li> edge[100100];
li dp[100100];
li n, k;
li res;

inline li dfs(li from, li parent) {
	li depth = 1;
	rep(i, sz(edge[from])) {
		li next = edge[from][i];
		depth = max(dfs(next, from) + 1, depth);
	}
	if (depth == k) {
		if (parent > 0) {
			res++;
			return 0;
		}
	}
	return depth;
}

int main() {
	cin >> n >> k;
	rin{
		cin >> child[i];
		child[i]--;
		if (i != 0)edge[child[i]].pb(i);
	}
	res = 0;
	dfs(0, -1);
	if (child[0] != 0)res++;
	cout << res  << endl;

	return 0;
}


Measured memory_bytes: 10112
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ls x<<1
#define rs x<<1|1
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-6;
const ull hashp=1e7+19;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=2e5+100;
char s[maxn];
void solve()
{
	int n;scd(n);
	scanf("%s",s+1);
	int ans=0;
	rep1(i,n-2){
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')ans++;
	}ac;
}
int main(){
    //IOS;
    solve();
    return 0;
}

Measured memory_bytes: 256
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*                                                    
      I ♥ CLARICE STARLING...                                                               
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
void solve()
{
    int a;cin>>a;
    cout<<(a+a*a+a*a*a)<<"\n";
}
int main()
{
   fastio
   //Test_cases
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>; 
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//If wrong on pretest 2 means logically wrong


/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int N,a[10'000];
main(){
  cin>>N;
  for(int i=0;i<N;++i)cin>>a[i];
  int n_count;
  for(int i=0;i<N;++i){
    while(a[i]%2==0){
      ++n_count;
      a[i]/=2;
    }
  }
  cout<<n_count<<endl;
}


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



int main(void){
    // Your code her
    int a,i,j,k;
    int ans;
    cin>>a;
    
    for (i=1; i<=33;i++)
    {
        for (j=2;j<=11;j++)
        {
            if(pow(i,j) <=a && pow(i,j) >=ans )
            {
               ans= pow(i,j);
            }
        }
    }
    
    cout <<ans<<endl;
    
    
    
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <ctype.h>
 
unsigned int data[8][2] = {
    1826015432,2468951863,
    4148788223,146179072,
    2147300159,2147667136,
    1813301512,332083959,
    1577336967,555301496,
    1359814671,771756592,
    268509233,17306118,
    16846885,268968466,
};
 
unsigned int count(unsigned int n){
    n = (n & 0x55555555) + ((n & 0xAAAAAAAA) >> 1);
    n = (n & 0x33333333) + ((n & 0xCCCCCCCC) >> 2);
    n = (n & 0x0F0F0F0F) + ((n & 0xF0F0F0F0) >> 4);
    n = (n & 0x00FF00FF) + ((n & 0xFF00FF00) >> 8);
    n = (n & 0x0000FFFF) + ((n & 0xFFFF0000) >> 16);
     
    return n;
}
 
int main(void) {
    int tmp,num,i,j,p;
    unsigned check;
    char c,kigo[7] = " .,-'?",kigo2[7] = " ',-.?";
     
    p = 0;
    check = 0xFFFFFFFF;
     
    while((c = getchar()) != EOF){
        if(isalpha(c)){
            num = c-'A';
        }else if(c == '\n'){
            putchar('\n');
            p = 0;
            check = 0xFFFFFFFF;
            continue;
        }else{
            for(num = 0;num < 6;num++){
                if(c == kigo[num]){
                    num += 26;
                    break;
                }
            }
        }
        for(i = 4;i >= 0;i--){
            tmp = (num&(1<<i))>>i;
            check &= data[p++][tmp];
            if(count(check) == 1){
                for(j = 0;j < 32;j++){
                    if(check&(1<<(31-j))){
                    	putchar(j < 6 ? kigo2[j] : j-6+'A');
                        break;
                    }
                }
                check = 0xFFFFFFFF;
                p = 0;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 520
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int main(){
    string s,ans="No";
    cin>>s;
    if(s[0]-'7'==0 || s[1]-'7'==0||s[2]-'7'==0)ans="Yes";
    cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>

using namespace std;
typedef long long ll;

int main()
{
	char N[100];
	cin >> N;
	
	if(N[0] == '7' || N[1] == '7' || N[2] == '7'){
		cout << "Yes" << endl;
	}else{
		cout << "No " << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3624
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647 -> 10桁
// MAX ll 9,223,372,036,854,775,807 -> 19桁
// MAX O(n) 10^8 -> 8回
// double pi = M_PI or acos(-1)
// printf("%.10f\n", ans);

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    rep(i, n- 1) {
        if (s.at(i) != s.at(i + 1)) ans++;
    }
    ans++;
    cout << ans << endl;

    return 0;
}


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

int main()
{
	ll n;
	cin >> n;
	ll mod = 26;
	
	string ans;
	while(n)
	{
		n--;
		//cout<<n<<endl;
		ans.push_back((n%mod)+'a');
		if(ans.back()=='`')ans.back()='z';
		n/=mod;
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[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; cin >> n;
    if(n/10==0 || n%2==1){
        pr(0);
        return 0;
    }

    ll b = 10;
    ll ans = 0;
    while(n/b != 0){
        ans += n/b;
        b *= 5; 
    }
    pr(ans);
    return 0;}

Measured memory_bytes: 3636
def verify_anagrams(w1, w2):
    f = lambda y: "".join(sorted(map(lambda x: x.replace(' ', '').lower(), y)))
    return f(w1) == f(w2)
#print(verify_anagrams(s,s2))
N = int(input())
ans = 0
unmatch_words = []
words = {}
for i in range(N):
    s = input()
    sorted_s = "".join(sorted(s))
    #print(sorted_s)
    if sorted_s in words:
        ans += words[sorted_s]
        words[sorted_s] += 1
    else:
        words[sorted_s] = 1


print(ans)

Measured memory_bytes: 17892