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

int main() {
  int N;
  cin >> N;
  int n = 100010;
  double sqn = sqrt(n);
  vector<int> v(n, 1);
  v[0] = 0;
  v[1] = 0;
  for(int i = 2;i <= sqn;i += 2) {
    if(v[i]) for(int j = 2;i * j <= n;j++) v[i * j] = 0;
    if(i == 2) i--;
  }
  int x = N;
  while(v[x] == 0) x++;
  cout << x << endl;
}

Measured memory_bytes: 3792
#include <math.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <ostream>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int _lcint;
#define REP(i, n) for (_lcint i = 0; i < n; i++)
#define FOR(i, a, b) for (_lcint i = (_lcint)(a); i < (_lcint)(b); i++)
#define FORREV(i, a, b) for (_lcint i = (_lcint)(b)-1; i >= (_lcint)(a); i--)
#define DEBUG(x) cout << #x << ": " << x << endl;
#define DEBUG_VEC(v)  \
  cout << #v << ": "; \
  REP(i, v.size()) cout << " " << v[i] << endl;

#define ALL(a) (a).begin(), (a).end()
#define CHMIN(a, b) a = min((a), (b))
#define CHMAX(a, b) a = max((a), (b))

// permutation
ll mPn(ll m, ll n) {
  ll a = 1;
  REP(i, n) { a *= m - i; }
  return a;
}

// excrametion
ll exc(ll m) {
  ll a = 1;
  FOR(i, 1, m) { a *= i + 1; }
  return a;
}

// combination
ll mCn(ll m, ll n) {
  ll a = 1, b = 1;
  REP(i, n) {
    a *= m - i;
    b *= n - i;
  }
  return a / b;
}

int main() {
  int a[5], k;
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
  int total = 0;
  int bm = 0;

  for (int i = 0; i < 5; i++) {
    int b = 0;
    if (a[i] % 10 != 0) {
      int aa = a[i] % 10;
      if (10 - aa > bm) {
        bm = 10 - aa;
      }
      b = a[i] - aa + 10;
    } else {
      b = a[i];
    }
    total += b;
  }

  cout << total - bm << endl;

  return 0;
}


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



