akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 1e18+7;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

int n,m;
int k[10];
int s[10][10];
int p[10];

int solve(int i,string state){
  if(i==n){
    rep(a,m){
      int tmp=0;
      rep(b,k[a]){
        if(state[s[a][b]]=='1'){
          tmp++;
        }
      }
      if(tmp%2!=p[a]){
        return 0;
      }
    }
    return 1;
  }
  return solve(i+1,state+'1')+solve(i+1,state+'0');
}

int main(){
  cin>>n>>m;
  rep(i,m){
    cin>>k[i];
    rep(j,k[i]){
      cin>>s[i][j];
      s[i][j]--;
    }
  }
  rep(i,m){
    cin>>p[i];
  }
  cout<<solve(0,"")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M,V,P;
    cin >> N >> M >> V >> P;
    vec<ll> A(N);
    for(int i=0;i<N;i++) cin >> A[i];
    sort(A.rbegin(),A.rend());

    auto ok = [&](int m){
        vec<ll> B = A;
        B[m] += M;
        if(B[m]<B[P-1]) return false;
        ll res = M*(V-1);
        for(int i=0;i<P-1;i++){
            res -= M;
            if(res<=0) return true;
        }
        for(int i=N-1;i>m;i--){
            res -= min(B[m]-B[i],M);
            if(res<=0) return true;
        }
        for(int i=m-1;i>=P-1;i--){
            if(B[i]>B[m]) return false;
            else{
                res -= min(B[m]-B[i],M);
                if(res<=0) return true;
            }
        }
        return res<=0;
    };

    int l = P-1,r = N;
    while(l+1<r){
        int m = (l+r)>>1;
        (ok(m)? l:r) = m;
    }
    cout << r << endl;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

template <typename T>
struct Edge {
  int from, to;
  T weight;
};

template <typename T>
class Graph {
 public:
  Graph(int n) : edges_(n) {}
  void AddEdge(int from, int to, T weight = T()) {
    edges_[from].push_back({from, to, weight});
  }
  const std::vector<Edge<T>>& Edges(int from) const { return edges_[from]; }
  int NumVertices() const { return edges_.size(); }

 private:
  std::vector<std::vector<Edge<T>>> edges_;
};

int main() {
  in(ll, n);
  Graph<ll> g(n);
  rep(i, n - 1) {
    in(ll, u, v, w);
    --u, --v;
    g.AddEdge(u, v, w);
    g.AddEdge(v, u, w);
  }
  vector<ll> color(n, -1);
  function<void(ll, ll, ll)> dfs = [&](ll node, ll parent, ll dist) {
    color[node] = dist % 2;
    for (const auto& e : g.Edges(node)) {
      if (e.to == parent) continue;
      if (color[e.to] != -1) continue;
      dfs(e.to, node, dist + e.weight);
    }
  };
  dfs(0, -1, 0);
  rep(i, n) out(color[i]);
}


Measured memory_bytes: 15860
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = readLine >>= print . solve

solve :: [Int] -> Int
solve [a, b, c] = min c $ b `div` a

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 380
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

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

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool is_prime(ll n) {
    if (n == 1) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}
ll rpow(ll x, ll n) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) k *= x;
        x *= x;
    }
    return k * x;
}
ll modpow(ll x, ll n, ll mod) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) (k *= x) %= mod;
        (x *= x) %= mod;
    }
    return k * x % mod;
}
ll modcomb(ll n, ll r, ll mod) {
    if (r < 0 || n < r) return 0;
    chmin(n - r, r);
    ll mul = 1, div = 1;
    for (ll i = 0; i < r; i++) {
        (mul *= n - i) %= mod;
        (div *= i + 1) %= mod;
    }
    return mul * modpow(div, mod - 2, mod) % mod;
}

/*------------------------------------------------------------------------*/

constexpr ll MOD = 1e9 + 7;

void solve();

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

    solve();
}

void solve() {
    ll x, y;
    std::cin >> x >> y;

    if ((x + y) % 3 != 0) { std::cout << 0 << '\n'; return; }

    ll n = (2 * y - x) / 3, m = (2 * x - y) / 3;

    if (n < 0 || m < 0) { std::cout << 0 << '\n'; return; }

    std::cout << modcomb(n + m, n, MOD) << '\n';
}


Measured memory_bytes: 3632
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=100010;
ll n,x,m;
int st[N];
ll s[N];
int main()
{
    IO;
    int T=1;
    //cin>>T;
    while(T--)
    {
        cin>>n>>x>>m;
        ll l,r;
        for(ll a=x,k=1;;a=a*a%m,k++)
        {
            if(!st[a]) st[a]=k;
            else
            {
                l=st[a],r=k-1;
                break;
            }
            s[k]=s[k-1]+a;
        }
        ll len=r-l+1;
        ll res=0;
        res+=s[min(n,l-1)];
        n=max(0ll,n-l+1);
        if(n) res+=(s[r]-s[l-1])*(n/len)+(s[n%len+l-1]-s[l-1]);
        cout<<res<<'\n';
    }
    return 0;
}


Measured memory_bytes: 4432
#include <iostream>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define NIL -1
#define MAX 10000

struct Node { int parent, left, right; };
Node T[MAX];

