akhauriyash/Code-Regression huggingface dataset:
// cities to vapori-
// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz // math is your friend
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define sz(x) int(x.size())
#define fill(x,v) memset(x,v,sizeof(x))
#define REP(i,a,b) for(int i = int(a); i < int(b); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int h,w,k;
int tab[16][1024];

int go(vector<int> vec){
	int ans = 0;
	vector<int> now(sz(vec),0);
	for(int i = 0; i < w; ++i){
		int ptr = 0;
		bool ok = true;
		for(int j = 0; j < sz(vec); ++j){
			while(ptr < vec[j]) now[j] += tab[ptr][i], ptr++;
			ok = ok && now[j] <= k;
		}
		if(!ok){
			ans++;
			ok = true;
			ptr = 0;
			for(int j = 0; j < sz(vec); ++j){
				now[j] = 0;
				while(ptr < vec[j]) now[j] += tab[ptr][i], ptr++;
				ok = ok && now[j] <= k;
			}
			if(!ok) return 1e9;
		}
	}
	return ans;
}

int main(){

	fastio;
	cin >> h >> w >> k;
	vector<string> cad(h);
	REP(i,0,h) cin >> cad[i];
	REP(i,0,h) REP(j,0,w) tab[i][j] = (cad[i][j] == '1');

	vector<int> cut;
	for(int i = 1; i < h; ++i) cut.pb(i);

	int ans = 1e9;
	for(int i = 0; i < (1<<sz(cut)); ++i){
		vector<int> vec;
		for(int j = 0; j < sz(cut); ++j)
			if(i&(1<<j)) vec.pb(cut[j]);
		vec.pb(h);
		ans = min(ans,go(vec)+__builtin_popcount(i));
	}

	cout << ans << endl;

	return 0;
}


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

#define ll long long int
ll const mod = 1e9 + 7;

ll power(ll x, ll y, ll p){ //x^y % p
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or equal to p 
    while (y > 0) {
        if (y & 1) // If y is odd, multiply x with result 
        res = (res*x) % p; 
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
}

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n, w;
    cin>>n>>w;
    ll v[n], we[n];
    for(int i=0;i<n;i++)
        cin>>we[i]>>v[i];
    ll dp[n+1][w+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=w;j++)
        {
            if(i==0 || w==0)
                dp[i][j] = 0;
            else if(we[i-1] > j)
                dp[i][j] = dp[i-1][j];
            else
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-we[i-1]]+v[i-1]);
        }
    }
    cout<<dp[n][w];
	// your code goes here
	return 0;
}


Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
    int len=d.size();
    rep(i,len){
        s<<d[i];if(i<len-1) s<<" ";
    }
    return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
    int len=d.size();
    rep(i,len){
        s<<d[i]<<endl;
    }
    return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
    s<<"{ ";
    for(auto itr=v.begin();itr!=v.end();++itr) {
        if (itr!=v.begin()) {s<< ", ";}
        s<<(*itr);
    }
    s<<" }";
    return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
    s<<"{"<<endl;
    for(auto itr=m.begin();itr!=m.end();++itr){
        s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
    }
    s<<"}"<<endl;
    return s;
}

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

struct SegmentTree{
private:
	vector<int> node;
	int n;
    int I=INF;

public:
	SegmentTree(){
		int sz=100010;
		n=1;
		while(n<sz) n*=2;
		rep(i,2*n-1) node.push_back(I);
	}

	void update(int k,int a){
		k+=n-1;
		node[k]=a;
		while(k>0){
			k=(k-1)/2;
			node[k]=min(node[2*k+1],node[2*k+2]);
		}
	}

	int find(int a,int b,int k=0,int l=0,int r=-1){
		if(r<0) r=n;
		if(r<=a || b<=l) return I;
		if(a<=l && r<=b) return node[k];
		else{
			int vl=find(a,b,2*k+1,l,(l+r)/2);
			int vr=find(a,b,2*k+2,(l+r)/2,r);
			return min(vl,vr);
		}
	}
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    string s;
    cin>>s;
    vector<int> dp(n+1,INF);
    dp[n]=0;
    SegmentTree seg;
    seg.update(n,0);
    for(int i=n-1;i>=0;i--){
        if(s[i]=='1') continue;
        chmin(dp[i],seg.find(i+1,min(i+m+1,n+1))+1);
        seg.update(i,dp[i]);
    }
	int now=dp[0],ind=0;
	if(now==INF){
		cout<<-1<<endl;
		return 0;
	}
	rep(i,n+1){
		if(dp[i]==now-1){
			cout<<i-ind<<endl;
			ind=i;
			now--;
		}
	}
}


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

const int MAX = 123456 * 2;

