akhauriyash/Code-Regression huggingface dataset:
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

void solve(){
	string s;
	cin >> s;
	if (s.length() <= 2) {
		cout << "No" << endl;
		return;
	}
	while (true) {
		int cnt[3] = {};
		int tea = 0;
		REP(q, s.length()) {
			if (q + 2 < s.length()) {
				if (s[q] == 'A' && s[q + 1] == 'B' && s[q + 2] == 'C') {
					q += 2;
					tea = 1;
					continue;
				}
			}
			cnt[s[q]-'A']++;
		}
		if (tea == 0) break;
		int target = -1;
		REP(q, 3) {
			if (cnt[q] == 0) {
				target = q;
				break;
			}
		}
		if (target == -1) {
			cout << "No" << endl;
			return;
		}
		string b;
		REP(q, s.length()) {
			if (q + 2 < s.length()) {
				if (s[q] == 'A' && s[q + 1] == 'B' && s[q + 2] == 'C') {
					q += 2;
					b.push_back(target + 'A');
					continue;
				}
			}
			b.push_back(s[q]);
		}
		s = b;
	}
	if (s == "A") {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3240
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial, log, log10, log2
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
from datetime import datetime as dt

def main():
  n = int(readline())
  H = list(map(int, readline().split()))
  i = 0
  ans = 0
  tmp = 0
  while i<n-1:
    if H[i]>=H[i+1]:
      tmp += 1
      i += 1
      ans = max(ans, tmp)
    else:
      tmp = 0
      i += 1
  print(ans)
  
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 22644
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String a = sc.next();
    	String b = sc.next();
    	int ab = Integer.parseInt(a+b);
    	boolean key = false;
    	for (int i = 1; i <= Math.sqrt(ab); i++) {
    		if (i*i == ab) {
    			key = true;
    		}
    	}
    	System.out.println(key ? "Yes" : "No");
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define AC ios_base::sync_with_stdio(0);
const int M = 1e9+7;
using namespace std;
int d;
string k;
ll dp[10005][105][2];

int dfs(int pos, int r, int f){
    if(pos==k.size()){
        if(r==0)
            return 1;
        else
            return 0;
    }

    if(dp[pos][r][f]!=-1)
        return dp[pos][r][f];

    int LMT;
    if(f) // sequence till pos-1 is has a digit smaller
        LMT = 9;
    else
        LMT = k[pos]-'0';

    ll res = 0;
    for(int i=0; i<=LMT; i++){
        //cout<<"trying "<<i<<endl;
        int nf = f;
        if(f==0 && i<LMT) nf=1;
        res = (res+dfs(pos+1, (r+i)%d, nf))%M;
    }

    return dp[pos][r][f] = res%M;

}

int main(){
    AC
    memset(dp, -1, sizeof(dp));
    cin>>k>>d;
    cout<<(dfs(0,0,0)-1+M)%M<<endl;
}

Measured memory_bytes: 20984
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
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;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int N;
int A[MAX_N];

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  priority_queue<P, vector<P>, greater<P>> q;
  REP(i, N)
  {
    int x;
    cin >> x;
    q.push(P(x, i + 1));
  }

  int i = 0;
  while (!q.empty()) {
    P p = q.top();
    q.pop();
    cout << p.second << SLN(i, N);
    i++;
  }
}


Measured memory_bytes: 1780
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>
#include <queue>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << c << " " << a << " " << b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits//stdc++.h>
using namespace std;
int main(void){
    int a,b,c,i,j,k;
    cin>>a>>b>>c;
    if(a>b&&a>c)
    cout<<b+c<<endl;
    else if(b>c)
    cout<<a+c<<endl;
    else
    cout<<a+b<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define F first
#define S second
#define pb push_back
#define f(i,s,n) for(int i=(int)s;i<=(int)n;++i)
#define Fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
void solve()
{
  string s;cin>>s;
  int n=s.size();
  if(s[n-1]=='s')
    cout<<s<<"es";
  else
    cout<<s<<'s';
}
int main()
{	Fast;
	//int t;cin>>t;
	//while(t--)
	solve();
}

Measured memory_bytes: 3608
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int t[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        int K = scan.nextInt();
        os.println(t[K-1]);
    }
}

Measured memory_bytes: 22096
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  ll K,X,Y;
  cin >> K >> X >> Y;

  bool xflag = false;
  bool yflag = false;
  bool xyswap = false;
  if(X < 0){
    X = -X;
    xflag = true;
  }
  if(Y < 0){
    Y = -Y;
    yflag = true;
  }
  if(X < Y){
    swap(X, Y);
    xyswap = true;
  }

  if(K % 2 == 0 && (X + Y) % 2 == 1){
    cout << -1 << endl;
    return 0;
  }

  vector<pair<ll, ll>> ans;
  if(X + Y == K)  ans.p_b(m_p(X, Y));
  else if(X + Y < K && (X + Y) % 2 == 1){
    ans.p_b(m_p(X, -(K - X)));

    ll overRight = (K + X - Y) / 2;

    ans.p_b(m_p(X + overRight, Y - (K - overRight)));
    ans.p_b(m_p(X, Y));
  }
  else{
    ll N;
    ll c = (K - (X + Y) % K) % K;
    if(X + Y < K && (X + Y) % 2 == 0) N = 2;
    else if(X + Y >= K && c % 2 == 0) N = (X + Y + K - 1) / K;
    else if(X + Y >= K && c % 2 == 1) N = (X + Y + K - 1) / K + 1;

    ll over = (K * N - (X + Y)) / 2;
    rep(i,N){
      ll dist = (i + 1) * K;
      if(dist <= over)  ans.p_b(m_p(0, -dist));
      else if(dist <= over + X) ans.p_b(m_p(dist - over, -over));
      else  ans.p_b(m_p(X, dist - 2*over - X));
      debug(dist);
      debug(over);
      debug(ans.at(sz(ans)-1).fi);
      debug(ans.at(sz(ans)-1).se);
    }
  }

  cout << sz(ans) << endl;
  rep(i, sz(ans)){
    ll x = ans.at(i).fi;
    ll y = ans.at(i).se;
    if(xyswap)  swap(x, y);
    if(yflag) y = -y;
    if(xflag) x = -x;
    cout << x << " " << y << endl;
  }

  return 0;
}