void preorder(int u)
{
    if ( u == NIL) return;
    printf(" %d", u);
    preorder(T[u].left);
    preorder(T[u].right);

    return;
}

void inorder(int u)
{
    if (u == NIL) return;
    inorder(T[u].left);
    printf(" %d", u);
    inorder(T[u].right);

    return;
}

void postorder(int u)
{
    if (u == NIL) return;
    postorder(T[u].left);
    postorder(T[u].right);
    printf(" %d", u);

    return;
}

int main()
{
    int n, id, l, r, root;

    // cin >> n;
    scanf("%d", &n);
    rep(i, n) T[i].parent = NIL;

    rep(i, n){
        cin >> id >> l >> r;
        // scanf("%d %d %d", &id, &l, &r);
        T[id].left = l;
        T[id].right = r;
        if(l != NIL) T[l].parent = id;
        if(r != NIL) T[r].parent = id;

    }

    rep(i, n) if(T[i].parent == NIL) root = i;

    printf("Preorder\n");    
    preorder(root);
    printf("\n");
    printf("Inorder\n");
    inorder(root);
    printf("\n");
    printf("Postorder\n");
    postorder(root);
    printf("\n");

    return 0;
}


Measured memory_bytes: 3184
using System;
using System.Linq;

namespace ABC158_C
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] S = Console.ReadLine().Trim().Split(' ').Select(a => int.Parse(a)).ToArray();
            for (int i = 0; i<=1000;i++)
            {
                if (Math.Floor(i * 0.08) == S[0] && Math.Floor(i * 0.1) == S[1])
                {
                    Console.WriteLine(i);
                    Environment.Exit(0);
                }
            }
            Console.WriteLine(-1);
        }
    }
}