int main(){
  int prime[MAX];
  for(int i = 0; i < MAX; i++) prime[i] = 1;
  prime[0] = 0;
  prime[1] = 0;
  for(int i = 2; i < MAX; i++){
    if(prime[i]){
      for(int j = i * 2; j < MAX; j+=i){
	prime[j] = 0;
      }
    }
  }

  int n;
  while(1){
    cin >> n;
    if(n == 0) break;

    int p = 0;
    for(int i = n+1; i <= 2*n; i++){
      if(prime[i]) p++;
    }

    cout << p << endl;
  }

  return 0;
}

Measured memory_bytes: 2124
import java.util.*

class Scanner(`in`: java.io.InputStream) {
    private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))
    private var tokenizer: StringTokenizer? = null

    fun next(): String {
        if (tokenizer?.hasMoreTokens() != true) {
            tokenizer = StringTokenizer(reader.readLine())
        }
        return tokenizer!!.nextToken()
    }

    fun nextLine(): String {
        return if (tokenizer?.hasMoreTokens() != true) {
            reader.readLine()
        } else tokenizer!!.nextToken("\n")
    }
}

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

////////////////////////////////////////////////////////////////////////

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val W = sc.next().toInt()
        val H = sc.next().toInt()
        val N = sc.next().toInt()
        var sx = 0
        var sy = 0
        var ex = W
        var ey = H
        repeat(N) {
            val x = sc.next().toInt()
            val y = sc.next().toInt()
            when (sc.next().toInt()) {
                1 -> if (sx < x) sx = x
                2 -> if (x < ex) ex = x
                3 -> if (sy < y) sy = y
                4 -> if (y < ey) ey = y
            }
        }
        pw.println(arrayOf(ex - sx, 0).max()!! * arrayOf(ey - sy, 0).max()!!)
    }
}


Measured memory_bytes: 33472
#include<bits/stdc++.h>
using namespace std;
#define Max(a, b) a>b?a:b
int main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    int n, W, i, j;
    cin >> n >> W;
    vector<long> w(n), v(n);
    vector<vector<long>> dp(n + 1, vector<long>(W + 1, 0));
    for (i = 0; i < n; ++i)
        cin >> w[i] >> v[i];
    for (i = 0; i < n; ++i)
        for (j = 1; j <= W; ++j)
            if (w[i] <= j)
                dp[i + 1][j] = Max(v[i] + dp[i][j - w[i]], dp[i][j]);
            else
                dp[i + 1][j] = dp[i][j];
    cout << dp[n][W];
    return 0;
}

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

#define LL long long int
#define mp make_pair
#define FOR(i, n) for(i = 0; i < n; ++i)
typedef vector <int> vi;
typedef vector <LL> vll;
typedef pair<LL, LL> iPair;
const int MOD = 1e9+7;

vector <int> adj[100000];
vector <int> dist(100000, -1);

void dfs(int i)
{
    for(auto x : adj[i])
    {
        if(dist[x] == -1)
            dfs(x);
        dist[i] = max(dist[i], 1 + dist[x]);
    }
}


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

    LL t = 1;
    LL i,j;
    // cin>>t;
    
    while(t--)
    {
        int n, m;
        cin >> n >> m;
        FOR(i, m)
        {
            int u, v;
            cin >> u >>v;
            u--;
            v--;
            adj[u].push_back(v);
            
        }
        
        for(int i = 0; i < n; ++i)
        {
            if(dist[i] == -1) dfs(i);
        }
        // FOR(i, n) cout<<dist[i]<<" ";
        cout<<1+*max_element(dist.begin(), dist.begin() + n);
        
    }

	return 0;
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long int ll;
const int MOD=1000000007;

