akhauriyash/Code-Regression huggingface dataset:
n, k  = map(int, input().split())
A = list(map(int, input().split()))
# リストを扱いやすいように変形
def subtraction(x):
    return x - 1
A = list(map(subtraction, A))

# 通ったことのある場所を持っておく
R = [0]*n
R[0] = 1
ROUTE = [0]
t = A[0]
while R[t] == 0:
    ROUTE.append(t)
    R[t] = 1
    t = A[t]

x = ROUTE.index(t) # ループのスタート地点
length = len(ROUTE) - x

if k < x:
    print(ROUTE[k]+1)
else:
    k = k - x
    s = k % length
    print(ROUTE[x + s]+1)

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

int main()
{
	long int N,W,i,weight,value;
	cin>>N>>W;
	vector<long int> dp(W+1,0);
	for(i=0;i<N;i++) {
		cin>>weight>>value;
		for(int weights_possible=W-weight; weights_possible>=0; weights_possible--) {
			dp[weights_possible + weight] = max(dp[weights_possible + weight], dp[weights_possible] + value); 
		}
	}
	long int answer = 0;
	for(i=0;i<=W;i++) {
		answer = max(answer, dp[i]); 
	}
	cout<<answer;
	return 0;
}


Measured memory_bytes: 3996
#include <iostream>
using namespace std;
 int main(){
 int a,b,c,d,e,x,y;
 cin>>a>>b>>c>>d>>e;
 x=b*e;
 y=(0-a)*c;
 if(a<0)cout<<d+x+y<<endl;
 else cout<<(b-a)*e<<endl;
 return 0;
 }


Measured memory_bytes: 3080
// ※※※ 解答不能 ※※※
// LHiC氏.
// https://atcoder.jp/contests/code-festival-2016-qualc/submissions/1054054
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
const int MAXN = 510000;
const LL MOD = 1e9 + 7;
int n, ff[MAXN], p[MAXN];
LL fc[MAXN], fc2[MAXN], pr[MAXN], en[MAXN];

LL get(int x){
    LL ans = 0;
    for(; x >= 0; x = (x & (x + 1)) - 1) ans += ff[x];
    return ans;
}

void add(int x){
    for(; x <= n; x |= (x + 1)) ff[x] += 1;
}