Measured memory_bytes: 13396
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N = in_n()
    A = sorted(in_nl())

    asum = [0] * (N + 1)
    for i in range(N):
        asum[i + 1] = asum[i] + A[i]

    ans = 1
    for i in range(N - 1, -1, -1):
        if A[i] <= asum[i] * 2:
            ans += 1
        else:
            break

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 18928
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	string a, b, c;
	cin >> a >> b;
	c = a + b;
	int n = stoi(c);
	cout << ((pow((int)(sqrt(n)),2) == n) ? "Yes" : "No") << endl;
	return 0;
}

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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define LOOP(i, N) for (int i = 1; i <= (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define RLOOP(i, N) for (int i =(int)N; i > 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
int main(){
  int n;
  cin>>n;
  int sum=0;
  vector<int> v;
  vector<int> x;
  v.push_back(0);
  REP(i,n){
    int tmp;
    cin>>tmp;
    v.push_back(tmp);
    x.push_back(abs(v[i]-tmp));
    sum+=x[i];
  }
  x.push_back(abs(v[n]-v[0]));
  sum+=x[n];
  REP(i,n){
    int ans=sum;
    if(i!=n-1){
      ans=ans-x[i]-x[i+1];
      ans+=abs(v[i]-v[i+2]);
      cout<<ans<<endl;
    }else{
      ans=ans-x[n]-x[n-1];
      ans+=abs(v[0]-v[n-1]);
      cout<<ans<<endl;
    }
  }

}

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

void Main()
{
    int x;
    for (int i = 0; i < 5; i++)
    {
        cin >> x;
        if(x == 0){
            cout << i+1 << endl;
            return;
        }
    }
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


Measured memory_bytes: 3624
// スタックサイズ: 100MB

#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1e18;
const double EPS = 1e-10;
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }



class UnionFind {
private:
	vector<ll> data;
public:
	UnionFind(ll size) : data(size, -1) { }
	bool unite(ll x, ll y) { //x が入っている集合と y が入っている集合を併合する. (O(α(n)))
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	ll find(ll x) { // x のグループ番号を得る. (O(α(n)))
		return root(x);
	}
	ll root(ll x) { // x のみが入る集合 {x} を作る.
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	ll size(ll x) { // x が入っている集合の大きさを調べる. (O(1))
		return -data[root(x)];
	}
};


int main() {
	fastio;
	
	ll N, M;
	cin >> N >> M;
	vll a(M), b(M);
	rep(i, M) {
		cin >> a[i] >> b[i];
		--a[i], --b[i];
	}

	ll ans = 0;
	rep(i, M) {
		UnionFind uf(N);
		rep(j, M) if (i != j) uf.unite(a[j], b[j]);
		if (uf.find(a[i]) != uf.find(b[i])) ++ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N = int(input())
H = list(map(int, input().split()))
ans = []

for i in range(N-1,0,-1):
    if H[i] < H[i-1]:
        H[i-1] -= 1
    if H[i] < H[i-1]:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 14252
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

vector<int> dp, path, pathid;
vector<bool> hasloop, touched, reachable;
vector<vector<pair<int, int>>> adj, radj;

#define INF (2000000000)

int p;

//void solve(int id, int step, int d) {
//	if (pathid[id] != -1) {
//		if (d > path[id]) {
//			hasloop[id] = true;
//		}
//		return;
//	}
//
//	dp[id] = max(dp[id], d);
//	if (touched[id]) return;
//
//	touched[id] = true;
//	path[id] = d;
//	pathid[id] = step;
//
//	for (auto p : adj[id]) {
//		solve(p.first, step + 1, d + p.second);
//	}
//
//	path[id] = -INF;
//	pathid[id] = -1;
//
//}

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

	int n, m, a, b, c, i, j, k, id, ans, d;
	cin >> n >> m >> p;
	adj.resize(n + 1);
	radj.resize(n + 1);

	for (i = 0; i < m; i++) {
		cin >> a >> b >> c;
		adj[a].push_back({ b, c - p });
		radj[b].push_back({ a, c - p });
	}

	dp.assign(n + 1, -INF);
	path.assign(n + 1, -INF);
	pathid.assign(n + 1, -1);
	touched.assign(n + 1, false);
	hasloop.assign(n + 1, false);

	priority_queue<pair<pair<int, int>, vector<int>>> pq;
	pq.push({ { 0, 1 }, path });
	while (!pq.empty()) {
		id = pq.top().first.second;
		d = pq.top().first.first;
		path = pq.top().second;

		pq.pop();
		touched[id] = true;

		if ((path[id] != -INF) && (d > path[id])) {
			hasloop[id] = true;
		}
		else {
			if ((path[id] == -INF) && (dp[id] < d)) {
				dp[id] = d;
				path[id] = d;
				for (auto p : adj[id]) {
					if (dp[p.first] < d + p.second)	pq.push({ { d + p.second, p.first }, path });
				}
				path[id] = -INF;
			}
		}
	}

	reachable.assign(n + 1, false);
	queue<int> q;
	q.push(n);
	reachable[n] = true;

	while (!q.empty()) {
		id = q.front();
		q.pop();

		for (auto p : radj[id]) {
			if (!reachable[p.first]) {
				reachable[p.first] = true;
				q.push(p.first);
			}
		}
	}

	bool foundloop = false;
	for (i = 1; i <= n; i++) {
		if (hasloop[i] && reachable[i]) foundloop = true;
	}

	if (foundloop) ans = -1;
	else ans = max(0, dp[n]);

	cout << ans << "\n";
	   

	return 0;
}


Measured memory_bytes: 49532
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long m = sc.nextLong();
        long d = sc.nextLong();
        
        double beautypos;
        if (d==0) beautypos = 1.0 * (n-d)/(n*n);
        else beautypos = 2.0*(n-d)/(n*n);
        System.out.println((m-1) * beautypos);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();

    vector<vector<int>> dp(n+1, vector<int>(m+1));  // dp[i+1][j+1] : sのi文字目までとtのj文字目までのLCSの長さ

    rep(i, n) {
        rep(j, m) {
            if(s[i] == t[j]) {
                dp[i+1][j+1] = dp[i][j] + 1;
            }
            else {
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
            }
        }
    }

    string ans = "";
    int i = s.size();
    int j = t.size();
    while(i > 0 && j > 0) {
        if(dp[i][j] == dp[i-1][j]) {
            i--;
        }
        else if(dp[i][j] == dp[i][j-1]) {
             j--;
        }
        else {
            ans = s[i-1] + ans;
            i--;
            j--;
        }
    }

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

Measured memory_bytes: 35584
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll N, K;
  std::cin >> N >> K;
  set<ll> num;
  map<ll, ll> waru;
  for(int i=1;i*i<=N;i++) if(num.find(N/i)==num.end()) num.insert(N/i);
  for(int i=1;i*i<=N;i++) if(num.find(i)==num.end()) num.insert(i);
  auto itre = num.begin();
  for(int i=0;i<num.size();i++) {
    waru.emplace(*itre, i);
    itre++;
  }
  vector<ll> pre(waru.size(), 1);
  vvl dp = vv(K+1, waru.size(), 0, ll);
  for(int i=0;i<K;i++){
    ll now = 0;
    auto it = waru.begin();
    for(int j=0;j<waru.size();j++){
      auto M = waru.lower_bound(N/(*it).first);
      dp[i+1][j] = (((*it).first - now)*pre[(*M).second])%1000000007;
      now = (*it).first;
      it++;
    }
    for(int j=0;j<waru.size();j++) pre[j]=((j==0?0:pre[j-1])+dp[i+1][j])%1000000007;
  }
  std::cout << pre[waru.size()-1] << '\n';
  return 0;
}


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

using namespace std;

pair < pair <int, int>, int > a[45];	

int dp[45][405][405];
int n;

int solve(int pos, int x, int y) {
	if (x < 0 || y < 0) return 1e9;
	if (pos == n) {
		if (x == 0 && y == 0) return 0;
		return 1e9;
	}
	if (dp[pos][x][y] != -1) return dp[pos][x][y];
	int ans = min(solve(pos + 1, x - a[pos].first.first, y - a[pos].first.second) + a[pos].second, solve(pos + 1, x, y));
	return dp[pos][x][y] = ans;
} 

int main() {
	int ma, mb;
	scanf("%d %d %d", &n, &ma, &mb);
	int foo = 0;
	int bar = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d %d %d", &a[i].first.first, &a[i].first.second, &a[i].second);
		foo += a[i].first.first;
		bar += a[i].first.second;
	}
	int res = max(foo, bar);
	int k = 1;
	int ans = 1e9;
	while (ma * k <= res && mb * k <= res) {
		memset(dp, -1, sizeof dp);
		int v = solve(0, ma * k, mb * k);
		ans = min(ans, v);
		k++;			
	} 
	printf("%d\n", (ans == 1e9) ? -1 : ans);
	return 0;
}

Measured memory_bytes: 29184
import java.util.*;


class Main {
    public static void main(String[] args) {
		
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
		int B = sc.nextInt();
		if(A<=8 && B<=8){
			System.out.println("Yay!");
		}else{
				System.out.println(":(");
		}
 }
}

Measured memory_bytes: 23124
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n,a;vector<int>x[120000];
int dfs(int p){
	vector<int>J;
	for(int i=0;i<x[p].size();i++){
		J.push_back(dfs(x[p][i]));
	}
	sort(J.begin(),J.end());int maxn=0;
	for(int i=0;i<(int)J.size();i++){
		maxn=max(maxn,J[i]+(int)J.size()-i);
	}
	return maxn;
}
int main(){
	cin>>n;for(int i=2;i<=n;i++){cin>>a;x[a].push_back(i);}
	cout<<dfs(1)<<endl;
	return 0;
}


Measured memory_bytes: 13952
#include <iostream>

#define rep(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define repr(i, b, e) for(int (i) = (b) - 1; (i) >= (e); --(i))
#define print(x) cout << (x) << endl 
#define min2(a, b) ((a) < (b)) ? (a) : (b)
#define max2(a, b) ((a) > (b)) ? (a) : (b)
#define count counting_variable

using namespace std;

int A[5];

int main(){
    int k;
    rep(i, 0, 5){
        cin >> A[i];
    }
    cin >> k;
    rep(i, 0, 4){
        rep(j, i + 1, 5){
            if(A[j] - A[i] > k){
                print(":(");
                return 0;
            }
        }
    }
    print("Yay!");
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();
	int k = 1;
	rep(i, N) if (getint() == k) k++;

	if (k != 1) printf("%d", N - k + 1);
	else printf("-1");

	Would you please return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int L, R;

void read() {
  cin >> L >> R;
  if (R / 2019 * 2019 >= L) {
    cout << 0;
    exit(0);
  }
  L %= 2019;
  R %= 2019;
}

void solve() {
  int sol = 2019;
  for(int i = L; i < R; ++i)
    for(int j = i + 1; j <= R; ++j)
      if ((i * j) % 2019 < sol)
        sol = (i * j) % 2019;
  cout << sol;
}

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

	return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <iostream>
#include <queue>
#include <stack>
#define lson rt<<1
#define rson rt<<1|1
using namespace std;
typedef long long ll;
typedef pair<int, int>  P;
typedef pair<int, P>  PP;
const int maxn=2e5+10;

int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    ll t=c-a-b;
    if(t<=0)
    {
        cout<<"No";
    }
    else
    {
        if(4*a*b<t*t)
            cout<<"Yes";
        else
            cout<<"No";
    }
}



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

typedef long long int LL;
#define REP(n) for(LL i = 0; i < (n); i++)
#define COUT(val) cout << (val) << endl
#define CIN(val) cin >> (val)
#define SORT(vec) sort(vec.begin(), vec.end())
#define SORT_GRE(vec) sort(vec.begin(), vec.end(), greater<LL>())

int main(){
    int a, b;
    cin >> a >> b;
    if(b % a == 0){
        cout << a + b << endl;
    } else {
        cout << b - a << endl;
    }
    return 0;
}


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

void solve() {

	string s;
	int A, B;
	cin >> A >> B;
	if (A < 10 && B < 10) {
		cout << A * B << endl;
	}
	else {
		cout << -1 << endl;
	}



	

}


int main() {
	
	solve();

}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

template<typename T>
T gcd(T x, T y){
    T r = x % y;
    while(r != (T)0){
        x = y;
        y = r;
        r = x % y;
    }
    return y;
}

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

    lint n, x;
    cin >> n >> x;

    lint g = gcd(n, x);

    lint ans = 3LL * (n - g);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/// Kazuki Hoshino


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
//#define endl '\n'
typedef tree<
int,
null_type,less<int>,
rb_tree_tag,tree_order_statistics_node_update>
ordered_set;


int n;
string s = " " , t ;


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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);

cin >> t;

n = t.size();
s+=t;

//cout << s << endl;
if(s[1]!='1' || s[n]=='1' ){
    cout << -1 << endl;
    return 0;
}

rep(i, 1, n){
    if(s[i]=='1'){
        if(s[n-i]!='1'){
            cout << -1 << endl;
            return 0;
        }
    }
}

int cur = 2, root = 1 ;

rep(i, 1, n-1){
    if(s[i]=='1'){
        cout << cur << " " << root << endl;
        root = cur;
        cur++;
    }
    else {
        cout << cur << " " << root << endl;
        cur++;
    }
}





return 0;}
///....


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;
using std::string;

#include <stdio.h>


unsigned int count_bits(unsigned int bits) 
{
	int c = 0;
	for (unsigned int i = 0; i < 32; i++) {
		if (bits & (1 << i)) { c++; }
	}
	return c;
}

int main()
{
	unsigned int n, m;	// N個のスイッチ、M個の電球
	unsigned int s[10]; // sの組み合わせをビット表現（0x01:スイッチ1、0x02:スイッチ2 ...）
	unsigned int k[10];
	unsigned int p[10];
	unsigned int ans;
	unsigned int i, j;	// for loop
	unsigned int t;		// temp

	// input
	cin >> n >> m;
	for (i = 0; i < m; i++) {
		cin >> k[i];
		s[i] = 0;
		for (j = 0; j < k[i]; j++) {
			cin >> t;
			s[i] |= (1 << (t - 1));
		}
	}
	for (i = 0; i < m; i++) {
		cin >> p[i];
	}

	// calc
	// t=全スイッチONの場合のビット値を計算
	t = 0;
	for (i = 0; i < n; i++) {
		t |= (1 << i);
	}
	// 全スイッチパターンを試行
	ans = 0;
	for (i = 0; i <= t; i++) {		// i=スイッチパターン
		for (j = 0; j < m; j++) {
			if (p[j] != (count_bits(s[j] & i) % 2)) {
				break;
			}
		}
		if (j == m) { ans++; }
	}

	// output
	cout << ans << endl;

	// debug output
	/*
	cout << "n = " << n << endl;
	cout << "m = " << m << endl;
	for (unsigned int i = 0; i < m; i++) {
		printf("[%d] k=%d, s=%04X, p=%d\n", i, k[i], s[i], p[i]);
	}
	 */

	return 0;
}


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

int h,w; char f[1000][1000];
int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};

int bfs(int n,queue<P> que){
    int l=que.size();
    if(l==0)return n-1;
    for (int i = 0; i < l; i++){
        P p=que.front(); que.pop();
        for (int j = 0; j < 4; j++){
            int ny=p.first+dy[j],nx=p.second+dx[j];
            if(ny>=0&&ny<h&&nx>=0&&nx<w&&f[ny][nx]=='.'){
                f[ny][nx]='#'; que.push(P(ny,nx));
            }
        }
    }
    return bfs(n+1,que);
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    cin>>h>>w; queue<P> que;
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            char c; cin>>f[i][j];
            if(f[i][j]=='#')que.push(P(i,j));
        }
    }
    cout<<bfs(0,que)<<endl;
}

