akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, m;
    cin >> n >> m;
    vector<bool> ok(n + 1, true);
    rep(i, 0, m) {
        int a;
        cin >> a;
        ok[a] = false;
    }

    ll dp[n + 1] = {};
    dp[0] = 1;
    rep(i, 1, n + 1) {
        if (ok[i]) {
            dp[i] += dp[i - 1];
            if (i >= 2) {
                dp[i] += dp[i - 2];
            }
        }
        dp[i] %= MOD;
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 1024
N,M=map(int,input().split())
V=[[]for i in range(N)]
for i in range(M):
    a,b=map(int,input().split())
    V[a-1].append(b-1)
    V[b-1].append(a-1)
print('Yes')
p,q=0,[0]
seen=[0]*N
d=[0]*N
while len(q)!=p:
    for i in V[q[p]]:
        if not seen[i]:
            q.append(i)
            d[i]=q[p]+1
        seen[i]+=1
    p+=1
d.pop(0)
for i in d:print(i)

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

int main()
{
  char S[5];
  int res=0;
  cin >> S;

  sort(S, S+4);
  if(S[0]==S[1] && S[2] == S[3] && S[1]!=S[2]) cout << "Yes" << endl;
  else  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

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


    int K;
    cin >> K;

    ll ans = 0;
    REP(a, K)
    {
        REP(b, K)
        {
            REP(c, K)
            {
                ans += gcd(gcd(a, b), c);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3648
#![allow(non_snake_case)]
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let N:usize = sc.read();
    let A:i64 = sc.read();
    let B:i64 = sc.read();
    let C:i64 = sc.read();
    let D:i64 = sc.read();
    let mut ans = "NO";
    let n = N as i64;
    for m in 0..N{
        let m = m as i64;
        if (m*C - (n-1-m)*D <= B - A) && ( B-A <= m*D - (n-1-m)*C){
            ans = "YES";
            break
        }
    }
    println!("{}", ans);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
        .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}




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

typedef long long ll;
const int MAXN = 100010;
const ll MOD = 1000000007;

int n;
ll s[MAXN], A, B, ans;

template<typename T> inline T read() {
	T x(0), f(1);
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1;
	for(; isdigit(ch); ch = getchar()) x = (x*10)+(ch^48);
	return x * f;
}

inline void Update(ll &cur, ll val) {
	cur += val;
	if(cur >= MOD) cur -= MOD;
}

struct Seg_T {
#define mid ((l+r)>>1)
#define ls (p<<1)
#define rs (p<<1|1)
	ll sum[MAXN*4], tag[MAXN*4];
	inline void init() {
		memset(tag, -1, sizeof(tag));
	}
	inline void pushdown(int p, int l, int r) {
		if(tag[p] != -1) {
			tag[ls] = tag[rs] = tag[p];
			sum[ls] = tag[p]*l%MOD;
			sum[rs] = tag[p]*r%MOD;
			tag[p] = -1;
		}
	}
	inline void modify(int p, int l, int r, int x, int y, ll val) {
		if(l == x && r == y) {
			tag[p] = val;
			sum[p] = val*(y-x+1)%MOD;
			return;
		}
		pushdown(p, mid-l+1, r-mid);
		if(y <= mid) modify(ls, l, mid, x, y, val);
		else if(x > mid) modify(rs, mid+1, r, x, y, val);
		else {
			modify(ls, l, mid, x, mid, val);
			modify(rs, mid+1, r, mid+1, y, val);
		}
		sum[p] = (sum[ls]+sum[rs])%MOD;
	}
	inline ll query(int p, int l, int r, int x, int y) {
		if(l == x && r == y) return sum[p];
		pushdown(p, mid-l+1, r-mid);
		if(y <= mid) return query(ls, l, mid, x, y);
		if(x > mid) return query(rs, mid+1, r, x, y);
		return (query(ls, l, mid, x, mid)+query(rs, mid+1, r, mid+1, y))%MOD;
	}
}f, g;


int main() {

	int i, j;

	n = read<int>();
	A = read<ll>(), B = read<ll>();
	if(A > B) swap(A, B);
	for(i = 1; i <= n; i++) s[i] = read<ll>();

	f.init(), g.init();
	f.modify(1, 1, n, 1, 1, 1);
	g.modify(1, 1, n, 1, 1, 1);
	/*for(i = 1; i <= n; i++) printf("%lld ", f.query(1, 1, n, i, i));
	printf("\n");
	for(i = 1; i <= n; i++) printf("%lld ", g.query(1, 1, n, i, i));
	printf("\n");*/
	for(i = 1; i < n; i++) {
		int loc = upper_bound(s+1, s+n+1, s[i+1]-B)-s-1;
		ll res = f.query(1, 1, n, 1, min(loc+1, i));
		//printf("%d:%lld ", loc, res);
		g.modify(1, 1, n, i+1, i+1, res);
		loc = upper_bound(s+1, s+n+1, s[i+1]-A)-s-1;
		res = g.query(1, 1, n, 1, min(loc+1, i));
		//printf("%d:%lld\n", loc, res);
		f.modify(1, 1, n, i+1, i+1, res);
		if(s[i+1]-s[i] < A) {
			f.modify(1, 1, n, 1, i, 0);
			//printf("fclear(%d, %d)\n", 1, i);
		}
		if(s[i+1]-s[i] < B) {
			g.modify(1, 1, n, 1, i, 0);
			//printf("gclear(%d, %d)\n", 1, i);
		}
	}
	Update(ans, f.query(1, 1, n, 1, n));
	Update(ans, g.query(1, 1, n, 1, n));
	printf("%lld\n", ans);
	return 0;
}


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

#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout if (false) cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vec(v, n) vector<int> v(n, 0);
#define vecll(v, n) vector<ll> v(n, 0);
#define vecvec(v,n,m) vector<vector<int>> v(n, vector<int>(m));
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力

#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define next asdnext
#define prev asdprev
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"

//	LLONG_MAX 9.2*1e18	9223372036854775807LL
//						999999999999999989
//	O(1e7) O(1e8)

void Main()
{
	int N,K;
	cin>>N>>K;
	vec(A,N);
	int longer=-1;
	rep(i,N){
		cin>>A[i];
		longer = max(longer, A[i]);
	}

	int l=0, r=longer+1;
	while(r-l>1){
		int mid=(l+r)/2;
		if(mid==0) mid=1;
		auto f = [&](){
			ll ans=0;
			rep(i,N){
				ans += (A[i]-1)/mid;
			}
			return (ans<=K);
		};
		if(f())r=mid;
		else l=mid;
	}

	cout<<r<<_n;
}


void Test();
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 3972
#include<iostream>
#include<vector>
#include <unordered_map>  
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <sstream>
#include <cmath>
using namespace std;



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

Measured memory_bytes: 256
# 2019/12/26

mod=10**9+7
n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]
dp=[0]*(n+1)
dp[0]=1
dp[1]=1
for aa in a:
    dp[aa]=-1

for i in range(2,n+1):
    if dp[i]==-1:continue
    if dp[i-1]!=-1:
        dp[i]+=dp[i-1]
    if dp[i-2]!=-1:
        dp[i]+=dp[i-2]
print(dp[-1]%mod)

Measured memory_bytes: 462708
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; ++i)
#define rep(i, n) repl(i, 0, n)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define chmax(x,y) x = max(x, y)
#define chmin(x,y) x = min(x, y)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using G = vector<vector<int>>;
const int MOD = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;
const int dy[] = {-1, 0, 1, 0};
const int dx[] = {0, -1, 0, 1};

int main()
{
    int n;
    cin >> n;
    vector<P> d(n);
    rep(i, n) {
        cin >> d[i].first >> d[i].second;
    }
    string ans = "No";
    repl(i, 2, n) {
        if(d[i].first == d[i].second && d[i-1].first == d[i-1].second &&d[i-2].first == d[i-2].second) {
            ans = "Yes";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<double, ll> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  ll n; cin>>n;
  ll ga, sa, ba;
  cin>>ga>>sa>>ba;
  ll gb, sb, bb;
  cin>>gb>>sb>>bb;

  vector<ll> dp(n+1, 0);
  for (int i=0; i<=n; i++) {
    ll t = i;
    if (i >= ga) t = max(t, dp[i-ga]+gb);
    if (i >= sa) t = max(t, dp[i-sa]+sb);
    if (i >= ba) t = max(t, dp[i-ba]+bb);
    dp[i] = t;
  }
  vector<ll> dp2(dp.back()+1, 0);
  for (int i=0; i<=dp.back(); i++) {
    ll t = i;
    if (i >= gb) t = max(t, dp2[i-gb]+ga);
    if (i >= sb) t = max(t, dp2[i-sb]+sa);
    if (i >= bb) t = max(t, dp2[i-bb]+ba);
    dp2[i] = t;
  }
  cout << dp2.back() << endl;
}

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


Measured memory_bytes: 195584
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

typedef long long s64;

const int MaxN = 200000;

int n;

struct number
{
	int u, v;
	number() {}
	number(const int &_u, const int &_v)
		: u(_u), v(_v) {}

	friend inline bool operator<(const number &lhs, const number &rhs)
	{
		if (lhs.u != rhs.u)
			return lhs.u < rhs.u;
		return lhs.v < rhs.v;
	}
};
number a[MaxN + 1];

struct info
{
	int u, v;
	info() {}
	info(const int &x)
		: u(x), v(x) {}
	info(const int &_u, const int &_v)
		: u(_u), v(_v) {}

	friend inline info operator+(const info &lhs, const int &rhs)
	{
		int a = min(lhs.u, rhs);
		int b = max(lhs.v, rhs);
		return {a, b};
	}
};
info pre[MaxN + 1], suf[MaxN + 1];

int main()
{
	ios::sync_with_stdio(false);

	cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i].u >> a[i].v;
		if (a[i].u < a[i].v)
			swap(a[i].u, a[i].v);
	}

	sort(a + 1, a + n + 1);

	pre[1] = a[1].v;
	suf[n] = a[n].v;
	for (int i = 2; i <= n; ++i)
		pre[i] = pre[i - 1] + a[i].v;
	for (int i = n - 1; i; --i)
		suf[i] = suf[i + 1] + a[i].v;

	s64 res = (s64)(a[n].u - a[1].u) * (suf[1].v - suf[1].u);
	for (int i = 1; i < n; ++i)
	{
		int x1 = min(a[1].u, suf[i + 1].u);
		int x2 = max(a[i].u, suf[i + 1].v);
		int y1 = min(a[i + 1].u, pre[i].u);
		int y2 = max(a[n].u, pre[i].v);
		res = min(res, (s64)(x2 - x1) * (y2 - y1));
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;

const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
struct edge{int to,cost;};

struct State{
    int d,m,n;
    bool operator<( const State& right ) const {
        return d > right.d;
    }
};

int d[1<<6][108];
int cake[6];
int m,n,k,di;

int str2index(string& str){
    if(str[0]=='H'){
        return 0;
    }else if(str[0]=='D'){
        return 1;
    }else if(str[0]=='C'){
        return (int)(str[1]-'1'+2);
    }else{
        int p = 1, ret = 0;
        for(int i=str.size()-1;i>=1;i--){
            ret += (str[i]-'0')*p;
            p *=10;
        }
        return ret+1+m;
    }
}

int main(){
    while(1){
        scanf("%d%d%d%d",&m,&n,&k,&di);
        if(!n)break;

        vector<vector<edge> > g(n+m+2);
        for(int i=0;i<m;i++){
            scanf("%d",&cake[i]);
        }
        for(int i=0;i<di;i++){
            string a,b;
            int c;
            cin >> a >> b >> c;
            int a_i = str2index(a), b_i = str2index(b);
            g[a_i].push_back((edge){b_i,c});
            g[b_i].push_back((edge){a_i,c});
        }

        for(int i=0;i<(1<<m);i++){
            for(int j=0;j<n+m+2;j++){
                d[i][j] = INF;
            }
        }


        d[(1<<m)-1][0] = 0;
        priority_queue<State> que;
        que.push((State){0,(1<<m)-1,0});

        while(que.size()){
            State p = que.top(); que.pop();
            //printf("p.d=%d p.m=%d p.n=%d\n",p.d,p.m,p.n);
            if(d[p.m][p.n] < p.d) continue;
            for(int i=0;i<g[p.n].size();i++){
                int next_d = p.d+g[p.n][i].cost*k;
                if(2<=g[p.n][i].to&&g[p.n][i].to<m+2){
                    int m_i = g[p.n][i].to - 2;
                    if((p.m>>m_i)&1){
                        next_d -= cake[m_i];
                        int next_m = p.m^(1<<m_i);
                        if(next_d < d[next_m][g[p.n][i].to]){
                            d[next_m][g[p.n][i].to] = next_d;
                            que.push((State){next_d,next_m,g[p.n][i].to});
                        }
                    }
                }else{
                    if(next_d < d[p.m][g[p.n][i].to]){
                        d[p.m][g[p.n][i].to] = next_d;
                        que.push((State){next_d,p.m,g[p.n][i].to});
                    }
                }
            }
        }

        int ans = INF;
        for(int i=(1<<m)-1;i>=0;i--) ans = min(ans, d[i][1]);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1404
#include<bits/stdc++.h>
#define LL long long
#define inf 1e18 
#define maxn 100050
using namespace std;
priority_queue<int,vector<int>,greater<int> >q1;
priority_queue<int,vector<int>,less<int> >q2;
int a[maxn*3];
LL suml[maxn*3],sumr[maxn*3];
int main(){
//	freopen("input.txt","r",stdin);
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=3*n;i++) cin>>a[i];
	LL sum=0;
	fill(suml+1,suml+1+3*n,-inf);
	fill(sumr+1,sumr+1+3*n,inf);
	for(int i=1;i<=3*n;i++){
		sum+=(LL)a[i];
		q1.push(a[i]);
		if(i>n){
			int t=q1.top();
			q1.pop();
			sum-=(LL)t;
		}
		if(i>=n) suml[i]=sum;
	}
	sum=0;
	for(int i=3*n;i>=1;i--){
		sum+=(LL)a[i];
		q2.push(a[i]);
		if(i<=2*n){
			int t=q2.top();
			q2.pop();
			sum-=(LL)t;
		}
		if(i<=2*n+1) sumr[i]=sum;
	}
	LL ans=-inf;
//	for(int i=1;i<=3*n;i++) cout<<suml[i]<<" "; cout<<endl;
//	for(int i=1;i<=3*n;i++) cout<<sumr[i]<<" "; cout<<endl;
	for(int i=1;i<=3*n-1;i++) ans=max(ans,suml[i]-sumr[i+1]);
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 7288
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    vector<int> vec(n);
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        vec[i] = x;
    }
    sort(vec.begin(), vec.end());
    int sum = 0;
    for(int i = 0; i < k; i++){
        sum += vec[i];
    }
    cout << sum;
}









Measured memory_bytes: 3624
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long r = sc.nextLong(), D = sc.nextLong(),x = sc.nextLong();
		for(int i = 0; i < 10; i++) {
			long sx = r*x - D;
			System.out.println(sx);
			x = sx;
		}
	}
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b

const long long int INF=1000000000;

signed main(){
	ll n,k,s; cin>>n>>k>>s;
	vl ans(n);
	if(s==INF){
		rep(i,0,k)ans[i]=INF;
		rep(i,k,n)ans[i]=1;
	}
	else{
		rep(i,0,k)ans[i]=s;
		rep(i,k,n)ans[i]=INF;
	}
	for(auto c:ans)cout<<c<<" ";
	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 4036
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) < (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[8] = { //移動
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL

struct Edge {
	int from, to;
	ll w;
};
typedef vector<vector<Edge>> Graph;

#define chmax(a,b) ((a) = max(a,b))

signed main(void) {
	ll n, lim;
	cin >> n >> lim;
	vector<ll> w(n),v(n);


	REP(i, n) {
		cin >> w[i] >> v[i];
	}

	ll dp[101][200001] = {};

	REP(i, n)
	{
		REP(j, lim + 1) {
			chmax(dp[i][j + 1], dp[i][j]);
			chmax(dp[i + 1][j], dp[i][j]);
			chmax(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
		}
	}

	cout << dp[n][lim] << endl;

	return 0;
}



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

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define int long long 

using namespace std;

int32_t main()
{
	fio;
	int n,m;
	cin>>n>>m;
	int *a=new int[n];
	int sum=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}

	int cnt=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]>=sum/(4.0*m))
		{
			cnt++;
		}
	}

	if(cnt>=m)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int d,n,m,k;
	int mise[1000000];
	long long ans;
	while(cin>>d,d){
		cin>>n>>m;
		mise[0] = 0;
		ans = 0;
		for(int i=1; i<n; i++)cin>>mise[i];
		sort(mise,mise+n);
		for(int i=0; i<m; i++){
			cin>>k;
			int left = 0;
			int right = n-1;
			int flag = 0;
			int diff;
			while(left<right){
				diff = (left+right)/2;
				if      ( mise[diff]<k ){
					if( diff == left )break;
					left = diff;
				}else if( mise[diff]>k ){
					right = diff;
				}else{
					flag = 1; break;
				}
			}
			//printf("i_%d,  k_%d, mise[%d]=%d\n",i,k,diff,mise[diff]);
			if( !flag ){
				if( diff==n-2 ){
					//puts("***");
					if( mise[diff+1]<k ){
						//puts("+++");
						diff++;
						ans += min( abs(k-mise[diff]),
										abs(d-k) );
					}else{
						ans += min( abs(k-mise[diff]),
										abs(mise[diff+1]-k) );
					}
				}else{
					ans += min( abs(k-mise[diff]),
									abs(mise[diff+1]-k) );
				}
			}
		}
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1264
#include <iostream>
#include <vector>
#include <map>

class BinaryIndexedTree
{
private:
    std::vector<int> vals;
    int n;
public:
    BinaryIndexedTree(int n_)
        : vals(n_, 0), n(n_) { }

    void add(int a, int w)
    {
        for (int x = a; x <= n; x += x & -x) {
            vals[x - 1] += w;
        }
    }

    int sum(int a) const
    {
        int ret = 0;
        for (int x = a; x > 0; x -= x & -x) {
            ret += vals[x - 1];
        }
        return ret;
    }
};

class SnLine
{
private:
    struct ProdRange
    {
        ProdRange() { l = r = 0; }
        ProdRange(int l_, int r_) { l = l_; r = r_; }
        int l, r;
    };

    static ProdRange makeProdRange(int l, int r)
    {
        return ProdRange { l, r };
    }

    std::map< int, std::vector<ProdRange> > prList;

    int numProds;
    int numStops;

public:
    SnLine(int numStops_)
    {
        numStops = numStops_;
        numProds = 0;
    }

    void addProdRange(int l, int r)
    {
        int d = r - l + 1;
        prList[d].emplace_back(l, r);
        ++numProds;
    }

    void solve()
    {
        BinaryIndexedTree bit(numStops);
        
        auto it = prList.begin();
        int numRemainingProds = numProds;

        for (int d = 1; d <= numStops; ++d)
        {
            int r = numRemainingProds;

            if (1 < d)
            {
                for (int a = d; a <= numStops; a += d)
                {
                    r += bit.sum(a);
                }
            }

            std::cout << r << std::endl;

            if (it != prList.end() && it->first == d)
            {
                for (const ProdRange& pr : it->second)
                {
                    bit.add(pr.l, 1);
                    bit.add(pr.r + 1, -1);
                }
                numRemainingProds -= static_cast<int>(it->second.size());
                ++it;
            }
        }
    }
};

int main()
{
    int N, M;
    std::cin >> N >> M;

    SnLine sl(M);

    for (int i = 0; i < N; ++i)
    {
        int l, r;
        std::cin >> l >> r;
        sl.addProdRange(l, r);
    }

    sl.solve();
    return 0;
}


Measured memory_bytes: 11264
#include <vector>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
const int inf = 1012345678;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	vector<vector<int> > G(N);
	for (int i = 0; i < N - 1; ++i) {
		int a, b;
		cin >> a >> b; --a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	vector<int> seq(N, inf);
	vector<int> ans(N);
	function<void(int, int)> dfs = [&](int pos, int pre) {
		int ptr = lower_bound(seq.begin(), seq.end(), A[pos]) - seq.begin();
		int preval = seq[ptr];
		seq[ptr] = A[pos];
		ans[pos] = lower_bound(seq.begin(), seq.end(), inf) - seq.begin();
		for (int i : G[pos]) {
			if (i == pre) continue;
			dfs(i, pos);
		}
		seq[ptr] = preval;
	};
	dfs(0, -1);
	for (int i = 0; i < N; ++i) {
		cout << ans[i] << '\n';
	}
	return 0;
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
ll LCM(int a, int b){
    return a*b/gcd(a,b);
}

int main(void)
{
    int n,m;
    cin>>n>>m;
    cout<<(1900*m+100*(n-m))*pow(2,m)<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr int MOD_TYPE = 1;
constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

#pragma endregion

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

  int n, m;
  cin >> n >> m;
  vector<pair<int, pii>> query;
  rep(i, m)
  {
    int a, b;
    cin >> a >> b;
    query.push_back(MP(b, MP(1, i)));
    query.push_back(MP(a, MP(2, i)));
  }
  sort(all(query));
  bool cut[100010] = {};
  int cnt = 0;
  vector<int> stock;
  for (auto q : query)
  {
    int type = q.second.first;
    int num = q.second.second;
    int pos = q.first;
    if (type == 2)
    {
      stock.push_back(num);
    }
    else
    {
      if (cut[num])
        continue;
      for (auto vi : stock)
      {
        cut[vi] = true;
      }
      cnt++;
      stock.clear();
    }
  }
  cout << cnt << endl;
  return 0;
}


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

int main() {
    string S;
    cin >> S;
    int count = S.size();
    string answer;
    for (int i = 0; i < count; i++)
    {
        if(S.at(i) == '0' )
        answer += '0';
        else if( S.at(i) == '1'){
            answer += "1";
        }
        else if(S.at(i) == 'B' ){
            if(answer.empty()){
                continue;
            }
            else{
                answer.pop_back();
            }
        }
    }
    cout << answer << endl;
    
    

}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <list>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <iomanip>
#define INF 2147483647
 
using namespace std;

bool isprime(int x)
{
    if (x == 2) return (true);
    if (x <= 1 || x % 2 == 0) return (false);
 
    for (int i = 3; i <= sqrt(x) + 1; i += 2) {
        if (x % i == 0) return (false);
    }
    return (true);
}

int main(void)
{
	int n;
	
	cin >> n;

	int tmp = n;

	cout << n << ":";

	if (isprime(n)) {
		cout << " " << n << endl;
		return (0);
	}

	for (int i = 2; i <= n; i++) {
		if (tmp == 1) break;
		if (isprime(i)) {
			if (tmp % i == 0) {
				cout << " " << i;
				tmp /= i;
				i--;
			} 
		}
	}
	cout << endl;

	return (0);
}

Measured memory_bytes: 1164
#include <iostream> 
#include <algorithm> 
#include <vector> 
 
#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,x; 
	while(cin >> n >> x) 
	{ 
		if(n == 0 && x == 0) break; 
		 
		int count = 0; 
		REP(i,1,n-1) 
		{ 
			REP(j,i+1,n) 
			{ 
				REP(k,j+1,n+1) 
				{ 
					if(i+j+k == x) count++; 
				} 
			} 
		} 
		 
		cout << count << endl;
	} 
	return 0; 
} 
 


Measured memory_bytes: 3108
N=int(input())
W=list(map(int,input().split()))
s=sum(W)
i=0
s1=0
s2=0
while s1<=s//2:
    s1+=W[i]
    i+=1
s11=s1
s21=s-s11
s12=s1-W[i-1]
s22=s-s12
aws=min(abs(s11-s21),abs(s12-s22))
print(aws)



Measured memory_bytes: 3060
n,y=[int(i) for i in input().split()]
y //= 1000
for i in range(n+1):
  for j in range(n-i+1):
    if 10*i+5*j+(n-i-j)==y:
      print(i,j,n-i-j)
      exit(0)
print(-1,-1,-1)

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(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);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    // char ;
    ll n,ans=0;
    scanf("%lld",&n);
    // ll [n];
    while(n>11){
        ans+=n/11*2;
        n%=11;
    }
    if(n>6){
        ans+=2;
    }else if(n>0){
        ans++;
    }
    
    
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  ll K; cin >> K;
  int N=50;
  vector<ll> ans(N);
  rep(i,N) ans[i]=i;
  ll add = K/N;
  rep(i,N){
    ans[i]+=add;
    K-=add;
  }
  reverse(all(ans));
  rep(i,K%N) ans[i]++;

  cout << N << endl;
  rep(i,N){
    if(i) cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}


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

using namespace std;

int main()
{
    int k, x;
    cin >> k >> x;
    bool f = false;
    for(int i = -1e5; i <= 1e5; ++i)
        if(abs(i - x) < k){
            if(f)
                cout << " ";
            cout << i;
            f = true;
        }
    cout << endl;
    return 0;
}




Measured memory_bytes: 256
a,b,c,d=map(int,input().split())

if a<=c and b<=d:
    if b-c>0:
        print(b-c)
    else:
        print(0)    
elif a>=c and b>=d:
    if d-a>0:
        print(d-a)
    else:
        print(0)
elif a<=c and b>=d:
    print(d-c)
elif a>=c and b<=d:
    print (b-a)



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

int main(){
    long long int a, b, n;
    cin >> a >> b >> n;
    long long int ans = 0;
    ans = max((a*max(n, b-1))/b - a * max(n, b-1)/b , (a*min(n, b-1))/b - a * (min(n, b-1)/b));

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

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> cities[100001];
    for(int i = 0; i < m; i++)
    {
        int p, y;
        cin >> p >>y;
        cities[p].push_back(make_pair(y, i));
    }
    pair<int, int> ans[100001];
    for(int i = 1; i <= n; i++)
    {
        sort(cities[i].begin(), cities[i].end());
        //jは県内の順番
        for(int j = 0; j < cities[i].size(); j++)
        {
            ans[cities[i][j].second] = make_pair(i, j+1); 
        }   
    }
    for(int i = 0; i < m; i++)
    {
        printf("%06d%06d\n", ans[i].first, ans[i].second);
    }
    
    return 0;
}

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


int main() {
	vector<long long>a;
	long long n, m, v, p;
	long long x, y, z;
	long long s, ans;
	bool vv;
	ans = 0;
	scanf("%lld %lld %lld %lld", &n, &m, &v, &p);
	f(i, n) {
		scanf("%lld", &x);
		a.push_back(x);
	}
	sort(a.begin(), a.end(), greater<long long>());
	if (p >= v) {
		f(i, n)if ((a[i] + m) >= a[p - 1])ans++;
		printf("%lld\n", ans);
		return 0;
	}
	long long l, r, mid;
	l = p - 1;
	r = n;
	while ((l + 1) < r) {
		mid = (l + r) / 2;
		s = 0;
		x = a[mid] + m;
		if (a[p - 1] > x)r = mid;
		else {
			for (int i = p - 1; i < n; i++) {
				if(i!=mid)s += min(x - a[i], m);
			}
			if (s >= ((v - p)*m))l = mid;
			else r = mid;
		}
	}
	ans = l + 1;
	printf("%lld\n", ans);


	return 0;
}

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

int main(){
  string S;
  cin >> S;
  string a[3][3][3][3];
  string ans="NO";
  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      for(int k=0;k<2;k++){
        for(int l=0;l<2;l++){
          string q="";
          if(i){q+='A';}
          q+="KIH";
          if(j){q+='A';}
          q+='B';
          if(k){q+='A';}
          q+='R';
          if(l){q+='A';}
          a[i][j][k][l]=q;
          if(S==q){ans="YES";}
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;

const int MOD = 1e9+7;
int a[200005], b[200005];
int c[8005][4005];
int d[8005][4005];

void add(int &x, int v) {
  if ((x += v) >= MOD) x -= MOD;
}

int main() {
  int n, MAXC = 0, MAXA = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &a[i], &b[i]);
    b[i] += a[i];
    MAXA = max(MAXA, a[i]);
    MAXC = max(MAXC, b[i]);
    c[b[i]][a[i]]++;
  }
  for (int i = MAXC; i > 0; i--) 
    for (int j = MAXA; j > 0; j--) {
      add(c[i-1][j], c[i][j]);
      if (j) add(c[i-1][j-1], c[i][j]);
      c[i][j] = 0;
    }
  for (int i = 0; i <= MAXA; i++) {
    //for (int j = 0; j <= MAXA; j++) add(d[0][i + j], c[0][i] * 1LL * c[0][j] % MOD);
    for (int j = i; j <= MAXC; j++) add(d[j][i], (c[0][i] * 1LL * c[j][0]) % MOD);
  }
  for (int i = 1; i <= MAXC; i++) {
    for (int j = 0; j <= MAXA && j <= i; j++) add(d[i][j], c[i][0] * 1LL * c[0][j] % MOD);
    for (int j = 1; j <= MAXC; j++) add(d[i + j][0], (c[i][0] * 1LL * c[j][0]) % MOD);
  }
  for (int i = 0; i < n; i++) add(d[2*b[i]][2*a[i]], (MOD-1));
  for (int i = 2*MAXC; i > 0; i--)
    for (int j = 2*MAXA; j >= 0; j--) {
      add(d[i-1][j], d[i][j]);
      if(j) add(d[i-1][j-1], d[i][j]);
    }
  
  printf("%d\n", (int)((d[0][0] * 1LL * (MOD/2+1)) % MOD));
  return 0;
}


Measured memory_bytes: 174208
t, h = 0, 0

gets.to_i.times do
  cards = gets.split
  if cards.uniq.size == 1
    t += 1
    h += 1
    next
  end
  judge = cards.sort
  judge[1] == cards[1] ? h += 3 : t += 3
end

puts "#{t} #{h}"

Measured memory_bytes: 8764
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [i64; n-1]
    };

    let mut buf = vec![0; n];

    for a in a {
        buf[(a - 1) as usize] += 1
    }

    for buf_iter in buf.iter() {
        println!("{}", buf_iter)
    }
}


Measured memory_bytes: 5512
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int NIL = -1;
const int MAX = 10000;
const int MOD = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int n;
    cin >> n;
    vector<pii> v(n);
    for (pii &p : v) {
        int a, b;
        cin >> a >> b;
        p = pii(a, b);
    }
    sort(v.rbegin(), v.rend());
    cout << v[0].first + v[0].second << endl;

}


Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
const int MAX_N=100010;
typedef long long ll;

vector<int> G[200200];
bool used[200200];

int main(){
    int N; cin >> N;
    for(int i=0; i<N; i++){
        int x, y; cin >> x >> y;
        x--; y--; y+=MAX_N;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    //じゅんびおけ

    ll num=0;

    for(int i=0; i<2*MAX_N; i++){
        if(used[i]) continue;
        queue<int> que;
        que.push(i);
//        used[i]=true;
        ll numx=0, numy=0;
        while(!que.empty()){
            int v=que.front(); que.pop(); used[v]=true;
            if(v<MAX_N) numx++; else numy++;
            for(auto x : G[v]){
                if(!used[x]) {
                    que.push(x);
                    used[x]=true;
                }
            }
        }
        num +=numx*numy;
    }

    cout << num-(ll)N << endl;
}

Measured memory_bytes: 8320
#include <iostream>

using namespace std;

typedef long long ll;

#define MAX_N 100000

int N;
ll K;
int Q;
int scores[MAX_N];

int main() {
  cin >> N >> K >> Q;
  for(int i=0; i<Q; i++){
    int A;
    cin >> A;
    scores[A-1] ++;
  }

  for(int i=0; i<N; i++){
    if(Q - scores[i] >= K) {
      cout << "No" << endl;
    }else {
      cout << "Yes" << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;

template<typename T>
struct LazySegmentTree{
private:
    int n;
    vector<T> node,lazy;
public:
    T SUP=0; /* 初期値　*/
    T merge(T x,T y){
        return min(x,y);
    }
    LazySegmentTree(vector<T> v){
        int sz=(int)v.size();
        n=1; while(n<sz) n*=2;
        node.resize(2*n-1);
        lazy.resize(2*n-1,0);
        for(int i=0;i<sz;i++) node[i+n-1]=v[i];
        for(int i=n-2;i>=0;i--){
            node[i]=merge(node[2*i+1],node[2*i+2]);
        }
    }
    void eval(int idx,int l,int r){
        if(lazy[idx]!=0){
            node[idx]+=lazy[idx];
            if(r-l>1){
                /* node[idx]からの伝播  */
                lazy[2*idx+1]+=lazy[idx];
                lazy[2*idx+2]+=lazy[idx];
                
            }
            lazy[idx]=0;
        }
    }
    void update(int a,int b,T x,int idx=0,int l=0,int r=-1){
        if(r<0) r=n;
        eval(idx,l,r);
        if(b<=l||r<=a) return;
        if(a<=l&&r<=b){
            lazy[idx]+=x;
            eval(idx,l,r);
        }else{
            update(a,b,x,2*idx+1,l,(l+r)/2);
            update(a,b,x,2*idx+2,(l+r)/2,r);
            node[idx]=merge(node[2*idx+1],node[2*idx+2]);
        }
    }
    T query(int a,int b,int idx=0,int l=0,int r=-1){
        if(r<0) r=n;
        if(b<=l || r<=a) return 1e15;
        eval(idx,l,r);
        if(a<=l && r<=b) return node[idx];
        T vl = query(a,b,2*idx+1,l,(l+r)/2);
        T vr = query(a,b,2*idx+2,(l+r)/2,r);
        return merge(vl,vr);
    };
};



signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n,q; cin >> n >> q;
    vector<ll> v(n,0);
    LazySegmentTree<ll> lsg(v);
    rep(i,q){
        int x; cin >> x;
        if(x==0){
            int s,t,y; cin >> s >> t >> y;
            t++;
            lsg.update(s,t,y);
        }else{
            int s,t; cin >> s >> t;
            t++;
            cout << lsg.query(s,t) << "\n";
        }
    }

    
}



Measured memory_bytes: 8696
#include<iostream>
using namespace std;
int main()
{
	int n,i,d;
	string s;
	cin>>n>>s;
 
	if(n%2!=0)
		cout<<"No"<<endl;
	else
	{
		d = n/2;
		bool ok = true;
 
		for(i=0;i<d;i++)
		{
			if(s[i]!=s[i+d])
			{
				ok = false;
				break;
			}
		}
 
		if(ok)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define pii 3.14
#define mod (ll)(998244353)
#define inf (ll)(1e18)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define pi pair<int,int>
#define N (ll)(2e5+5)

void solve()
{
    int x,y;
    cin>>x>>y;

    if(y%2==0 && 2*x<=y && y<=4*x)
        cout<<"Yes";
    else
        cout<<"No";
}

int main()
{
    fio;
    ll tc = 1;
    //cin>>tc;
    while(tc--)
    {
        solve();
    }
}


Measured memory_bytes: 3664
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <string>
using namespace std;

typedef long long ll;
ll a[200001];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(NULL);

	ll n, k; cin >> n >> k;
	ll Max = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i]; 
		Max = max(Max, a[i]);
	}
	ll l = 1;
	ll r = Max;
	while (l <= r) {
		ll mid = (l + r) / (ll)2;
		ll tmp = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] <= mid)continue;
			tmp += (a[i] / mid);
			if (a[i] % mid != 0)tmp += 1;
			tmp -= 1;
		}
		if (tmp <= k) {
			r = mid - 1;
		}
		else l = mid + 1;
	}

	cout << l << '\n';



}

Measured memory_bytes: 4700
n=int(input())
h=list(map(int,input().split()))
hm=max(h)
s=['']*hm
for k in range(1,hm+1):
  for i in range(n):
    if h[i]>=k:
      s[k-1]+='#'
    else:
      s[k-1]+=' '

#print(s)
ans=0
for k in range(hm):
  ans+=len(list(s[k].split()))
print(ans)


Measured memory_bytes: 38768
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

point = {"r": p, "s": r, "p": s}

ans = 0
for start in range(k):
    prev = "nil"
    for e in t[start::k]:
        if e != prev:
            ans += point[e]
            prev = e
        else:
            prev = "nil"

print(ans)


Measured memory_bytes: 3316
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	
	S := ScanText(scanner)
	
	var ans string
	if strings.Contains(S, "N") && !strings.Contains(S, "S") {
	    ans = "No"
	}
	if strings.Contains(S, "S") && !strings.Contains(S, "N") {
	    ans = "No"
	}
	if strings.Contains(S, "E") && !strings.Contains(S, "W") {
	    ans = "No"
	}
	if strings.Contains(S, "W") && !strings.Contains(S, "E") {
	    ans = "No"
	}
	if ans != "No" {
	    ans = "Yes"
	}
	
	fmt.Println(ans)
}

func ScanInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func ScanFloat64(scanner *bufio.Scanner) float64 {
	scanner.Scan()
	f, e := strconv.ParseFloat(scanner.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func ScanText(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func Max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Abs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define first fst
#define second scd

#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long


signed main(){
  int n;
  cin>>n;
  int cnt=1,a=1;
  while(n>a){
    cnt++;
    a+=cnt;
  }
  for(int i=cnt;i>=1;i--){
    if(n>=i){
      cout<<i<<endl;
      n-=i;
      //cout<<n<<endl;
    }
  }
    

  return 0;
}











Measured memory_bytes: 256
# python3だとTLE,pypy3だとAC
def main():
    s = input()
    t = input()
    dp = [[0 for _ in range(len(t)+1)] for _ in range(len(s)+1)]
    for i, cs in enumerate(s, start=1):
        for j, ct in enumerate(t, start=1):
            if cs == ct:
                dp[i][j] = dp[i-1][j-1] + 1
            else:
                dp[i][j] = max(dp[i-1][j], dp[i][j-1])
    ans = ""
    i = len(s)
    j = len(t)
    while i > 0 and j > 0:
        if dp[i][j] == dp[i-1][j]:
            i -= 1
        elif dp[i][j] == dp[i][j-1]:
            j -= 1
        else:
            i -= 1
            j -= 1
            ans = s[i] + ans

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 119900