int main(){
    int n;
    cin>>n;
    vector<ll> a(n+1);
    rep(i,n)cin>>a[i];
    a[n]= 0;
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int l = 0,cnt=0;
    ll ans = 1;
    while(l<n-1&&cnt<2){
        if(a[l]==a[l+1]){
            cnt++;
            ans *= a[l];
            l = l + 2;
        }
        else {;l++;}
    }
    if(cnt<2)cout<<0<<endl;
    else cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{      
    int n;
    cin >> n;
    char a[n+1],b[n+1];
    cin >> a >> b;

    for(int i=0;i<n;i++){
        cout << a[i]; 
        cout << b[i];
    }
    


}
 

Measured memory_bytes: 256
// Millennium
#include <iostream>
using namespace std;

struct Date {
  int year, month, day;

  void Increment() {
    day += 1;
    int day_of_month = (year % 3 != 0 && month % 2 == 0) ? 19 : 20;
    if (day > day_of_month) {
      day = 1;
      month += 1;
      if (month > 10) {
        month = 1;
        year += 1;
      }
    }
  }
};


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

  int n; cin >> n;
  for (int i = 0; i < n; ++i) {
    Date d; cin >> d.year >> d.month >> d.day;
    int ans = 0;
    while (d.year < 1000) {
      d.Increment();
      ++ans;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 900
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
// #include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

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

int main() //input->compute->output
{
        int A, B;
        cin >> A >> B;
        cout << max({A + B, A - B, A * B}) << endl;
        return 0;
}

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

int main(){
    string O,E;
    cin >> O >> E;
    for(int i=0;i<E.size();i++){
        cout<<O[i]<<E[i];
    }
    if(O.size()>E.size()) cout<<O[O.size()-1];
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll factorial(int i) {       //階乗
    if (i == 0) return 1;
    return (factorial(i - 1)) * i;
}

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    // ans += k * (k / a);
    if(a >= k) ans += k;
    else ans += a;
    ans -= max(k - (a + b), 0);
    cout << ans << endl;
}

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

using namespace std;

const int MAXN=2005;
int n,k,q,cnt;
int a[MAXN],b[MAXN],c[MAXN];

struct node{
	int pos,mn,sz,ls,rs;
	unsigned key;
	node(){memset(this,0,sizeof(node));}
	node(int _val):key((unsigned)rand()*rand()),sz(1){
		pos=mn=_val; ls=rs=0;
	}
}d[MAXN];

class Treap{
	public:
		int rt,sz;
		struct dual_rt{
			int lrt,rrt;
			dual_rt(int _lrt=0,int _rrt=0):lrt(_lrt),rrt(_rrt){}
		};
		int new_nd(int val){
			d[++cnt]=node(val);
			return cnt;
		}
		void upd(int u){
			d[u].sz=d[d[u].ls].sz+d[d[u].rs].sz+1;
			d[u].mn=d[u].pos;
			if(c[d[u].mn]>c[d[d[u].ls].mn]) d[u].mn=d[d[u].ls].mn;
			if(c[d[u].mn]>c[d[d[u].rs].mn]) d[u].mn=d[d[u].rs].mn;
		}
		dual_rt split(int u,int val){
			dual_rt ret;
			if(!u) return ret;
			if(val<d[u].pos){
				ret=split(d[u].ls,val);
				d[u].ls=ret.rrt;
				ret.rrt=u;
			}
			else{
				ret=split(d[u].rs,val);
				d[u].rs=ret.lrt;
				ret.lrt=u;
			}
			upd(u);
			return ret;
		}
		int merge(int u,int v){
			if(!u || !v) return u|v;
			if(d[u].key<d[v].key){
				d[u].rs=merge(d[u].rs,v);
				upd(u);
				return u;
			}
			else{
				d[v].ls=merge(u,d[v].ls);
				upd(v);
				return v;
			}
		}
		void clear(){rt=sz=0;}
		void ist(int x){++sz,rt=merge(rt,new_nd(x));}
		int del_mn(){
			int pos=d[rt].mn;
			dual_rt x=split(rt,pos);
			dual_rt y=split(x.lrt,pos-1);
			rt=merge(y.lrt,x.rrt);
			--sz;
			return c[pos];
		}
}T[MAXN];

struct data{
	int id;
	data(int _id=0):id(_id){};
	bool operator <(const data &that)const{
		return c[d[T[id].rt].mn]<c[d[T[that.id].rt].mn] || c[d[T[id].rt].mn]==c[d[T[that.id].rt].mn] && id<that.id;
	}
};

int main(){
	srand((size_t)new(char));
	scanf("%d%d%d",&n,&k,&q);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(b+1,b+n+1);
	int tot=unique(b+1,b+n+1)-b-1;
	int ans=INT_MAX;
	for(int i=1,mn;i<=tot;++i){
		mn=b[i];
		int now=1;
		cnt=0;
		T[now].clear();
		bool flag=false;
		int _=0;
		c[0]=INT_MAX;
		int __=0;
		for(int j=1;j<=n;++j)
			c[++__]=a[j];
		for(int j=1;j<=__;++j){
			if(c[j]<mn){
				if(flag) T[++now].clear();
			}
			else flag=true,T[now].ist(j);
		}
		set<data> se;
		for(int j=1;j<=now;++j){
			if(T[j].sz>=k) se.insert(data(j));
		}
		int mx=mn;
		for(int j=1;j<=q;++j){
			if(se.empty()){
				mx=INT_MAX;
				break;
			}
			int iter=se.begin()->id;
			se.erase(se.begin());
			mx=T[iter].del_mn();
			if(T[iter].sz>=k) se.insert(iter);
		}
		ans=min(ans,mx-mn);
	}
	printf("%d",ans);
	return 0;
}

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

typedef vector<int> vi;
typedef bitset<16> MASK;
#define ll long long
#define PI 3.14159265359
//#define x first
//#define y second
#define point pair<double,double>
#define clr(x, val)	memset((x), (val), sizeof(x))

//you don't know math, unless you can do math!
int n,m,k;
char grid[7][7];
int ans = 0;

set<int> rows, cols;
void solve(int r, int c){
    if(c == m){
        int cnt = 0;
        for(int i = 0; i < n; i++){
            if(rows.count(i)) continue;
            for(int j = 0; j < m; j++){
                if(cols.count(j)) continue;
                cnt += (grid[i][j] == '#');
            }
        }

        ans+= (cnt == k);
        return;
    }

    if(r != n)
    {
        //taking row r
        rows.insert(r);
        solve(r + 1, c);
        rows.erase(r);

        //leaving
        solve(r + 1, c);
    }
    else
    {
        cols.insert(c);
        solve(r, c + 1);
        cols.erase(c);

        solve(r, c + 1);
    }
}

int main(){
    //freopen("output.txt" , "w" , stdout) ;

    //cin.tie(0);
    //cin.sync_with_stdio(0);

    cin>>n>>m>>k;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            cin>>grid[i][j];

    solve(0,0);
    cout<<ans;
}


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

int main() {
    pair<long long, long long> List[4];
    for(size_t i = 0; i < 4; ++i) {
        cin >> List[i].second;
    }
    List[0].first = 1, List[1].first = 2, List[2].first = 4, List[3].first = 8;
    sort(List, List + 4, [&](auto &a, auto &b){ return a.second * b.first < b.second * a.first; });
    /*
    for(size_t i = 0; i < 4; ++i) {
        cout << List[i].first << " " << List[i].second << endl;
    }
    */
    long long N;
    cin >> N;
    N *= 4LL;
    long long res = 0LL;
    for(int i = 0; i < 4; ++i) {
        long long p = N/List[i].first;
        res += p*List[i].second;
        N -= p*List[i].first;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

class Main {
	static int d;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> ary = new ArrayList<Integer>();
		int x,count;
        count = sc.nextInt();
		for(int i =0; i<count; i++) {
			x = sc.nextInt();
			ary.add(x);
		}

        long max = ary.get(0);
		long min = ary.get(0);
		long sum = 0;

		for (int i = 0; i < ary.size(); i++) {
		    int v = ary.get(i);
		    sum += ary.get(i);
		    if (v > max) {
		        max = v;
		    }
		    if (v < min) {
		        min = v;
		    }
		}
		System.out.println(min +" "+max+" "+sum);

	}
}


Measured memory_bytes: 42580
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  if(n < 2){ cout << 0 << endl; return 0;}
  int a[n];
  for(int i=0; i<n; ++i) cin >> a[i];
  long long ans = 0;
  for(int i=1; i<n; ++i){
    int d = a[i-1] - a[i];
    if(d > 0){
      ans += d;
      a[i] += d;
    }
  }
  cout << ans << endl;
}

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

string divide[4] = {"dream","dreamer","erase","eraser"};

int main(){
  string S;
  cin >> S;
  reverse(S.begin(), S.end());
  for (int i=0;i < 4; i++)
  reverse(divide[i].begin(),divide[i].end());

  bool can = true;
  for (int i=0 ;i< S.size();) {
    bool can2 = false;
    for (int j=0; j< 4;j++) {
      string d = divide[j];
      if (S.substr(i, d.size())==d){
        can2=true;
        i += d.size();
      }
    }
    if (!can2){
      can=false;
      break;
    }
  }
  if (can) cout << "YES" << "\n";
  else cout<< "NO"  << "\n";
}

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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;
const ll mod = 1000000007;

int W;

vector<ll> f2v(9, -1);

ll f2(int w){
    if(w <= 1)return 1;
    if(w == 2)return 2;
    if(f2v[w] != -1)return f2v[w];
    f2v[w] = (f2(w-1)+f2(w-2))%mod;
    return f2v[w];
}

vector<vector<ll>> fv(101, vector<ll>(9, -1));// not 8, -1

ll f(int h, int k){
    if(k<=0 || k>W)return 0;
    ll res;
    if(fv[h][k]!= -1){
        return fv[h][k];
    }
    ll l =  f(h-1, k-1);

    l = ((l*f2(k-2))%mod*f2(W-k))%mod;
    
    ll r = f(h-1, k+1);
    r = ((r * f2(k-1))%mod*f2(W-k-1))%mod;
    res = (l+r)%mod;
    ll mid = ((f(h-1, k)*f2(W-k))%mod*f2(k-1))%mod;
    res = (res+mid)%mod;
    fv[h][k] = res;
    debug(h)debug(k)
    debug(l)
    debug(r)
    debug(mid)
    debug(res)
    return res;
}

int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);

    int H, K;
    cin >> H >> W >> K;
    if(W==1){
        cout << 1 << "\n";
        return 0;
    }
    fv[1][1] = f2(W-1);
    fv[1][2] = f2(W-2)*1;
    for(int i = 3; i < W+1; i++)fv[1][i]=0;
    cout << f(H, K) << "\n";

    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())

prefec = [[] for _ in range(N)]

for i in range(M):
  p,y = map(int,input().split())
  prefec[p-1].append((y,i))

ans = [None]*M

for i,y in enumerate(prefec):
  y.sort()
  for k ,(y,j) in enumerate(y):
    ans[j] = "%06d%06d" %(i+1,k+1)
    
print(*ans,end ='\n')


Measured memory_bytes: 37480
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <math.h>
#include <stdbool.h>
#include <algorithm>
#include <vector>
using namespace std;

class Point {
    public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {}

    Point operator + (Point p) { return Point(x+p.x, y+p.y); }
    Point operator - (Point p) { return Point(x-p.x, y-p.y); }
    Point operator * (double a) { return Point(a*x, a*y); }
    Point operator / (double a) { return Point(x/a, y/a); }

    double abs() {return sqrt(norm()); }
    double norm() {return x*x + y*y; }
};

typedef Point Vector;


double dot(Vector a, Vector b) {
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
    return a.x*b.y - a.y*b.x;
}

bool comp (Point p1, Point p2){   
    return ( p1.y < p2.y ) || ( (p1.y == p2.y) && (p1.x < p2.x) );
}  

int main(){
    #if 0
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
    #endif

    int n;
    cin >> n;

    vector<Point> data(n);
    for(int i=0; i<n; i++){
        cin >> data[i].x >> data[i].y;
    }

    std::sort(data.begin(), data.end(), *comp); //yの値で昇順にsort
    
    vector<Point> left(0);
    vector<Point> right(0);
    Point t0, t1, t2;
    
    //左半分
    left.push_back(data[0]);
    left.push_back(data[1]);

    for(int i = 2; i < n; i++){
        int m = left.size();
        t0 = left[m - 2];
        t1 = left[m - 1];
        t2 = data[i];

        if(cross(t1-t0, t2-t1) <= 0){
            left.push_back(t2);
        }
        else{
            while(cross(t1-t0, t2-t1) > 0){
                left.pop_back();
                m = left.size();
                if(m == 1) break;
                t0 = left[m-2];
                t1 = left[m-1];
            }
            left.push_back(t2);
        }
    }

    //右半分
    right.push_back(data[0]);
    right.push_back(data[1]);

    for(int i = 2; i < n; i++){
        int m = right.size();
        t0 = right[m - 2];
        t1 = right[m - 1];
        t2 = data[i];

        if(cross(t1-t0, t2-t1) >= 0){
            right.push_back(t2);
        }
        else{
            while(cross(t1-t0, t2-t1) < 0){
                right.pop_back();
                m = right.size();
                if(m == 1) break;
                t0 = right[m-2];
                t1 = right[m-1];
            }
            right.push_back(t2);
        }
    }

    cout << left.size() + right.size() - 2 << endl;
    for(int i=0; i<right.size(); i++){
        cout << right[i].x <<" "<<right[i].y<<endl;
    }
    for(int i=left.size()-2; i>0; i--){
        cout << left[i].x <<" "<<left[i].y<<endl;
    }
 
    return 0;
}


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

//using namespace std;

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

  std::ios_base::sync_with_stdio(false);
  std::cin.tie();

  std::string s ;
  std::cin >> s ;

  if(s[2] == s[3] and s[4] == s[5]) {
    std::cout << "Yes\n";
  }

  else std::cout << "No\n";

  return 0;
}


