akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x-x;}

void resolve() {
    string s;
    cin >> s;
    int n[4];
    REP(i,0,4) n[i] = s[i] - '0';
    REP(i,0,1) {
        if (n[0] + n[1] + n[2] + n[3] == 7) printf("%d+%d+%d+%d=7\n", n[0], n[1], n[2], n[3]);
        else if (n[0] + n[1] + n[2] - n[3] == 7) printf("%d+%d+%d-%d=7\n", n[0], n[1], n[2], n[3]);
        else if (n[0] + n[1] - n[2] + n[3] == 7) printf("%d+%d-%d+%d=7\n", n[0], n[1], n[2], n[3]);
        else if (n[0] + n[1] - n[2] - n[3] == 7) printf("%d+%d-%d-%d=7\n", n[0], n[1], n[2], n[3]);
        else if (n[0] - n[1] + n[2] + n[3] == 7) printf("%d-%d+%d+%d=7\n", n[0], n[1], n[2], n[3]);
        else if (n[0] - n[1] + n[2] - n[3] == 7) printf("%d-%d+%d-%d=7\n", n[0], n[1], n[2], n[3]);
        else if (n[0] - n[1] - n[2] + n[3] == 7) printf("%d-%d-%d+%d=7\n", n[0], n[1], n[2], n[3]);
        else if (n[0] - n[1] - n[2] - n[3] == 7) printf("%d-%d-%d-%d=7\n", n[0], n[1], n[2], n[3]);
    }
}

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

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



struct Point{
	ll x,y;
};

ll W,H,V,T,X,Y,P,Q,R;
ll num_row,num_col,center_row,center_col;
Point center;

Point calc_loc(ll row,ll col){

	Point point;
	point.x = col*W;

	if(abs(center_col-col)%2 == 0){
		point.x += P;
	}else{
		point.x += (W-P);
	}

	point.y = (row*H);

	if(abs(center_row-row)%2 == 0){
		point.y += Q;
	}else{
		point.y += (H-Q);
	}
	return point;
}


ll calc_dist(Point a,Point b){
	return ((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}

ll calc_left(ll row){

	ll left = 0,right = center_col,m = (left+right)/2;
	ll res = BIG_NUM;

	Point point;

	while(left <= right){
		point = calc_loc(row,m);

		if(calc_dist(point,center) <= R*R){
			res = m;
			right = m-1;
		}else{
			left = m+1;
		}
		m = (left+right)/2;
	}

	return res;
}

ll calc_right(ll row){

	ll left = center_col,right = num_col-1,m = (left+right)/2;
	ll res = num_col;

	Point point;

	while(left <= right){
		point = calc_loc(row,m);

		if(calc_dist(point,center) > R*R){
			res = m;
			right = m-1;
		}else{
			left = m+1;
		}
		m = (left+right)/2;
	}

	return res;
}

int main(){

	scanf("%lld %lld %lld %lld %lld %lld %lld %lld",&W,&H,&V,&T,&X,&Y,&P,&Q);

	R = V*T;

	num_row = 2*(R/H+2)+1;
	num_col = 2*(R/W+2)+1;

	center.x = W*(R/W+2)+X;
	center.y = H*(R/H+2)+Y;

	center_row = (R/H+2);
	center_col = (R/W+2);

	ll ans = 0,left,right;

	for(ll row = num_row-1; row >= 0; row--){
		left = calc_left(row);
		if(left == BIG_NUM)continue;
		right = calc_right(row);
		ans += (right-left);
	}

	printf("%lld\n",ans);

	return 0;
}



Measured memory_bytes: 3204
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>
#include "bits/stdc++.h"

namespace adaptor = boost::adaptors;

const int64_t max = 100000;
const int64_t sentinel = 10000000000;

struct Card {
    char suit;
    int64_t value;
};

Card L[max / 2 + 2], R[max / 2 + 2];

void merge(Card A[], int64_t n, int64_t left, int64_t mid, int64_t right) {
    int64_t n1 = mid - left;
    int64_t n2 = right - mid;
    for (int64_t i = 0; i < n1; i++) {
        L[i] = A[left + i];
    }
    for (int64_t i = 0; i < n2; i++) {
        R[i] = A[mid + i];
    }
    L[n1].value = R[n2].value = sentinel;

    int64_t i = 0, j = 0;
    for (int64_t k = left; k < right; k++) {
        if (L[i].value <= R[j].value) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }
    }
}

void mergeSort(Card A[], int64_t n, int64_t left, int64_t right) {
    int64_t mid;
    if (left + 1 < right) {
        mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int64_t partition(Card A[], int64_t n, int64_t p, int64_t r) {
    int64_t i, j;
    Card x;
    x = A[r];
    i = p - 1;
    for (j = p; j < r; j++) {
        if (A[j].value <= x.value) {
            i++;
            std::swap(A[i], A[j]);
        }
    }
    std::swap(A[i + 1], A[r]);
    return i + 1;
}

void quickSort(Card A[], int64_t n, int64_t p, int64_t r) {
    if (p < r) {
        int64_t q = partition(A, n, p, r);
        quickSort(A, n, p, q - 1);
        quickSort(A, n, q, r);
    }
}

void solve() {
    int64_t n;
    std::cin >> n;

    Card A[max], B[max];
    char s;
    int64_t v;
    for (int64_t i = 0; i < n; i++) {
        std::cin >> s >> v;
        A[i].suit = B[i].suit = s;
        A[i].value = B[i].value = v;
    }

    mergeSort(A, n, 0, n);
    quickSort(B, n, 0, n - 1);

    bool stable = true;
    for (int64_t i = 0; i < n; i++) {
        if (A[i].suit != B[i].suit) stable = false;
    }

    if (stable) {
        std::cout << "Stable" << std::endl;
    } else {
        std::cout << "Not stable" << std::endl;
    }

    for (int64_t i = 0; i < n; i++) {
        std::cout << B[i].suit << " " << B[i].value << std::endl;
    }

    return;
}

int main() {
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}



Measured memory_bytes: 7780
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> t(n+1),x(n+1),y(n+1);
  for(int i=0;i<n;i++){
    cin >> t[i+1] >> x[i+1] >> y[i+1];
  }
  bool can=true;
  for(int i=0;i<n;i++){
    int dt=t[i+1]-t[i];
    int dis=abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
    if(dt<dis){
      can=false;
      break;
    }
    if(dt%2!=dis%2){
      can=false;
      break;
    }
  }
  if(can){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;
 
int h[100010];
int dp[100010];
 
int main()
{
	int N, K;
 
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> h[i];
		dp[i + 1] = mod;
	}
	dp[0] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 1; j <= K; j++) {
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[j + i] - h[i]));
		}
	}
	cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
