akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
int iso_lower(vector<int> V, int x) {
    //ソートされたVの中から、V[i]>=xとなる最小のiを返す.存在しなければVの要素数を返す
    int s = V.size();
    //V.push_back(INF);
    int l = -1;
    int r = s;  //rが常にtrue
    while(r - l > 1) {
        int mid = (l + r) / 2;
        if(V[mid] < x)
            l = mid;
        else
            r = mid;
    }
    return r;
}
signed main(){
    string S;cin>>S;
    int n=S.size();
    if(S[n-1]=='s'){
        S+="es";
    }else{
        S+='s';
    }
    cout<<S<<endl;
    
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		int a[]=new int[4];
		int b[]=new int[4];
		int i,j,hit=0,blow=0;
		while(s.hasNext()){
			for(i=0;i<4;i++){
				a[i]=s.nextInt();
			}
			for(i=0;i<4;i++){
				b[i]=s.nextInt();
			}
			for(i=0;i<4;i++){
				if(a[i]==b[i]){
					hit++;
				}
				else{
					for(j=0;j<4;j++){
						if(b[i]==a[j])
							blow++;
					}//j for
				}//else
			}//i for
			System.out.println(hit+" "+blow);
			hit=0;blow=0;
		}//while
	}
}

Measured memory_bytes: 11000
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
long long INF = 1LL<<60;
int main( ){
    int n;
    cin>>n;
    vi s(n);
    rep(i,0,n)cin>>s[i];
    int q;
    cin>>q;
    int t;;
    int cnt=0;
    rep(i,0,q){
        cin>>t;
        int small,big;
        if(s[0]<=t&&t<=s[n-1]){
            //半開区間で範囲を持つ．
           small=0; big=n;
           while(abs(big-small)>1){
            int mid=(small+big)/2;
            if(s[mid]>=t)big=mid;
            else small=mid;
           }
            if(s[big]==t)cnt++;
        }
        //範囲外
        else
        {
            continue;
        }
    }
    cout<<cnt<<endl;
    return 0;
}





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

int main() {
    int n;
    cin >> n;
  vector<int> p(n);
  for(int i = 0; i < n;i++){
    cin >> p.at(i);
  }
  int c = 0;
  vector<int> vec(3);
  for(int i = 1; i < n-1;i++){
   vec.at(0) = p.at(i-1);
   vec.at(1) = p.at(i);
   vec.at(2) = p.at(i+1);
    sort(vec.begin(), vec.end());
    if(vec.at(1) == p.at(i)) c++;
  }
  cout << c << endl;
         
}

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

#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define sum(n) accumulate((n).begin(), (n).end(), 0)
using namespace std;


int main(){
	int a, num;
	num = 0;
	cin >> a;


	cout << (a/2) * (a - a/2) << endl;
	return 0;
}

Measured memory_bytes: 256
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i

#               arr.append(i)   # こちらにすると素因数分解


            arr.append(i)



    if temp != 1:
        arr.append(temp)

    if arr == []:
        arr.append(n)
    return arr

def euc(a,b):

    while b!=0:
        a,b =b,a%b

    return a


def main():

    A,B=map(int,input().split())
    s =euc(A,B)
    if s==1:
        print(1)
        exit()
    print(len(factorization(s))+1)
if __name__ == "__main__":
    main()