Measured memory_bytes: 17552
#include <iostream>

using namespace std;

char c;
char s[100];
int n;

int main(int argc, const char * argv[]) {
    while ((cin >> c)) {
        if (c != 'B') {
            s[n] = c;
            n++;
        }else if (n > 0) {
            n--;
        }
    }
    s[n] = '\0';
    cout << s << endl;
    return 0;
}


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

int n = 0, id = 0, dmax = 0;
vector<vector<int>> c;
vector<int> d, p, h;

int depth(int id) {
	if (p[id] == -1)
		return 0;
	else if (d[p[id]] != -1)
		return d[p[id]] + 1;
	else
		return depth(p[id]) + 1;
}

int main()
{
	cin >> n;

	c.resize(n);
	d.assign(n, -1);
	p.assign(n, -1);
	h.assign(n, -1);

	vector<int> sib(n, -1), deg(n, 0);

	for (int i = 0; i < n; i++) {
		int l = 0, r = 0;
		cin >> id >> l >> r;
		c[id].push_back(l);
		c[id].push_back(r);

		if (l == -1 && r == -1)
			h[id] = 0;
		if (l != -1) {
			p[l] = id;
			sib[l] = r;
			deg[id]++;
		}
		if (r != -1) {
			p[r] = id;
			sib[r] = l;
			deg[id]++;
		}
	}

	for (int i = 0; i < n; i++) {
		d[i] = depth(i);
		if (dmax < d[i])
			dmax = d[i];
	}

	for (int i = 0; i <= dmax; i++) {
		for (int j = 0; j < n; j++) {
			if (h[j] == i && p[j] != -1)
				if(sib[j] == -1 || h[j] >= h[sib[j]])
					h[p[j]] = i + 1;
		}
	}

	for (int i = 0; i < n; i++) {
		string type;

		if (p[i] == -1)
			type = "root";
		else if (c[i][0] == -1 && c[i][1] == -1)
			type = "leaf";
		else
			type = "internal node";

		cout << "node " << i 
			 << ": parent = " << p[i]
			 << ", sibling = " << sib[i]
			 << ", degree = " << deg[i]
			 << ", depth = " << d[i]
			 << ", height = " << h[i]
			 << ", " << type << endl;
	}

	return 0;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0; i<(int)n; i++)