long long int n,k;
long long int a[200000];

int f(long long int x)
{
    long long int ai,res,ok,ng,mid;
    res = 0;
    for (int i = 0; i < n; i++)
    {
        // printf("%lld\n", res);
        ai = a[i];
        if(ai == 0){
            if(x < 0){
                res += 0;
            } else {
                res += n - 1;
            }
        } else
        {
            if(ai <= -1){
                if (ai * ai <= x){
                    res -= 1;
                }
                ok = n;
                ng = -1;
                while (ok-ng>1)
                {
                    mid = (ok + ng) / 2;
                    if(a[mid]*ai<=x){
                        ok = mid;
                    } else {
                        ng = mid;
                    }
                }
                res += n - ok;
            } else
            {
                if (ai * ai <= x)
                {
                    res -= 1;
                }
                ok = -1;
                ng = n;
                while (ng - ok > 1)
                {
                    mid = (ok + ng) / 2;
                    if (a[mid] * ai <= x)
                    {
                        ok = mid;
                    }
                    else
                    {
                        ng = mid;
                    }
                }
                res += ok + 1;
            }
            
        }
    }
    // printf("%lld\n", res);
    return k <= res / 2;
}
int asc(const void *a, const void *b)
{
    long long *A = (long long *)a;
    long long *B = (long long *)b;
    if (*A > *B)
        return 1;
    if (*A < *B)
        return -1;
    return 0;
}
int main(){
    scanf("%lld", &n);
    scanf("%lld", &k);
    for (int i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
    }
    qsort(a, n , sizeof(long long int), asc);
    long long int ok, ng,mid;
    ok = 1000000000000000000;
    ng = -1000000000000000000 - 1;
    while(ok - ng>1){
        mid = (ok + ng) / 2;
        if(f(mid)){
            ok = mid;
        } else {
            ng = mid;
        }
    }
    printf("%lld\n", ok);

    return 0;
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  int res = 0;
  bool ok = true;
  while (ok) {
    rep(i, n) {
      if (a.at(i) % 2 == 1) {
        ok = false;
        break;
      }
      a.at(i) /= 2;
    }
    if (ok) {
      res++;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if (i & 1) {
            if (s[i] == 'R') {
                cout << "No";
                return 0;
            }
        } else {
            if (s[i] == 'L') {
                cout << "No";
                return 0;
            }
        }
    }
    cout << "Yes";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>*/
 
#define pb push_back
#define mp make_pair
#define sz(s) ((int)(s.size()))
#define all(s) s.begin(), s.end()
#define rep(i, a, n) for (int i = a; i <= n; ++i)
#define per(i, n, a) for (int i = n; i >= a; --i)
#define onlycin ios_base::sync_with_stdio(false); cin.tie(0) 
using namespace std;
// using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
/*typedef tree<
pair < int, int >,
null_type,
less< pair < int, int > >,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;*/
// find_by_order() order_of_key()
const int MAXN = (int)5e5+228;
const char nxtl = '\n';
const int mod = (int)1e9+7;
const double eps = (double)1e-7;
template<typename T> inline bool updmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
template<typename T> inline bool updmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}

int n, m, a[333][333], cnt[333], last[333], ban[333];

inline bool check(int mid) {
	memset(last, 0, sizeof last);
	memset(ban, 0, sizeof ban);
	rep(i, 1, n) last[i] = 1;
	while(1) {
		bool ok = 1;
		memset(cnt, 0, sizeof cnt);
		rep(i, 1, n) {
			cnt[a[i][last[i]]]++;
			if(cnt[a[i][last[i]]] > mid || ban[a[i][last[i]]]) ok = 0;
		}
		if(ok) return 1;
		rep(i, 1, n) {
			if(cnt[a[i][last[i]]] > mid || ban[a[i][last[i]]]) {
				if(last[i] == n) return 0;
				ban[a[i][last[i]]] = 1;
				last[i]++;
			}
		}
	}
	assert(0);
}

int main() {
	#ifdef accepted
		freopen(".in", "r", stdin);
		freopen(".out", "w", stdout);
	#endif
	onlycin;
	cin >> n >> m;
	rep(i, 1, n) {
		rep(j, 1, m) cin >> a[i][j];
	}
	int l = 0, r = n + 1;
	while(r - l > 1) {
		int mid = l + r >> 1;
		if(check(mid)) r = mid;
		else l = mid;
	}
	cout << r << nxtl;
	
	return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
int main() {
	ll n, t, t2, t3;
	cin >> n;
	t = n / 3;
	t2 = n / 5;
	t3 = n / 15;
	printf("%lld\n", n * (n + 1) / 2 - t * (t + 1) / 2 * 3 - t2 * (t2 + 1) / 2 * 5 + t3 * (t3 + 1) / 2 * 15);
	return 0;
}


Measured memory_bytes: 3716
import collections

h, w, n = map(int, input().split())
squares = collections.defaultdict(lambda: collections.defaultdict(int))
for index in range(n):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    for i in range(-2, 1):
        for j in range(-2, 1):
            y = a + i
            x = b + j
            if 0 <= x < w - 2 and 0 <= y < h - 2:
                squares[y][x] += 1
counter = collections.Counter()
for y, xs in squares.items():
    for x, count in xs.items():
        counter[count] += 1
print((h - 2) * (w - 2) - sum(counter.values()))
for i in range(1, 10):
    print(counter[i])

Measured memory_bytes: 145464
#include "stdio.h"

int N, Q, l[100000], r[100000];
char S[100000];
int map[100000];

void load(void);
void calc(void);

int main(void){
  load();
  calc();
}

void load(void){
  scanf("%d %d\n%s\n", &N, &Q, S);
  for(int i = 0;i < Q;i++){
    scanf("%d %d\n", &l[i], &r[i]);
  }
}

void calc(void){
  int count = 0, Aflag = 0;
  for(int i = 0;i < N;i++){
    if(S[i] == 'C' && Aflag == 1){
      count++;
    }
    if(S[i] == 'A'){
      Aflag = 1;
    }else{
      Aflag = 0;
    }
    map[i] = count;
  }
  for(int i = 0;i < Q;i++){
    count = map[r[i] - 1] - map[l[i] - 1];
    printf("\n%d", count);
  }
}

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

using namespace std;

void solve() {
    int N, K;
    cin >> N >> K;
    vector<int> P(N), C(N);
    for (int i = 0; i < N; i++)
    {
        cin >> P[i];
        P[i]--;
    }
    for (int i = 0; i < N; i++)
    {
        cin >> C[i];
    }
    
    long long ans = LONG_LONG_MIN;
    for (int i = 0; i < N; i++)
    {
        int v = i;
        long long cycle_sum = 0;
        long long cycle_cnt = 0;
        while (true)
        {
            cycle_cnt++;
            cycle_sum += C[v];
            v = P[v];
            if (v == i)
            {
                break;
            }
        }
        long long path = 0;
        int cnt = 0;
        while (true)
        {
            cnt++;
            path += C[v];
            if (cnt > K)
            {
                break;
            }
            int num = (K - cnt) / cycle_cnt;
            long long score = path + max(0ll, cycle_sum) * num;
            ans = max(ans, score);

            v = P[v];
            if (v == i)
            {
                break;
            }
            
        }
        
    }
    
    cout << ans << endl;
}

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

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =998244353;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; 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(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   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;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
    


  int main(){
     lint n;
     cin>>n;
     M mp;
     lint sum=0;
     rep(i,n){
         lint x;
         cin>>x;
         mp[x]++;
         sum+=x;
              }
     lint q;
     cin>>q;
     rep(i,q){
         lint b,c;
         cin>>b>>c;
         lint count=mp[b];
         mp[b]=0;
         sum+=(c-b)*count;
         mp[c]+=count;
         cout<<sum<<endl;
     }
     }
     

  
 
  
      
      
    
 
  
          
  

Measured memory_bytes: 9348
const main = (input) => {
  input = input.trim().split('\n')

  const [, k] = input[0].split(' ').map(Number)
  const l = input[1].split(' ').map(Number).sort((a, b) => a - b)

  return console.log(l.slice(0, k).reduce((a, b) => a+b, 0))
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

template <typename T>
struct SegmentTree{
  using F = function<T(T,T)>;
  int n;
  F f;
  T ti;
  vector<T> dat;

  SegmentTree(){}
  SegmentTree(F f,T ti):f(f),ti(ti){}

  void init(int n_){
    n=1;
    while(n<n_) n<<=1;
    dat.assign(n<<1,ti);
  }

  void build(const vector<T> &v){
    int n_=v.size();
    init(n_);
    for(int i=0;i<n_;i++) dat[n+i]=v[i];
    for(int i=n-1;i;i--)
      dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
  }

  void set_val(int k,T x){
    dat[k+=n]=x;
    while(k>>=1)
      dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]);
  }

  T query(int a,int b){
    if(a>=b) return ti;
    T vl=ti,vr=ti;
    for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[l++]);
      if(r&1) vr=f(dat[--r],vr);
    }
    return f(vl,vr);
  }

  template<typename C>
  int find(int st,C &check,T &acc,int k,int l,int r){
    if(l+1==r){
      acc=f(acc,dat[k]);
      return check(acc)?k-n:-1;
    }
    int m=(l+r)>>1;
    if(m<=st) return find(st,check,acc,(k<<1)|1,m,r);
    if(st<=l&&!check(f(acc,dat[k]))){
      acc=f(acc,dat[k]);
      return -1;
    }
    int vl=find(st,check,acc,(k<<1)|0,l,m);
    if(~vl) return vl;
    return find(st,check,acc,(k<<1)|1,m,r);
  }

  template<typename C>
  int find(int st,C &check){
    T acc=ti;
    return find(st,check,acc,1,0,n);
  }
  //アウトの条件を渡す
};

