akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

int main() {
  int H, W, h, w;
  cin >> H >> W >> h >> w;

  int ans = H * W;
  ans -= W * h + w * H;
  ans += h * w;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h> 
using namespace std; 
int main() 
{
int n,k;
cin>>n>>k;
vector<int>dp(n,1e9),arr(n);
for(int i=0;i<n;i++) cin>>arr[i];
dp[0]=0;
for(int i=0;i<n;i++) for(int j=1; j<=k&&j<=i; j++) dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
cout<<dp[n-1];
} 


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

int  main(){
  int N,K;
  cin >> N >> K;
  int d[K];
  int A[K][N];
  for(int i=0;i<K;i++){
    cin >> d[i];
    for(int j=0;j<d[i];j++){cin >> A[i][j];}
  }
  int sum=0;
  int a[N];
  for(int i=0;i<N;i++){a[i]=0;}
  for(int i=0;i<K;i++){
    for(int j=0;j<d[i];j++){
      if(a[A[i][j]-1] == 0){a[A[i][j]-1] = 1;}
    }
  }
  for(int i=0;i<N;i++){
    if(a[i]==0){sum++;}
  }
  cout << sum << endl;
}

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

using namespace std;
using ll = long long int;
constexpr ll M = 1e9 + 7;
inline ll sum_1(const ll n) { return ((n * (n + 1)) / 2) % M; }
inline ll sum_2(const ll n) { return ((n * (n + 1) * (2 * n + 1)) / 6) % M; }
inline ll sum_3(const ll n) { return (((n * (n + 1)) / 2) % M * ((n * (n + 1)) / 2) % M) % M; }
inline ll sum_1(const ll i, const ll j) { return (sum_1(j) - sum_1(i - 1) + M) % M; }
inline ll sum_2(const ll i, const ll j) { return (sum_2(j) - sum_2(i - 1) + M) % M; }
inline ll sum_3(const ll i, const ll j) { return (sum_3(j) - sum_3(i - 1) + M) % M; }

ll pow_f(ll b, ll e) {
    ll ans = 1;
    b = b % M;
    while (e) {
        if (e&1) {
            ans = (ans * b) % M;
        }
        b = (b * b) % M;
        e >>= 1;
    }
    return ans;
}

ll nCr(ll n, ll r) {
    if (r > n || n < 0 || r < 0) { return 0; }
    if (n == r || r == 0) { return 1; }
    r = min(r, n-r);
    ll ans = 1;
    for (ll i = 1; i <= r; ++i) {
        ans = (ans * (n-i+1))/(i); 
    }
    return ans;
}

ll nCr(tuple<ll,ll> t) {
    auto n = get<0>(t);
    auto k = get<1>(t);
    return nCr(n+k-1, k);
}

void solve() {
    ll n, m;
    cin >> n >> m;
    vector<ll> h(n);
    for (auto &i : h) {
        cin >> i;
    }
    vector<bool> isGood(n, true);

    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        if (h[a-1] > h[b-1]) {
            isGood[b-1] = false;
        } else if (h[a-1] < h[b-1]) {
            isGood[a-1] = false;
        } else {
            isGood[a-1] = false;
            isGood[b-1] = false;
        }
    }

    ll ans = 0;
    for (auto i : isGood) {
        ans += (i) ? 1 : 0;
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifdef D_LOCAL
        freopen("in.in", "r", stdin);
        freopen("out.out", "w", stdout);
    #endif

    solve();

    return 0;
}

Measured memory_bytes: 3992
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace MyProgram{
    public class Program
    {	
        public static void Main(string[] args)
    	{
            int[] n = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int N = n[0];
            int L = n[1];
            
            List<string> list = new List<string>();
            
            for(int i = 0 ; i < N ; i++)
            {
                list.Add(Console.ReadLine());
            }
            list.Sort();
            foreach(string s in list) Console.Write(s);
            Console.WriteLine();
    	}
    }
}

Measured memory_bytes: 13536
import java.util.*;

/**
 * Main
 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int V[] = new int[N];
		int C[] = new int[N];
		int mouke[] = new int[N];
		int ans = 0;

		for (int i = 0; i < N; i++) {
			V[i] = sc.nextInt();
		}
		for (int i = 0; i < N; i++) {
			C[i] = sc.nextInt();
		}
		for (int i = 0; i < N; i++) {
			ans += Math.max(V[i] - C[i], 0);
		}

		System.out.println(ans);

		sc.close();
	}
};

Measured memory_bytes: 35736
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

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

	long long maxA = 0;
	vector<long long> b(N);
	for (auto i = 0; i < N; ++i)
	{
		long long a;
		cin >> a >> b[i];
		maxA = max(a, maxA);
	}

	sort(b.begin(), b.end(), greater<long long>());

	auto count = 0ll;
	for (auto i = 0; i < N && H > 0 && b[i] > maxA; ++i)
	{
		H -= b[i];
		++count;
	}

	if (H > 0)
	{
		count += H / maxA;
		if (H % maxA > 0)
		{
			++count;
		}
	}

	cout << count << endl;

	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

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

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << 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; }

int n, m, q, ans = 0;
vi a, b, c, d;

void calc(vi v) {
    int sum = 0;
    rep(i, q) if(v[b[i]] - v[a[i]] == c[i]) sum += d[i];
    ans = max(ans, sum);
}

void func(int prev, int depth, vi v) {
    if(depth == n) {
        calc(v);
        return;
    }

    for(int add = prev; add <= m; add++) {
        v.push_back(add);
        func(add, depth+1, v);
        v.pop_back();
    }
}

int main()
{   
    cin >> n >> m >> q;
    a.resize(q), b.reserve(q), c.resize(q), d.resize(q);
    rep(i, q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        --a[i], --b[i];
    }

    vi v;
    func(1, 0, v);
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3596
#include<iostream>

using namespace std;

int main()
{
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  sort(a,a+n);
  int sum=0;
  for(int i=0;i<k;i++)
    sum=sum+a[i];
  cout<<sum;
}

Measured memory_bytes: 3184
from collections import Counter
from itertools import accumulate
from math import factorial

def comb(n, r):
    return factorial(n) // (factorial(n-r) * factorial(r))

n = int(input())
A = list(map(int, input().split()))
B = [0] + list(accumulate(A))
C = Counter(B)
ans = 0
for count in C.values():
    if count == 1:
        continue
    else:
        ans += comb(count, 2)
print(ans)


Measured memory_bytes: 41984
#include <bits/stdc++.h>
using namespace std;
 
const int INF = 1e9;
long long int dp[3000][3000][2];

int main() {

    int n;
    cin>>n;
    int a[n];
    for (int i=0; i<n; i++){
        cin>>a[i];
    }
    //dp[l][r][0] - value of X-Y when Taro start the game 
    //Initialize
    for (int i=0; i<n; i++){
        dp[i][i][0] = a[i];
        dp[i][i][1] = -a[i];
    }
    
    for (int l=n; l>=0; l--){
        for (int r=0; r<n; r++){
            if (r>l){
                dp[l][r][0] = max(a[l]+dp[l+1][r][1], a[r]+dp[l][r-1][1]);
                dp[l][r][1] = min(dp[l+1][r][0]-a[l], dp[l][r-1][0]-a[r]);
            }
        }
    }

    // ans - dp[0][n-1][0] - value of X-Y for complete array when Taro starts
    cout<<dp[0][n-1][0];
    return 0;
}




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

int main(){

    cin.tie(0);
    ios::sync_with_stdio(0);

    int n;
    cin >> n;
    
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    
    ll x2 = 0;
    rep(i,n){
        if(i%2) x2 -= a[i];
        else x2 += a[i];
    }
    vector<int> ans(n);
    ans[0] = x2 / 2;
    
    rep(i,n){
        ans[i + 1] = a[i] - ans[i];
    }
    
    rep(i, n) ans[i] *= 2;
    rep(i,n) printf("%d%c", ans[i], i==n-1?'\n':' ');

}


Measured memory_bytes: 2560
#include <stdio.h>

int main(void) {
	int n, x=1;
	scanf("%d", &n);
	int num[n];
	for (int i=0; i<n; ++i) scanf("%d", &num[i]);
	for (int i=0; i<n; ++i) {
		if (num[i]%2==0){
			if(num[i]%3!=0 && num[i]%5!=0) x=0;
		}
	}
	if (x) puts("APPROVED\n");
	else puts("DENIED\n");
	return 0;
}

Measured memory_bytes: 128
h, w = map(int, input().split())
grid = [[i & 1 for i in map(int, input().split())] for _ in range(h)]

# 注目するマスが奇数の場合下に動かしていく
ans = []

for i in range(h-1):
    for j in range(w):
        if grid[i][j] % 2 == 0:
            continue
        grid[i + 1][j] += 1
        ans.append((i+1, j+1, i + 2, j+1))

for i in range(w - 1):
    if grid[-1][i] % 2 == 0:
        continue
    grid[-1][i + 1] += 1
    ans.append((h, i+1, h, i+2))

print(len(ans))
for i in ans:
    print(*i, sep=" ")


Measured memory_bytes: 26568
//cで提出　事故る
#include<iostream>
#include<algorithm> //min,max
using namespace std; //cin cout
static const int MAX = 200000;

//static 存在し続ける
//const 値を書き換えない

int main() {
    int R[MAX], n;
    
    cin >> n;
    for ( int i = 0;i < n; i++ ) cin >> R[i];
    
    int maxv = -2000000000; //こんなとこで定義？
    int minv = R[0];
    
    for (int i = 1;i < n; i++ ) { //i=1からじゃないとmaxv=0入ってしまう
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    cout << maxv << endl; 
    
    return 0;
}


Measured memory_bytes: 3884
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <list>
#include <map>
#include <deque>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0
template <class T>
void dumplist(T list)
{
    for (auto item : list) {
        cout << item << " ";
    }
    cout << endl;
}


void solve()
{
    string s;
    cin >> s;
    if ((s[0] == s[1]) || (s[1] == s[2]) || (s[2] == s[3])) {
        cout << "Bad" << endl;
    } else {
        cout << "Good" << endl;
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    do {
        solve();
    } while (DEBUG);
}


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

int main(void){
    int N;
    cin >> N;
    double sum = 0;
    for(int i=0;i<N;i++) {
        double tmp;
        cin >> tmp;
        sum += (1/tmp);
    }
    cout << 1/sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <atcoder/dsu>
#include <iostream>

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n, q;
  std::cin >> n >> q;
  atcoder::dsu uf(n);
  while (q--) {
    int t, u, v;
    std::cin >> t >> u >> v;
    if (t) {
      if (uf.same(u, v)) {
        std::cout << 1 << '\n';
      } else {
        std::cout << 0 << '\n';
      }
    } else {
      uf.merge(u, v);
    }
  }
  return 0;
}

Measured memory_bytes: 3968
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String string = sc.next();
		int N = Integer.parseInt(sc.next());
		boolean switchFlg = false;
		StringBuilder sb = new StringBuilder(string);

		for (int i = 0; i < N; i++) {
			int T =sc.nextInt();
			if (T == 1) {
				if (switchFlg) {
					switchFlg = false;
				}else {
					switchFlg = true;
				}
			}else {
				int F = sc.nextInt();
				if ((F == 1 && switchFlg == false) || (F == 2 && switchFlg == true)) {
					String top = sc.next();
					sb.insert(0, top);
				}else if ((F == 1 && switchFlg == true) || (F == 2 && switchFlg == false)) {
					String end = sc.next();
					sb.append(end);
				}
			}
		}

		if (switchFlg) {
			System.out.println(sb.reverse().toString());
		}else {
			System.out.println(sb.toString());
		}

	}
}

Measured memory_bytes: 64056
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(ceil((double)a/d) >= ceil((double)c/b)) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1000000001)
#define MOD (1000000007)
#define PI (acos(-1))

int main(){
  string s;
  cin >> s;
  int a=0,b=0,c=0;
  rep(i,s.size()){
    if(s[i]=='a')a++;
    if(s[i]=='b')b++;
    if(s[i]=='c')c++;
  }
  int tmp = min({a,b,c});
  a-=tmp;
  b-=tmp;
  c-=tmp;
  if(max({a,b,c})<=1){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}



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

int max_keta(int n) {
    while (n / 10 != 0) n /= 10;
    return n;
}

int min_keta(int n) {
    return n % 10;
}

int counter(int i, int j, int n) {
    int count = 0;
    if (i == j && i <= n) count++;
    for (int k = 10; k <= n; k++) {
        if (max_keta(k) == i && min_keta(k) == j) count++;
    }
    return count;
}

int main() {
    int n, sum = 0;
    cin >> n;
    rep (i, 9) {
        rep (j, 9) {
            //cout << "i = " << i + 1 << " j = " << j + 1 << " count = " << counter(i + 1, j + 1, n) << endl;
            sum += counter(i + 1, j + 1, n) * counter(j + 1, i + 1, n);
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class CPeaks {
public:

    std::vector<int> par;
    std::vector<int> rak; // rank

    set<int> graph[100005];

    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, m; cin >> n >> m;
      vector<int> h(n);
      rep(i, n) {
         cin >> h[i];
      }
      rep(i, m) {
        int a, b; cin >> a >> b;
        a--; b--;
        graph[a].insert(b);
        graph[b].insert(a);
      }

      int ans = 0;
      rep(i, n) {
        bool flag = true;
        for(auto e: graph[i]) {
          if (h[i] <= h[e]) {
            flag = false;
            break;
          }
        }
        if (flag) ans++;
      }


      cout << ans << endl;

    }
};

signed main() {
  CPeaks solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 17756
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
char in[5100];
string str[30000];
int main(){
	scanf("%s",in);
	int n=strlen(in);
	int a;
	scanf("%d",&a);
	int sz=0;
	for(int i=0;i<n;i++){
		string cur="";
		for(int j=0;j<5;j++){
			if(i+j>=n)break;
			cur+=in[i+j];
			str[sz++]=cur;
		}
	}
	std::sort(str,str+sz);
	for(int i=0;i<sz;i++){
		if(i==0||str[i]!=str[i-1]){
			a--;
			if(a==0){
				printf("%s\n",str[i].c_str());return 0;
			}
		}
	}
}


Measured memory_bytes: 1664
#include<math.h>
L(int ax,int ay,int bx,int by,int cx,int cy,int dx,int dy,float*X,float*Y){
	int acx,acy,bunbo;
	int r,s;
	acx=cx-ax;
	acy=cy-ay;
	bunbo=(bx-ax)*(dy-cy)-(by-ay)*(dx-cx);
	if(bunbo){
		r=((dy-cy)*acx-(dx-cx)*acy);
		s=((by-ay)*acx-(bx-ax)*acy);
		if(bunbo<0){
			r=-r;
			s=-s;
			bunbo=-bunbo;
		}
		if(r>=0&&r<=bunbo&&s>=0&&s<=bunbo){
			*X=ax+r/(float)bunbo*(bx-ax);
			*Y=ay+r/(float)bunbo*(by-ay);
			return 1;
		}
	}
	return 0;
}
main(){
	int x1[3],y1[3],x2[3],y2[3];
	float X[3],Y[3],S;
	int i=0;
	for(;~scanf("%d%d%d%d",x1+i,y1+i,x2+i,y2+i);){
		if(++i==3){
			if(L(x1[0],y1[0],x2[0],y2[0],x1[1],y1[1],x2[1],y2[1],X+0,Y+0)&&
			   L(x1[1],y1[1],x2[1],y2[1],x1[2],y1[2],x2[2],y2[2],X+1,Y+1)&&
			   L(x1[2],y1[2],x2[2],y2[2],x1[0],y1[0],x2[0],y2[0],X+2,Y+2))
			{
				S=0;
				for(i=0;i<3;i++){
					S+=(X[i]-X[(i+1)%3])*(Y[i]+Y[(i+1)%3])/2;
				}
				S=fabs(S);
				if(S==0)
					puts("kyo");
				else if(S<100000)
					puts("syo-kichi");
				else if(S<1000000)
					puts("kichi");
				else if(S<1900000)
					puts("chu-kichi");
				else
					puts("dai-kichi");
			}else{
				puts("kyo");
			}
			i=0;
		}
	}
}

Measured memory_bytes: 0
N = int(input())
cnt = 0
for i in range(1,N+1,2):
    ans=0
    for j in range(1,i+1):
        if i % j == 0:
            ans += 1
        else:
            pass
    if ans == 8:
        cnt += 1
    else:
        pass
print(cnt)

Measured memory_bytes: 63864
// -*- mode:c++; coding:utf-8; indent-tabs-mode:nil; -*-
// ALDS1_2-D

#include <algorithm>
#include <cstdio>

static void print_ints(const int as[], const unsigned int n,
                       const char* sep = " ") {
  const char* out_sep = "";
  for (unsigned int i = 0; i < n; ++i) {
    std::printf("%s%d", out_sep, as[i]);
    out_sep = sep;
  }
  std::puts("");
}

static void print_int(const unsigned int n) {
  std::printf("%d\n", n);
}

static unsigned int cnt = 0;

inline
static void insert(int as[], const unsigned int i, const unsigned int d) {
  const int asi = as[i];
  unsigned int j = i;
  while (j >= d && asi < as[j-d]) {
    as[j] = as[j-d];
    j -= d;
    ++cnt;
  }
  as[j] = asi;
}

void insertion_sort(int as[], const unsigned int n, const unsigned int d) {
  for (unsigned int i = d; i < n; ++i) {
    insert(as, i, d);
  }
}

inline
unsigned int next_g(const unsigned int g) { return 3*g + 1; }

unsigned int gen_m(const unsigned int n) {
  unsigned int m = 1;
  for (unsigned int g = 1;;) {
    g = next_g(g);
    if (n < g) break;
    ++m;
  }
  return m;
}

void shell_sort(int as[], const unsigned int n) {
  cnt = 0;

  unsigned int m = gen_m(n);
  int gs[m];
  for (unsigned int g = 1, i = 0; i < m; ++i) {
    gs[m-1-i] = g;
    g = next_g(g);
  }
  print_int(m);
  print_ints(gs, m);

  for(unsigned int i = 0; i < m; ++i) {
    insertion_sort(as, n, gs[i]);
  }
  
  print_int(cnt);
}

int main(void) {
  unsigned int n;
  std::scanf("%d", &n);
  int as[n];
  for (unsigned int i = 0; i < n; ++i) {
    std::scanf("%d", &as[i]);
  }

  shell_sort(as, n);
  print_ints(as, n, "\n");

  return 0;
}
// end

Measured memory_bytes: 4944
#include<stdio.h>
int main(){
  int n,x,i,j,k,sum,com=0;
  while(1){
      com = 0;
    scanf("%d %d",&n,&x);
    if(n == 0 && x == 0) break;
    for(i=1;i<=n-2;i++){
      for(j=i+1;j<=n-1;j++){
        for(k=j+1;k<=n;k++){
          sum = i + j+ k;
          if(sum == x) com++;
        }
      }
    }
    printf("%d\n",com);
  }
  return 0;
}



Measured memory_bytes: 2128
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,x,n) for (int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;

typedef pair<int,int> P;
string s;
int k;
ll INF = 10000000000000000;

int main(){
    ll N,M;
    cin >> N>> M;
    vector<P> ask(M);
    rep(i,M){
        cin >>ask[i].second>>ask[i].first;     
    }
    sort(all(ask));

    ll ans=1;
    ll end=ask[0].first-1; 
    rep2(i,1,M){
        if(ask[i].second > end){
            ans++;
            end = ask[i].first-1;
        }

    }
    cout <<ans<<endl;

}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
long long f[110][10], n, p[110][11], res = -110000000000, g[10];

void dfs(int x) {
    if (x == 10) {
        int e = 0;
        for (int i = 0; i < 10; i++) {
            if (g[i] == 1) e = 1;
        } 
        if (e == 0) return;
        long long ans = 0;
        for (int i = 0; i < n; i++) {
            int cou = 0;
            for (int j = 0; j < 10; j++) {
                if (g[j] == 1 && f[i][j] == 1) cou++;
            }
            ans += p[i][cou];
        }
        res = max(ans, res);
    } else {
        g[x] = 0;
        dfs(x + 1);
        g[x] = 1;
        dfs(x + 1);
    }
}

int main(void){
    // Your code here!
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> f[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 11; j++) {
            cin >> p[i][j];
        }
    }
    dfs(0);
    cout << res << endl;
}


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

int main()
{
    int l, r, d, a, t, h;
    cin >> l >> r >> d;
    a = 0;
    t = 0;
    h = 0;
    while (a <= r)
    {

        if (a >= l)
        {
            t++;
        }
        h++;
        a = d * h;
    }
    cout << t;
    return 0;
}

Measured memory_bytes: 3520
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 59;
const int MXS = 50 * 50 * 50 + 9;

int a[N];
long long b[N];
int pa[N];
int o[N];
int sa[N];
long long sb[N];
long long f[MXS];
long long nf[MXS];

int main() {
  int n, m, d;
  scanf("%d %d %d", &n, &m, &d);
  for (int i = 0; i < n; ++i) {
    a[i] = 1;
    int v;
    scanf("%d", &v);
    b[i] = v;
    if (i > 0) {
      scanf("%d", pa + i);
      --pa[i];
    }
  }
  for (int i = n - 1; i >= 1; --i) {
    a[pa[i]] += a[i];
    b[pa[i]] += b[i];
  }
  memset(f, -1, sizeof f);
  f[0] = 0;
  for (int i = 0; i < n; ++i) {
    memset(nf, -1, sizeof nf);
    for (int j = 0; j < MXS; ++j) {
      if (f[j] == -1) {
        continue;
      }
      for (int k = 0; k <= min(n, d) && j + k * a[i] < MXS; ++k) {
        nf[j + k * a[i]] = max(nf[j + k * a[i]], f[j] + k * b[i]);
      }
    }
    memcpy(f, nf, sizeof f);
  }
  for (int i = 0; i < n; ++i) {
    o[i] = i;
  }
  sort(o, o + n, [](int i, int j) {
    return (long long)b[i] * a[j] < (long long)b[j] * a[i];
  });
  sa[0] = 0;
  sb[0] = 0;
  for (int i = 0; i < n; ++i) {
    sa[i + 1] = sa[i] + a[o[i]];
    sb[i + 1] = sb[i] + b[o[i]];
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < MXS; ++j) {
      if (f[j] == -1) {
        continue;
      }
      if (d > 0 && sb[i] > 1'000'000'000'000'000'000 / d) {
        continue;
      }
      long long v = sb[i] * d + (sb[n] - sb[i]) * min(n, d) - f[j];
      if (v < 0 || v > m) {
        continue;
      }
      long long cur = (long long)sa[i] * d + (sa[n] - sa[i]) * min(n, d) - j;
      if (cur < 0) {
        continue;
      }
      int q = (int)((m - v) / b[o[i]]);
      if (o[i] != 0) {
        q = min(q, max(0, d - n));
      }
      ans = max(ans, (int)cur + q * a[o[i]]);
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 2176
using System;
using System.Collections.Generic;
namespace Q3
{
    class Program
    {
        static void Main(string[] args)
        {
            string r = Console.ReadLine();
            int N = int.Parse(r);
            var list = new List<int>();

            list.Add(1);
            
            for(int i = 1; (int)System.Math.Pow(6, i) <= N; i++)
            {
                list.Add((int)System.Math.Pow(6, i));
            }
            for (int i = 1; (int)System.Math.Pow(9, i) <= N; i++)
            {
                list.Add((int)System.Math.Pow(9, i));
            }

            list.Sort((a, b) => b - a);
            int result = 0;
            result = Calc(N, list, 0);
            //for (int i = 0; N > 0; )
            //{
            //    if (N >= list[i])
            //    {
            //        N -= list[i];
            //        result++;
            //    }
            //    else
            //    {
            //        i++;
            //    }
            //}
            
            Console.Write(result);
            r = Console.ReadLine();
        }


        static int Calc(int N, List<int> list, int limit)
        {
            if (N == 0) return 0;
            int result = 100000;
            int kouho = 0;
            for (int i = limit; i < list.Count; i++)
            {
                if (list[i] * 9 < N) continue;
                for(int j = 1; j <= 8; j++)
                {
                    if (N >= list[i] * j)
                    {
                        kouho = Calc(N - list[i] * j, list, i + 1) + j;
                        if (kouho < result) result = kouho;
                    }
                }
            }

            return result;
        }
    }
}

Measured memory_bytes: 13268
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        new Program().Solve();
    }

    void Solve()
    {
        Scanner cin = new Scanner();
        int r = cin.NextInt();
        int d = cin.NextInt();
        int x = cin.NextInt();
        for (int i = 0; i < 10; i++)
        {
            x = r * x - d;
            Console.WriteLine(x);
        }
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string Next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return Next();
        i = 0;
        return s[i++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public char[] ArrayChar()
    {
        return Next().ToCharArray();
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextInt() + add;
        }
        return Array;
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextLong() + add;
        }
        return Array;
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

int main() {
    int N,M;cin>>N>>M;
    vector<priority_queue<int>> tbl(100010);
    rep(i,N) {
        int a,b;cin>>a>>b;
        tbl[a].push(b);
    }
    ll ans = 0;
    priority_queue<P> pq;
    for(int i = 1;i<M+1;i++) {
        if(tbl[i].size()!=0) {
            int val = tbl[i].top();
            tbl[i].pop();
            pq.push(P(val,i));
        }
        if(!pq.empty()) {
            int val = pq.top().first;
            int day = pq.top().second;
            pq.pop();
            ans += val;
            if(tbl[day].size()!=0) {
                int val = tbl[day].top();
                tbl[day].pop();
                pq.push(P(val,day));
            }
        }
    }
    cout<<ans<<endl;
}

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

int main()
{
    int n;
    cin >> n;
    int v[101] = {};
    for(int i=1; i<10; i++){
        for(int j=1; j<10; j++){
            v[i*j] = 1;
        }
    }
    if(v[n] == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define loop(i,a,b) for(ll i=a;i<b;++i)

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int r,w;
	cin>>r>>w;
	char a[r][w];
	for(int i=0;i<r;++i)
        for(int j=0;j<w;++j)
        cin>>a[i][j];
	for(int i=1;i<=w+2;++i) cout<<"#";
	cout<<"\n";
	for(int i=0;i<r;i++)
    {
        cout<<"#";
        for(int j=0;j<w;j++)
            cout<<a[i][j];
        cout<<"#\n";
    }
    for(int i=1;i<=w+2;++i) cout<<"#";
}


Measured memory_bytes: 256
import java.util.*
import kotlin.collections.HashMap

fun main(args: Array<String>) {
    val read = Scanner(System.`in`)
    var n = read.nextInt()
    var k = read.nextInt()
    val map = HashMap<Int , MutableList<Int>>()
    for(i in 1..n)
        map.put(i , ArrayList())
    for(row in 1..k) {
        val d = read.nextInt()
        for(col in 1..d) {
            val snuck = read.nextInt()
            map.get(snuck)?.add(col)
        }
    }
    var count = 0;
    for((x , y) in map)
        if(y.isEmpty()) count++
    println(count)

}

Measured memory_bytes: 47056
#include<stdio.h>
int main()
{
	int d[101]={0},t,m=-1;
	while(scanf("%d",&t)!=EOF)
		m=++d[t]>m?d[t]:m;
	for(t=1;t<101;t++)
		if(d[t]==m)
			printf("%d\n",t);
	return 0;
}

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

using namespace std;

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

  int n;
  long long k;
  cin >> n >> k;
  vector<int> a(n), f(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> f[i];
  }
  sort(a.begin(), a.end());
  sort(f.rbegin(), f.rend());
  vector<pair<long long, int>> kek;
  for (int i = 0; i < n; ++i) {
    kek.emplace_back(1ll * a[i] * f[i], f[i]);
  }
  sort(kek.begin(), kek.end());
  long long l = -1, r = 1e18;
  while (l + 1 < r) {
    long long m = l + r >> 1;
    long long need = 0;
    for (int i = 0; i < n; ++i) {
      need += (max(0ll, kek[i].first - m) + kek[i].second - 1) / kek[i].second;
    }
    if (need <= k) {
      r = m;
    } else {
      l = m;
    }
  }
  cout << r;

  return 0;
}

Measured memory_bytes: 8048
#!python3.8
# -*- coding: utf-8 -*-
# abc170/abc170_d
import sys
from collections import Counter

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    A = sorted(int(c) for c in i2s().split(' '))
    max_ = A[-1]
    B = Counter(A)
    for a in A:
        if B[a] == 0:
            continue
        if B[a] > 1:
            B[a] = 0
        for i in range(2, max_ // a + 1):
            if a * i in B:
                B[a * i] = 0
    res = 0
    for v in B.values():
        if v:
            res += 1
    print(res)
    return

main()


Measured memory_bytes: 35836
import java.util.Scanner;

// https://atcoder.jp/contests/abc049/tasks/arc065_a
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		String scanStr = scanner.nextLine();
		scanner.close();
		scanner = null;

		String[] divineArray = { "dream", "dreamer", "erase", "eraser" };

		// 入力した値を反転
		scanStr = ReverseString(scanStr);
		for (int i = 0; i < divineArray.length; i++) {
			divineArray[i] = ReverseString(divineArray[i]);
		}

		boolean flag = true;
		String str = scanStr;

		for (int i = 0; i < scanStr.length()&&flag;) {
			for (String divineStr : divineArray) {
				int length = divineStr.length();
				if(scanStr.length()-i>=length) {
					str = scanStr.substring(i, length+i);
				}

				if (str.equals(divineStr)) {
					i = i + length;
					flag = true;
					break;
				}else {
					flag = false;
				}
			}
		}

		// 結果
		returnResult(flag);
	}

	// str を反転するメソッド。
	public static String ReverseString(String str) {
		StringBuffer sb = new StringBuffer(str);
		str = sb.reverse().toString();
		sb = null;
		return str;
	}

	// 結果を返すメソッド
	public static void returnResult(boolean flag) {
		if (flag) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 28208
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;

const ll MOD_CONST = 1000000007;

ll digit10(ll num) {
	ll d = 0;
	while (num > 0) {
		d++;
		num /= 10;
	}
	return d;
}

ll s(ll x) {
	int sum = 0;
	while (x > 0) {
		sum += (x % 10);
		x /= 10;
	
	}
	return sum;
}

int main()
{
	ll k;
	cin >> k;

	
	ll num = 1;
	
	for (ll i = 0; i < k; i++) {
		cout << num << endl;
		num++;
		priority_queue<ll, vector<ll>, greater<ll>> pq;
		pq.push(num);
		ll d_max = digit10(num) + 1;
		ll p10 = 10;
		for (int i = 0; i <= d_max; i++) {
			
			pq.push((num / p10 + 1) * p10 - 1);
			p10 *= 10;
		}

		ll minX = pq.top();
		pq.pop();
		ll minS = s(minX);

		for (int i = 0; i < d_max; i++) {
			ll x1 = pq.top();
			ll s1 = s(x1);
			pq.pop();
			//cout << x1 << endl;
			if (x1 * minS < minX * s1) {
				minX = x1;
				minS = s1;
			}

		}
		

		num = minX;
		
		
	}
}  



Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

ll modpow(ll a, ll b){
    if(b == 0) return 1;
    else if(b % 2 == 0){
        ll d = modpow(a, b/2) % MOD;
        return (d * d) % MOD;
    }
    else{
        return (a * modpow(a, b-1)) % MOD;
    }
}

const int MAX_N = 1000010;

ll fact[MAX_N], finv[MAX_N];
ll comb(int n, int r){
    if(n < r || r < 0) return 0;
    return fact[n] * finv[n-r] % MOD * finv[r] % MOD;
}

void calc(int n){
    fact[0] = finv[0] = 1;
    for(int i=1; i<=n; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        finv[i] = modpow(fact[i], MOD-2);
    }
}

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

    calc(1000005);

    int x, y; cin>>x>>y;

    int n = -1, r = -1;
    for(int i=0; i<=1000000; i++){
        int tmpx = x, tmpy = y;
        tmpx -= i, tmpy -= i * 2;

        if(0 <= tmpx && 0 <= tmpy && tmpy * 2 == tmpx){
            r = i;
            n = i + tmpy;
            break;
        }
    }

    cout << comb(n, r) << endl;

    return 0;
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    int N;
    cin >> N;
    map<int,int> m;
    rep(i,N){
        int a;
        cin >> a;
        m[a]++;
    }
    vector<int> cnt;
    for (auto x:m){
        cnt.push_back(x.second);
    }
    sort(cnt.begin(),cnt.end());
    int s=cnt.size();
    vector<int> cnt2(s+1);
    cnt2[0]=0;
    rep(i,s){
        cnt2[i+1]=cnt2[i]+cnt[i];
    }
    rep(i,N){
        int lb=-1,ub=N+1;
        while(ub-lb>1){
            int mid=(ub+lb)/2;
            int x=lower_bound(cnt.begin(),cnt.end(),mid)-cnt.begin();
            int sum=cnt2[x]+mid*(s-x);
            if (sum>=(i+1)*mid){
                lb=mid;
            }
            else {
                ub=mid;
            }
        }
        cout << lb << endl;
    }
}

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

int main(){
  int num[5];
  int min1 = 10;
  int ans = 0;
  for(int i=0;i<5;i++){
      cin >> num[i];
      if(num[i]%10==0) ans += num[i];
      else{
        ans += ((num[i]/10)+1)*10;
      }
      if(num[i]%10!=0 && min1>(num[i]%10)) min1 = num[i]%10;
  }
  cout << ans + min1 -10 << endl;
}


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

int main() {
    int N; cin >> N;
    int T, A; cin >> T >> A;
    int min_diff = 10000000;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int H; cin >> H;
        int diff = 1000 * abs(A - T + H * 0.006);
        if (min(min_diff, diff) == diff) {
            min_diff = diff;
            ans = i + 1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3592
from bisect import bisect
from math import log2
n = int(input())
a = [int(i) for i in input().split()]
a,x,ans = sorted(a),[1]*n,0
for i in range(n-1,-1,-1):
	if x[i]:
		m = 2**(int(log2(a[i]))+1)
		b = bisect(a,m-a[i],hi=i)-1
		if b+1 and a[b]==m-a[i]: x[b],ans,a[b],a[i] = 0,ans+1,a[b]+0.1,a[i]+0.1
print(ans)

Measured memory_bytes: 25968
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

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


class CPeaks {
public:
    int dy[4]={-1,1,0,0};
    int dx[4]={0,0,1,-1};
    int N, M;
    vector<int> H;
    vector<vector<int>> edges;
    vector<int> group;
    vector<int> highest_num;

    void bfs(int node) {
        queue<int> q;
        q.push(node);
        group[node] = node;
        highest_num[node] = 1;
        int highest = H[node];

        while (!q.empty()) {
            int n = q.front(); q.pop();
            for(auto nn: edges[n]) {
                if (group[nn] == -1) {
                    group[nn] = node;
                    if (highest < H[nn]) {
                        highest = H[nn];
                        highest_num[node] = 1;
                    } else if (highest == H[nn]) {
                        highest_num[node]++;
                    }
                    q.push(nn);
                }
            }
        }
    }

	void solve(std::istream& in, std::ostream& out) {
        in >> N >> M;
        H.resize(N);
        edges.resize(N);
        REP(i, N) in >> H[i];
        REP(i, M) {
            int a, b;
            in >> a >> b;
            a--;b--;
            edges[a].push_back(b);
            edges[b].push_back(a);
        }
        group.resize(N, -1);
        highest_num.resize(N, 0);
        int ans = 0;
        REP(i, N) {
            int a = 1;
            for(auto x: edges[i]) {
                if (H[x] >= H[i]) {
                    a = 0;
                    break;
                }
            }
            ans += a;
        }
        out << ans << endl;
	}
};


int main() {
    ios::sync_with_stdio(false);
	CPeaks solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 9568
n = gets.chomp.to_i
s = gets.chomp.split('')

def next_animal(last2_animal, last_animal, last_o_or_x)
  if last2_animal == 'S'
    if last_animal == 'S'
      if last_o_or_x == 'o'
        return 'S'
      else
        return 'W'
      end
    else
      if last_o_or_x == 'o'
        return 'W'
      else
        return 'S'
      end
    end
  else
    if last_animal == 'S'
      if last_o_or_x == 'o'
        return 'W'
      else
        return 'S'
      end
    else
      if last_o_or_x == 'o'
        return 'S'
      else
        return 'W'
      end
    end
  end
end

def check(ans, s, n)
  if next_animal(ans[n-2], ans[n-1], s[n-1]) == ans[0] && next_animal(ans[n-1], ans[0], s[0]) == ans[1]
    puts ans.join('')
    exit
  end
end

['SS', 'SW', 'WS', 'WW'].each do |uu|
  ans = []
  fi, se = uu.split('')
  ans.push(fi)
  ans.push(se)
  2.upto(n-1) do |i|
    ans.push(next_animal(ans[i-2], ans[i-1], s[i-1]))
  end
  check(ans, s, n)
end
p -1


Measured memory_bytes: 27300
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	int n, m;
	cin >> n >> m;

	int d[105][105] = {};
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (i == j)d[i][j] = 0;
			else d[i][j] = 1000000007;
		}
	}

	vector<int>a(m), b(m), c(m);

	for (int i = 0; i < m; i++) { 
		cin >> a[i] >> b[i] >> c[i]; 
		d[a[i]][b[i]] = c[i];
		d[b[i]][a[i]] = c[i];
	}

	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	

	int ans = 0;

	for (int i = 0; i < m; i++) {
		if (d[a[i]][b[i]] < c[i])ans++;
	}
	cout << ans << endl;

	return 0;


}

Measured memory_bytes: 256
X, Y = map(int, input().split())

def mod_Combination(n, k, mod):
    def ext_gcd(a, b):
        if b == 0:
            return a, 1, 0
        else:
            d,x,y = ext_gcd(b,a%b)
            x-=(a//b)*y 
        return d,y,x
    p,q=1,1
    for i in range(n-k+1, n+1):
        p=(p*i)%mod
    for i in range(2, k+1):
        q=(q*i)%mod
    return int(p*(ext_gcd(q, mod)[1]%mod)%mod)

a = (2*X - Y)/3
b = (2*Y - X)/3

if (X+Y)%3 != 0:
    ans = 0

elif a<0 or b<0:
    ans = 0

else:
    ans = mod_Combination(int(a + b), int(b), 10**9 + 7)

print(ans)


Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int N = sc.nextInt();
		int[][] aiXY = new int[N][2];
      	for(int i=0; i< N;  i++){
        	aiXY[i][0] = sc.nextInt();
            aiXY[i][1] = sc.nextInt();
        }
      
      	double[][] aiD = new double[N][N];
      	int M = 0;
      	for(int i=0; i< N;  i++){
          	for(int j=M; j< N;  j++){
              	if(i==j){
                  aiD[i][j] = 0;
                  continue;
                }
              	double db0 = Math.pow(((double)aiXY[i][0]-(double)aiXY[j][0]),2);
              	double db1 = Math.pow(((double)aiXY[i][1]-(double)aiXY[j][1]),2);
            	double dst = Math.sqrt(db0+db1);
              	aiD[i][j] = dst;
              	aiD[j][i] = dst;
            }
          	M++;
        }
      
		double sum_db = 0.0;
      
      	for(int i=0; i< N;  i++){
          	for(int j=0; j< N;  j++){
              sum_db += aiD[i][j];
            }
        }
        System.out.println(sum_db/N); 
        return;
	}
}


Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {

  int N; std::cin >> N;
  int T, A; std::cin >> T >> A;

  int ans = 0;
  float diffmin = std::numeric_limits<float>::max();
  for(int i=0; i<N; i++) {
    int H; std::cin >> H;
    if ( diffmin > std::abs( (T-H*0.006)-A ) ) {
      diffmin =  std::abs( (T-H*0.006)-A );
      ans = i+1;
    }
  }

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

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

int gcd(int m, int n){
 if(n==0) return m;
 return gcd(n, m%n);
}

int main(){
 int W, H, C;
 cin >> W >> H >> C;

 int g = gcd(W, H);

 cout << W/g*H/g*C << endl;

 return 0;
} 

Measured memory_bytes: 3084
n = int(input())
aaa = list(map(int, input().split()))
ans = 0
while True:
    flag = True
    for i, a in enumerate(aaa):
        if a >= n:
            flag = False
            k = (a - n) // n + 1
            ans += k
            for j in range(n):
                if i == j:
                    aaa[j] -= k * n
                else:
                    aaa[j] += k
    if flag:
        break
print(ans)


Measured memory_bytes: 3060
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const n = +input[0];

const toNum = (x:number) => +(x.toString(4).replace(/3/g,"7").replace(/2/g,"5").replace(/1/g,"3"));
let crr = 0;
let result = 0;
loop:
while(true){
  const crr4 = crr.toString(4);
  const check = [false, false, false, false]
  for(let i=0; i<crr4.length; i++){
    if(crr4[i] === "0") {
      crr += 1;
      continue loop;
    }
    check[+crr4[i]] = true;
  }
  if(toNum(crr) > n) break;
  if (check[1] && check[2] && check[3]) result += 1;
  crr += 1;
}

console.log(result);


Measured memory_bytes: 10296