int main(){
    scanf("%d", &n);
    fc[0] = 1;
    repx(i, 1, n + 1) fc[i] = (fc[i - 1] * i) % MOD;
    fc2[0] = 0;
    fc2[1] = 1;
    fc2[2] = 1;
    repx(i, 3, n + 1) fc2[i] = fc2[i - 1] * i % MOD;
    rep(i, n) scanf("%d", p + i), en[p[i]] = 1;
    int cnt = 0;
    repx(i, 1, n + 1) cnt += en[i];
    repx(i, 1, n + 1) pr[i] = pr[i - 1] + (en[i] == 0 ? 1 : 0);
    cnt = n - cnt;
    LL ans = fc[cnt];
    int now = 0;
    LL sum = 0;
    repr(i, n - 1, 0){
        LL x = 0;
        if(p[i] == 0){
            x = fc2[cnt] * now % MOD;
            x = (x + fc[cnt - 1] * sum) % MOD;
            ++now;
        }else{
            x = fc[cnt] * get(p[i]) % MOD;
            if(cnt >= 1) x = (x + now * fc[cnt - 1] % MOD * pr[p[i]]) % MOD;
            add(p[i]);
            sum = sum + (cnt - pr[p[i]]);
            sum %= MOD;
        }
        ans = (ans + x * fc[n - 1 - i]) % MOD;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 20096
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

ll mult_mod(ll x, ll y, ll mod){
    return (x * y - (ll)(x / (long double)mod * y + 1e-3) * mod + mod) % mod;
}

ll pow_mod(ll a, ll b, ll p){
    ll res = 1;
    while (b){
        if (b & 1)
            res = mult_mod(res, a, p);
        a = mult_mod(a, a, p);
        b >>= 1;
    }
    return res % p;
}

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

const double pi = acos(-1);

double a, b, x, s, h, ans;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> a >> b >> x;
    s = x / a;
    if (s >= a * b / 2){
        h = (a * b - s) * 2 / a;
        ans = 180 * atan2(h, a) / pi;
    }
    else{
        h = s * 2 / b;
        ans = 180 * atan2(b, h) / pi;
    }
    printf("%.8lf\n", ans);
    return 0;
}

Measured memory_bytes: 256
n,w=map(int,input().split())
P=[]
for _ in range(n):
  iw,iv=map(int,input().split())
  P.append([iw,iv])
INF=float('inf')
 
dp=[[0 for i in range(w+1)] for j in range(n+1)]
 
for i in range(1,n+1):
  for j in range(1,w+1):
    if j-P[i-1][0]>=0:
      dp[i][j]=max(dp[i-1][j],dp[i-1][j-P[i-1][0]]+P[i-1][1])
    else:
      dp[i][j]=dp[i-1][j]
print(dp[n][w])

Measured memory_bytes: 218156
#include<cstdlib>
#include<cstdio>
#include<iostream>
#include<vector>
#include <algorithm>
#include <sstream>
#include <iomanip>


int main(){
  int n;
  double r = 0.0;
  std::cin >> n;
  for(int i=0; i<n; i++){
      int a;
      std::cin >> a;
      r = r + 1./(double)a;
  }
  std::cout << std::setprecision(6) << 1.0d/r << std::endl;
  
  return 0;
}



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

#define FOR(i,a,b)  for(ll i=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll i=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cout << #a << " = " << a << endl

const ll inf = 1e15;
const ll mod = 1e9+7;

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

int loop_start;
int loop_start_count;

int main() {
    int N;
    ll K;
    cin >> N >> K;
    vector<int> A(N);
    REP(i, N) cin >> A.at(i);

    vector<int> s;
    vector<int> ord(N+1, -1);

    int c = 1;
    int l = 0;
    int v = 1;
    while(ord[v] == -1) {
        ord[v] = s.size();
        s.push_back(v);
        v = A[v-1];
    }
    c = s.size() - ord[v];
    l = ord[v];

    if (K < l) cout << s[K] << endl;
    else {
        K -= l;
        K = K % c;
        cout << s[K + l] << endl;
    }
}

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

int main() {
	int x,y,t;
	while (true) {
		cin >> x >> y;
		if (x==0 && y==0)break;
		if(x > y) {
			t = x;
			x = y;
			y = t;
		}
		cout << x << " " << y << endl;
	}
}

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

using namespace std;

typedef long long ll;

double getTime() { 
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

int main() {
  int a, b; cin >> a >> b;
  string aa = "";
  for(int i = 0; i < b; i++) {
    aa += a + '0';
  }
  string bb = "";
  for(int i = 0; i < a; i++) {
    bb += b + '0';
  }
  cout << min(aa, bb) << '\n';
}


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

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

  int z = 0;
  vector<int> A;
  for ( int i = 0; i < N; i++ ) {
    int r;
    cin >> r;

    bool b = true;
    for ( int j = 0; j < A.size(); j++ ) {
      if ( r == A.at(j) ) b = false;
    }
    if ( b ) {
      z++;
      A.push_back(r);
    }
  }

  cout << z << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  ll n, ans = 0;
  cin >> n;
  vector<ll> a(n);
  rep(i, 0, n) cin >> a[i];
  rep(i, 0, n-1) {
    if(a[i] == a[i+1]) {
      a[i+1] = -1;
      ans++;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <chrono>
#include <random>
#include <vector>
#include <string>
#include <cmath>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cassert>

#define sq(x) ((x) * (x))
#define err(x) cerr << "["#x"]  " << (x) << "\n";
#define errv(x) {cerr << "["#x"]  [";for(const auto& ___ : (x)) cerr << ___ << ", "; cerr << "]\n";}
#define errvn(x, n) {cerr << "["#x"]  [";for(auto ___ = 0; ___ < (n); ++___) cerr << (x)[___] << ", "; cerr << "]\n";}
#define errf() cerr << "\n\n";

//#pragma GCC optimize("Ofast, unroll-loops", "omit-frame-pointer","inline")
//#pragma GCC option("arch=native","tune=native","no-zero-upper")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native,avx2")

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getrnd(int l, int r) {
    return uniform_int_distribution<int>(l, r)(rng);
}

template <typename T1, typename T2>
bool relax(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

template <typename T1, typename T2>
bool strain(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

// :::::::::::::::::::::::::::::::

const ll MOD = 1e9 + 7;
const int N = 1e5 + 3;
ll fact[N];

ll add(ll a, ll b) {
    if (a + b >= MOD) return a + b - MOD;
    return a + b;
}

ll sub(ll a, ll b) {
    if (a - b < 0) return a - b + MOD;
    return a - b;
}

ll binpow(ll a, ll n) {
    ll res = 1;
    while (n) {
        if (n & 1)
            res = (res * a) % MOD;
        a = (a * a) % MOD;
        n /= 2;
    }
    return res;
}

ll divide(ll a, ll b) {
    return (a * binpow(b, MOD - 2)) % MOD;
}

ll C(ll n, ll k) {
    return divide(fact[n], (fact[k] * fact[n - k]) % MOD);
}

void solve() {
    int n, k;
    cin >> n >> k;
    
    fact[0] = 1;
    for (ll i = 1; i < N; ++i)
        fact[i] = (fact[i - 1] * i) % MOD;
    
    vector<ll> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    sort(a.begin(), a.end());
    
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        if (i >= k - 1)
            ans = add(ans, (a[i] * C(i, k - 1)) % MOD);
        if (i + k - 1 < n)
            ans = sub(ans, (a[i] * C(n - i - 1, k - 1) % MOD));
    }
    assert(ans >= 0);
    cout << ans % MOD << '\n';
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    srand(time(0));
    
    int t = 1;
//    cin >> t;
    while (t--)
        solve();
    
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long
#define mod 998244353
#define max(p,q)((p)>(q)?(p):(q))
ll powe(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
ll n,x,m;
ll l[212345],r[212345];
ll flag[112345],sum[112345];

int main(){
  scanf("%lld%lld%lld",&n,&x,&m);
  ll tmp=x;
  ll ans=0;
  ll count=1;
  while(flag[tmp]==0 && count<n){
    flag[tmp]=count;
    sum[tmp]=ans;
    ans+=tmp;
    tmp=tmp*tmp%m;
    count++;}
  if(count==n){
    printf("%lld\n",ans+tmp);
    }
  else{
    ans=sum[tmp]+(n-flag[tmp]+1)/(count-flag[tmp])*(ans-sum[tmp]);
    n=(n-flag[tmp]+1)%(count-flag[tmp]);
    while(n>0){
      ans+=tmp;
      tmp=tmp*tmp%m;
      //ans+=tmp;
      n--;}
    printf("%lld\n",ans);}
  
  return 0;
}


Measured memory_bytes: 3292
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

#define endl "\n"

/* see https://cp-algorithms.com/data_structures/disjoint_set_union.html
 * Also known as union find structure. 
 * Note that the above link has some optimizations for faster combining of sets if needed. 
 */

struct Dsu {
    vector<int> p;
    vector<int> s;
/* initializes each (0..size-1) to single set */
    Dsu(int size) {
        p.resize(size);
        iota(p.begin(), p.end(), 0);
        s.resize(size, 1);
    }

/* makes v a single set, removes it from other set if contained there. */
    void make_set(int v) {
        p[v] = v;
    }

/* finds set representative for member v */
    int find_set(int v) {
        if (v == p[v])
            return v;
        return p[v] = find_set(p[v]);
    }

/* combines the sets of two members. 
 * Use the bigger set as param a for optimized performance.  */
    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            p[b] = a;
            s[a]+=s[b];
        }
    }
};

void solve() {
    cini(n);
    cini(m);

    int ans=1;
    Dsu dsu(n);
    for(int i=0; i<m; i++) {
        cini(a); a--;
        cini(b); b--;
        dsu.union_sets(a,b);
        ans=max(ans, dsu.s[dsu.find_set(a)]);
    }
    cout<<ans<<endl;
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


Measured memory_bytes: 6336
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;typedef vector<ll> vll;
#define fill(a) memset(a, 0, sizeof (a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define sz(x) (int)x.size()

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int maxn = 2000100;

int main(){
        _ios;

        ll n;cin>>n;
        string s;
        map<string,int>chk;
        rep(i, n){
            cin>>s;
            chk[s]++;
        }
        vector<string>cnt;
        vi v;
        for(auto x: chk){
            v.pb(x.ss);
        }
        int mx = maxv(v);
        for(auto x: chk){
            if(x.ss==mx)cnt.pb(x.ff);
        }
        sort(all(cnt));
        for(auto x: cnt){
            cout<<x<<endl;
        }




return 0;
}






Measured memory_bytes: 26352
#include <bits/stdc++.h>
typedef long long ll;
#define p3 pair<int,pair<int,int> >
using namespace std;

p3 make_p3(int a,int b,int k){
	return make_pair(a,make_pair(b,k));
}

const int MAX_E = 210000; 

struct edge{ int u, v, cost; };
edge es[MAX_E];
int V, E; // 頂点数と辺数


//--------Union-Find木------------
vector<int> par; // 親
vector<int> rnk; // 深さ

// Union-Find木の初期化
void init_union_find(int n) {
  par  = vector<int>(n);
  rnk = vector<int>(n);
  for (int i = 0; i < n; i++) {
    par[i] = i;
    rnk[i] = 0;
  }
}

// 木の根を求める
int find(int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

// xとyの属する集合を併合
void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;

  if (rnk[x] < rnk[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (rnk[x] == rnk[y]) rnk[x]++;
  }
}

// xとyが同じ集合に属するか否か
bool same(int x, int y) {
  return find(x) == find(y);
}

//----------クラスカル法------------
bool comp(const edge& e1, const edge& e2) {
  return e1.cost < e2.cost;
}
long long kruskal() {
  sort(es, es + E, comp); // edge.costの小さい順
  init_union_find(V); // Union-Findの初期化
  long long res = 0;
  for (int i = 0; i < E; i++) {
    edge e = es[i];
    if (!same(e.u, e.v)) {
      unite(e.u, e.v);
      res += e.cost;
    }
  }
  return res;
}

int main() {
  cin>>V;
  E = 2*V-2;
  int c;
  int k = 0;

  vector<p3> v1,v2;
  int i,x,y;
  for(i=0;i<V;i++){
	cin>>x>>y;
	v1.push_back(make_p3(x,y,i));
	v2.push_back(make_p3(y,x,i));
  }
  sort(v1.begin(),v1.end());
  sort(v2.begin(),v2.end());
  for (int i = 1; i < V; i++) {
        edge e1 = {v1[i-1].second.second,v1[i].second.second,abs(v1[i-1].first-v1[i].first)};
        es[k++] = e1;
	edge e2 = {v2[i-1].second.second,v2[i].second.second,abs(v2[i-1].first-v2[i].first)};
	es[k++] = e2;
  }
    // 最小全域木をクラスカル法で求める
  int res = kruskal();
    // 出力
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 5676
#include <iostream>
#include <string>

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	rep(i,n)
	{
		string s;
		cin >> s;

		if(s[0] == '>' && s[1] == '\'' && s[2] == '=')
		{
			int i = 2;
			int cnt = 0;
			while(s[i] == '=')
			{
				i++;
				cnt++;
			}

			if(s[i] == '#' && i < s.size())
			{
				i++;
				while(s[i] == '=')
				{
					if(i == s.size()-1) break;
					i++;
					cnt--;
				}
			}

			if(cnt == 0 && s[i] == '~') cout << "A" << endl;
			else cout << "NA" << endl;
		}
		else if(s[0] == '>' && s[1] == '^' && s[2] == 'Q')
		{
			int i = 2;
			int cnt = 0;
			bool end = false;
			while(i+1 < s.size())
			{
				if(s[i] == 'Q' && s[i+1] == '=')
				{
					i += 2;
				}
				else if(s[i] == '~' && s[i+1] == '~')
				{
					end = true;
					cout << "B" << endl;
					i += 2;
				}
				else
				{
					break;
				}
			}

			if (!end) cout << "NA" << endl;
		}
		else
		{
			cout << "NA" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1204
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int H1 = in.nextInt();
        int M1 = in.nextInt();
        int H2 = in.nextInt();
        int M2 = in.nextInt();
        int K = in.nextInt();

        int H = 48 + H2 - H1;
        int M = M2 - M1;
        if (M < 0) {
            M += 60;
            H--;
        }
        H %= 24;

        out.println(H * 60 + M - K);

        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}



Measured memory_bytes: 32604
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
	int h,a;
	scanf("%d%d",&h,&a);
	if(h<=a){
		printf("1\n");
	}
	else{
		if(h%a==0){
			printf("%d\n",h/a);
		}
		else{
			printf("%d\n",h/a+1);
		}
	}
	return 0;
} 

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

#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//プロトタイプ宣言
void faster(void);
template <class T>
T gcd(T , T);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);



int main(){
  faster();
  string s;
  cin >> s;
  rep(i,s.size()) cout << "x";
  cout << endl;
}



























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//ユークリッドの互除法
template <class T>
T gcd(T a, T b) {
  return (b ? gcd(b, a%b) : a);
} 

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//べき乗計算
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 



Measured memory_bytes: 256
#include<stdio.h>

#define N 100

int main(int argc, char *argv[]){
  int i,j,tmp,n,arr[N];
  // read the number of elements and the elements
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&arr[i]);
  }

  // sorting
  for(i = 0; i < n; i++){
    tmp = arr[i];
    j = i - 1;
    while(j >= 0 && arr[j] > tmp){
      arr[j+1] = arr[j];
      j--;
    }
    arr[j+1] = tmp;
    // output the sorted array
    for(j = 0; j < n; j++){
    printf("%d",arr[j]);
    if(j == n - 1) break;
    printf(" ");
  }
  printf("\n");
  
  }
}



Measured memory_bytes: 2732
#include <iostream>

using namespace std;

int main(){
  int n,a;
  
  cin >> n;
  
  long long int sum=0;
  
  int min=1000000;
  
  int max=-1000000;
  
for(int i=0;i<n;i++){
  
  cin >> a;
  
if(min > a){
  
  min = a;
}
  
if(max < a){
  
  max = a;
}
  
sum += a;
}
  
  cout << min << ' ' << max << ' ' << sum << endl;
}




Measured memory_bytes: 3116
import string as st
string=[]
try:
    while True:
        s = input()#入力
        string =list(string)#list変換
        if not s :#空入力のときループぬける
            break
        string.extend(s)#list追加
        string=map(str,string)
        string="".join(string).lower()#str型変換と小文字
except EOFError:
    for i in range(len(st.ascii_lowercase)):
        print("{} : {}".format(st.ascii_lowercase[i],string.count(st.ascii_lowercase[i])))


Measured memory_bytes: 6680
#include<bits/stdc++.h>
using namespace std;
int main()
{
	//Inspiration@99
	long long n;
	cin>>n;
	vector<long long> v;
	long long k;
	cin>>k;
	for(long long i=0;i<n;i++)
	{
		long long x;
		cin>>x;
		v.push_back(x);
	}
	vector<long long> ans;
	ans.push_back(0);
	ans.push_back(abs(v[1]-v[0]));
	if(n>2)
	{
	if(n>k)
	{
		for(long i=2;i<k;i++)
		{
			long long min=1000000000;
			for(long j=0;j<i;j++)
			{
				if(abs(v[i]-v[j])+ans[j]<min)
				{
					min=abs(v[i]-v[j])+ans[j];
				}
			}
			ans.push_back(min);
		}
		if(k==1)
		{
					for(long i=2;i<n;i++)
		{
			long long min=1000000000;
			for(long j=i-k;j<i;j++)
			{
				if(abs(v[i]-v[j])+ans[j]<min)
				{
					min=abs(v[i]-v[j])+ans[j];
				}
			}
			ans.push_back(min);
		}
		}
		else
		{
		for(long i=k;i<n;i++)
		{
			long long min=100000000000;
			for(long j=i-k;j<i;j++)
			{
				if(abs(v[i]-v[j])+ans[j]<min)
				{
					min=abs(v[i]-v[j])+ans[j];
				}
			}
			ans.push_back(min);
		}
		}
	}
	else
	{
		for(long i=2;i<n;i++)
		{
			long long min=100000000000;
			for(long j=0;j<i;j++)
			{
				if(abs(v[i]-v[j])+ans[j]<min)
				{
					min=abs(v[i]-v[j])+ans[j];
				}
			}
			ans.push_back(min);
		}
	}
	}
	cout<<ans[n-1]<<endl;
}

Measured memory_bytes: 2548
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
count = 0
for i in range(N):
    A = map(int,input().split())
    suma = 0
    for j in zip(A,B):
        suma += j[0]*j[1]
    if suma + C > 0:
        count += 1
print(count)


Measured memory_bytes: 3060
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

"""
・正、負の部分に分けて。本質的には正の場合ができればよい
・4A_i > A_{i+1} となってるものはまとめる。運命共同体の区間たちができる
・一番弱い区間と勝負する。成長すると次の区間とマージできる
"""

N,*A = map(int,read().split())

def calc_positive_case(N,A):
    INF = 1<<32
    # ある場所を始点として、そこから全部positiveにしたい場合
    dp = [0] * N
    left_end = []
    right_end = []
    items = []
    mult_cnt = 0
    for i,x in enumerate(A[::-1]):
        left_end.append(x); right_end.append(x); items.append(1)
        # 最小の矛盾を解消
        while len(items) >= 2:
            l2,l1 = left_end[-2:]
            r2,r1 = right_end[-2:]
            n2,n1 = items[-2:]
            if r1*4<=l2:
                # mergeせず
                break
            while r1>l2:
                l2 *= 4; r2 *= 4; mult_cnt += n2
            left_end.pop(); left_end[-1]=l1
            right_end.pop(); right_end[-1]=r2
            items.pop(); items[-1] += n1
        if right_end[0] > INF:
            right_end[0] = INF
        dp[i] = mult_cnt
    return dp[::-1]

pos = calc_positive_case(N,A) # ある点を正の始点としたときに必要な、4倍の回数
neg = calc_positive_case(N,A[::-1])[::-1] # ある点を負の始点としたときの～～

pos = [2*x for x in pos] + [0]
neg = [0] + [2*x+i for i,x in enumerate(neg,1)] # -2倍の初期コストが乗る

answer = min(x+y for x,y in zip(pos,neg))
print(answer)

Measured memory_bytes: 39904
#include <iostream>
#include <functional>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	int N, K;
	vector<int> lens;

	cin >> N;
	cin >> K;
	for ( int i = 0; i < N; ++i ) {
		int len;
		cin >> len;
		lens.push_back( len );
	}

	std::sort( lens.begin(), lens.end(), std::greater<int>() );
	int res = 0;
	for ( int i = 0; i < K; ++i ) {
		res += lens[i];
	}

	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
using namespace std;
int main(){
    int N, i, j, k, s1, s2, min = 10000;
    cin >> N;
    int W[N];
    for (i=0; i < N; i++){
        cin >> W[i];
    }
    for (i = 1; i < N; i++){
        s1 = 0;
        s2 = 0;
        for (j = 0; j < i; j++){
            s1 += W[j];
        }
        for (k = i; k < N; k++){
            s2 += W[k];
        }
        if (min > abs(s1 - s2)){
            min = abs(s1 - s2);
        }
    }
    cout << min << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 1e18
const double EPS = 1E-10;

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



 
 
int main(){
    int N; std::cin >> N;
    std::vector<int> a(N);
    for(int i(0); i < N; ++i){
        std::cin >> a[i];
        --a[i];
    }
    for(int cnt(0), cur(0); cnt <= N; ++cnt){
        if(cur == 1){
            std::cout << cnt << std::endl;
            return 0;
        }
        cur = a[cur];
    }
    std::cout << -1 << std::endl;
    return 0;
}


Measured memory_bytes: 640
def isPrime(n):
    if (n == 1): return False
    if (n == 2): return True
    if (0 == n % 2) : return False
    i = 2
    while(n >= i * i):
        if (0 == n % i): return False
        i += 1
    return True

def main():
    c = 0
    n = input()
    for i in range(n):
        if (isPrime(input())):
            c += 1
    print(c)

main()

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll a = 0, b = 0, c = 0;
    REP(i, S.length()) {
        if (S[i] == 'a')
            a++;
        if (S[i] == 'b')
            b++;
        if (S[i] == 'c')
            c++;
    }

    if (max({a, b, c}) - min({a, b, c}) < 2)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
//#define int long long
//#define _DEBUG
class UnionFindTree{
    private:
    int P[10007];
    int rank[10007];
    public:
    UnionFindTree(int N){
        for(int i=0; i<=N; i++) P[i] = i;
    }
    int root(int a){
        if (P[a] == a) return a;
        return (P[a] = root(P[a]));
    }
    bool is_same_set(int a, int b){
        return root(a) == root (b);
    }
    void unite(int a, int b){
        int ra = root(a);
        int rb = root(b);
        if(ra == rb) return;
        if(rank[ra] < rank[rb]){
            P[ra] = rb;
        }else{
            P[rb] = ra;
            if(rank[ra] == rank[rb]){
                rank[ra]++;
            }
        }        
    }
};
signed main(){
    int n, q;
    while(cin >> n >> q){
        auto uft = UnionFindTree(n);
        for(int i=0; i<q; i++){
            int c, x, y;
            cin >> c >> x >> y;
            if(c==0){
                uft.unite(x,y);
            }else{
                cout << uft.is_same_set(x,y) << endl;
            }
        }
    }
}


Measured memory_bytes: 3192
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  int K;
  cin >> K;
  if (K%2==0) {
    cout << K/2*K/2 << endl;
  }
  else {
    int odd = K/2+1;
    int even = K-odd;
    
    cout << even*odd << endl;
  }
}

Measured memory_bytes: 256
<?php
define('ROOF', pow(10, 18));
fscanf(STDIN, "%d", $N);
$A = array_map('intval', explode(' ', trim(fgets(STDIN))));
$summary = array_count_values($A);

if (isset($summary[0])) {
    $ans = 0;
} else {
    $ans = array_pop($A);
}
while($A && $ans !== 0) {
    $x = array_pop($A);
    $limit = ROOF / $ans;
    //echo "x: {$x}  limit: " . $limit . PHP_EOL;
    if ($limit < $x) {
        $ans = -1;
        break;
    } else {
        $ans *= $x;
    }
}
if ($ans > ROOF) {
    $ans = -1;
}
printf("%d", $ans);


Measured memory_bytes: 30948
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>

#define div 1000000000+7

typedef long long ll;

using namespace std;

void solve(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int x = a*b-c*d;
    if(x >= 0){
        cout << a*b << endl;
    }else{
        cout << c*d << endl;
    }
}

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main () {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	for (int i=0; i<k; i++) {
		if (c>b && b>a) {
			break;
		}
		if (c<=b || c<=a) {
			c*=2;
		}
		else {
			b*=2;
		}
	}
	if (c>b && b>a) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,i;
  cin>>a;
  char ar1[a],ar2[a];
  cin>>ar1>>ar2;
  for(i=0; i<a; i++)
  {
    cout<<ar1[i]<<ar2[i];
  }
}


Measured memory_bytes: 3592
#include <iostream>
#include <map>
#include <vector>
#include <string>

using namespace std;

int main() {
	string s;
	cin >> s;

	string ans = "";
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == '0')
			ans += "0";
		else if (s[i] == '1')
			ans += "1";
		else if (s[i] == 'B') {
			if (ans.empty() == 0)
				ans.pop_back();
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;



signed main(){
	char c;
	cin >> c;
	if(isupper(c))out('A');
	else out('a');
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

int main() {

	double R;
	cin >> R;

	double pi = acos(-1.0);

	cout << fixed;
	cout << setprecision(5) << 2 * pi * R << endl;

	return 0;
}


Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
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 ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k;cin >> k;
    if(k<=1){
        cout << 2 << endl;
        cout << 0 << " " << k+1 << endl;
        return 0;
    }
    if(k<=50){
        cout << k << endl;
        FOR(i,1,k+1){
            cout << i << " ";
        }
        cout << endl;
        return 0;
    }
    cout << 50 << endl;
    FOR(i,1,51){
        if(50-i+1<=k%50){
            cout << (k+49)/50+i-1 << " ";
        }
        else{
            cout << k/50+i-1 << " ";
        }
    }
    cout << endl;
}

Measured memory_bytes: 3628
N = int(input())
L = sorted(map(int,input().split()))
count = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if L[i] < L[j] < L[k]:
                if L[i]+L[j]>L[k]:
                    count += 1
print(count)

Measured memory_bytes: 67936
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
const int N=1e2+10;
const int Vmax=1e5+10;
const ll INF=4611686018427387903;
int n,W,w[N],v[N],tot;
ll dp[Vmax];
int main(){
	scanf("%d%d",&n,&W);
	for(register int i=1;i<=n;i++)
		scanf("%d%d",&w[i],&v[i]),tot+=v[i];
	for(register int i=1;i<=tot;i++)dp[i]=INF;
	for(register int i=1;i<=n;i++)
		for(register int j=tot;j>=v[i];j--)
			if(dp[j-v[i]]!=INF)dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
	for(register int i=tot;i>=0;i--)if(dp[i]<=W){printf("%d\n",i);break;}
	return 0;
}

Measured memory_bytes: 1024
n=int(input())-1
al=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
ans=[]
m=n
k=1
while m>=26**k:
    m-=26**k
    k+=1
for i in range (k):
    ans.append(al[m%26])
    m=(m-m%26)//26
if k==1:
    print(ans[0])
elif k==2:
    print(ans[1]+ans[0])
elif k==3:
    print(ans[2]+ans[1]+ans[0])
elif k==4:
    print(ans[3]+ans[2]+ans[1]+ans[0])
elif k==5:
    print(ans[4]+ans[3]+ans[2]+ans[1]+ans[0])
elif k==6:
    print(ans[5]+ans[4]+ans[3]+ans[2]+ans[1]+ans[0])
elif k==7:
    print(ans[6]+ans[5]+ans[4]+ans[3]+ans[2]+ans[1]+ans[0])
elif k==8:
    print(ans[7]+ans[6]+ans[5]+ans[4]+ans[3]+ans[2]+ans[1]+ans[0])
elif k==9:
    print(ans[8]+ans[7]+ans[6]+ans[5]+ans[4]+ans[3]+ans[2]+ans[1]+ans[0])
elif k==10:
    print(ans[9]+ans[8]+ans[7]+ans[6]+ans[5]+ans[4]+ans[3]+ans[2]+ans[1]+ans[0])
elif k==11:
    print(ans[10]+ans[9]+ans[8]+ans[7]+ans[6]+ans[5]+ans[4]+ans[3]+ans[2]+ans[1]+ans[0])


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

using namespace std;

#define li long long int
#define pb push_back
#define vl vector<li>

int main() {
    li k; cin>>k;
    vl d;
    for( li i = 2; i*i <= k ; i++ ) {
        if( k%i == 0 ) {
            d.pb(i);
            li o = k/i;
            if( i != o ) d.pb(o); 
        }
    }
    d.pb(k);
    sort(d.begin(),d.end());
    int ans = 0;
    for( auto e : d ) {
        li t = k;
        while( t%e == 0 ) {
            t /= e;
        }
        ans += ( t%e == 1 );
    }
    ans += ( k > 2 );
    k--;
    for( li i = 2; i*i <= k ; i++ ) {
        if( k%i == 0 ) {
            ans += 2;
            if( i*i == k ) ans--;
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 384
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define PI 3.14159265358979323846264338327950288
#define testP	 cout << "------------------ test ------------------" << endl;	// 動作確認テスト
#define testX(x) cout << "testout : " << x << endl;	// テストアウト
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)
typedef long long ll;
using namespace std;

// ------------------ ベクター表示 ------------------ //
void printVec(vector<int>& vec) {
	cout << "";
	for (auto it = vec.begin(); it != vec.end(); it++) cout << *it << " ";
	cout << endl;
}

// ------------------ ベクター合計 ------------------ //
int sumVec(vector<int> v) {
	int sum = 0;
	for (size_t i = 0; i < v.size(); i++) sum += v[i];
	return sum;
}

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	int N, K;
	cin >> N >> K;
	vector<int> p(N);
	rep(i, N) cin >> p[i];
	sort(p.begin(), p.end());

	int ans = 0;
	rep(i, K) ans += p[i];

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


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
long long a[200002];
int main()
{
	long long n;
	cin>>n;
	for(long long i=1;i<=n;i++)		cin>>a[i];	
	sort(a+1,a+n+1);
	for(long long i=1;i<n;i++)
	{
		if(a[i]==a[i+1])
		{
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES";
	return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
using namespace std;
int gi(){
	int x=0,w=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')w=0,ch=getchar();
	while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
const int N=2e5+5;
int n,q,a[N],b[N];
struct fenwick{
	int c[N],top,tt[N];pair<int,int>S[N*20];
	void init(int v){
		for(int i=1;i<=n;++i)c[i]=v;
	}
	void modify(int x,int v){
		while(x<=n){
			if(c[x]<v)S[++top]=make_pair(x,c[x]),c[x]=v;
			x+=x&-x;
		}
	}
	void rollback(int i){
		while(top>tt[i])c[S[top].first]=S[top].second,--top;
	}
	int query(int x){
		int res=-1<<30;
		while(x)res=max(res,c[x]),x^=x&-x;
		return res;
	}
}foo,bar;
bool check(int x,int v){
	if(v<0)return false;
	if(v&1)return foo.query(n+1-x)>=v;
	else return bar.query(n+1-x)>=v;
}
bool check(int max0,int max1,int dif){
	return check(max0,q-dif)||check(max1,q+dif);
}
int main(){
	n=gi();
	for(int i=1,pre_max=0;i<=n;++i){
		a[i]=gi();
		if(a[i]>pre_max){
			pre_max=a[i];
			b[i]=1;++q;
		}
	}
	foo.init(-1<<30);bar.init(0);
	for(int i=n;i;--i){
		int x=-1<<30,y=-1<<30;
		if(b[i]){
			x=foo.query(n+1-a[i])+2;
			y=bar.query(n+1-a[i])+2;
		}else{
			x=bar.query(n+1-a[i])+1;
			y=foo.query(n+1-a[i])+1;
		}
		foo.tt[i]=foo.top;foo.modify(n+1-a[i],x);
		bar.tt[i]=bar.top;bar.modify(n+1-a[i],y);
	}
	if(!check(1,q))return puts("-1"),0;
	for(int i=1,max0=1,max1=1,dif=0;i<=n;++i){
		if(b[i])--q;
		foo.rollback(i);bar.rollback(i);
		if(a[i]>=max0)
			if(check(a[i],max1,dif+1))
				putchar('0'),max0=a[i],++dif;
			else
				putchar('1'),dif-=a[i]>=max1,max1=max(max1,a[i]);
		else
			if(check(max0,max1,dif))
				putchar('0');
			else
				putchar('1'),dif-=a[i]>=max1,max1=max(max1,a[i]);
	}
	puts("");return 0;
}


Measured memory_bytes: 67584
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::ops::Bound::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

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

    let mut dsu = DSU::new(n);
    for _ in 0..q {
        input! {
            t: u8, u: usize, v: usize,
        }
        match t {
            0 => {
                dsu.merge(u, v);
            }
            1 => {
                let res = dsu.same(u, v) as u8;
                println!("{}", res);
            }
            _ => unreachable!()
        }
    }
}
#[allow(dead_code)]
pub struct DSU {
    parent_or_size: Vec<isize>,
}

#[allow(dead_code)]
impl DSU {
    pub fn new(n: usize) -> Self {
        assert!(n <= std::isize::MAX as usize);
        Self {
            parent_or_size: vec![-1; n],
        }
    }

    pub fn merge(&mut self, a: usize, b: usize) -> usize {
        let mut x = self.leader(a);
        let mut y = self.leader(b);
        if x == y {
            return x;
        }
        if -self.parent_or_size[x] < -self.parent_or_size[y] {
            std::mem::swap(&mut x, &mut y);
        }
        self.parent_or_size[x] += self.parent_or_size[y];
        self.parent_or_size[y] = x as isize;
        x
    }

    pub fn same(&mut self, a: usize, b: usize) -> bool {
        self.leader(a) == self.leader(b)
    }

    pub fn leader(&mut self, mut a: usize) -> usize {
        while self.parent_or_size[a] >= 0 {
            a = self.parent_or_size[a] as usize;
        }
        a
    }

    pub fn size(&mut self, a: usize) -> usize {
        let leader = self.leader(a);
        -self.parent_or_size[leader] as usize
    }

    pub fn groups(&mut self) -> Vec<Vec<usize>> {
        let mut leader_buf = vec![0usize; self.parent_or_size.len()];
        let mut group_size = vec![0usize; self.parent_or_size.len()];
        for i in 0..self.parent_or_size.len() {
            leader_buf[i] = self.leader(i);
            group_size[leader_buf[i]] += 1;
        }
        let mut result = vec![Vec::new(); self.parent_or_size.len()];
        for i in 0..self.parent_or_size.len() {
            result[i].reserve(group_size[i]);
        }
        for i in 0..self.parent_or_size.len() {
            result[leader_buf[i]].push(i);
        }
        result.retain(|v| !v.is_empty());
        result
    }
}

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

const int MOD = 1e9+7;

//素因数分解
void factorization(long long n,map<long long ,long long>& mp){
    for(long long i=2;i*i<=n;i++){
        while(n%i==0){
            mp[i]++;
            n /= i;
        }
      }
      if(!(n == 1)) mp[n]++;
}

int main(){
  int n;
  cin>>n;
  map<ll,ll> mp;
  for(int i = 1; i <= n; i++){
    factorization(i,mp);
  }
  ll ans=1;
  for(auto x : mp){
    ans*=(x.second+1);
    ans%=MOD;
  }
  cout<<ans<<endl;
}


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

int main() {
  vector<int> N(3);
  cin >> N.at(0) >> N.at(1) >> N.at(2);
  sort(N.begin(),N.end());
  if(N.at(0)==5 && N.at(1)==5 && N.at(2)==7){
  cout << "YES" << endl;
  }
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){

	string s1,s2;
	while(cin >> s1 >> s2){
		int maxLength = 0;
		// ツづづェツつセツつッツつクツづァツつキツつゥ
		for(int i = -(int)s1.size(); i <= (int)s2.size(); i++){
			// ツ債。ツづ個つクツづァツつオツつスツ湘ウツ妥板づ個淞催オツづーツ渉堕つッツづゥ
			int cnt = 0;
			for(int j = 0; j < s1.size(); j++){
				if(i + j >= 0 && i + j < s2.size()){
					if(s1[j] == s2[i+j])
						cnt++;
					else{
						maxLength = max(maxLength,cnt);
						cnt=0;
					}
				}
			}
			maxLength = max(maxLength,cnt);
		}

		//for(int i = 0; i < str[0].size(); i++){
		//	for(int j = 0; j < str[1].size(); j++){
		//		if(str[0][i] == str[1][j]){
		//			int length = 1;
		//			for(int k = 1; k + i < str[0].size() && k + j < str[1].size(); k++){
		//				if(str[0][k+i] == str[1][k+j])
		//					length++;
		//				else
		//					break;
		//			}
		//			maxLength = max(maxLength,length);
		//		}
		//	}
		//}
		cout << maxLength << endl;
	}

	return 0;
}

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

int main() {
    int H,W;
    cin >> H >> W;
    string S[50];
    for(int i = 0; i < H; ++i) cin >> S[i];

    int num;
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            //each cell
            if(S[i][j] == '#') continue;

            //count
            num = 0;
            for(int k = i-1; k <= i+1; ++k){
                if(k < 0 || k >= H) continue;
                for(int l = j-1; l <= j+1; ++l){
                    if(l < 0 || l >= W) continue;
                    if(S[k][l] == '#') num++;
                }
            }
            S[i][j] = '0' + num;
        }
    }
    for(int i = 0; i < H; ++i) cout << S[i] << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	buf.Split(bufio.ScanWords)

	n := scanInt()
	a := scanInt()
	b := scanInt()

	q := n / (a + b)
	d := n % (a + b)

	if d < a {
		fmt.Printf("%d", q*a+d)
	} else {
		fmt.Printf("%d", q*a+a)
	}
}

var buf = bufio.NewScanner(os.Stdin)

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

func scanInts(n int) []int {
	a := make([]int, n)
	for k, _ := range a {
		a[k] = scanInt()
	}
	return a
}

func scanString() string {
	buf.Scan()
	return buf.Text()
}

func scanStrings(n int) []string {
	a := make([]string, n)
	for k, _ := range a {
		a[k] = scanString()
	}
	return a
}


Measured memory_bytes: 640
A,B,C,X,Y = map(int, input().split())

C2=C*2

if(A>C2 and B>C2):
    print(max(X,Y)*2*C)
    exit()

if(A>C2):
    t=X*2*C
    y=Y-X
    t+=max(0,y)*B
    print(t)
    exit()

if(B>C2):
    t=Y*2*C
    x=X-Y
    t+=max(0,x)*A
    print(t)
    exit()

if(A+B>C2):
    z=min(X,Y)
    t=z*2*C
    t+=(X-z)*A
    t+=(Y-z)*B
    print(t)
    exit()

print(A*X+B*Y)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e18;
using namespace std;
typedef long long ll;
int main() {
  ll N;
  cin >> N;
  ll A[N + 1], B[N];
  REP(i, N + 1) { cin >> A[i]; }
  REP(i, N) { cin >> B[i]; }

  ll ans = 0;
  REP(i, N) {
    if (A[i] - B[i] <= 0) {
      B[i] -= A[i];
      ans += A[i];
      if (A[i + 1] - B[i] <= 0) {
        ans += A[i + 1];
        A[i + 1] = 0;
      } else {
        ans += B[i];
        A[i + 1] -= B[i];
      }
    } else {
      ans += B[i];
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 1792
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils,Classes;
var
  h,w,i,j,count,x,y,sw,m,n,a,b,c:Integer;
  s123,s1,s2,s3:string;
  tf:Boolean;
  nyu:TStringList;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Read(a);
    Read(b);
    Readln(c);

    if (c>=a) and (c<=b) then
      Writeln('Yes')
    else
      Writeln('No');
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 256
package main
import(
  "fmt"
)

func main(){
  var a, b, c, k int
  ans:=0
  fmt.Scan(&a, &b, &c, &k)
  if a>=k{
    fmt.Println(k)
    return
  }else{
    k-=a
    ans+=a
    if b>=k{
      fmt.Println(ans)
      return
    }
    k-=b
    ans-=k
  }
  fmt.Println(ans)
}


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

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

  int n;
  cin >> n;

  int max_v, min_v;
  max_v = 1;
  min_v = 1e9;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    max_v = max(max_v, x);
    min_v = min(min_v, x);
  }

  cout << max_v - min_v << endl;

  return 0;
}

Measured memory_bytes: 256