signed main(){
    int N, M;
    cin >> N >> M;
    vector<pair<int,int>>v(N);
    REP(i, N) {
        cin >> v[i].first >> v[i].second;
    }
    sort(ALL(v));
    vector<vector<int>>ls(M + 1);
    vector<vector<int>>rs(M + 2);
    vector<int>start(M + 1, N);
    RREP(i, N) {
        start[v[i].first] = i;
        ls[v[i].first].emplace_back(i);
        rs[v[i].second + 1].emplace_back(i);
    }
    RREP(i, M) CHMIN(start[i], start[i + 1]);
    SegmentTree<int>seg([](int a, int b){return a + b;},0);
    seg.build(vector<int>(N));
    vector<vector<int>>primes(M + 1);
    for(int i = 1; i < M + 1; i++) {
        for(int j = i; j < M + 1; j += i) {
            primes[j].emplace_back(i);
        }
    }
    vector<int>ans(M + 1);
    FOR(i, 1, M + 1) {
        for(auto idx : ls[i]) {
            seg.set_val(idx, 1);
        }
        for(auto idx : rs[i]) {
            seg.set_val(idx, 0);
        }
        for(auto p : primes[i]) {
            int l = start[i - p + 1];
            ans[p] += seg.query(l, N);
        }
    }
    FOR(i, 1, M + 1) out(ans[i]);
}

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