Measured memory_bytes: 7408
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {

  i64 N, i;
  cin >> N;
  i64 m = N + 1, ans = 0;
  REP(0, N, i) {
    i64 p;
    cin >> p;
    m = min(m, p);
    if(m == p) {
      ++ans;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
# Problem D - Coloring Edges on Tree

from collections import deque

# input
N = int(input())
node_list = {} # 隣接リストの作成
color_count_list = [0]*(N+1)
ans_list = []
for i in range(N-1):
    a, b = map(int, input().split())
    if a in node_list:
        node_list[a].append(b)
    else:
        node_list[a] = [b]
    color_count_list[a] += 1
    color_count_list[b] += 1
    ans_list.append([a, b])

# initialization
color_list = {}
color_max_count = max(color_count_list)

# bfs search
visit_queue = deque([[-1, 1]]) # [[既に使った色], 遷移ノード]
while len(visit_queue)>0:
    p = visit_queue.popleft()

    used_color = p[0]
    if p[1] in node_list:
        nodes = node_list[p[1]]
        nodes_len = len(nodes)
        color_num = 1
        if nodes_len>=1:
            coloring_count = 0
            while coloring_count<nodes_len:
                if color_num==used_color:
                    color_num += 1
                    continue
                # 隣接リストによる表現
                if p[1] in color_list:
                    color_list[p[1]][nodes[coloring_count]] = color_num
                else:
                    color_list[p[1]] = {nodes[coloring_count]:color_num}
                if nodes[coloring_count] in color_list:
                    color_list[nodes[coloring_count]][p[1]] = color_num
                else:
                    color_list[nodes[coloring_count]] = {p[1]:color_num}
                # queue insert
                visit_queue.append([color_num, nodes[coloring_count]])
                # color update
                coloring_count += 1
                color_num += 1

# output
print(color_max_count)
for a in ans_list:
    print(color_list[a[0]][a[1]])


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

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

int main() {
  string s;
  cin >> s;
  int ans = 0,cnt = 0;
  rep(i,3) {
    if (s[i] == 'R') cnt++;
    else ans = max(ans,cnt),cnt = 0;
  }
  cout << max(ans,cnt) << endl;
  return 0;
}

Measured memory_bytes: 3596
_n = gets.chomp
t = gets.chomp.split.map(&:to_i)
m = gets.chomp.to_i
px = []
m.times do
  px << gets.chomp.split.map(&:to_i)
end
d = t.inject { |sum, x| sum + x }
px.each do |p, x|
  puts (d - t[p - 1] + x).to_s
end


Measured memory_bytes: 1788
n = int(input())
ans = 0
flag = True if n == 1 else False

tmp = 0
while n % 2 == 0:
    n //= 2
    tmp += 1
i = 0
while tmp >= (i+1)*(i+2)//2:
    i += 1
ans += i

idx = 3
while n > idx**2:
    tmp = 0
    if n % idx == 0:
        while n % idx == 0:
            n //= idx
            tmp += 1
        i = 1
        while tmp >= (i+1)*(i+2)//2:
            i += 1
        ans += i
    idx += 2

print(0 if flag else (ans+1 if n > 1 else ans))

Measured memory_bytes: 9128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

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

using namespace std;
int main() {
	int a[3];
	rep(i, 3) cin >> a[i];

	sort(a, a + 3);
	cout << a[0] + a[1] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <typeinfo>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> t(N+1);
  vector<int> x(N+1);
  vector<int> y(N+1);
  t.at(0)=0;
  x.at(0)=0;
  y.at(0)=0;
  for(int i=1;i<N+1;i++)  cin >> t.at(i) >> x.at(i) >> y.at(i);

  bool flag=true;
  for(int i=1;i<N+1;i++){
    int tim=t.at(i)-t.at(i-1);
    int dis=abs(x.at(i)-x.at(i-1)) + abs(y.at(i)-y.at(i-1));
    if(tim<dis) flag=false;
    else if((tim-dis)%2!=0) flag=false;
  }

  if(flag)  cout << "Yes" << endl;
  else  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 1408
//Coded by tzc_wk
/*
Êý¾Ý²»Çå¿Õ£¬±¬ÁãÁ½ÐÐÀá¡£
¶à²â²»¶ÁÍê£¬±¬ÁãÁ½ÐÐÀá¡£
±ß½ç²»ÌØÅÐ£¬±¬ÁãÁ½ÐÐÀá¡£
Ì°ÐÄ²»Ö¤Ã÷£¬±¬ÁãÁ½ÐÐÀá¡£
D P Ë³Ðò´í£¬±¬ÁãÁ½ÐÐÀá¡£
´óÐ¡ÉÙµÈºÅ£¬±¬ÁãÁ½ÐÐÀá¡£
±äÁ¿²»Í³Ò»£¬±¬ÁãÁ½ÐÐÀá¡£
Ô½½ç²»ÅÐ¶Ï£¬±¬ÁãÁ½ÐÐÀá¡£
µ÷ÊÔ²»×¢ÊÍ£¬±¬ÁãÁ½ÐÐÀá¡£
Òç³ö²» l l£¬±¬ÁãÁ½ÐÐÀá¡£
*/
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(a)		a.begin(),a.end()
#define giveup(...) return printf(__VA_ARGS__),0;
#define fill0(a)	memset(a,0,sizeof(a))
#define fill1(a)	memset(a,-1,sizeof(a))
#define fillbig(a)	memset(a,0x3f,sizeof(a))
#define fillsmall(a) memset(a,0xcf,sizeof(a))
#define mask(a)		(1ll<<(a))
#define maskx(a,x)	((a)<<(x))
#define _bit(a,x)	(((a)>>(x))&1)
#define _sz(a)		((int)(a).size())
#define filei(a)	freopen(a,"r",stdin);
#define fileo(a)	freopen(a,"w",stdout);
#define fileio(a) 	freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
#define y1			y_chenxiaoyan_1
#define y0			y_chenxiaoyan_0
typedef pair<int,int> pii;
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline void print(int x){
	if(x<0){
		putchar('-');
		print(abs(x));
		return;
	}
	if(x<=9)	putchar(x+'0');
	else{
		print(x/10);
		putchar(x%10+'0');
	}
}
inline int qpow(int x,int e,int _MOD){
	int ans=1;
	while(e){
		if(e&1)	ans=ans*x%_MOD;
		x=x*x%_MOD;
		e>>=1;
	}
	return ans;
}
int n=read();
vector<int> g[200005];
int col[200005];
int cnt[2],a[200005];
inline void dfs(int x,int fa){
	col[x]=col[fa]^1;
	cnt[col[x]]++;
	foreach(it,g[x]){
		int y=*it;
		if(y==fa)	continue;
		dfs(y,x);
	}
}
signed main(){
	fz(i,1,n-1){
		int x=read(),y=read();
		g[x].push_back(y);
		g[y].push_back(x);
	}
	dfs(1,0);
	set<int> st;
	fz(i,1,n)	st.insert(i);
	if(cnt[0]<=n/3){
		int cnt1=0;
		fz(i,1,n)	if(col[i]==0)	cnt1++,a[i]=cnt1*3,st.erase(st.find(a[i]));
		fz(i,1,n){
			if(!a[i])	a[i]=*st.begin(),st.erase(st.begin());
		}
	}
	else if(cnt[1]<=n/3){
		int cnt1=0;
		fz(i,1,n)	if(col[i]==1)	cnt1++,a[i]=cnt1*3,st.erase(st.find(a[i]));
		fz(i,1,n){
			if(!a[i])	a[i]=*st.begin(),st.erase(st.begin());
		}
	}
	else{
		int cnt1=0,cnt2=0;
		fz(i,1,n){
//			cout<<col[i]<<endl;
			if(col[i]==0&&cnt1*3+1<=n)	a[i]=cnt1*3+1,cnt1++,st.erase(st.find(a[i]));
			if(col[i]==1&&cnt2*3+2<=n)	a[i]=cnt2*3+2,cnt2++,st.erase(st.find(a[i]));
			}
		fz(i,1,n){
			if(!a[i])	a[i]=*st.begin(),st.erase(st.begin());
		}
	}
	fz(i,1,n)	cout<<a[i]<<" ";
	return 0;
}

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

int main(){
  long long int n,i=1,kotae=0;
  cin>>n;
  for(;;){
    if(n==0){
      break;
    }
    n/=2;
    kotae+=i;
    i*=2;
  }
  cout<<kotae;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  vector<int> ABCDE(5); rep(i, 5) cin >> ABCDE.at(i);
  int min1 = 10;
  int num;
  rep(i, 5){
    if(min1 > ABCDE.at(i)%10 && ABCDE.at(i)%10 != 0){
      min1 = ABCDE.at(i)%10;
      num = i;
    }
  }
  int ans = 0;
  rep(i, 5){
    if(i != num){
      ans += (((ABCDE.at(i)-1)/10)+1)*10;
    }
  }
  ans += ABCDE.at(num);
  cout << ans << endl;
  return 0;
}


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

int64_t mod = 1000000007;
int64_t large = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int N;
    double x, ans = 0;
    string v;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> x >> v;
        if (v == "JPY")
            ans += x;
        else
            ans += x * 380000;
    }
    cout << fixed << setprecision(6) << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#define mod 1000000007
using namespace std;

int main()
{
    int m,n,o=0,i,j,k,bus=0;
    //long long int m,n,o,i,j,k,len=0;
    //vector <int> v;
    //float f,g,h;
    //char c,d;
    string a;
    cin>>n>>m>>k;
    int *t=new int [n];
    //cin>>m>>c>>n>>d>>i;
    //cin>>f>>g;
    //cin>>c;
    for(i=0;i<n;i++) cin>>t[i];
    sort(t,t+n);
    for(i=0;i<n;i++)
    {
        o=0;
        for(j=1;j<m;j++)
        {
            if(j>=n) break;
            if(t[i]+k<t[i+j])
            {
                break;
            }
            o++;
        }
        i+=o;
        bus++;
    }
    cout<<bus;
    delete [] t;
    return 0;
}



Measured memory_bytes: 640
N, Q = map(int, input().split())
tree = {}
ans = []
ans.extend([0 for _ in range(N)])

for i in range(N-1):
    a, b = map(lambda x: int(x) - 1, input().split())
    tree.setdefault(a, []).append(b)
    tree.setdefault(b, []).append(a)

for i in range(Q):
    p, x = map(int, input().split())
    ans[p-1] += x

sta = [(0, 0)]
while sta:
    k, p = sta.pop()
    for c in tree.get(k, []):
        if c == p:
            continue
        ans[c] += ans[k]
        sta.append((c, k))

print(' '.join([str(x) for x in ans]))

Measured memory_bytes: 123660
def solve():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = 0
    cur = 1
    for i in range(N):
        a = A[i]
        if a != cur:
            ans += 1
        else:
            cur += 1
    print(ans if ans != N else -1)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 100652
#ABC044C
n,a=map(int,input().split())
x=list(map(int,input().split()))
res=[[0  for i in range(max(1+a*n,1+sum(x)))] for j in range(n+1)]
res[0][0]+=1
for i in range(n):
    for k in range(sum(x),0,-1):
        if k-x[i]<0:continue
        for j in range(1,i+2):
            res[j][k]+=res[j-1][k-x[i]]
ans=0
for i in range(1,n+1):
    ans+=res[i][a*i]
print(ans)

Measured memory_bytes: 4464
s=list(input())
l=[]
f=0
for i in range(len(s)-1):
    if s[i]=="A":
        l.append("A")
        f=0
    elif s[i]=="B":
        if s[i+1]=="C":
            l.append("D")
            f=1
        else:
            l.append("B")
            f=0
    else:
        if f:
            f=0
            continue
        else:
            l.append("C")
ac=0
ans=0
for i in range(len(l)):
    if l[i]=="A":
        ac+=1
    elif l[i]=="D":
        ans+=ac
    else:
        ac=0
print(ans)


Measured memory_bytes: 6436
n=int(input())
c=[];s=[];f=[]
for i in range(n-1):
    ci,si,fi=map(int,input().split())
    c.append(ci);s.append(si);f.append(fi)
for i in range(n-1):
    ans=s[i]+c[i]
    for j in range(i+1,n-1):
        tmp=ans
        if s[j]>=tmp:
            ans+=s[j]-tmp+c[j]
        else:
            ans+=f[j]-((tmp-s[j])%f[j] if (tmp-s[j])%f[j]!=0 else f[j])+c[j]
    print(ans)
print(0)

Measured memory_bytes: 9208
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    auto S = readln.chomp;

    long[] Ls;
    long[] Rs;
    foreach (i; 0..S.length) {
        if (S[i] == 'L') Ls ~= i;
        else Rs ~= i;
    }
    auto Lss = assumeSorted(Ls);
    auto Rss = assumeSorted(Rs);
    
    auto result = new long[S.length];

    foreach (i; 0..S.length) {
        // i番目の子供が10^100回後にどこにいるか
        if (S[i] == 'L') {
            // Rsの中でi未満のもの
            auto j = Rss.lowerBound(i).back;

            // このRまでにi-j回移動している
            if ((i-j) % 2 == 0) {
                // 残り移動回数が偶数回なら、このマスで終わる
                result[j]++;
            } else {
                // 奇数回なら反対側で終わる
                result[j+1]++;
            }
        } else {
            // Lsの中でiを超えるもの
            auto j = Lss.upperBound(i).front;
            // このLまでにj-i回移動している
            if ((j-i) % 2 == 0) {
                // 残り移動回数が偶数回なら、このマスで終わる
                result[j]++;
            } else {
                // 奇数回なら反対側で終わる
                result[j-1]++;
            }
        }
    }
    result.map!(to!string).join(" ").writeln;
}



Measured memory_bytes: 5372
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,min=INT_MAX;
  cin>>n>>k;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  sort(h.begin(),h.end());
  for(int i=k-1;i<n;i++){
    if(min>h[i]-h[i-k+1]){
      min=h[i]-h[i-k+1];
      //cout<<h[i]<<" "<<h[i-k+1]<<" "<<i<<" "<<i-k+1<<endl;
    }
  }
  cout<<min<<endl;
  return 0;
}


Measured memory_bytes: 3724
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
#include <stack>
typedef std::stack<int> IntStack;
typedef std::stack<char> charStack;

using namespace std;
using ll = long long;
typedef pair <int, int> pii;
int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll n, m;
	char tmp;
	ll memo[1003][1003] = { {} };
	ll memox[1003] = {};
	ll memoy[1003] = {};
	ll x[100005] = {};
	ll y[100005] = {};
	ll z[100005] = {};
	string s;
	//IntStack yStack;
	//charStack Stack;
	cin >> n;
	cin >> m;
	for (int i = 1; i <= m; i++)
	{
		cin >> x[i];
		cin >> y[i];
	}
	for (int i = 1; i <= m; i++)
	{
		a = 1;
		for (int k = 1; k <= n; k++)
		{
			z[k] = k;
		}
		while (a == 1)
		{
			a = 0;
			for (int k = 1; k <= m; k++)
			{
				if (k != i&&z[x[k]] != z[y[k]])
				{
					z[x[k]] = min(z[x[k]], z[y[k]]);
					z[y[k]] = min(z[x[k]], z[y[k]]);
					a = 1;
				}
			}
		}
		a = 0;
		for (int k = 1; k <= n; k++)
		{
			if (z[k] != 1)
			{
				a = 1;
				break;
			}
		}
		if (a == 1)
		{
			ans++;
		}
	}




	cout << ans << endl;

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

Measured memory_bytes: 2560
# coding: utf-8
# Your code here!

N, K = map(int, input().split())
arr = [int(input()) for i in range(N)]
arr.sort()
num = 0
min_num = pow(10,9)

for i in range(N - K + 1):
    num = arr[i + K - 1] - arr[i]
    if min_num > num:
        min_num = num
print(min_num)


Measured memory_bytes: 7384
h, w, m = map(int, input().split())
HW = [[*map(lambda x: int(x)-1, input().split())] for _ in range(m)]

sum_h = [[0,0] for _ in range(h)] # [sum, index]
sum_w = [[0,0] for _ in range(w)]
for i in range(m):
    h,w = HW[i]
    sum_h[h][0] += 1
    sum_w[w][0] += 1
    sum_h[h][1] = h
    sum_w[w][1] = w

h_num_ix = {}
for num,ix in sum_h:
    if not num in h_num_ix:
        h_num_ix[num] = set()
    h_num_ix[num].add(ix)

w_num_ix = {}
for num,ix in sum_w:
    if not num in w_num_ix:
        w_num_ix[num] = set()
    w_num_ix[num].add(ix)

max_h_num = max(h_num_ix)
max_w_num = max(w_num_ix)

SHW = set()
for h,w in HW: SHW.add((h,w))

max_num = max_h_num + max_w_num - 1
for h_ix in h_num_ix[max_h_num]:
    for w_ix in w_num_ix[max_w_num]:
        num = max_h_num + max_w_num
        if (h_ix, w_ix) in SHW: continue
        max_num += 1
        print(max_num)
        exit()
print(max_num)


Measured memory_bytes: 166316
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=0x61=97 '0'=0x30=48
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef string str;
typedef pair<int,int> pairii;
typedef vector<int> veci;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int main() {
  int n,m;
  cin>>n>>m;
  int mi,ma;
  cin>>mi>>ma;
  rep(i,m){
    int ti=-1,ta=mod;
    cin>>ti>>ta;
    mi=max(ti,mi);ma=min(ta,ma);
  }cerr<<mi<<" "<<ma;
  cout<<(mi>ma?0:ma-mi+1)<<endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n, c, k := nextInt(), nextInt(), nextInt()
	t := make([]int, n)
	for i := 0; i < n; i++ {
		t[i] = nextInt()
	}
	sort.Ints(t)

	p, b, s := 1, 1, t[0]+k // 乗客数, バス数, 出発時刻
	for i := 1; i < n; i++ {
		p++
		if t[i] > s || p > c {
			p = 1
			s = t[i] + k
			b++
		}
	}

	fmt.Println(b)
}


Measured memory_bytes: 2944
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String args[]) throws Exception {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String strArray[] = br.readLine().split(" ");
	int A = Integer.parseInt(strArray[0]);
	int B = Integer.parseInt(strArray[1]);
	int intArray[] = { A + B, A - B, A * B };
	Arrays.sort(intArray);
	System.out.println(intArray[2]);

    }
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    int N;
    cin >> N;

    const char march[] = "MARCH";

    Vl nums(5);
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < 5; j++) {
            if (s[0] == march[j]) ++nums[j];
        }
    }

    ll ans = 0;
    for (int i = 0; i < 5; i++) {
        for (int j = i + 1; j < 5; j++) {
            for (int k = j + 1; k < 5; k++) {
                ans += nums[i] * nums[j] * nums[k];
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/**************************
*                         *
*  Nothing Is Impossible  *
*                         *
**************************/
#include <algorithm>
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <string>
#include <vector>
#include <thread>
#include <math.h>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <set>
#include <map>
#define GetRand(Min, Max) ((rand()%(int)(((Max) + 1)-(Min))) + (Min))
#define Rep(i, min, max) for(int i = min; i < max; ++i)
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef long double ld;
using namespace std;

string s;

void Solve(){
	cin >> s;
	ll n = 0;
	Rep(i,0,(int)s.length()){
		int digit = s[i]-'0';
		n += digit;
	}
	if(n % 9 == 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

int main(){
	ios::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);
	int t = 1;
	//int t;	cin >> t;
	while(t--) Solve();
	return 0;
}



Measured memory_bytes: 3752
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n-1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
#define RALL(a) rbegin(a),rend(a)
typedef long long int ll;
typedef long double ld;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
const int MAX = 510000;
const int MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(void) {
    int n; cin >> n; vector<int> a(n);
    rep(i, n) cin >> a[i];
    ll sum = 0, now = a[0];
    rep(i, n) {
        if (now > a[i]) sum += (now - a[i]);
        else now = a[i];
    }cout << sum << endl;
}

Measured memory_bytes: 4044
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Scanner cin2;


    void calc()
    {
        cin = new Scanner();
        cin2 = new Scanner();
        int[] AB= cin.ArrayInt(2,0);
        int ans=0;
        if(AB[0]<AB[1]){ans+=AB[1];if(AB[1]-1>AB[0])ans+=AB[1]-1;else ans+=AB[0];}
        else if(AB[0]>AB[1]){ans+=AB[0];if(AB[0]-1>AB[1])ans+=AB[0]-1;else ans+=AB[1];}
        else ans=AB[0]*2;
        Console.WriteLine(ans);
    }


}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> w(n);
    int i;
    int all_sum = 0;
    int sum = 0;
    int difference;
    for(i = 0;i < n;++i){
        cin >> w.at(i);
        all_sum += w.at(i);
    }
    int min = all_sum;
    for(i = 0;i < n;++i){
        sum += w.at(i);
        difference = abs((all_sum-sum)-sum);
        if(difference < min){
            min = difference;
        }
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iterator>
#include <string>
#include <algorithm>
namespace Mylib{
    using namespace std;
    
    
}
int main(void){
    using namespace std;
    string S;
    cin >> S;
    string X[S.length()];
    
    for(int i=0;i<S.length();i++)X[i]='x';
    
    for(string x:X)cout << x;
    cout << endl;
    return 0;
}


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

int a[]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};

int main(){
	int n;
	cin >> n;
	cout << a[n-1];
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
    int num;
    int a, b;

    cin >> num;
    a = num/100;
    b = num%100;

    bool a1 = a <= 12 && a >= 1;
    bool b1 = b <= 12 && b >= 1;

    if(a1 && b1)
        cout << "AMBIGUOUS" << endl;
    else if(a1 && !b1)
        cout << "MMYY" << endl;
    else if(!a1 && b1)
        cout << "YYMM" << endl;
    else
        cout << "NA" << endl;
    

    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cassert>
#include <utility>
#include <numeric>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#define rep(i,n) for (int i=0; i<(n); ++i)

using namespace std;
using ll = long long;
int main (){
    string S;
    cin >> S;
    int c=0;
    for (int i;i<S.size()/2;i++){
        if (S[i] != S[S.size()-i-1]){
            c++;
        }
    }
    
    cout << c;


}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long k = sc.nextLong();
        double ans = 0;
        for(long i = 1; i <= n; i++){
            long deno = n;
            if(i >= k){
                ans += 1d/deno;
            }else{
                long p = i;
                while(p < k){
                    deno *= 2;
                    p *= 2;
                }
                ans += 1d/deno;
            }
        }
        System.out.println(String.format("%.12f", ans));
    }
}



Measured memory_bytes: 21588
#include <iostream>

using namespace std;

int main() {
	int N;
	cin >> N;
	
	int max = 0, min = 1000, a;
	for (int i = 0; i < N; ++i) {
		cin >> a;
		
		if (a > max) max = a;
		if (a < min) min = a;
	}
	
	cout << max - min << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cinttypes>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

using ll = long long;
map<pair<ll, ll>, bool> memo;

bool F(ll X, ll Y) {
  if (X > Y) {
    swap(X, Y);
  }

  if (X <= 1 && Y <= 1) {
    return false;
  }
  
  pair<ll, ll> key{X, Y};
  auto it = memo.find(key);
  if (it != memo.end()) {
    return it->second;
  }
  
  for (ll i = 1; 2 * i <= X; ++i) {
    if (!F(X - 2 * i, Y + i)) {
      return memo[key] = true;
    }
  }
  for (ll i = 1; 2 * i <= Y; ++i) {
    if (!F(X + i, Y - 2 * i)) {
      return memo[key] = true;
    }
  }
  
  return memo[key] = false;
}

const char* Format(bool value) {
  return value ? "WIN" : "LOOSE";
}

ll Abs(ll x) {
  return x < 0 ? -x : x;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
//  for (ll x = 0; x <= 50; ++x) {
//    for (ll y = 0; y <= 50; ++y) {
//      cout << F(x, y) << ' ';
//    }
//    cout << '\n';
//  }
  
  ll X, Y;
  cin >> X >> Y;
  if (Abs(X - Y) <= 1) {
    cout << "Brown" << '\n';
  } else {
    cout << "Alice" << '\n';
  }

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = 1e9 + 7;
const ll INF = 1e9;
int main() {
	cin.sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	int d = 1;
	rep(i, N) {
		if (d * 2 < d + K) {
			d *= 2;
		}
		else d += K;
	}
	cout << d << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
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;}
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
using namespace std;
using Graph=vector<vector<int>>;
int DP[100010];
Graph G(100010);
bool CAN=true;

int tree(int X){
  if(DP[X]!=0) return DP[X];
  
  vector<int> L;
  REP(i,G[X].size()){
    int a=G[X][i];
    L.push_back(tree(a));
  }
  SORT(L);
  int cnt=0;
  REP(i,L.size()){
    if(cnt<L[i]) cnt=L[i];
    cnt++;
  }
  return DP[X]=cnt;
}

int main(){
  int N;
  cin>>N;
  
  REP(i,N-1){
    int A;
    cin>>A;
    G[A-1].push_back(i+1);
  }
  
  tree(0);
  cout<<DP[0]<<endl;
  return 0;
}

Measured memory_bytes: 15488
main :: IO ()
main = do
  [a, b, c, d] <- map (read :: String -> Int) . words <$> getLine
  let e = lcm c d
  let bb = b - (b `div` c) - (b `div` d) + (b `div` e)
  let ad = a - 1
  let aa = ad - (ad `div` c) - (ad `div` d) + (ad `div` e)
  print $ bb - aa


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
int a[110];
int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a,a+n);
    cout << a[n-1] - a[0] << endl;
    return 0;
}

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

int main(){
    using namespace std;
    unsigned long H, W;
    cin >> H >> W;
    vector<vector<char>> kanou{{'6', '3', '1', '4'}, {'2', '0', '2', '0'}, {'1', '3', '6', '4'}, {'5', '0', '5', '0'}};
    vector<vector<unsigned long>> moveable(H + 2, vector<unsigned long>(W + 2));
    for(unsigned long i{0}; i < H; ++i){
        string S;
        cin >> S;
        for(unsigned long j{0}; j < W; ++j)moveable[i + 1][j + 1] = static_cast<unsigned long>(S[j] == kanou[i & 3][j & 3]);
    }
    vector<pair<unsigned long, unsigned long>> tansaku, dist{{0, 1}, {0, -1}, {-1, 0}, {1, 0}};
    tansaku.emplace_back(1, 1);
    while(!tansaku.empty()){
        auto t = tansaku.back();
        tansaku.pop_back();
        moveable[t.first][t.second] = 0;
        if(t.first == H && t.second == W)return 0 & puts("YES");
        for(const auto& d : dist)if(moveable[t.first + d.first][t.second + d.second]){
            tansaku.emplace_back(t.first + d.first, t.second + d.second);
            moveable[t.first + d.first][t.second + d.second] = 0;
        }
    }
    return 0 & puts("NO");
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>x;
	cout<<x*800-(x/15)*200<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <string.h>
#include <utility>
#include <vector>
using namespace std;

#define dlog(str) cout << "====" << str << endl;
#define INF 999999999
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define REPR(i, n) for(int i = n - 1; 0 <= i; i--)
#define FOR(i, s, e) for(int i = s; i <= e; i++)
#define FORR(i, s, e) for(int i = s; e <= i; i--)
#define LLI long long int
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    int N, K;
    cin >> N >> K;
    string s;
    cin >> s;
    vector<int> v;
    int pre = -1;
    REP(i, N) {
        if(pre != s[i]) {
            v.push_back(i);
        }
        pre = s[i];
    }
    v.push_back(N);

    int ma = 0;
    int size = v.size();
    REP(i, v.size()) {
        if(i != size && s[v[i]] == '1') {
            chmax(ma, v[min(i + 2 * K + 1, size - 1)] - v[i]);
        } else if(i == 0 && s[0] == '0') {
            chmax(ma, v[min(i + 2 * K, size - 1)] - v[i]);
        }
    }
    cout << ma;
    return 0;
}

Measured memory_bytes: 1020
#include <stdio.h>
#define n 10000
#define q 500

int main (){
  
  int S, T, i, j, s[n], t[q], count=0;
  
  scanf("%d", &S);
  
  for(i=0; i<S; i++){
    scanf("%d", &s[i]);
  }
  
  scanf("%d", &T);
  
  for(j=0; j<T; j++){
    scanf("%d", &t[j]);
  }
  
  
  for(i=0; i<T; i++){
    for(j=0; j<S; j++){
      if(s[j]==t[i]){
	count++;
	break;
      }
    }
  }
  printf("%d\n", count);
  
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

signed main(void)
{
  string s;
  cin >> s;

  REP(i, s.size()/2) {
    swap(s[i], s[s.size()-i-1]);
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h> 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<long, long> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const LL MOD=1e9+7;



int main(){
    int N,M;
    cin>>N>>M;
    priority_queue<LL, vector<LL>, greater<LL> >A;
    REP(i,N){
        LL tmp;
        cin>>tmp;
        A.push(tmp);
    }
    vector<PLL>CB;
    REP(i,M){
        LL B,C;
        cin>>B>>C;
        CB.PB(MP(-C,B));
    }
    SORT(CB);
    REP(i,M){
        LL B=CB[i].second;
        LL C=-CB[i].first;
        if(A.top()>=C)break;
        REP(b,B){
            if(A.top()<C){
                A.pop();
                A.push(C);
            }else{
                break;
            }
        }
    }
    LL res=0;
    while(!A.empty()){
        res+=A.top();A.pop();
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 4212
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <cstdlib>
#include <cmath>

typedef long long ll;

#define reps(i, s, e) for (ll i = s; i < e; ++i)
#define rep(i, n) reps(i, 0, n)
#define rreps(i, s, e) for (ll i = e-1; i >= s; --i)
#define rrep(i, n) rreps(i, 0, n)

// const ll LL_INF = 1LL<<60;

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

using namespace std;

ll gcd(ll a, ll b) {
    if (a < b) {
        ll tmp = b;
        b = a;
        a = tmp;
    }
    ll rem = a % b;
    if (rem == 0) return b;
    else return gcd(b, rem);
}

int main() {
    // 最大公約数
    ll a, b;
    cin >> a >> b;
    cout << gcd(a, b) << endl;
}


Measured memory_bytes: 3096
n,a,b=map(int,input().split())
c=n//(a+b)
d=0
if a==0:
	print(0)
else:
	if n>=(a+b):
		if n-c*(a+b)<=a:
			d=a*c+n-c*(a+b)
			print(d)
		else:
			d=a*(c+1)
			print(d)
	else:
		if n>=a:
			print(a)
		else:
			print(n)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


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

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


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























ll f(ll n){
    ll ans = 0;
    for(ll i = 1; i <= sqrt(n); i++){
        for(ll j = i; j <= sqrt(n); j++){
            ll tt = i * i + j * j + i * j;
            if(tt > n) break;
            for(ll k = j; k <= sqrt(n); k++){
                ll t = i * i + j * j + k * k + i * j + j * k + k * i;
                if(t == n){
                    if(i == j && j == k){
                        ans++;
                    }
                    else if(i != j && j != k && k != i){
                        ans += 6;
                    }
                    else{
                        ans += 3;
                    }
                }
                if(t > n) break;
            }
        }
    }
    return ans;
}

int main(){
    ll n;
    cin >> n;
    for(ll i = 1; i <= n; i++){
        cout << f(i) << endl;
    }
}

Measured memory_bytes: 3576