Measured memory_bytes: 256
//*************************************JAI SAI RAM*************************************//
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl '\n'
ll a[300001],q[300001];
ll P=998244353;
void solve()
{
    ll i,j,k,l,m,n,o,r;
    ll ans=0;
    set<ll> se;
    vector<ll> v;
    map<ll,ll> mp;   
    cin>>i>>j>>k;
    cout<<((i+j-1)/j)*k<<endl; 
}
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);
     ll t=1;
   // cin>>t;
    ll o=1;
    while(t--)
    {

        solve();
        o++;
    }
     return 0;
}












































//manpreet.singh orz
//humane orz
//arnavvats orz
//leoamish300 orz
//cipher76 orz
//aug16arpit orz
//aayushindwan orz
//ig_monkey orz
//DeadlyCritic orz
//lucky_21 orz
//sak23 orz
//spookywooky orz
//supahotfire orz
//__FAILURE_orz
//Errichto orz
//tourist orz
//Um_nik orz
//300iq orz
//antontrygub_Oo orz
//boboniu orz
//MikeMirzayanov orz
//MiFaFaOvO orz
// Benq orz
//Radewoosh orz
//AshishGup orz
//Ashishchup orz
//aryanc403 orz
//ma_da_fa_ka orz
// Striver_79 orz
//Love babbar orz
// My Life of ultimate patience and hard work orz!!!!!!!


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, k, x[100000];