int main(){
  int n;
  cin >> n;
  ll cnt=0;
  int a=1,b=1;
  for(int a=1; a*b<n; a++){
    for(int b=1; a*b<n; b++){
      cnt++;
    }
  }
  cout << cnt << endl;
}

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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define pb push_back


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = 1000100010010010;
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};


/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
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; }
template<class T>auto cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */
vec<vi> edges(100010);



signed main(){


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

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

    rep(i,0,m){
        int f, t; cin >> f >> t;
        f--; t--;
        edges[f].push_back(t);
        edges[t].push_back(f);
    }

    int l = 0;
    int r = edges[0][0];

    set<int> path; 
    path.insert(l); 
    path.insert(r);

    deque<int> ans;
    ans.push_front(l);
    ans.push_back(r);

    bool left = false;
    while(not left){
        bool tmp = true;
        for(int v : edges[l]){
            if(not exist(path, v)){
                tmp = false;
                l = v;
                path.insert(v);
                ans.push_front(v);
                break;
            }
        }
        left = tmp;
    }

    bool right = false;
    while(not right){
        bool tmp = true;
        for(int v : edges[r]){
            if(not exist(path, v)){
                tmp = false;
                r = v;
                path.insert(v);
                ans.push_back(v);
                break;
            }
        }
        right = tmp;
    }
    print(ans.size());
    while(not ans.empty()){
        cout << ans.front() + 1;
        ans.pop_front();
        if(not ans.empty()) cout << " ";
    }
    cout << endl;








    

    

    


    

}