#define rep2(i,a,n) for(long long i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
//const ll mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

ll N, M, K, H, W, L, R, X;
string S, T;

int main(){
  cin >> N >> M >> K;
  vll A(N+1,0), B(M+1,0);
  vll asum(N+1,0), bsum(M+1,0);
  
  rep2(i,1,N+1) {
    cin >> A[i];
    asum[i] = asum[i-1]+A[i];
  }
  rep2(i,1,M+1) {
    cin >> B[i];
    bsum[i] = bsum[i-1]+B[i];
  }
  ll ans = 0;
  ll bchk = M;
  for(ll i=0; i<=N; i++){
    if(asum[i]>K) break;
    for(ll j=bchk; j>=0; j--){
      if(asum[i]+bsum[j] > K) continue; 
      else {
        ans = max(ans,i+j);
        bchk = j; 
        break;
      }
    }
  }
  
  cout << ans << endl;  
  return 0;
}

Measured memory_bytes: 9508
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 1010;

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char c[310][310];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	ll k;
	cin >> k;
	ll res = k;
	while (b <= a) {
		b *= 2;
		res--;
	}
	while (c <= b) {
		c *= 2;
		res--;
	}
	if (res >= 0)puts("Yes");
	else {
		puts("No");
	}
	return 0;
}


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