int main() {
	int R, G, B, N;
	int r, g, b, cnt;
	r = g = b = cnt = 0;

	cin >> R >> G >> B >> N;

	for (r = N / R; r >= 0; r--) {
		for (g = (N - r*R) / G; g >= 0; g--) {
			if ((N - r*R - g*G) % B == 0){
				cnt++;
			}		
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int S, h, m, s;
  scanf("%d", &S);

  if (S >= 3600){
    h = S / 3600;
    m = S / 60 - h*60;
    s = S - m*60 - h*3600; 
  }else if (S >= 60){
    h = 0;
    m = S / 60;
    s = S - m*60 - h*3600;
  }else{
    h = 0;
    m = 0;
    s = S;
  } 
  printf("%d:%d:%d\n", h, m, s);
  return 0;
}

Measured memory_bytes: 592
/* 2018-01-15-15.31.11 */
 
#include<bits/stdc++.h>
#define ll long long int
 
using namespace std;
 
int main()
{
    int N,A,B;
    cin >> N >> A >> B;
    if((B-A-1)%2==0) printf("Borys\n");
    else printf("Alice\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int main()
{
 	ios::sync_with_stdio(false);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	cin>>n;
	int a[n];
	for (int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort (a,a+n);
	double ans=a[0];
	for (int i=0;i<n;i++)
	{
		ans=(a[i]+ans)/2;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
namespace ABC126_C
{
    using System;
    using static System.Console;
    using System.Linq;
    using System.Collections.Generic;

    public class Program
    {
        static void Main(string[] args)
        {
            var l = ReadInputsAsInt();
            var n = l.First();
            var k = l.Last();
            WriteLine(Solve(n, k));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="n">N面サイコロの面の数</param>
        /// <param name="k">得点の閾値？</param>
        /// <returns></returns>
        public static double Solve(int n, int k)
        {
            double p = 0.0;

            for (int i = 1; i <= n; i++)
            {
                if (i >= k)
                {
                    p += 1;
                    continue;
                }
                for (int j = 1; ; j++)
                {
                    if (i * Math.Pow(2, j) >= k)
                    {
                        p += Math.Pow(0.5, j);
                        break;
                    }
                }
            }
            return p / n;
        }


        static IEnumerable<int> ReadInputsAsInt() => ReadLine().Split(' ').Select(x => int.Parse(x));

    }
}

Measured memory_bytes: 11348
#include<bits/stdc++.h>
using namespace std ; 
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fast ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define endl "\n"
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define pii pair<int,int> 
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

long long M  = 1e9+7;
 
signed main(){
    fast;
    int n; cin >> n;
    vector <int> a(n+1);
    multiset <int> st1,st2;
    map <int, int> mp1, mp2;
    for(int i=1 ; i<=n ; i++){
    	cin >> a[i];
    	st1.insert(a[i] - i);
    	st2.insert(a[i] + i);
    	mp1[a[i] - i]++;
    	mp2[a[i] + i]++;
    }
    int ans = 0;
    map <int,int> mp;
    for(auto x : st1){
    	if(st2.find(-x) != st2.end()){
    		ans += mp2[-x];
    	}
    }
    for(auto x : st2){
    	if(st1.find(-x) != st1.end()){
    		ans += mp1[-x];
    	}
    }
    cout << ans/2 << endl;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG printf("Hi\n")
#define i64 long long int
#define ui64 unsigned long long int
#define xx first
#define yy second
#define ln 17
#define off 2002

#define IN freopen("circular_circles_input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define sq(x) ((x)*(x))

#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace __gnu_pbds;
using namespace std ;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<int,int> pii;


#define log 20
#define mod 1000000007LL
#define INF 1000000000000000000LL
#define maxn 1000005

const long double eps = 1e-9 ;

i64 a[maxn] ;

int main()
{
    int n , q ;

    scanf("%d %d",&n,&q) ;

    vector <i64> v ;
    v.pb(n) ;

    for(int i=1 ; i<=q ; i++)
    {
        i64 x ;
        scanf("%lld",&x) ;
        while( v.size() > 0 && v.back() >= x ) v.pop_back() ;
        v.push_back(x) ;
    }

    map<i64,i64> cnt ;

    cnt[ v.back() ] = 1 ;

    reverse(v.begin(),v.end()) ;

    for(int i=0; i+1<v.size() ; i++)
    {
      //  printf("-- %lld\n",v[i]) ;
        i64 full = v[i+1] ;
        i64 fullCnt = 0 ;

        while( cnt.size() > 0 )
        {
            map<i64,i64> :: iterator it = cnt.end() ;
            it-- ;

            if( it->xx <= v[i+1] ) break ;

            pair<i64,i64> p = *it ;
            cnt.erase(it) ;

            fullCnt += ( p.xx/full )*p.yy ;
            if( p.xx%full != 0 )
            {
                i64 sz = p.xx%full ;
                if( cnt.find( sz ) == cnt.end() ) cnt[sz] = 0 ;
                cnt[ sz ] += p.yy ;
            }
        }
        if( cnt.find(full) == cnt.end() ) cnt[full] = 0 ;
        cnt[full] += fullCnt ;
    }

    for(auto p:cnt) a[ p.xx ] += p.yy ;

    for(int i=n ; i>=1 ; i--) a[i] += a[i+1] ;

    for(int i=1 ; i<=n ; i++) printf("%lld\n",a[i]) ;

    return 0 ;
}


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

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    bool flag = false;
    for(int i = 1;i <= b;i++){
        int tmp = a*i;
        if(tmp%b == c) flag = true;
    }
    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

char str[10001];
unsigned long long K, A, B;

void receive_input() {
	fgets(str, sizeof(str), stdin);
	sscanf(str, "%llu %llu %llu", &K, &A, &B);
}

void initialize() {
	// nop
}

int main(void) {
	receive_input();
	initialize();

	unsigned long long ans = 1;
	if (A+1 < B) {
		unsigned long long clap = A-1;
		ans += (K - clap) / 2 * (B - A);
		if ((K - clap) % 2 == 1) {
			clap += 1;
		}
		ans += clap;
	} else {
		ans += K;
	}

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

	return 0;
}


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

int main(void)
{
	int oCount = 0, xCount = 0;
	int len;
	char S[16] = {};
	scanf("%s", S);
	len = strlen(S);
	for (int i = 0; i < len; i++)
	{
		if(S[i] == 'o')
			oCount++;
		else if(S[i] == 'x')
			xCount++;
	}

	int day = (15 - len) + oCount;
	if(day >= 8)
		printf("YES\n");
	else
		printf("NO\n");

	return 0;
}

Measured memory_bytes: 128
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>

#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;


Int Tail(Int n) {
	if (n < 10)return n;
	Int tmp = n;
	n /= 10;
	return tmp - n * 10;
}

void calc() {

	Int K; std::cin >> K;
	Int cnt = 0;
	std::queue<Int> q;
	rep(i, 9) {
		q.push(i + 1);
	}
	while (!q.empty()) {
		cnt++;
		Int val = q.front(); q.pop();
		if (cnt == K) {
			std::cout << val;
			break;
		}
		Int tail = Tail(val);
		for (Int i = -1; i <= 1; ++i) {
			Int tmp = tail + i;
			if (tmp < 0 || 9 < tmp)continue;
			q.push(val * 10 + tmp);
		}
	}

}


int main() {

	calc();

	return 0;
}

Measured memory_bytes: 1920
/*
 _    _    _______   _    _
| |  / /  |  _____| | |  / /
| | / /   | |       | | / /
| |/ /    | |_____  | |/ /
| |\ \    |  _____| | |\ \
| | \ \   | |       | | \ \
| |  \ \  | |_____  | |  \ \
|_|   \_\ |_______| |_|   \_\

*/
/*#include <iostream>
#include <cstdio>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <cstring>
#include <string>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <assert.h>*/

#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek

const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const ld eps = 1e-7;
const int N = 2e6 + 6;

int main() {
	ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //freopen("in", "r", stdin);

    ll n, A, B;
    cin >> n >> A >> B;
    cout << max((n - 1) * B + A - ((n - 1) * A + B) + 1, 0ll) << "\n";

	return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]
dij4=[(0,1),(1,0),(-1,0),(0,-1)]

def solve():
    aa = [[-1] * w for _ in range(h)]
    stack = [(si, sj, 0)]

    while stack:
        wall = []
        while stack:
            i, j, d = stack.pop()
            crash = False
            for di, dj in dij4:
                ni, nj = i + di, j + dj
                if ni < 0 or ni >= h or nj < 0 or nj >= w: continue
                if aa[ni][nj] != -1: continue
                if ss[ni][nj]: crash = True
                else:
                    aa[ni][nj] = d
                    stack.append((ni, nj, d))
            if crash: wall.append((i, j, d))

        for i, j, d in wall:
            for di in range(-2, 3):
                for dj in range(-2, 3):
                    if di == 0 and dj == 0: continue
                    ni, nj = i + di, j + dj
                    if ni < 0 or ni >= h or nj < 0 or nj >= w: continue
                    if ss[ni][nj]: continue
                    if aa[ni][nj] != -1: continue
                    aa[ni][nj] = d + 1
                    stack.append((ni, nj, d + 1))

    print(aa[gi][gj])

h,w=MI()
si,sj=MI1()
gi,gj=MI1()
ss=[[1 if c=="#" else 0 for c in SI()] for _ in range(h)]
solve()


Measured memory_bytes: 130096
import math
import sys

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

lis = [0] * N  


for _ in range(M):
    A, B = map(int, input().split())

    hightA = H[A-1]
    hightB = H[B-1]

    if hightA < hightB:
        if lis[B-1] == 0:
            lis[B-1] = 1
            lis[A-1] = -1
        
        elif lis[B-1] == 1 or lis[B-1] == -1:
            lis[A-1] = -1
    
    if hightB < hightA:
        if lis[A-1] == 0:
            lis[A-1] = 1
            lis[B-1] = -1
        
        elif lis[A-1] == 1 or lis[A-1] == -1:
            lis[B-1] = -1

    if hightB == hightA:
        lis[A-1] = -1
        lis[B-1] = -1

ans = 0
for i in lis:
  if i == 0 or i == 1:
    ans = ans + 1

print(ans)


Measured memory_bytes: 20028
#include<bits/stdc++.h>
using namespace std;
string s;
long long ans=0;
long long tom(long long a,long long b,long long c,string d)
{
  long long r=0;
  if(a==d.size())
   return c;
  int t=d[a]-'0';
  if(a+1!=d.size())
   r+=tom(a+1,b*10+t,c,d);
   r+=tom(a+1,0,c+b*10+t,d);
  return r;
}
int main()
{
  while(cin>>s)
      {
        ans=tom(0,0,0,s);
        cout<<ans<<endl;
      }
  return 0;
}

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

int main() {
	int l, r, d;
	cin >> l >> r >> d;
	int ans = 0;
	for(int i = l; i <= r; i++) if(i%d == 0) ans++;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;

int num[26],co[26];

int main(){
  int n,a[110000],b[2]={1,0};
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  ll sum=0,ans,count=0;
  for(int j=0;j<2;j++,count=0,sum=0){
    for(int i=0;i<n;i++){
      sum+=a[i];
      if(i%2==b[j]){
        if(sum>=0){
          count+=sum+1;
          sum=-1;
        }
      }else{
        if(sum<=0){
          count+=1-sum;
          sum=1;
        }
      }
    }
    if(j==0) ans=count;
    else ans=min(ans,count);
  }
  cout<<ans<<endl;
  
}


Measured memory_bytes: 640
def dfs(i: int, t: int, op: str):
  if i == 3:
    if t == 7:
      return op
    else:
      return ""

  return dfs(i + 1, t + s[i + 1], op + "+") + dfs(i + 1, t - s[i + 1], op + "-")

s = list(map(int, list(input())))
op = ""

op = dfs(0, s[0], op)
ans = str(s[0]) + op[0] + str(s[1]) + op[1] + str(s[2]) + op[2] + str(s[3]) + "=7"
print(ans)


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

/*2進数配列+1*/
vector<int> twoadd(vector<int> v, int N){
    v[N-1]+=1;
    int ind = N-1;
    int j=N-1;
    for(j=N-1;j>=1;j--){
        if(v[j]>1){
            v[j-1]+=1;
            v[j]=0;
        }
    }
    return v;
}

/*フィボナッチ*/
long long fibonatti(long long d){
    long long count = 0;
    long long f1 = 1;
    long long f2 = 1;/*ここを変える*/
    long long temp;
    if(d == 1){
        count = f1;
    }else if(d == 2){
        count = f2;
    }else if(d==0){
        count = 1;
    }else{
        for(int i=0;i<d-2;i++){
            temp = f1+f2;
            f1 = f2;
            f2 = temp;
        }
        count = temp;
    }
    return count;
}

/*最大公約数*/
unsigned long long GCD(long long L,long long R){
    if(L>R){
        long long temp=R;
        R = L;
        L = temp;
    }
    unsigned long long pp=0,ppt=0;
    unsigned long long ans=0;
    if(R%L==0){
        ans = L;
    }else{
        while(true){
            ppt = pp;
            pp=R%L;
            if(pp == 0){
                ans = ppt;
                break;
            }
            R = L;
            L = pp;
        }
    }    
    return ans;    
}

/*最小公倍数*/
unsigned long long LCM(long long L,long long R){
    unsigned long long ans;
    unsigned long long gcd = GCD(L,R);
    ans = (L/gcd)*R;
    return ans;
}

/*Combination set*/
#define mod 1000000007
#define maxcomb 1000000/*大きいものを求めるときはここを変える*/
vector<long long> fc(maxcomb+1);
vector<long long> ifc(maxcomb+1);
long long modpow(long long x,long long n){
    long long ans = 1;
    while(n > 0){
        if(n & 1) {
            ans = ans*x%mod;
        }
        x = x*x%mod;
        n >>= 1;
    }
    return ans;
}
void Conb(){
    fc[0]= 1;
    ifc[0]=1;
    for(long long i=0;i<maxcomb;i++){
        fc[i+1] = fc[i]*(i+1)%mod;//n!(mod)
        ifc[i+1] = ifc[i]*modpow(i+1,mod-2)%mod;//k!^{M-2} (mod)
    }
}
unsigned long long Combination(long long L,long long R){
    unsigned long long up=1,ans;
    Conb();
    if(L==0&&R==0){
        return 1;
    }else if(L<R||L<0){
        return 0;
    }else{
        long long t = ifc[L-R]*ifc[R]%mod;
        ans = t*fc[L]%mod;
    }
    return ans;
}
/*Combination set ここまで*/

/*ここから*/
int main() {
    ll N;
    cin >> N;
    if(N==1){
        cout << 0 << endl;
        exit(0);
    }
    ll ans= modpow(10,N)-modpow(9,N)-modpow(9,N)+modpow(8,N);
    ans %= mod;
    ans = (ans+mod)%mod;
    cout << ans << endl;
    return 0;
}

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

int main(void){
    int n; cin >> n;
    string s; cin >> s;
    ll ans=0;
    vector<vector<int>> dp(5005,vector<int>(5005,0));
    for(int i=n-1;0<=i;i--){
        for(int j=n-1;0<=j;j--){
            if(s[i]==s[j]) dp[i][j] = dp[i+1][j+1] + 1;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            int tmp = min(dp[i][j],j-i);
            if(ans < tmp) ans = tmp;
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 98432
import java.util.Scanner;

class Main {
/*
  static int DrawingLots(int j, int i, int[][] ab, int n) {
    for (; j < n; j++) {
      if (ab[j][0] == i) return DrawingLots(j+1, ab[j][1], ab, n);
      else if (ab[j][1] == i) return DrawingLots(j+1, ab[j][0], ab, n);
    }
      return i;
  }
*/
public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);

    int w = stdIn.nextInt(); int[] ans = new int[w];
    int n = stdIn.nextInt(); 

    for (int i = 0; i < w; i++) {
      ans[i] = i+1;
    }
    for (int i = 0; i < n; i++) {
      String tmp = stdIn.next();
     String[] ab = tmp.split(",");
      int a = Integer.parseInt(ab[0]) - 1;
      int b = Integer.parseInt(ab[1]) - 1;
      int tmpnum;
      tmpnum = ans[a];
      ans[a] = ans[b];
      ans[b] = tmpnum;
    }
/*
    for (int i = 1; i < w+1; i++) {
      int j = 0;
      ans[i] = DrawingLots(j, i, ab, n);
    }  
*/
/*
    for (int i = 1; i < w+1; i++) {
    for (int j = 1; j < w+1; j++)
      if (ans[j] == i)
      System.out.println(j);
    }
*/
    for (int i=0; i < w; i++)
    System.out.println(ans[i]);
  }
   
}


Measured memory_bytes: 26340
N, M = map(int, input().split())
li = [int(p) for p in list(input().split())]
total=sum(li)
count=0
for l in li:
    if l >= total*0.25/M:
        count+=1
    else:
        pass
if count >= M:
    print("Yes")
else:
    print("No")

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main(){
    COMinit();
   ll n;cin >>n;
   vector<ll>a(n+1);
   vector<ll>cnt(n,0);
    for (int i = 0; i < n+1; ++i) {
        cin >>a[i];
        a[i]--;
        cnt[a[i]]++;
    }
    ll key;
    for (int i = 0; i < n; ++i) {
        if(cnt[i]==2)key=i;
    }
    ll l,r;
    ll co=0;
    for (int i = 0; i < n+1; ++i) {
        if(co==0&&a[i]==key){
            l=i;
            co++;
        }
        else if(a[i]==key){
            r=n-i;
        }
    }
//    cout <<l<<r<<endl;
    for (int k = 1; k <=n+1; ++k) {
        ll ans=COM(n+1,k)-COM(l+r,k-1);
//        cout <<COM(n+1,k)<<" "<<COM(l+r,k-1)<<endl;
        ans%=mod;
        if(ans<0)ans+=mod;
        cout <<ans <<endl;
    }
   return 0;
}

Measured memory_bytes: 14720
open System
open System.Collections.Generic

let N = stdin.ReadLine() |> int
let dic = new Dictionary<string, int64>()

let rec resolver s i =
    if i = N then s
    else
        let rs =
            stdin.ReadLine().ToCharArray()
            |> Array.sort
            |> fun x -> new String(x)
        if dic.ContainsKey(rs) then dic.[rs] <- dic.[rs] + 1L
        else dic.[rs] <- 0L
        resolver (s + dic.[rs]) (i + 1)

resolver 0L 0 |> stdout.WriteLine

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

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(1000010);

int main() {
  int n;
  cin >> n;
  vector<mint> a(n), s(n + 1);
  rep(i, n) cin >> a[i];
  rep(i, n) s[i + 1] = a[i] + s[i];
  mint ans = 0;
  rep(i, n - 1) ans += a[i] * (s[n] - s[i + 1]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 22004
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;} 
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<ll> T(n);
  rep(i,n) cin >> T[i];
  
  ll ans = T[n - 1];
  rep(i,n - 1){
  	ans = lcm(ans, T[i]);
  }
  
  dunk(ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define vt vector
#define ii pair<int,int>
#define pb push_back
#define pob pop_back
#define vi vt<int>
#define vvi vt<vi>
#define vii vt<ii>
#define vvii vt<vii>
typedef long long ll;
#define For(i,a,b) for(int i = a; i < b; i++)
#define foR(i,a,b) for(int i = a; i <= b; i++)
#define roF(i,a,b) for(int i = a - 1; i >= b; i--)
#define Rof(i,a,b) for(int i = a; i >= b; i--)

int a[51], b[51];
map<ii,int> cnt;

signed main (){
	/*
	freopen(".inp","r",stdin);
	freopen(".out","w",stdout);
	*/
	int n;
	cin >> n;
	For(i,0,n){
		cin >> a[i] >> b[i];
	}
	For(i,0,n){
		For(j,0,n){
			if(i != j){
				cnt[ii(a[i]-a[j],b[i]-b[j])]++;
			}
		}
	}
	int mymax = 0;
	for(auto i : cnt){
		mymax = max(mymax,i.second);
	}
	cout << n - mymax;
}



Measured memory_bytes: 384
#!/usr/bin/env python3
from collections import Counter
n, *A = map(int, open(0).read().split())
A.sort()
c, s = Counter(A), set()
M = max(A) + 1
ans = 0
for a in A:
    if a in s:
        continue
    ans += c[a] == 1
    for i in range(a, M, a):
        s.add(i)
print(ans)

Measured memory_bytes: 104520
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;

const int maxn = 52;
const int mo = 1e9 + 7;

int n;

vector<vector<int> > multiply(vector<vector<int> > &a, vector<vector<int> > &b) {
	vector<vector<int> > res(n, vector<int>(n));
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			for(int k = 0; k < n; ++k)
				res[i][j] = ((long long)a[i][k] * b[k][j] % mo + res[i][j]) % mo;

	return res;
}

void fastPower(vector<vector<int> > &res, vector<vector<int> > &a, long long k) {

	for (int i = 0; i < n; ++i)
		res[i][i] = 1;
	
	while (k > 0) {
		if (k&1)
			res = multiply(res, a);

		k >>= 1;
		a = multiply(a, a);
	}
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	long long K;
	cin >> n >> K;

	vector<vector<int> > a(n, vector<int>(n)), b(n, vector<int>(n));
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			cin >> a[i][j];

	fastPower(b, a, K);
	
	long long res = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j)
			res += b[i][j];
		res %= mo;
	}

	cout << res << endl;

	return 0;
}

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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

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

const ll inf = 1LL<<60;

int main()
{
  ll H; cin >> H;
  ll W; cin >> W;
  ll m; cin >> m;
  vector<ll> h(H);
  vector<ll> w(W);
  set<pair<ll, ll>> st;
  for (int i=0; i<m; i++) {
    ll y,x; cin>>y>>x; y--; x--;
    h[y]++;
    w[x]++;
    st.insert(make_pair(y, x));
  }

  ll hmax = 0;
  ll wmax = 0;
  rep(i, H) hmax = max(hmax, h[i]);
  rep(i, W) wmax = max(wmax, w[i]);

  vector<ll> hh, ww;
  rep(i, H) if (h[i] == hmax) hh.push_back(i);
  rep(i, W) if (w[i] == wmax) ww.push_back(i);

  ll f = -1;
  for (auto i:hh) {
    if (f == 0) break;
    for (auto j:ww) {
      if (st.find(make_pair(i, j)) == st.end()) {
        f = 0;
        break;
      }
    }
  }
  cout << hmax + wmax + f << endl;

  return 0;
}


Measured memory_bytes: 34952
n, m= map(int, input().split())

links = [[] for x in range(n + 1)]
sums = [0 for x in range(n + 1)]
adds = [0 for x in range(n + 1)]

links[0].append(1)
for _ in range(n - 1):
  a, b= map(int, input().split())
  links[a].append(b)
  links[b].append(a)

for _ in range(m):
  p, x = map(int, input().split())
  adds[p] += x

que = [0,[1]]
checked = [0 for x in range(n+1)]

que = [[-1, [0]]]

while que:
  link = que.pop()
  par = link[0]
  childs = link[1]

  for child in childs:
    if checked[child] != 1:
      sums[child] = sums[par] + adds[child]
      que.append([child, links[child]])
      checked[child] = 1

  
print(*sums[1:])

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

#define x first
#define y second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const int mod=1000000000+7;

int addm(int& a,int b) {return (a+=b)<mod?a:a-=mod;}

template<class T,class U> bool smin(T& a,U b) {return a>b?(a=b,1):0;}
template<class T,class U> bool smax(T& a,U b) {return a<b?(a=b,1):0;}

int id[3][200001],sz[3][200001],par[3][200001];
vi al[3][200001];
int n,k,l;
int ans[200001];

vector<ii> seen;

int dfs(int cc,int i,int cid,int p) {
	if (id[cc][i]) return 0;
	int &ans=sz[cc][i];
	par[cc][i]=p;
	id[cc][i]=cid;
	if (cc==2) seen.push_back({id[1][i],i});
	ans=1;
	for (int j:al[cc][i]) ans+=dfs(cc,j,cid,p);
	return ans;
}

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

	cin >> n >> k >> l;
	for (int i=0;i<k;i++) {
		int u,v;
		cin >> u >> v;u--;v--;
		al[0][u].push_back(v);
		al[0][v].push_back(u);
	}
	for (int i=0;i<l;i++) {
		int u,v;
		cin >> u >> v;u--;v--;
		al[1][u].push_back(v);
		al[1][v].push_back(u);
	}
	copy(al[0],al[0]+n,al[2]);

	for (int cc=0;cc<3;cc++) {
		int idc=1;
		for (int i=0;i<n;i++) if (id[cc][i]==0) {
			dfs(cc,i,idc++,i);
			if (cc==2) {
				sort(seen.begin(),seen.end());
				//for (ii a:seen) cout << a.x << ' ' << a.y << endl;
				//cout << endl;
				for (int c=0,d=0;c<seen.size();c=d) {
					for (;d<seen.size() && seen[c].x==seen[d].x;d++);
					for (int e=c;e<d;e++) ans[seen[e].y]=d-c;
				}
				seen.clear();
			}
		}
	}
/*
	for (int i=0;i<3;i++) {
		for (int j=0;j<n;j++) cout << id[i][j] << ' ';
		cout << endl;
	}
*/
	for (int i=0;i<n;i++) {
		if (i) cout << ' ';
		cout << ans[i];
	}
	cout << endl;
}

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

const int MAXN = 133, MAXW = 1e5 + 33;

ll dp[MAXN][MAXW];
int n ,w, waga[MAXN], koszt[MAXN];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> w;
	for(int i = 1; i <= n; i++) {
		cin >> waga[i] >> koszt[i];
	}
	for(int i = 1; i <= n ; i++) {
		for(int j = 0; j <= w; j++) {
			dp[i][j] = max(dp[i][j], dp[i - 1][j]);
			if(waga[i] <= j) {	
				dp[i][j] = max(dp[i][j], dp[i - 1][j - waga[i]] + (ll)koszt[i]);
			}
		}
	}
	ll wy = 0;
	for(int i = 0; i <= w; i++) wy = max(wy, dp[n][i]);
	cout << wy;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
#define MAX (1 << 20)
#define mod 1000000007

long long dp[MAX+1][2];
long long zerocount[MAX+1];
int pre[MAX+1];


long long modpow(int n, int r) {
    long long ret = 1; long long tmp = (long long) n;
    while (r != 0) {
        if (r % 2) ret *= tmp;
        tmp *= tmp; tmp %= mod; ret %= mod;
        r /= 2;
    }
    return ret;
}

int main() {
    int n; cin >> n;
    vector<int> v(n); int all = 0;
    for (int i = 0; i < n; i++) {
        cin >> v[i]; all ^= v[i]; v[i] = all;
    }
    memset(pre, -1, sizeof(pre));
    for (int i = 0; i < n; i++) {
        int c = v[i];
        zerocount[i+1] = zerocount[i] + (c == 0);
        if (pre[c] == -1) {
            dp[c][0] = 1; dp[c][1] = 1;
        } else {
            long long zc = (zerocount[i]-zerocount[pre[c]]);
            dp[c][1] = (dp[c][1] + zc * dp[c][0]) % mod;
            dp[c][0] = (dp[c][0] + dp[c][1]) % mod;
        }
        pre[c] = i;
    }
    long long sum = 0;
    for (int i = 1; i <= MAX; i++) {
        sum += dp[i][0]; sum %= mod;
    }
    if (all) {
        cout << dp[all][1] % mod << endl;
    } else {
        long long ans = sum + modpow(2, zerocount[n]-1);
        cout << ans % mod << endl;
    }
    return 0;
}

Measured memory_bytes: 26752
// abc167_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    ll A, B, C, K;
    cin >> A >> B >> C >> K;

    if (K <= A){
        print(K);
    } else if (K <= A + B){
        print(A);
    } else {
        print(A - (K - A - B));
    }

    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
using namespace std;
int main() {
    int c[5] = {};
    for (int i = 0; i < 6; i++) { int x; cin >> x; c[x]++; }
    int d[3] = {};
    for (int i = 1; i <= 4; i++) d[c[i]]++;
    cout << (d[1] == 2 && d[2] == 2 ? "YES" : "NO") << endl;
}


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

using namespace std;

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

#define int ll

main(){
	int n;
	int a[200001];
	int sum[200001];

	cin >> n;
	for(int i=0;i<n;i++) cin >> a[i];

	sum[0] = a[0];
	for(int i=1;i<n;i++) sum[i] = sum[i-1] + a[i];

	ll ans = sum[n-1];
	for(int i=0;i<n;i++){
		ans = min(ans, abs(sum[n-1]-2*sum[i]));
	}

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

	return 0;
}


Measured memory_bytes: 6868
#include <stdio.h>

int main(){

  int N,i,sum=0,S1=0,S2=0,min=10000,j,k;
  scanf("%d", &N);

  int W[N];

  for(i=0;i<N;i++){
    W[i]=0;
    scanf("%d", &W[i]);
    sum+=W[i];
  }

  for(j=0;j<N-1;j++){
    S1=0;
    for(k=0;k<j+1;k++){
      S1+=W[k];
    }
    S2=sum-S1;
    if(S1>S2){
      if(S1-S2<min){
        min=S1-S2;
      }
    }else{
      if(S2-S1<min){
        min=S2-S1;
      }
    }
  }

  printf("%d\n", min);
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
import java.util.InputMismatchException;

public class Main
{
	public static int combination(int n, int s, int ans, int lowlim)
	{
		if(lowlim <= 9)
		{
			if( n == 1 && (s >= lowlim && s <= 9) )
			{
				ans++;
			}
			else if(s >= lowlim * n && s <= 9 * n)
			{
				for(int i = lowlim; i <= 9 && s - i >= 0; i++)
				{
					ans = combination(n - 1, s - i, ans, i + 1);
				}
			}
		}
		
		return ans;
	}
	
	public static void main(String[] args)
	{
		try
		{
			Scanner sc = new Scanner(System.in);
			int ans;
			
			while(true)
			{
				int n = sc.nextInt();
				int s = sc.nextInt();
				if(n == 0 && s == 0)
				{
					break;
				}
				
				ans = 0;
				ans = combination(n, s, ans, 0);
				System.out.println(ans);
			}
		}
		catch(InputMismatchException e)
		{
			System.out.println(e);
		}
	}
}

Measured memory_bytes: 25980
#include <bits/stdc++.h>
using namespace std;
 
 
int N,W,w[104], v[104];
long long dp[104][100004];
 
int main() {
	cin>>N>>W;
	for(int i=0; i<N; i++)	cin>>w[i]>>v[i];
	for(int i = 0 ; i < N ; i++)
		for(int j = 0 ; j <=100000; j++)
			dp[i][j] = 987654321000;
  
	dp[0][0] = 0;
	
	for(int i=0; i<N;  i++){
		for(int value=0; value<=100000; value++){
			if(v[i]>value)	dp[i+1][value] = dp[i][value];
			else dp[i+1][value] = min(dp[i][value], dp[i][value-v[i]]+w[i]);
		}
	}
	for(int j=100000; j>=0; j--)
	if(dp[N][j]<=W){
		cout<<j;
		break;
	}
 
	return 0;
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define all_acc(x) (x).begin(),(x).end(),0LL
#define int long long
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;

void output(vector<int> s){
    int n=s.size();
    for(int i=0;i<n;i++){
        //if(i!=0) cout<<" ";
        cout<<s[i]<<endl;
    }
    //cout<<endl;
}


int D,score;
vector<int> c(27);
vector<int> last_day(27);
vector<vector<int>> s(D,vector<int>(27));
vector<int> t;

int unpresure(int d,int i){
    return c[i]*(d-last_day[i]);
}

int good_contest(int d){
    int contest=distance(s[d].begin(),max_element(s[d].begin()+1,s[d].end()));
    t.push_back(contest);
    return contest;
}

void day(int d,int i){
    score+=s[d][i];
    last_day[i]=d;
    for(int j=1;j<=26;j++){
        score-=unpresure(d,j);
    }
}

signed main(){ 
   cin>>D; score=0;
   last_day.assign(27,0);
   s.assign(D+1,vector<int>(27));


   for(int i=1;i<=26;i++) cin>>c[i];

   for(int i=1;i<=D;i++){
       for(int j=1;j<=26;j++){
           cin>>s[i][j];
       }
   }

   for(int d=1;d<=D;d++){
       int good=good_contest(d);
       day(d,good);
   }

   output(t);

}  

Measured memory_bytes: 3728
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
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;}
const long long INF=1LL<<60;
//set<int>::iterator it;



int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int a,b,t=0;
	cin>>a>>b;
	int ans[4];
	ans[0]=ans[1]=ans[2]=ans[3]=1000000001;
	if(b-a>=0)ans[0]=b-a;
	if(-b+a>=0)ans[1]=-b+a+2;
	if(b+a>=0)ans[2]=b+a+1;
	if(-b-a>=0)ans[3]=-b-a+1;
	cout<<min(min(ans[0],ans[1]),min(ans[2],ans[3]));
	
	return 0;
}


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

int main() {
  int n,m;cin>>n>>m;
  vector<int> h(n),vec(n);
  rep(i,n)cin>>h[i];
  rep(i,m){
    int a,b;cin>>a>>b;
    a--;b--;
    if(h[a]<=h[b])vec[a]++;
    if(h[b]<=h[a])vec[b]++;
  }
  int ans=0;
  rep(i,n){
    if(vec[i]==0)ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<endl
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  srand((unsigned)time(NULL));
  int T;
  R T;
  ll n=26;
  ll c[n];
  rep(i,n) R c[i];
  ll a[T][n];
  rep(i,T)rep(j,n) R a[i][j];
  ll d[n];
  mem(d);
  rep(k,T) {
    ll M=-MAX,x=0;
    ll s=0;
    rep(i,n) s+=d[i]-c[i];
    rep(i,n) {
      ll z=s-(d[i]-c[i])+a[k][i];
      if(M<z) {
        M=z;
        x=i;
      }
    }
    pr(x+1);
    d[x]=a[k][x];
  }
}

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


Measured memory_bytes: 3712
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;

int main() {
  int n; cin>>n;
  int nm = 0;
  int k;
  int ans = 0;
  rep(i, n) {
    cin>>k;
    if (k > nm) nm = k;
    ans += k;
  }
  cout << ((nm < ans - nm) ? "Yes" : "No") << endl;;
}


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

constexpr int MaxN = 100;

int main()
{
	int N;
	int h[MaxN];

	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> h[i];
	}

	int count = 0;
	int i = 0;
	while (true)
	{
		int min_h = 1000;
		for (; i < N && h[i] == 0; ++i)
		{
		}

		if (i == N)
		{
			break;
		}

		int j = i;
		for (; j < N && h[j] > 0; ++j)
		{
			min_h = min(min_h, h[j]);
		}
		--j;

		count += min_h;
		for (int k = i; k <= j; ++k)
		{
			h[k] -= min_h;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
from sys import stdin

def main():
    k, x = [int(x) for x in stdin.readline().rstrip().split()]
    ans = [x]

    for i in range(1, k):
        ans.insert(0,x-i)
        ans.append(x+i)

    print(*ans)


if __name__ == '__main__':
    main()


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

for i in range(n[0]):
    a.append(list(map(int, input().split())))

for i in range(n[1]):
    b.append(int(input()))

for i in range(n[0]):
    ab_sum = 0
    for j in range(n[1]):
        ab_sum += a[i][j] * b[j]
    print(ab_sum)



Measured memory_bytes: 6012
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
int main(){
   int a,b,k;
   cin>>a>>b>>k;
   rep(i,a,b+1){
       if ((i-a<k)||(b-i<k)) cout<<i<<endl;
   }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cctype>
using namespace std;
int main(){
	while(1){
		char ch;
		scanf("%c",&ch);
		if(ch=='\n'){
			break;
		}else if(isalpha(ch)!=0){
			if(isupper(ch)==0){
				ch = toupper(ch);
			}else{
				ch = tolower(ch);
			}
		}
		printf("%c",ch);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 3024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

//int gcd(int a,int b){return b?gcd(b,+1 %ab):a;}

/*ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(+1 %k2==0){
    ll memo = modpow(n,k/2+1 %)MOD;
    return memo*mem+1 %oMOD;
  }else{
    return n * modpow(n,k-1+1 %)MOD;
  }
}*/

int main(){

  vector<P> v;

  int n,k;cin>>n>>k;
  if(n==2){
    if(k==0){
      cout<<1<<endl;
      cout<<1<<" "<<2<<endl;
    }else {
      cout<<-1<<endl;
    }
    
    return 0;
  }/*else if(n==3){
    if(k==1){
      cout<<2<<endl;
      cout<<1<<" "<<2<<endl;
      cout<<2<<" "<<3<<endl;
    }else{
      cout<<-1<<endl;
    }
    return 0;
  }else if(n==4){
    if(k==0){
      cout<<6<<endl;
      for(int i=1;i<=4;i++){
        cout<<i<<" "<<(i+1-1) %4+1<<endl;
      }
      cout<<1<<" "<<3<<endl;
      cout<<2<<" "<<4<<endl;
    }else if(k==1){
      cout<<5<<endl;
      for(int i=1;i<=4;i++){
        cout<<i<<" "<<(i+1-1 )%4+1<<endl;
      }
      cout<<1<<" "<<3<<endl;
    }else if(k==2){
      cout<<4<<endl;
      for(int i=1;i<=4;i++){
        cout<<i<<" "<<(i+1-1 )%4+1<<endl;
      }
    }else if(k==3){
      cout<<3<<endl;
      for(int i=1;i<4;i++){
        cout<<i<<" "<<4<<endl;
      }
    }else{
      cout<<-1<<endl;
    }
    return 0;
  }*/

  if((n-1)*(n-2)/2 < k){
    cout<<-1<<endl;
    return 0;
  }

  if(1==2){
    for(int i=1;i<=n;i++){
      P p;
      p.first = i;
      p.second = (i+1-1) %  n+1;
      v.pb(p);
    }
    for(int i=1;i<=n-k;i++){
      P p;
      p.first = i;
      p.second = (i+2-1) %  n + 1;
      v.pb(p);
    }
  }else{
    for(int i=2;i<=n;i++){
      P p;
      p.first = 1;
      p.second = i;
      v.pb(p);
    }
    ll count = (n-1)*(n-2)/2 - k;
    int x = 2;
    int y = 3;
    while(count>0){
      P p;
      p.first = x;
      p.second = y;
      v.pb(p);

       y++;
      if(y>n){
        x++;
        y = x+1;
        if(x>n)break;
      }
      count--;
    }
  }


  cout<<v.size()<<endl;
  REP(i,v.size()){
    cout<<v[i].first<<" "<<v[i].second<<endl;
  }



 

  return 0;
}

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

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main()
{
	ll q,h,s,d;
	ll n;
	cin >> q>>h>>s>>d>>n;

	ll ans = 0;
	if (n>=2) {
		ll tmp = std::min(q*8, h*4);
		tmp = std::min(tmp, s*2);
		tmp = std::min(tmp, d);

		ll t2 = n/2;
		n = n % 2;
		ans += t2 * tmp;
	}

	if (n>=1) {
		ll tmp = std::min(q*4, h*2);
		tmp = std::min(tmp, s);
		ll t2 = n;
		ans += t2 * tmp;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

map<Int,Int> dic;
int main(void) {
    int N,M;
    cin>>N>>M;

    vector<int> A;
    for(int i = 0;i < N;i++) {
        Int a;
        cin>>a;
        dic[a] += 1;
    }
    for(int i = 0;i < M;i++) {
        Int b,c;
        cin>>b>>c;
        dic[c] += b;
    }

    int rest = N;
    Int ans = 0;
    for(auto u = dic.rbegin();u != dic.rend();u++) {
        if(u->second <= rest) {
            ans += u->first*u->second;
            rest -= u->second;
        } else {
            ans += u->first*rest;
            break;
        }
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 12800