Measured memory_bytes: 11776
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, parser) => {
        $next
    };

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

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn main() {
    input! {
        n: usize,
        x: [i64; n],
    }
    let mut ans: usize = 1 << 40;
    for i in 0..101 {
        let mut sum = 0;
        for &xx in &x {
            let i = i as i64;
            sum += (xx - i) * (xx - i);
        }
        ans = min(sum as usize, ans);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int counter = 0;
  vector<int> a(N);
  for(int i = 0; i<N; i++){
    cin >> a.at(i);
  }
  int button = 1;
  while(button != 2 && counter <= N+1){
    button = a.at(button-1);
    counter++;
  }
  if(counter == N+2){
    counter = -1;
  }
  cout << counter << endl;
}
  



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    int x = 0;
    string s = to_string(n);
    for(char i:s) x += i - '0';
    if(n%x == 0)Yes;
    else No;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(); //N種類の商品
    int M = sc.nextInt(); //M個を選ぶ
    int[] A = new int[N]; //得票数
    int sum = 0; //総投票数
    int cnt = 0; //許容選択数
    String S = ""; //空
    
      for(int i=0; i<N; i++) { //商品 i
        A[i]=sc.nextInt(); 
        sum += A[i];
      }
      for(int i=0; i<N; i++){
        if(A[i]*4*M >= sum){
          cnt++;
        } 
      }
      if(cnt>=M) {
        S="Yes";
      } else {
        S="No";
      }
    System.out.println(S);
  }
}

Measured memory_bytes: 35580
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
#define INFL (ll)1e11
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	int n;
	cin >> n;
	int a[3];
	REP(i, 3) {
		a[2 - i] = n % 10;
		if (a[2 - i] == 1) a[2 - i] = 9;
		else if (a[2 - i] == 9) a[2 - i] = 1;
		n /= 10;
	}

	REP(i, 3) cout << a[i];
	cout << "\n";

	return 0;
}



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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n; cin >> n;
	vector<Int> a(n);
	for(auto &i:a) cin >> i;
	Int k = 0;
	for(size_t i=2; i<a.size(); ++i)
		k ^= a[i];
	Int l = a[0] + a[1];
	if(l - k < 0 || (l - k) % 2 == 1){
		cout << -1 << "\n";
		return 0;
	}
	Int ans = (l - k) / 2;
	for(Int i=1; i<1ll<<41; i<<=1)
		if((ans & i) != 0 && (k & i) != 0){
			cout << -1 << "\n";
			return 0;
		}
	for(Int i=1ll<<40; i>0; i>>=1)
		if((i & k) != 0 && ans + i <= a[0])
			ans += i;
	cout << (ans == 0 || ans > a[0] ? -1 : a[0] - ans) << "\n";
}

Measured memory_bytes: 3516
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
    int n,k;
    while(scanf("%d %d",&n,&k)==2)
    {
        int ara[n+5];
        for(int i=0;i<n;i++)sf("%d",&ara[i]);

        sort(ara,ara+n);
        int mn=INT_MAX;
        for(int i=0;i<=n-k;i++)
        {
            mn=min(mn,ara[i+k-1]-ara[i]);
        }
        pf("%d\n",mn);
    }   
    return 0;
}
 









 




























Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>

void run(void){
  int h,w;
  scanf("%d%d",&h,&w);
  int i,j;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      char s[10];
      scanf("%s",s);
      if(strcmp(s,"snuke")==0){
	printf("%c%d\n",'A'+j,1+i);
      }
    }
  }
}

int main(void){
  run();
  return 0;
}

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() {
	string s;
	cin >> s;
	int count = 0;
	rep(i, s.size() - 1) {
		if (s[i] == s[i+1]) {
			count++;
		}
	}
	if (count > 0) {
		cout << "Bad" << endl;
	} 
	else {
      cout << "Good" << endl;
    }
} 

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