int main() {
	cin >> n >> k;
	inc(i, n) { cin >> x[i]; }
	
	int ans = 1e9;
	inc(i, n) {
		int j = i + (k - 1);
		if(j >= n) { continue; }
		
		     if(x[j] < 0) { setmin(ans, -x[i]); }
		else if(0 < x[i]) { setmin(ans,  x[j]); }
		else {
			assert(inII(0, x[i], x[j]));
			setmin(ans, 2 * min(-x[i], x[j]) + max(-x[i], x[j]));
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

vector<int> sieve(int n) {
	vector<int> res(1, 2);
	vector<bool> prime(n, true);
	for(int i = 3; i < n; i += 2) {
		if(prime[i]) {
			res.push_back(i);
			for(long long j = static_cast<long long>(i) * i; j < n; j += i * 2)
				prime[j] = false;
		}
	}

	return res;
}

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

	constexpr int MAX_N = 1120;
	constexpr int MAX_K = 14;

	const vector<int> primes = sieve(MAX_N);

	vector<vector<int>> dp(MAX_N + 1, vector<int>(MAX_K + 1, 0));
	dp[0][0] = 1;

	for(int i = 0; i < static_cast<int>(primes.size()); ++i) {
		for(int j = MAX_N - primes[i]; j >= 0; --j) {
			for(int k = 0; k < MAX_K; ++k) {
				dp[j + primes[i]][k + 1] += dp[j][k];
			}
		}
	}

	for(int n, k; cin >> n >> k && (n | k);) {
		cout << dp[n][k] << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1332
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>
#include <time.h>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

const double PI = 3.14159265358979;
/******変数定義start******/
string s, t;
/*******変数定義end*******/

ll solve(){
    cin >> s >> t;
    ll count = 0;
    bool flag = false;
    for(ll i = s.size()-1; i >= t.size()-1; i--){
        if(!flag && i >= t.size()-1){
            REP(j, t.size()){
                if(s.substr(i-j, 1) == t.substr(t.size()-j-1, 1) || s.substr(i-j, 1) == "?"){
                    count++;
                }else{
                    count = 0;
                    break;
                }
                if(count == t.size()){
                    count = 0;
                    flag = true;
                    s.replace(i-j, t.size(), t);
                    break;
                }
            }
        }else{
            break;
        }
        count = 0;
    }
    REP(i, s.size()){
        if(s.substr(i, 1) == "?"){
            s.replace(i, 1, "a");
        }
    }
    if(flag){
        cout << s << endl;
    }else{
        cout << "UNRESTORABLE" << endl;
    }
    return 0;
}
int main(){

    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */
    return end;
}


Measured memory_bytes: 256
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n,m,k;
int a,b;
class UnionFind {
    private:
        vi par;    // x の親ノード
        vi rank;   // 木の高さ
        vi mem;    // メンバの数
        int siz;             // 集合の個数
    public:
        UnionFind(int n) :
            par(n, -1), rank(n, 0), mem(n, 1), siz(n) {
            REP(i,n) par[i] = i;
        }
    
    int size() { return siz; }

    // 集合の追加
    void makeset() {
        par.pb(par.size());
        rank.pb(0);
        mem.pb(1);
        siz++;
    }

    int find(int x) {
        if (par[x] == x)
            return x;
        else
            return par[x] = find(par[x]);
    }

    int member(int x){
        x = find(x);
        return mem[x];
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;

        if (rank[x] < rank[y]){
            par[x] = y;
            mem[y] += mem[x];
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
            mem[x] += mem[y];
        }
        siz--;
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

vi relate[100000];
map<int,bitset<100000>> kaiwai;

signed main(){

    UnionFind uf = UnionFind(100000);

    I(n); I(m); I(k);
    REP(i,m){
        I(a); I(b);
        a--; b--;
        uf.unite(a,b);
        relate[a].pb(b);
        relate[b].pb(a);
    }
    REP(i,k) {
        I(a); I(b);
        a--; b--;
        relate[a].pb(b);
        relate[b].pb(a);
    }
    REP(i,n) if (uf.member(i) > 1) kaiwai[uf.find(i)].set(i);
    
    REP(i,n){
        bitset<100000> relbit;
        for(auto neigh: relate[i]) relbit.set(neigh);

        cout << (
            uf.member(i) > 1 ? (relbit.flip() & kaiwai[uf.find(i)]).count() - 1 : 0
        ) << " ";
    }
    cout << endl;
}

Measured memory_bytes: 79232
#include <iostream>
#include <string>
#include <memory>
using namespace std;

class tree {
public:
    tree(int v) : val(v), l(nullptr), r(nullptr) {}
    string print() {
        return "(" + (l ? l->print() : "") + ")[" + to_string(val) + "](" + (r ? r->print() : "") + ")";
    }
    tree& operator+(tree const& other) {
        val += other.val;
        if(!l || !other.l) {
            l = nullptr;
        } else {
            *l = *l + *other.l;
        }
        if(!r || !other.r) {
            r = nullptr;
        } else {
            *r = *r + *other.r;
        }
        return *this;
    }
    int val;
    shared_ptr<tree> l, r;
};

int number(string const& s, int& p) {
    int res = 0;
    while(isdigit(s[p])) {
        res *= 10;
        res += s[p] - '0';
        p += 1;
    }
    return res;
}

shared_ptr<tree> parse(string const& s, int& p) {
    shared_ptr<tree> res(new tree(0));
    if(s[p+1] == ')') {
        p += 1;
    } else {
        res->l = parse(s, ++p);
    }
    p += 2;
    res->val = number(s, p);
    p += 1;
    if(s[p+1] != ')') {
        res->r = parse(s, ++p);
        p += 1;
    } else {
        p += 2;
    }
    return res;
}

int main() {
    string s1, s2;
    cin >> s1 >> s2;
    int p = 0;
    auto t1 = parse(s1, p);
    p = 0;
    auto t2 = parse(s2, p);
    cout << (*t1 + *t2).print() << endl;
}


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

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

  ll n, a, b;
  cin >> n >> a >> b;

  if((b-a) % 2 == 0)
  {
    cout << (b-a)/2 << endl;
  }
  else
  {
    ll ans = min(n-b+1, a) + ((b-a-1) / 2);
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(int i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(int i=(a);i<(n);i++)cout<<(arr)[i]<<' ';

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}

int main(){
	fast;
	ll n;
	cin>>n;
	ll a[n];
	scan(a, 0, n);
	sort(a, a+n);
	ld ans = a[0];
	forn(i, 1, n){
		ans+=a[i];
		ans/=2;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3740
#include <stdio.h>
#include <stdlib.h>

struct horieyui {
	int value, count;
};

int cmp_int(const void* x, const void* y) {
	int a = *(const int*)x, b = *(const int*)y;
	return a < b ? -1 : a > b;
}

int cmp_horieyui(const void* x, const void* y) {
	int a = ((const struct horieyui*)x)->count, b = ((const struct horieyui*)y)->count;
	return a < b ? -1 : a > b;
}

int N, K;
int A[271828];

int asumikana;
struct horieyui asanomasumi[271828];

int main(void) {
	int i;
	int toyosakiaki;
	if (scanf("%d%d", &N, &K) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}
	qsort(A, N, sizeof(*A), cmp_int);
	asumikana = 1;
	asanomasumi[0].value = A[0];
	asanomasumi[0].count = 1;
	for (i = 1; i < N; i++) {
		if (A[i] != asanomasumi[asumikana - 1].value) {
			asanomasumi[asumikana].value = A[i];
			asanomasumi[asumikana].count = 0;
			asumikana++;
		}
		asanomasumi[asumikana - 1].count++;
	}
	qsort(asanomasumi, asumikana, sizeof(*asanomasumi), cmp_horieyui);
	toyosakiaki = 0;
	for (i = 0; i < asumikana - K; i++) {
		toyosakiaki += asanomasumi[i].count;
	}
	printf("%d\n", toyosakiaki);
	return 0;
}


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

const int M = 1e9+7;

int mul(int a, int b){
    return (ll)a*b%M;
}

int add(int a, int b){
    return (a+b)%M;
}

int pow(int x, int y){
    int r = 1;
    while(y>0){
        if(y%2) r = mul(r,x);
        x = mul(x,x);
        y/=2;
    }
    return r%M;
}

int inv(int x){
    return pow(x,M-2);
}

int sub(int a, int b){
   a-=b;
   if(a<0) a+=M;
   return a;
}

int main(){
    int n,k;
    cin>>n>>k;
   vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end()); 
    vector<int> fact(2*n+1);
    fact[0] = fact[1] = 1;

    for(int i = 2; i < 2*n; i++){
        fact[i] = mul(fact[i-1],i);
    }
    
    auto bin = [&](int n, int k){
        if(n<k) return 0;
        return mul(fact[n],inv(mul(fact[k],fact[n-k])));
    };
    ll ans = 0;
    for(int i = 0 ; i < n-1; i++){
      int diff = (a[i+1] - a[i])%M;
      int nk = bin(n,k);
      int ak = bin(i+1,k);
      int bk = bin(n-i-1,k);
      int ss = sub(nk,ak);
      int tmp = sub(ss,bk);
      ans+=(mul(tmp,diff))%M;
    }
    cout<<ans%M;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
  int x3 = x2 + y1 - y2, y3 = y2 + x2 - x1;
  int x4 = x1 + x3 - x2, y4 = y1 + y3 - y2;
  cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << '\n';
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<int,int>
#define INT_MAX 2147483647
#define MOD 1000000007
using namespace std;
typedef long long ll;

int n;
void dfs(int i,string s,char x) {
	if (i == n) {
		cout << s << endl;
		return;
	}
	for (int j = 'a'; j <= x+1; j++) {
		char l = max(j, (int)x);
		dfs(i+1, s + char(j),l);
	}
	return;
}

int main(void) {
	cin >> n;
	string s = "a";
	dfs(1, s,'a');
	return 0;
}



Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin>>n;
    vector<ll> ans(n,0);
    rep(i,n-1){
        ll a;cin>>a;
        ans[a-1]++;

    }
    for(ll x:ans){
        cout<<x<<endl;
    }
    return 0;
}

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

using namespace std;

/**************************************************************/

#define int long long
#define tie() ios_base :: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f(i,from,to) for(int i = from ; i <to ; i++)
#define mem(a , v) memset(a , v , sizeof a)
#define all(v) v.begin() , v.end()
#define pb push_back
#define ff first
#define ss second
#define mp make_pair


const int INF = 1e9 + 7;
const int sz = 1e5 + 20;
/***************************************************************/

void solve()
{
    int s= 0 ;
    int n;cin>>n;int a[n];
    f(i,0,n) cin>>a[i];
    f(i,0,n)
    {
        f(j,i+1,n)
        {
                s+=(a[i] * a[j]);
        }
    }
    cout<<s<<endl;
    return;
}

int32_t main()
{
    clock_t st = clock();
    tie();
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    clog<<(long double)((clock() - st)/CLOCKS_PER_SEC)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
long long int n;
long long int a[401];
long long int dp[401][401];
int v[401][401];
long long int sum[401];
long long int solve(long long int s,long long int e)
{
    if(s==e || s>e)
    return  0;
    if(v[s][e]!=0)
    return dp[s][e];
    v[s][e]=1;
    long long int ans=(2e18+10);
    for(int i=s+1;i<=e;i++)
    {
        ans=min(ans,solve(s,i-1)+solve(i,e)+sum[e]-(i==0?0:sum[s-1]));
    }
    return dp[s][e]=ans;
}
int main()
{
    long long int i,j;
    cin>>n;
    for(i=0;i<n;i++)cin>>a[i];
    sum[0]=a[0];
    for(i=1;i<n;i++)
    sum[i]=sum[i-1]+a[i];
    cout<<solve(0,n-1);
}

Measured memory_bytes: 2176
#include"bits/stdc++.h"
using namespace std;
int main(){

    int mx=INT_MIN,mn=INT_MAX;
    int a,n; cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        mx=max(mx,a);
        mn=min(mn,a);
    }
    cout<<mx-mn;
}


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

int main(){
  string S,T;
  cin>>S>>T;
  int N=S.size();
  int count=0;
  for(int i=0;i<N;i++){
    if (S[i]!=T[i]){
      count++;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3912
//B - 1D Reversi: 
//Assunto: 
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    string s;
    int ans = 0;

    cin >> s;
    loop(i, 0, s.size()-1) {
        if(s[i] != s[i+1]) ans++;
    }
    cout << ans <<'\n';
}
    

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
    int A[3];

    //N K入力
    int i;

    while(scanf("%d %d %d",&A[0],&A[1],&A[2])<3);

    //計算処理
    int wa = 0;
    for(i=0;i<3;i++){
        if(A[i]==5||A[i]==7){
            wa=wa+1;
        }
    }
    //最終出力 
    if((wa==3)&&((A[0]+A[1]+A[2])==17)){
        printf("YES");
    }else{
        printf("NO");
    }

    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    int a[n][m],b[m],c[n] = {0};
    
    rep(i,0,n){
        rep(j,0,m){
            cin >> a[i][j];
        }
    }
    
    rep(i,0,m){
        cin >> b[i];
    }
    
    rep(i,0,n){
        rep(j,0,m){
            c[i] += a[i][j]*b[j];
        }
    }
    
    rep(i,0,n){
        cout << c[i] << endl;
    }
    
    return 0;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll S, W;
  IN(S,W);

  if(W>=S){
    OUT("unsafe");
  }else{
    OUT("safe");
  }

  return 0;
}


Measured memory_bytes: 3640
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

ll N, K;
ll p[1000];

signed main(){
    cin >> N >> K;
    rep(i, N) cin >> p[i];
    sort(p, p+N);

    ll ans = 0;
    rep(i, K) ans += p[i];
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define INF 100000000000
#define MAX 200001
#define MOD 1000000007
ll fac[MAX], finv[MAX], inv[MAX];
const int MX = 1000005;
const double PI = acos(-1);

int main(){
    int N, K;
    cin >> N >> K;
    int ans = 0;
    vector<int> p(N);
    for(int i = 0; i < N; i++) cin >> p[i];
    sort(p.begin(), p.end());
    for(int i = 0; i < K; i++) ans += p[i];
    cout << ans << endl;
}

Measured memory_bytes: 3632