Measured memory_bytes: 63332
use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let (h, w, d): (usize, usize, usize) = parse!(it, 3);
    let mut map = vec![(0, 0); h * w];
    for i in 0..h {
        for j in 0..w {
            let k: usize = parse!(it);
            map[k - 1] = (i, j);
        }
    }
    let mut costs = vec![vec![]; d];
    let abs = |x, y| if x > y { x - y } else { y - x };
    for i in 0..d {
        let mut cur = i;
        let mut cost = 0;
        loop {
            let next = cur + d;
            if next >= h * w {
                break;
            }
            cost += abs(map[next].0, map[cur].0) + abs(map[next].1, map[cur].1);
            costs[i].push(cost);
            cur = next;
        }
    }

    let q: usize = parse!(it);
    for _ in 0..q {
        let (l, r): (usize, usize) = parse!(it, 2);
        let l = l - 1;
        let r = r - 1;
        println!(
            "{}",
            if r < d { 0 } else { costs[l % d][r / d - 1] }
                - if l < d { 0 } else { costs[l % d][l / d - 1] }
        );
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 12668
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 10000000000000000;
const ll mod = 1000000007;
ll iti[12345678], cnt[12345678], cost[4321][4321];
char maze[100][100];
signed main() {
	ll n, m, ans = 0; cin >> n >> m;
	for (int h = 0; h < 100; h++) {
		for (int i = 0; i < 100; i++) {
			maze[h][i] = '.';
		}
	}
	for (int h = 1; h <= n; h++) {
		for (int i = 1; i <= m; i++) {
			cin >> maze[h][i];
		}
	}
	for (int h = 1; h <= n; h++) {
		for (int i = 1; i <= m; i++) {
			ll cnt = 0;
			if (maze[h][i] == '#') { cout << '#'; continue; }
			if (maze[h - 1][i - 1] == '#') { cnt++; }
			if (maze[h - 1][i] == '#') { cnt++; }
			if (maze[h - 1][i + 1] == '#') { cnt++; }
			if (maze[h][i - 1] == '#') { cnt++; }
			if (maze[h][i + 1] == '#') { cnt++; }
			if (maze[h + 1][i - 1] == '#') { cnt++; }
			if (maze[h + 1][i] == '#') { cnt++; }
			if (maze[h + 1][i + 1] == '#') { cnt++; }
			cout << cnt;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

ll powmod(ll a,ll n,ll m) {
    if(n == 0)
        return 1;

    if(n % 2 ==0){
        ll r = powmod(a,n/2,m);
        return r*r % m;
    }

    return a*powmod(a,n-1,m)%m;
}

int main(){

  ll n;
  cin >> n;
  ll c[n];
  for(ll i=0;i<n;i++)cin >> c[i];

  sort(c,c+n);

  ll s=0;
  for(ll i=0;i<n-1;i++){
    ll d=c[i];
    ll a=powmod(2,n+i,mod);
    d*=a;
    d%=mod;

    ll b=0;
    b+=powmod(2,n-i-1,mod);
    ll e=(n-i-1)*powmod(2,n-i-2,mod);
    e%=mod;
    b+=e;
    b%=mod;
    
    b*=d;
    b%=mod;

    s+=b;
    s%=mod;
  }

  ll d=c[n-1];
  d*=powmod(2,2*n-1,mod);
  d%=mod;
  s+=d;
  s%=mod;


  cout << s << endl;

}

Measured memory_bytes: 5164
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<array>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<stack>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int r;
	cin>>r;
	double x=r*2*3.14;
	cout<<fixed<<setprecision(7)<<x;
	return 0;
}

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

void main_()
{
    ll X;
    cin >> X;

    auto ans = static_cast<ll>(ceil((-1 + sqrt(1 + 8 * X)) / 2));
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#define pi 3.14159265358979323846264338327950
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}

int main() {
	int N; std::cin >> N;
	long long i;
	for (i = N; i < 1000000000; ++i)
        if (IsPrime(i) == true) break;
	std::cout << i << std::endl;

	return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

using namespace std;
struct UnionFind
{
  vector< int > data;
 
  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k)
  {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k)
  {
    return (-data[find(k)]);
  }
};
 
struct LowLink
{
  UnionFind uf;
  vector< vector< int > > g;
  vector< int > used, ord, low, parent;
 
  LowLink(size_t v) : g(v), used(v, 0), ord(v), low(v), uf(v), parent(v, -1) {}
 
  virtual void add_edge(int x, int y)
  {
    g[x].push_back(y);
    g[y].push_back(x);
  }
 
  void dfs(int idx, int &k, int par = -1)
  {
    used[idx] = true;
    ord[idx] = k++;
    low[idx] = ord[idx];
 
    for(auto &to : g[idx]) {
      if(!used[to]) {
        dfs(to, k, idx);
        low[idx] = min(low[idx], low[to]);
        parent[to] = idx;
        if(ord[idx] >= low[to]) uf.unite(idx, to);
      } else if(to != par) {
        low[idx] = min(low[idx], ord[to]);
      }
    }
  }
 
  void dfs()
  {
    int k = 0;
    for(int i = 0; i < g.size(); i++) {
      if(used[i]) continue;
      dfs(i, k);
    }
  }
};
 
struct BiConnectedComponents : LowLink
{
  vector< pair< int, int > > edges;
  vector< int > comp;
 
  BiConnectedComponents(size_t v) : LowLink(v), comp(v) {}
 
  void add_edge(int x, int y)
  {
    LowLink::add_edge(x, y);
    edges.push_back(minmax(x, y));
  }
 
  int operator[](int k)
  {
    return (comp[k]);
  }
 
  vector< pair< int, int > > build(vector< vector< int > > &t)
  {
    LowLink::dfs();
    int ptr = 0;
    vector< int > cc(g.size());
    for(int i = 0; i < g.size(); i++) {
      if(i == uf.find(i)) cc[i] = ptr++;
    }
 
    t.resize(ptr);
    for(int i = 0; i < g.size(); i++) {
      comp[i] = cc[uf.find(i)];
    }
    vector< pair< int, int > > vs;
    for(auto &e : edges) {
      int x = comp[e.first], y = comp[e.second];
      if(x == y) continue;
      vs.emplace_back(e.first, e.second);
      t[x].push_back(y);
      t[y].push_back(x);
    }
    sort(begin(vs), end(vs));
    return (vs);
  }
};
 

int n, m;
std::vector<int> w;
std::vector<std::vector<int>> g, dp, tree;
void solve(int v = 0, int par = -1) {
	dp[v][1] = w[v];
	dp[v][0] = 0;
	
	for(auto e : tree[v]) {
		if(e == par) continue; solve(e, v);
		dp[v][1] += dp[e][0];
		dp[v][0] += std::max(dp[e][0], dp[e][1]);
	}
};

int main() {
	cin >> n >> m; g.resize(n);
	BiConnectedComponents bcc(n);
	for(int i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		bcc.add_edge(a, b);
	}
	bcc.build(tree);
	
	w.resize(tree.size(), 0);
	for(int i = 0; i < n; i++) w[bcc[i]]++;
	
	int ans = 0;
	dp.resize(tree.size(), std::vector<int>(2, -1));
	for(int i = 0; i < tree.size(); i++) {
		if(~dp[i][0]) continue; solve(i);
		ans += std::max(dp[i][0], dp[i][1]);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 25028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

struct UnionFind{
    vector<int> par;

    UnionFind(int n) : par(n,-1) { }
    void init(int n) { par.assign(n,-1); }

    int root(int x){
        if(par[x]<0) return x;
        else return par[x]=root(par[x]);
    }

    bool issame(int x,int y){
        return root(x)==root(y);
    }

    bool merge(int x,int y){
        x=root(x);
        y=root(y);
        if(x==y) return false;
        if(par[x]>par[y]) swap(x,y);
        par[x]+=par[y];
        par[y]=x;
        return true;
    }

    int size(int x){
        return -par[root(x)];
    }
};

int main(){
    int n,q;
    cin>>n>>q;
    UnionFind uf(n);

    while(q--){
        int c,x,y;
        cin>>c>>x>>y;
        if(c==0) uf.merge(x,y);
        else{
            if(uf.issame(x,y)) cout<<1<<endl;
            else cout<<0<<endl;
        }
    }

    return 0;
}



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

int main()
{
    //A
    string S, T, U;
    int A, B;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;
    if (S == U)
        A--;
    else
        B--;
    cout << A << " " << B << endl;
    /*B
    string S, V = "";
    cin >> S;
    rep(i, 0, S.length())
    {
        V += "x";
    }
    cout << V << endl;
    /*/
    //C
    /*
    int N;
    cin >> N;
    vector<int> A(N);
    bool flag = false;
    rep(i, 0, N) cin >> A[i];
    sort(A.begin(), A.end());
    rep(i, 1, N)
    {
        if (A[i] == A[i - 1])
        {
            flag = true;
            break;
        }
    }
    if (flag)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;
*/
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void program(); int main() {cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit); program();}
#define int long long
#define endl "\n"
#define all(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pii pair<int,int>

#define N 101
#define K 100007

int a[N],w[K];
int n, k;

void program(){
    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=1;i<=k;i++) for(int j=0;j<n;j++) if(i-a[j]>=0)
        w[i] |= !w[i-a[j]];
    cout<<(w[k]?"First":"Second")<<endl;
}

/*
WA:
-bounds on loops
-truncating
-intialization
-0 vs 1 indexing

TLE:
-might need unordered_set/map
-infinite while loop

Stuck:
-different perspective?
-bruteforce?
-greedy?
-reduce dimensionality with problem contraints?
*/


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
const int  COMMAX = 510000;

long long fac[COMMAX], finv[COMMAX], inv[COMMAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < COMMAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> rank;
  int num;
  UnionFind(int N) : par(N) , rank(N) { //最初は全てが根であるとして初期化
    num = N;
    for(int i = 0; i < N; i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    if(rank[rx] < rank[ry]){
      par[rx] = ry;  
    }else{
      par[ry] = rx;
      if(rank[rx] == rank[ry])rank[rx]++;
    }
    num--;
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
};
vector<pair<int,int>> edge;
int main(){
  int n,m;
  cin >> n >> m;
  rep(i,0,m){
    int a,b;
    cin >> a >> b;
    edge.push_back(make_pair(a-1,b-1));
  }
  int res = 0;
  rep(i,0,edge.size()){
    UnionFind uf(n);
    rep(j,0,edge.size()){
      if(i==j)continue;
      uf.unite(edge[j].first,edge[j].second);
    }
    if(uf.num != 1)res++;
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <iterator>
#include <climits>
#include <unordered_map>
#include <queue>


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

inline int ctoi(char c) {
    return (int)(c -'0');
}

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

int main() {
    ll n,t;
    cin >> n >> t;
    vector<P> vec(n);
    rep(i, n) {
        cin >> vec[i].first >> vec[i].second;
    }

    ll min_cost = 10000000;
    rep(i, n) {
        if (t < vec[i].second) {
            continue;
        }
        ll cc = vec[i].first;
        if (cc < min_cost) {
            min_cost = cc;
        }
    }
    if (min_cost > 1000000) {
        cout << "TLE" << endl;
    } else {
        cout << min_cost << endl;
    }
    return 0;
}

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

int main(void){
    cin >> x >> y;
    for(int i = 0; i <= x; i++){
        int j = x-i;
        if(2*i+4*j == y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#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 all(x) x.begin(), x.end()
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const ll inf = 1e9;
const int MAX_N = 500;

int main() {
    int n; cin >> n;
    int ans = 0;
    rep(i,n) {
        int x; cin >> x;
        int ct = 0;
        while (x % 2 == 0) {
            x >>= 1;
            ct++;
        }
        ans += ct;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;


namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int c = int.Parse(str[2]);
            int[] d = new int[3];
            d[0] = a;
            d[1] = b;
            d[2] = c;
             Array.Sort(d);
            Console.WriteLine("{0} {1} {2}",d[0],d[1],d[2]);
            

        }
    }
}

Measured memory_bytes: 9316
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int n, m; cin >> n >> m;
    vector<int> h(n);
    rep(i, n) {
        cin >> h[i];
    }
    vector<vector<int>> g(n, vector<int>());
    rep(i, m) {
        int a, b; cin >> a >> b; --a, --b;
        g[a].pb(b);
        g[b].pb(a);
    }
    int ans = 0;
    rep(i, n) {
        bool ok = 1;
        for(int nv: g[i]) {
            if(h[nv] >= h[i]) ok = 0;
        }
        if(ok) ++ ans;
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 8744
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;
	int n = s.length(), m = t.length();
	int p = -1;
	for(int i = n-1; i >= m-1; i--){
		bool unmatch = false;
		for(int j = 0; j < m; j++){
			if(s[i-j] != t[m-1-j] && s[i-j] != '?'){
				unmatch = true;
				continue;
			}
		}
		if(!unmatch){
			p = i-m+1;
			break;
		}
	}
	if(p == -1){
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	int q = 0;
	for(int i = 0; i < n; i++){
		if(p <= i && i < p+m){
			cout << t[q];
			q++;
		}
		else{
			if(s[i] == '?') cout << 'a';
			else cout << s[i];
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
//Hey u r far away to know this
#include <bits/stdc++.h>
using namespace std;
#define     ff      	    	first
#define     pb 	         	push_back
#define     ss          		second
#define     ll      	    	long long
#define     MAX  	       	5000
#define     mpi         		map<int, int>
#define     mpll        		map<ll, ll>
#define     pll         		pair<ll, ll>
#define     plld        		pair<ll, double>
#define     SKILLER     		ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     vi          		std::vector<int>
#define     vll         		std::vector<ll>
#define     vs          		std::vector<string>
#define     vvi         		std::vector<std::vector<int>>
#define     vvll        		std::vector<std::vector<ll>>
#define     all(v)      		v.begin(), v.end()
#define     allr(v)      		v.rbegin(), v.rend()
#define     loop(i, a, b) 	for(int i = a; i < b; i++)
#define 	  debug(x) 		cout << x <<" " <<"\n";
#define 	  debug1(x, y) 	cout << x << " " << y  << "\n";
#define 	  debug2(x, y, z) 	cout << x << " " << y << " " << z<<"\n";
#define 	  int 			ll
const   int N = 1e6+5, Mod = 1e9 + 7;
int32_t main(){
    	SKILLER;
    
     ll t; t = 1;
     while(t--){
     	ll n, k; cin >> n >> k;
     	map<int, int> mp;
     	int ans = n;
     	for(int i = 0; i <k; i++){
     		int d; cin >> d;
     		while(d--){
     			int x; cin >> x;
     			if(mp[x] == 0){
     				mp[x] = 1;
     				ans--;
     			}
     		}
     	}
     	cout << ans;
     }
    	return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int h, w; cin >> h >> w;
	int ans = INF;
	int sx, sy, sz;
	rep(i, w - 1) {
		sx = (i + 1)*h;
		sy = (h / 2)*(w - i - 1);
		sz = ((h + 1) / 2)*(w - i - 1);
		ans = min(ans, max({ sx,sy,sz }) - min({ sx,sy,sz }));
	}
	swap(h, w);
	rep(i, w - 1) {
		sx = (i + 1)*h;
		sy = (h / 2)*(w - i - 1);
		sz = ((h + 1) / 2)*(w - i - 1);
		ans = min(ans, max({ sx,sy,sz }) - min({ sx,sy,sz }));
	}
	chmin(ans, min(((w + 2) / 3)*h - (w / 3)*h, ((h + 2) / 3)*w - (h / 3)*w));
	cout << ans << endl;
	return 0;
}

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

int main() {
  int N,i,k=0;
  cin >> N;
  vector<int> a(N);
  for(i=0;i<N;++i)
    cin >> a.at(i);
  i=0;
  do{
    ++k;
    i=a.at(i)-1;
    if(i==1)
      break;
  }while(--N);
  if(N==0)
    cout << -1 << endl;
  else
    cout << k << endl;
    
}


Measured memory_bytes: 3792
function main(){

var seats = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
var groupMembers = [2,5,2,2,2];
var eatTimes = [19,39,25,36,22,42];

var headGroup = -1;
var pastMinutes = 0;
var waitTime = [];

while(waitTime.length < 100){
  // たべおわる
  for(var i = 0; i < seats.length; i++){
    seats[i] = seats[i] == 0 ? 0 : seats[i] - 1;
  }

  // 来店
  if(headGroup == -1 && pastMinutes % 5 == 0){
    headGroup = pastMinutes / 5;
  }

  // ちゃくせき
  while(headGroup != -1){
    var needsSequencialSeats = groupMembers[headGroup % 5];
    var sequencialSeats = 0;
    var startIndex = -1;
    for(var i = 0; i < seats.length; i++){
      sequencialSeats = seats[i] == 0 ? sequencialSeats + 1 : 0;

      if(sequencialSeats == needsSequencialSeats){
        startIndex = i - (needsSequencialSeats - 1);
        break;
      }
    }

    if(startIndex != -1){
      // すわれたみたい
      waitTime[headGroup] = pastMinutes - (headGroup * 5);
      for(var i = startIndex; i < (needsSequencialSeats + startIndex); i++){
        seats[i] = eatTimes[headGroup % 6];
      }
      
      headGroup = (((headGroup + 1) * 5) <= pastMinutes) ? headGroup + 1 : -1;
    }else{
      // すわれなかったみたい
      break;
    }

  }

  pastMinutes++;

}

for(var i = 0; i < (input.length - 1); i++){
  console.log(waitTime[parseInt(input[i], 10)]);
}

}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

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

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


Measured memory_bytes: 3124
n,m=map(int,input().split())
p=[0 for i in range(n)]
penalty=[0 for i in range(n)]
acc=0
for i in range(m):
  a,b=input().split()
  a=int(a)
  a-=1

  if (p[a]==0 or p[a]=='WA') and b=='AC':
    acc+=1
    p[a]='AC'
  elif (p[a]==0 or p[a]=='WA') and b=='WA':
    penalty[a]+=1
    p[a]='WA'

for i in range(n):
  if p[i] == 'WA' or p[i] == 0:
    penalty[i]=0

print(acc,sum(penalty))

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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, K;
int V[55];
signed main() {
    cin >> N >> K;
    rep(i, N) { cin >> V[i]; }
    int ans = 0;
    for (int l = 0; l <= N; l++) {
        for (int r = 0; r <= N; r++) {
            if (l + r > K) { continue; }
            deque<int> D;
            rep(i, N) { D.push_back(V[i]); }
            vint get;
            rep(i, l) { get.push_back(D.front()), D.pop_front(); }
            rep(i, r) {
                if (D.empty()) { break; }
                get.push_back(D.back()), D.pop_back();
            }
            sort(all(get));
            int cur = 0;
            rep(i, get.size()) { cur += get[i]; }
            rep(i, min((int) get.size(), K - l - r)) { if (get[i] < 0) { cur -= get[i]; }}
            chmax(ans, cur);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  int N,M;
  cin>>N>>M;
  ll CNT[N],A[M],B[M];
  REP(i,N) CNT[i]=0;
  REP(i,M){
    cin>>A[i]>>B[i];
    CNT[A[i]-1]++;
    CNT[B[i]-1]++;
  }
  
  bool CAN=true;
  REP(i,N){
    if(CNT[i]%2==1) CAN=false;
  }
  
  if(CAN) COYE;
  else CONO;
  return 0;
}

Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int a = sc.NextInt();
        int b = sc.NextInt();

        int[] nums = new int[] { a + b, a - b, a * b };

        int answer = nums.Max();

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    vector<int> v;
    v.push_back(a);
    v.push_back(b);
    v.push_back(c);

    sort(v.begin(), v.end(), greater<int>());

    int ans = v.at(0) * 10 + v.at(1) + v.at(2);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <algorithm>
#include <time.h>
#include <stdlib.h>
#include <math.h>

using namespace std;

int main (void)
{
	long m,min,max,p[10000],g[10000],kkk,rrr;

	for (long o = 0; o < 10000; o++)
	{
	cin >> m >> min >> max;

	if (m == 0 && min == 0)
	{
		if (max == 0)
		{
			break;
		}
	}

	kkk = 0;

	for (long i = 1; i < m + 1; i++)
	{
		cin >> p[i];
	}

	for (long j = min; j < max + 1; j++)
	{
		g[j] = p[j] - p[j + 1];

		if (kkk <= g[j])
		{
			kkk = 0;
			kkk = g[j];
			rrr = 0;
			rrr = j;
		}
	}

		cout << rrr << endl;
	}
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[4];
	for(int i=0;i<4;i++)cin>>a[i];
	sort(a,a+4);
	if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9)puts("YES");
	else puts("NO");
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> A;
  tools::read(A, N);

  std::vector<i64> search;
  for (i64 i = N - 1; i >= 0; --i) {
    auto it = std::upper_bound(search.begin(), search.end(), A[i]);
    if (it == search.end()) {
      search.push_back(A[i]);
    } else {
      search[std::distance(search.begin(), it)] = A[i];
    }
  }

  std::cout << search.size() << std::endl;
  return 0;
}

Measured memory_bytes: 2168
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;

void main() {
	auto data = readln.split, N = data[0].to!int, K = data[1].to!int;
	int[] h;
	foreach (i; 0 .. N) { h ~= readln.split[0].to!int; }
	h = h.sort().array;
	(N-K+1).iota.map!(x => h[x+K-1]-h[x]).reduce!"min(a, b)".writeln;
}

Measured memory_bytes: 3708
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
    string s; cin >> s;
    for (int i = 1; i < s.size(); i++)
        if (s[i-1] == s[i]) { cout << i << ' ' << i+1 << endl; return 0; }
    for (int i = 2; i < s.size(); i++)
        if (s[i-2] == s[i]) { cout << i-1 << ' ' << i+1 << endl; return 0; }
    cout << "-1 -1\n";
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using std::cerr;
using std::endl;

struct IO {
  const static int S = 3e7;
  char buc_in[S], *p_in = buc_in;
  IO() {
    fread(buc_in, 1, S, stdin);
  }
  inline int rd() {
    int b = 0;
    while (!isdigit(*p_in)) ++p_in;
    while (isdigit(*p_in)) b = b * 10 + *p_in++ - '0';
    return b;
  }
} io;

const int N = 8e5 + 233, P = 924844033, Gp = 5;
inline int fpow(int x, int y) {
  int ret = 1;
  for ( ; y; y >>= 1, x = 1ll * x * x % P)
    if (y & 1) ret = 1ll * ret * x % P;
  return ret;
}
int fac[N], inv[N], ifac[N];

int rev[N], lim, L, inv_lim, w[N];
inline void init(int n) {
  for (lim = 1, L = 0; lim < n; lim <<= 1, ++L);
  for (int i = 0; i < lim; ++i)
    rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (L - 1));
  inv_lim = fpow(lim, P - 2);
  int qwq = lim >> 1, omega = fpow(Gp, (P - 1) / lim);
  w[qwq] = 1;
  for (int i = qwq + 1; i < lim; ++i)
    w[i] = 1ll * w[i - 1] * omega % P;
  for (int i = qwq - 1; i; --i)
    w[i] = w[i << 1];
}

inline void DFT(int f[], int o) {
  unsigned long long tmp[N];
  for (int i = 0; i < lim; ++i)
    tmp[rev[i]] = f[i];
  for (int i = 0; i < lim; i += 2) {
    int nx = tmp[i], ny = tmp[i + 1];
    tmp[i] = nx + ny, tmp[i + 1] = nx + P - ny;
  }
  for (int i = 2; i < lim; i <<= 1) {
    for (int j = 0; j < lim; j += i << 1) {
      auto *a = tmp + j, *b = tmp + i + j;
      auto *p = w + i;
      for (int k = 0; k < i; ++k) {
        int ny = b[k] * p[k] % P;
        b[k] = a[k] + P - ny;
        a[k] += ny;
      }
    }
  }
  for (int i = 0; i < lim; ++i)
    f[i] = tmp[i] % P;
  if (o == -1) {
    std::reverse(f + 1, f + lim);
    for (int i = 0; i < lim; ++i)
      f[i] = 1ll * f[i] * inv_lim % P;
  }
}

int n, size[N], cnt[N];
int A[N], B[N];
std::vector<int> G[N];

void dfs(int x, int fa) {
  size[x] = 1;
  ++cnt[n];
  for (int y : G[x])
    if (y != fa) {
      dfs(y, x);
      size[x] += size[y];
      --cnt[size[y]];
    }
  if (fa) --cnt[n - size[x]];
}

int main() {
  n = io.rd();
  fac[0] = inv[1] = ifac[0] = ifac[1] = 1;
  for (int i = 1; i <= n; ++i)
    fac[i] = 1ll * fac[i - 1] * i % P;
  for (int i = 2; i <= n; ++i) {
    inv[i] = P - 1ll * P / i * inv[P % i] % P;
    ifac[i] = 1ll * ifac[i - 1] * inv[i] % P;
  }
  for (int i = 1; i < n; ++i) {
    int x = io.rd(), y = io.rd();
    G[x].push_back(y), G[y].push_back(x);
  }
  dfs(1, 0);
  for (int i = 0; i <= n; ++i) {
    A[i] = 1ll * cnt[i] * fac[i] % P;
    B[i] = ifac[i];
    if (A[i] < 0) A[i] += P;
  }
  std::reverse(A, A + n + 1);
  init((n + 1) << 1), DFT(A, 1), DFT(B, 1);
  for (int i = 0; i < lim; ++i)
    A[i] = 1ll * A[i] * B[i] % P;
  DFT(A, -1);
  for (int i = 1; i <= n; ++i) {
    int ans = A[n - i];
    ans = 1ll * ans * ifac[i] % P;
    printf("%d\n", ans);
  }
  /*
  for (int i = 1; i <= n; ++i) {
    int ans = 0;
    for (int j = i; j <= n; ++j)
      ans = (ans + 1ll * cnt[j] * fac[j] % P * ifac[i] % P * ifac[j - i]) % P;
    std::cout << ans << '\n';
  }
  */
  return 0;
}


Measured memory_bytes: 56512
#include <stdio.h>

int main() {
	int A, B, C, X;
	scanf("%d", &A);
	scanf("%d", &B);
	scanf("%d", &C);
	scanf("%d", &X);
	int count = 0;
	for (int i = 0; i <= A; i++) {
		for (int j = 0; j <= B; j++) {
			for (int p = 0; p <= C; p++) {
				if (500 * i + 100 * j + 50 * p == X) {
					count++;
				}
			}
		}
	}
	printf("%d", count);
}

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

int main(){
    stack<int> s1;
    stack<pair<int,int> > s2;
    char c;
    int A = 0; 
    for(int i = 0; cin >> c; i++){
        if(c == '\\'){
            s1.push(i); 
        }else if(c == '/' && s1.size() > 0){
            int j = s1.top(); s1.pop();
            A += i - j;
            int a = i - j;
            while(s2.size() > 0 && s2.top().first > j){
                a += s2.top().second;
                s2.pop();
            }
            s2.push(make_pair(j, a));
        }
    }

    vector<int> ans;
    while(s2.size() > 0){
        ans.push_back(s2.top().second);
        s2.pop();
    }
    reverse(ans.begin(),ans.end());
    cout << A << endl;
    cout << ans.size();
    for(int i = 0; i < ans.size(); i++){
        cout << " ";
        cout << ans.at(i);
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3200
N,M = map(int,input().split())
d = {}
for i in range(M):
    a,b = map(int,input().split())
    if a in d.keys():
        d[a].append(b)
    else:
        d[a] = [b]

flag = False
for i in d[1]:
    if i in d.keys():
        for j in d[i]:
            if j == N:
                flag = True
                break
        if flag:
            break
if flag:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 30696
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP2(i, n) for (Int i = 0, max_i = (n); i < max_i; i++)
#define REP3(i, a, b) for (Int i = (a), max_i = (b); i < max_i; i++)
#define OVERLOAD2(_1, _2, _3, name, ...) name
#define REP(...) OVERLOAD2(__VA_ARGS__, REP3, REP2)(__VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Tue Feb 11 19:59:56 JST 2020
 **/

using pii = pair<Int, Int>;
signed main() {
    Int n;
    cin >> n;
    map<pii, Int> mp;
    Int ans = 0;
    REP(i, 1, n + 1) {
        string s = to_string(i);
        Int a = s[0] - '0', b = s.back() - '0';
        ans += 2 * mp[{b, a}];
        mp[{a, b}]++;
        ans += a == b;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 0
for i in range(n):
    if b[i] > a[i]:
        ans += a[i]
        b[i] -= a[i]
        if b[i] > a[i + 1]:
            ans += a[i + 1]
            a[i + 1] = 0
        else:
            ans += b[i]
            a[i + 1] -= b[i]
    else:
        ans += b[i]
        
print(ans)


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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; }

void Main(){
    int N; cin >> N;
    VI ans(N,0);
    FOR(x,1,101)FOR(y,1,101)FOR(z,1,101){
        int n = x*x+y*y+z*z+x*y+y*z+z*x;
        if(n <= N) ans[n-1]++;
    }

    REP(i,N) cout << ans[i] << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3696
#include<iostream>

using namespace std;

int main() {
	int n,a,b,ans=0;
	cin >> n >> a >> b;
	for (int i = 1; i <= n; i++) {
		int sec = 0, thi = 0, fou = 0;
		int fir = i % 10;
		if (n >= 10) {
			sec = ((i - fir) / 10)%10;
		}if (n >= 100) {
			thi = ((i - fir - sec) / 100)%10;
		}if (n >= 1000) {
			fou = ((i - fir - sec - thi) / 1000)%10;
		}
		if (i == 10000 && a == 1)ans += 10000;
		else if (a <= fir + sec + thi + fou && fir + sec + thi + fou <= b) ans += i;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
while True:
    (n, x) = [int(i) for i in input().split()]
    if n == x == 0:
        break
    count = 0
    for a in range(n if n < x else x, 2, -1):
        for b in range(a-1, 1, -1):
            if a + b > x:
                continue
            for c in range(b-1, 0, -1):
                s = a + b + c
                if s == x:
                    count += 1
                    break
                elif s < x:
                    break
    print(count)

Measured memory_bytes: 6724