int main() {
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	for (int i = 0;i < n-2;++i) {
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
# AtCoder Beginner Contest 156
# D - Bouquet
# https://atcoder.jp/contests/abc156/tasks/abc156_d
n, a, b = map(int, input().split())
mod = 10**9 + 7

MAX = 202020

cmb = [0]*MAX
facinv = [0]*MAX
inv = [0]*MAX


def nCk_init(n, mod, MAX):
    facinv[0] = facinv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        inv[i] = -inv[mod % i] * (mod // i) % mod
        facinv[i] = facinv[i-1] * inv[i] % mod
    cmb[0] = 1
    for i in range(1, MAX):
        cmb[i] = cmb[i-1] * ((n-i+1)*inv[i] % mod) % mod


nCk_init(n, mod, MAX)
ans = pow(2, n, mod)
ans += mod - cmb[a]
ans %= mod
ans += mod - cmb[b]
ans %= mod
ans += mod - 1
ans %= mod
print(ans)


Measured memory_bytes: 26952
<?php
  fscanf(STDIN, "%d%d", $n, $k);
  $p = explode(" ", trim(fgets(STDIN)));
  $dp = array_fill(0,$n-$k,0);
  for($i=0; $i<$k; $i++){
      $dp[0] += $p[$i];
  }
  for($i=1; $i<=$n-$k; $i++){
      $dp[$i] = $dp[$i-1]-$p[$i-1]+$p[$i+$k-1];
  }
  arsort($dp);
//   print_r($dp);
  $key = key($dp);
  function s($a){
      return ($a*($a+1))/2;
  }
  $ans = 0;
  for($i=$key; $i<$key+$k; $i++){
      $ans += s($p[$i])/$p[$i];
  }
  echo $ans;

Measured memory_bytes: 41444
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000

#define Edge pair<long long,int>

vector<Edge> dijkstra(int s,vector<vector<Edge>> &E){
	int n = E.size();
	vector<Edge> dis(n);
	
	for(int i=0;i<n;i++){
		dis[i].first = Inf;
		dis[i].second = i;
	}
	
	dis[s].first=0;
	priority_queue<Edge,vector<Edge>,greater<Edge>> Q;
	Q.push(make_pair(0,s));
	vector<bool> visited(E.size(),false);
	while(Q.size()!=0){
		Edge e = Q.top();
		Q.pop();
		int now = e.second;
		if(visited[now])continue;
		visited[now] = true;
		
		
		for(int i=0;i<E[now].size();i++){
			long long cost = E[now][i].first;
			int to = E[now][i].second;
			if(dis[now].first + cost < dis[to].first){
				dis[to].first = dis[now].first+cost;
				Q.push(dis[to]);
			}
		}
	}
	
	return dis;
}
		


int main(){
	
	int N,M,S,T;
	cin>>N>>M>>S>>T;
	S--;T--;
	
	vector<vector<Edge>> E(N,vector<Edge> (0));
	
	
	for(int i=0;i<M;i++){
		long long a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		c*=2;
		E[a].push_back(make_pair(c,b));
		E[b].push_back(make_pair(c,a));
	}
	
	vector<vector<Edge>> dis(2);
	vector<vector<Edge>> D;
	
	dis[0] = dijkstra(S,E);
	dis[1] = dijkstra(T,E);
	
	
	D = dis;
	
	long long d = dis[0][T].first;

	for(int i=0;i<2;i++)sort(dis[i].begin(),dis[i].end());
	
	vector<vector<int>> cnt(2,vector<int>(N,0));
	cnt[0][S]=1;cnt[1][T]=1;
	for(int i=0;i<2;i++){
		for(int j=0;j<N;j++){
			long long D1 = dis[i][j].first;
			int from = dis[i][j].second;
			
			for(int k=0;k<E[from].size();k++){
				long long D2 = E[from][k].first;
				int to = E[from][k].second;
				if(D1 + D2 + D[i^1][to].first==d){
					cnt[i][to] = mod(cnt[i][to] + cnt[i][from]);
				}
				
			}
		}
	}
	
	int ho = 0;
	for(int i=0;i<N;i++){
		if(D[0][i].first+D[1][i].first==d&&D[0][i].first==d/2){
			int x = mod(cnt[0][i] * cnt[1][i]);
			x = mod(x*x);
			ho = mod(x+ho);
		}
		
		for(int j=0;j<E[i].size();j++){
			int from = i;
			int to = E[i][j].second;
			long long DD = E[i][j].first;
			if(D[0][from].first+DD+D[1][to].first!=d)continue;
			if(D[0][from].first>=d/2||D[1][to].first>=d/2)continue;
			int x = mod(cnt[0][from]*cnt[1][to]);
			x = mod(x*x);
			ho = mod(x+ho);
		}
		
	}
	
	//cout<<ho<<endl;
	
	int ans = mod(cnt[0][T]*cnt[0][T]);
	
	ans = mod(ans - ho);
	

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


Measured memory_bytes: 20564
import sys

s = input()

hasC = False
hasA = False
for i in range(len(s)):
    if i == 0 and s[i] == 'A' and not hasA:
        hasA = True
        continue
    if i >= 2 and i <= len(s)-2 and s[i] == 'C' and not hasC:
        hasC = True
        continue
    if s[i].islower(): continue

    print("WA")

    sys.exit()


if hasC and hasA: print("AC")
else : print("WA")







Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;

    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    
    typedef std::pair<int, int> pair;
    vector<pair> p;
    rep(i, n) p.push_back(pair(i, a[i]));
    sort(all(p), [](const pair& lhs, const pair& rhs) {
        return lhs.second < rhs.second;
    });

    ll total = 0;
    rep(i, n) {
        int idx = p[i].first;
        ll ai = a[idx];
        ll bi = b[idx];

        if (m >= bi) {
            total += ai * bi;
            m -= bi;
        }
        else {
            total += ai * m;
            break;
        }
    }

    put(total);

    return 0;
}

Measured memory_bytes: 5856
#include<bits/stdc++.h>
using namespace std;
int n, a[100005];
vector<int> adj[100005];

int solve (int cur) {
	int ret = 0, pl = 0;
	vector<int> tmp;
	for(auto nxt : adj[cur]) {
		tmp.push_back(solve(nxt));
	}
	sort(tmp.begin(), tmp.end());
	for(int i=tmp.size();i--;) {
		ret = max(ret, tmp[i] + (++pl));
	}
	return ret;
}

int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;i++) {
		scanf("%d",&a[i]);
		adj[a[i]].push_back(i);
	}
	printf("%d\n",solve(1));
}


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

signed main(){
	int n,m; cin>>n>>m;
	vl h(n);
	rep(i,0,n){
		ll f; cin>>f;
		h[i]=f;
	}
	vl vec[n];
	rep(i,0,m){
		ll a,b; cin>>a>>b;
		--a; --b;
		vec[a].push_back(h[b]);
		vec[b].push_back(h[a]);
	}
	ll ans=0;
	rep(i,0,n){
		ll m=h[i];
		bool ok=true;
		for(ll c:vec[i]){
			if(c>=m) ok=false;
		}
		if(ok){
			ans++;
			//cout<<i<<" ";
		}
	}
	cout<<endl<<ans;
	return 0;
}

Measured memory_bytes: 9852
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

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

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

// 最大流を求めるプログラム　Ford-Fulkerson法
type edge struct {
	to, cap, rev int
}

type node struct {
	to []edge
}

// G :
var G []node
var used []bool

// initG : グラフの初期化
func initG(N int) {
	G = make([]node, N)
}

func addEdge(from, to, cap int) {
	G[from].to = append(G[from].to, edge{to, cap, len(G[to].to)})
	G[to].to = append(G[to].to, edge{from, 0, len(G[from].to) - 1})
}

func dfs(v, t, f int) int {
	if v == t {
		return f
	}
	used[v] = true
	for i, e := range G[v].to {
		if used[e.to] || e.cap <= 0 {
			continue
		}
		d := dfs(e.to, t, min(f, e.cap))
		if d > 0 {
			G[v].to[i].cap -= d
			G[e.to].to[e.rev].cap += d
			return d
		}
	}
	return 0
}

const inf = math.MaxInt64 >> 10

func fordFulkerson(s, t, N int) int {
	flow := 0
	for {
		used = make([]bool, N)
		f := dfs(s, t, inf)
		if f == 0 {
			break
		}
		flow += f
		// out(f)
	}
	return flow
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	a := make([]int, N)
	b := make([]int, N)
	c := make([]int, N)
	d := make([]int, N)
	for i := 0; i < N; i++ {
		a[i], b[i] = getInt(), getInt()
	}
	for i := 0; i < N; i++ {
		c[i], d[i] = getInt(), getInt()
	}

	initG(N*2 + 2)

	for i := 0; i < N; i++ {
		addEdge(0, i+1, 1)
		addEdge(i+N+1, 2*N+1, 1)
	}
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			if a[i] < c[j] && b[i] < d[j] {
				addEdge(i+1, j+N+1, 1)
			}
		}
	}
	res := fordFulkerson(0, 2*N+1, 2*N+2)
	out(res)
}