int main(){
    int n; cin>>n;
    double ans;
    for (int i=0; i<n; i++){
        double x;
        string u; cin>>x>>u;
        if(u=="JPY") ans +=x;
        else ans += x*380000;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FASTIO std::ios::sync_with_stdio(false);
#define MAXN 200005
int main(){
  FASTIO
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  int a[s.length()+1]={0}, ans=0, count=0;
  a[0]=0;
  for(int i=1;i<s.length();i++){
    if(s[i]==s[i-1]){
      a[i]=a[i-1]+1;
    }
    else {
      a[i]=a[i-1];
    }
    if(a[i]==a[i-1])count++;
    ans=max(ans, a[i]);
    // cout<<a[i]<<" ";
  }
  if(count>=2*k)ans+=2*k;
  else {
    ans+=count;
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 848
/*
* ID: juryc
* PROG: poll
* LANG: C++
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
int n; string s; cin>>n;
map<string,int> mp;
int mx=0;
while(n--){
cin>>s;
if(mp.find(s)==mp.end()) mp[s]=1;
else mp[s]++;
mx=max(mx,mp[s]); 
}
for(auto i: mp){
if(i.second==mx) cout<<i.first<<endl; 
}
}

Measured memory_bytes: 19236
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 100000000;
const int MAX_N = 100;
typedef pair<int , int> P;
typedef long long ll;
 
int main () {
  string S;
  cin >> S;
  int len = S.length();
  string tmp;
  tmp = S[len-1];
  if (tmp == "s") {
    S = S + "es";
  } else {
    S = S + "s";
  }
  cout << S << endl;
  return 0;
}

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

int n,m,r,l;
int a[100005]={0};
int minn,minnum=inf;

int main(){
  int i,j,k,ans=0;

  cin >> n >> k;
  for(i=0;i<n;i++){
    cin >> a[i];
    if(a[i]==1)minn=i;
  }
  r = n - 1 - minn;
  l = minn;
  
  ans+=r/(k-1);
  ans+=l/(k-1);
  if(r%(k-1)!=0)ans++;
  if(l%(k-1)!=0)ans++;
  if(r%(k-1)!=0&&l%(k-1)!=0&&(k-1-l%(k-1))>=r%(k-1))ans--;
  cout <<ans<< endl;

  return 0;
}


Measured memory_bytes: 640
local function ord(a) return a:byte() end
local A, Z = ord('A'), ord('Z')
local LL = Z - A + 1
local N, _, S = io.read("n", "l", "l")
S = {S:byte(1,#S)}
local t = {}
for i=1,#S do
  t[i] = string.char((S[i] + N - A) % LL + A)
end
print(table.concat(t,""))

Measured memory_bytes: 1136
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <numeric>
#include <mutex>
#include <cmath>
#include <set>
#include <climits>
#define lli long long int
#define ll long long
#define mod 1000000007
#define pii pair<int,int>
#define mp make_pair
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
  string S;
  cin >> S;
  int count = 0;
  for(int i = 0; i < S.size(); i++){
    if(S[i] == 'L'){
      count++;
    }
    if(i < S.size()-1){
      i++;
      if(S[i] == 'R'){
        count++;
      }
    }
  }
  if(count == 0){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;
typedef pair<ll  ,ll > pll;

const ll maxn =2e6;
const ll mod = 1e9+7;
const ld PI = 4 * atan((ld) 1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
#define ms(x , y) memset(x , y , sizeof x);
ll pw(ll a, ll b) {
    return (!b ? 1 : (b & 1 ? a * pw(a * a % mod, b / 2) % mod : pw(a * a % mod, b / 2) % mod));
}

int n;
int inp;

int main(){
    migmig
    cin >> n;
    while(n -- ){
        cin >> inp;
        if(inp%2==1){
            continue;
        }
        if(inp%3 and inp%5){
            dokme("DENIED")
        }
    }
    cout << "APPROVED";

    return(0);
}


//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.


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

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

using namespace std;

struct UnionFind {
  vector<int> parent;
  UnionFind (int n) { parent.assign(n, -1); }
  int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (parent[y] < parent[x]) swap(x, y);
    if (parent[x] == parent[y]) --parent[x];
    parent[y] = x;
    return true;
  }
};

typedef int Weight;
struct Edge{
  int src, dest; Weight weight;
  bool operator < (const Edge &rhs) const {return weight > rhs.weight;}
};

typedef vector<Edge> Edges;

// Kruskal
// N, operator <
Edges kruskal(int V, Edges &es) {
  sort(es.rbegin(), es.rend());
  UnionFind uf(V);
  Edges res;
  REP(i, es.size()) {
    Edge e = es[i];
    if(uf.root(e.src) != uf.root(e.dest)) {
      uf.merge(e.src, e.dest);
      res.push_back(e);
    }
  }
  return res;
}

int main() {
  while(1){
    int n,m;
    cin>>n>>m;
    if(!n) break;
    Edges g;
    REP(i,m){
      int s,t,c;
      cin>>s>>t>>c;
      --s;--t;
      g.push_back((Edge){s,t,c});
      g.push_back((Edge){t,s,c});
    }
    auto res = kruskal(n, g);
    cout << res[n/2-1].weight << endl;
  }
  return 0;
}

Measured memory_bytes: 1700
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

long long fibo[100];

int main(){
    fibo[0] = 2;
    fibo[1] = 1;
    for (int i = 2; i <= 86; i++)
        fibo[i] = fibo[i - 1] + fibo[i - 2];
    int n;
    cin >> n;
    cout << fibo[n] << endl;
}


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


int main() {
    int64_t N;
    cin >> N;

    int64_t ans = 0;
    int64_t itr = pow(N,0.5);
  
    for (int64_t i = itr ; i >= 1; --i) {
        int64_t j = N / i;
        if (N % i == 0) {
            ans = i - 1 + j - 1;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <cstring>
using namespace std;
int h,a,c=0;
int main()
{
	scanf("%d%d",&h,&a);
	while(h>0)
	{
		h-=a;
		c++;
	}
	printf("%d",c);
	return 0;
}



Measured memory_bytes: 256
import math

N,K = map(int, input().split())
A = list(map(int, input().split()))
epsilon = 10**(-5)
#A = [a-epsilon for a in A]

_min = 0
_max = max(A)

while _max - _min > epsilon:
  new = (_min+_max)/2
  if _min < int(new):
    new = int(new)
  times = sum([math.ceil(a/new)-1 for a in A])
  #print(_min, new, _max, times, [math.ceil(a/new)-1 for a in A])
  
  if times <= K:
    _max = new
  else:
    _min = new
  #print(_min, _max)

if  sum([math.ceil(a/_max)-1 for a in A]) <= K:
  print(math.ceil(_max))
else:
  print(math.ceil(_min))

Measured memory_bytes: 169112
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  vector<int> kushi;
  for(int i = 0; i < 2 * N; i++){
    int a; cin >>a;
    kushi.push_back(a);
  }
  sort(kushi.begin(),kushi.end());
  int ans = 0;
  for(int i = 0; i < 2 * N; i+=2)
    ans += kushi.at(i);
  
  cout << ans << endl;
}

Measured memory_bytes: 3612
N = int(input())
a = list(map(float, input().split()))
dp=[[[0.0] *(N+2) for _ in range(N+2)] for _ in range(N+2)]
one,two,three=a.count(1),a.count(2),a.count(3)
for k in range(three+1):
    for j in range(two+three+1-k):
        for i in range(N+1):
            if k==0 and j==0 and i==0:
                continue
            num=N
            if i>0:
                num+=dp[i-1][j][k]*i
            if j>0:
                num+=dp[i+1][j-1][k]*j
            if k>0:
                num+=dp[i][j+1][k-1]*k
            dp[i][j][k]=num/(k+j+i)
print(dp[one][two][three])

Measured memory_bytes: 298780
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll mod = 1000000007;

const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}



// check
// 問題文を復唱する


int main() {
  // ll r,d,x;
  ll n,x;
  cin >> n >> x;

  vector<ll> l(n);

  cin >> l;



  ll ans = 0;
  ll pos = 0;

  for (int i = 0; i < n; i++) {
      if (pos<=x)ans++;
      pos += l[i];
  }
  if (pos<=x)ans++;
  
  cout <<ans <<endl;

}




















Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i,m,n) for(int i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
int main() {
  lli A,B,C=1,D=0,E=0,F=0,G=0,H=0,N,M;
  string S;
  cin >> S;
  A=S.size();
  rep(i,0,A){
    if(S[i]=='0')D++;
    else E++;
  }
  Out(min(D,E)*2);
}

Measured memory_bytes: 512
#include <stdio.h>

void bubbleSort(int* , int );
  
int main(){

  int i,j,k,N,A[100],v;

  scanf("%d",&N);
  for(i=0;i<N;i++) scanf("%d",&A[i]);

  bubbleSort(A, N);
  
   

  return 0;
}

void bubbleSort(int *A, int N){
  int i=0,j,flag,tmp;

  flag=1;
  while(flag){
    flag=0;
  for(j=N-1;j>0;j--){
    if(A[j]<A[j-1]){
      tmp=A[j];
      A[j]=A[j-1];
      A[j-1]=tmp;
      flag=1;
      i++;
    }
  }
  }

  for(j=0;j<N-1;j++) printf("%d ",A[j]);
    printf("%d\n",A[N-1]);
    printf("%d\n",i);
}



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

int main () {
    int n, a=0, b=0, c=0, d=0;
    string s;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s;
        if (s=="AC") {
            a++;
        }
        if (s=="WA") {
            b++;
        }
        if (s=="TLE") {
            c++;
        }
        if (s=="RE") {
            d++;
        }
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;
}

Measured memory_bytes: 3548
int main(void){
    int i, j;
    int sublen = 0;
    char str[11];
    scanf("%s", str);
    for (i = 0; i < 11; i++){
        if(str[i] == 'A' || str[i] == 'C' || str[i] == 'G' || str[i] == 'T'){
            for(j = i + 1; j < 11; j++){
                if(str[j] != 'A' && str[j] != 'C' && str[j] != 'G' && str[j] != 'T'){
                    if((j - i) > sublen) sublen = (j - i);
                    break;
                }
            }
        }
    }
    printf("%d\n", sublen);

    return 0;
}

Measured memory_bytes: 1696
#include <iostream>
#include <time.h>
#include <math.h>
#include <map>


using namespace std;
int main()
{

	int N, M, D[200000], T[200000], flag=1, x;
	map <int, int> mapn, mapm;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> D[i];
		mapn[D[i]]++;

	}

	cin >> M;
	for (int i = 0; i < M; i++) {
		cin >> T[i];
		mapm[T[i]]++;
	}

	for (int i = 0; i < M; i++) {
		x = T[i];
		if (mapn[x] - mapm[x] < 0) {
			flag = -1;
			break;
		}
	}
	flag == 1 ? cout << "YES" : cout << "NO";
	return 0;
}

Measured memory_bytes: 20608
#include <bits/stdc++.h>
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  size_t n; std::cin >> n;
  constexpr size_t max = 2002;
  auto a = std::vector<std::bitset<max>>(n + 2);
  auto insert = [&] (size_t i, size_t j, bool k) {
    a[i][j] = k;
    a[j][i] = !k;
  };
  for (size_t i = 1; i <= n; i++) {
    insert(i, 0, true);
    insert(i, n + 1, true);
  }
  for (size_t i = 2; i <= n; i++) {
    for (size_t j = 1; j < i; j++) {
      char x; std::cin >> x;
      insert(i, j, x == '1');
    }
  }
  auto dp = std::vector<std::bitset<max>>(n + 2);
  for (size_t i = 0; i <= n; i++) dp[i][i + 1] = dp[i + 1][i] = true;
  for (size_t d = 2; d <= n + 1; d++) {
    for (size_t i = 0, j = d; j <= n + 1; i++, j++) {
      dp[j][i] = dp[i][j] = (dp[i] & dp[j] & (a[i] | a[j])).any();
    }
  }
  int ret = 0;
  for (size_t i = 1; i <= n; i++) {
    if (dp[0][i] & dp[i][n + 1]) ret++;
  }
  std::cout << ret << std::endl;
  return 0;
}


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

int main()
{
    int n, d; cin >> n >> d;
    int ans = n / (2 * d + 1);
    if(n % (2*d+1) == 0){
        ans = n / (2 * d + 1);
    } else {
        ans = n / (2 * d + 1) + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
=begin
        0
    3   1   2   4
        5
=end

a = gets.split(" ").map(&:to_i)
n = gets.chomp.to_i

n.times do |i|
    top, front = gets.split(" ").map(&:to_i)

    "EEEESEEEESEEEESEEEESREEERREEE".each_char do |i|
        if i.eql?("N") then
            a[0], a[1], a[5], a[4] = a[1], a[5], a[4], a[0]
        elsif i.eql?("S") then
            a[0], a[1], a[5], a[4] = a[4], a[0], a[1], a[5]
        elsif i.eql?("E") then
            a[0], a[2], a[5], a[3] = a[3], a[0], a[2], a[5]
        elsif i.eql?("W") then
            a[0], a[2], a[5], a[3] = a[2], a[5], a[3], a[0]
        elsif i.eql?("R") then
            a[3], a[1], a[2], a[4] = a[4], a[3], a[1], a[2]
        elsif i.eql?("L") then
            a[3], a[1], a[2], a[4] = a[1], a[2], a[4], a[3]
        end
        
        if a[0] == top && a[1] == front then
            break
        end
    end

    print a[2], "\n"
end



Measured memory_bytes: 6880
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define dbug(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef long long ll;
typedef pair<ll, ll> pll;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  return is;
}


int main(){

  string s;
  int a=-2,b=-2;
  cin>>s;
  int N=s.length();
  s+="##";
  rep(i,N){
    if(s[i]==s[i+1]){
      a=i,b=i+1;
      i=N+1;
    }
    else if (s[i]==s[i+2]){
      a=i,b=i+2;
      i=N+1;
    }
  }

  cout << a+1 <<" "<< b+1 <<endl;
  return 0;
}


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

LL n,s,x[100009],p[100009],ans[100009];

void call(int l,int r)
{
    if(l==r)
    {
        ans[l]=fabs(x[l]);
        return;
    }
    if(x[l]>0)
    {
        call(l,r-1);
        ans[r]=ans[r-1]+x[r]-x[r-1];
        return;
    }
    if(x[r]<0)
    {
        call(l+1,r);
        ans[l]=ans[l+1]+x[l+1]-x[l];
        return;
    }
    if(p[l]>=p[r])
    {
        p[l]+=p[r];
        call(l,r-1);
        ans[r]=ans[l]+x[r]-x[l];
        return;
    }
    p[r]+=p[l];
    call(l+1,r);
    ans[l]=ans[r]+x[r]-x[l];
    return;
}

int main()
{
    scanf("%lld %lld",&n,&s);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld %lld",&x[i],&p[i]);
        x[i]-=s;
    }
    call(1,n);
    LL foo=max(ans[1],ans[n]);
    cout<<foo<<endl;
    return 0;
}


Measured memory_bytes: 5760