Measured memory_bytes: 1152
#include<stdio.h>

void writexy(int px1,int px2);

int main()
{
    int n,m,i,ans;
	scanf("%d %d",&n,&m);
	for(i=(m/n);i>0;i--)
	{
		if(m%i==0)break;
	}
	printf("%d",i);
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

bool used[222222];

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

    ll n;cin >> n;

    int ng = 1;
    REP(i, 30){
        if(n == ng){
            cout << "No" << endl;
            return 0;
        }
        ng *= 2;
    }

    int sum = 0;
    REP(i, n){
        sum ^= (i+1);
    }

    cout << "Yes" << endl;
    int now = 2;
    vector<P> ans;
    REP(i, 30){
        if(sum & (1<<i)){

            if(i == 0){
                ans.EB(3, n + 1);
                used[n+1] = true;
            }
            else if(i == 1){
                if(sum & 4){
                    ans.EB(n + 4, n + 2);
                }
                else {
                    ans.EB(5, n+2);
                }
                used[n+2] = true;
            }
            else {
                ans.EB(1<<i, now);
                ans.EB((1<<i)+1, n+(1<<i));
                used[1<<i] = true;
                used[n+(1<<i)] = true;
                now = (1<<i);
            }
        }
    }

    now = 1;
    for(int i = 2;i <= 2*n;i++){
        if(used[i]){
            continue;
        }
        ans.EB(now, i);
        now = i;
    }

    REP(i, ans.size()){
        cout << ans[i].SE << " " << ans[i].FI << endl;
    }

	return 0;
}


Measured memory_bytes: 6892
// ABC 052 B

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

	 string s;
	 cin >> s;

	 int maxi = 0;
	 int tmp = 0;
	 for(int i = 0; i < s.size(); ++i) {
	 	if(s[i] == 'I') ++tmp;
	 	else --tmp;

	 	if(maxi < tmp) maxi = tmp;
	 	else continue;
	 }

	 cout << maxi << "\n";

	 return 0;
}

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

int main(){
    ll n,ans=1,x,y;
    cin>>n>>x;
    rep(i,n-1){
        cin>>y;
        if(x>=y)ans++;
        x=y;
    }
    cout<<ans<<endl<<n<<endl;
}


Measured memory_bytes: 3108
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n, m;
	cin >> n >> m;
	vector<int> s[m];
	for(int i=0; i<m; i++){
		int k;
		cin >> k;
		for(int j=0; j<k; j++){
			int x;
			cin >> x;
			s[i].push_back(x-1);
		}
	}
	int p[m];
	for(int i=0; i<m; i++) cin >> p[i];
	int ans=0;
	for(int i=0; i<(1<<n); i++){
		bool b=true;
		for(int j=0; j<m; j++){
			int cnt=0;
			for(int k=0; k<s[j].size(); k++){
				if((i>>s[j][k])%2==1) cnt++;
			}
			if(cnt%2!=p[j]) b=false;
		}
		if(b) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int min = sc.nextInt();
    int max = sc.nextInt();
    int range = sc.nextInt();
    Set<Integer> lhs = new LinkedHashSet<Integer>();
    for (int i = min; i < Math.min(min + range, max) ; i++) {
      lhs.add(i);
    }
    for (int i = Math.max(max - range + 1, min); i <= max; i++) {
       lhs.add(i);
    }
    for (Integer num : lhs) {
      System.out.println(num);
    }
  }
}

Measured memory_bytes: 21844
import math

A, B, H, M = (int(x) for x in input().split())

H %= 12

deg = abs(H*30 - M*5.5)
if deg >= 180:
    deg = 360 - deg

rad = deg*math.pi / 180

print((A**2 + B**2 - 2*(A*B*math.cos(rad)))**0.5)

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

using namespace std;

int main(){

int R;
cin >> R;

if (R < 1200){
cout << "ABC" << endl;
}else if (R >= 1200 && R< 2800){
cout << "ARC" << endl;
}else{
cout << "AGC" << endl;
}

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String a = scan.next();
        String b = scan.next();
        String X = a + b;
        int target = Integer.valueOf(X);
        boolean answer = false;
        for (int i = 1; i * i <= target; i++) {
            if (i * i == target) {
                answer = true;
                break;
            }
        }
        System.out.println(answer ? "Yes" : "No");
    }
}


Measured memory_bytes: 21844
# -*- coding: utf-8 -*-

N, M = map(int, input().split())

min_num = min(N, M)
max_num = max(N, M)
diff = abs(N-M)
K = 10**9 + 7

if diff >= 2:
    print(0)
    exit()

ans = 0
if diff == 1:
    ans = 1
else:
    ans = 2

for i in range(N):
    ans = ((i+1)*ans) % K

for i in range(M):
    ans = ((i+1)*ans) % K

print(ans)

Measured memory_bytes: 3064