akhauriyash/Code-Regression huggingface dataset:
#ifdef OJ_MISC_OFFLINE

#include "prolog.h"

#else
#define LOG
#define PRINT
#define LCERR

#include <iostream>

auto optimize_cpp_stdio = []() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::setvbuf(stdout, nullptr, _IOFBF, BUFSIZ);
    return 0;
}();
#endif

#include <algorithm>
#include <array>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>

namespace {

using namespace std;

const static array<int, 10> digit_to_match = {-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};

class Solution {
public:
    string match_matching(int N, vector<int>& digits) {
        sort(digits.begin(), digits.end());
        // DP to find how many digits at most can you build with exact k matches, -1 if none
        vector<int> can_build_digits(N + 1, -1);
        can_build_digits[0] = 0;
        for (int i = 1; i <= N; ++i) {
            int max_digits = -1;
            for (int d : digits) {
                int matches = digit_to_match[d];
                if (i - matches >= 0 && can_build_digits[i - matches] >= 0) {
                    max_digits = max(max_digits, can_build_digits[i - matches] + 1);
                }
            }
            can_build_digits[i] = max_digits;
        }
        int num_digits_in_result = can_build_digits[N];
//        for (int i = 0; i <= N; ++i) {
//            PRINT("{} ", can_build_digits[i]);
//        }

        string result(num_digits_in_result, '\0');
        int matches_left = N;
        for (int i = 0; i < can_build_digits[N]; ++i) {
            for (int j = digits.size() - 1; j >= 0; --j) { // larger to smaller
                int d = digits[j];
                int matches = digit_to_match[d];
                if (matches_left - matches >= 0 &&
                    can_build_digits[matches_left - matches] + i + 1 == num_digits_in_result) {
                    result[i] = '0' + d;
                    matches_left -= matches;
                    break;
                }
            }
        }
        return result;
    }

private:

};

int solve() {
    Solution solution;
    // handle IO here
    int N, M;
    cin >> N >> M;
    vector<int> digits(M);
    for (int i = 0; i < M; ++i) {
        cin >> digits[i];
    }
    cout << solution.match_matching(N, digits) << '\n';
    return 0;
}

} // anonymous namespace

#ifdef OJ_MISC_OFFLINE

#include "epilog.h"

#else

int main() {
    return solve();
}

#endif


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
#define rep(i,x) for(ll i = 0;i<x;i++)
#define REP(i,x) for(ll i = 1;i<=x;i++)
#define mp make_pair
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 62;
const dou pi = 3.14159265358;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T, class U> inline bool chmin(T& a, const U& b){ if(a > b){ a = b; return 1; } return 0; }
template<class T, class U> inline bool chmax(T& a, const U& b){ if(a < b){ a = b; return 1; } return 0; }
template<class T, class U> inline bool change(T& a,U& b){if(a > b){swap(a,b);return 1;}return 0;}
template<class T>
T gcd(T a,T b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
template<class T>
T lcm(T a,T b){
    return a / gcd(a,b) * b;
}

//素数判定O(sqrt(N))
template<class T>
inline bool isp(T n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
vector<ll> fac(cmax),finv(cmax),inv(cmax);

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; 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;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if(fac[0] == 0)COMinit();
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logm)
ll modpow(ll n,ll m,ll MOD){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}
ll mypow(ll n,ll m){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n);
        m >>= 1;
        n *= n;
    }
    return res;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll N;
    cin >> N;
    cout << lcm(N,360LL) / N << endl;
}


Measured memory_bytes: 26528
S=list(str(input()))
for i in range(9):
    S.append('')
t=''
for i in range(9):
    if i==0 or i==4 or i==6 or i==8:
        if S[0]=='A':
            t+=S.pop(0)
        else:
            t+='A'
    elif i==1:
        if S[0]=='K':
            t+=S.pop(0)
    elif i==2:
        if S[0]=='I':
            t+=S.pop(0)
    elif i==3:
        if S[0]=='H':
            t+=S.pop(0)
    elif i==5:
        if S[0]=='B':
            t+=S.pop(0)
    elif i==7:
        if S[0]=='R':
            t+=S.pop(0)
if t=='AKIHABARA' and len(S)==9:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

const int N=100009;
int n,a[N],ans;

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);

    sort(a+1,a+n+1);
    reverse(a+1,a+n+1);

    for(int i=1;i<=n;i++)
        if(i+1>a[i+1])
        {
            for(int j=i+1;a[j]==i;j++)
                ans^=1;
            ans|=(a[i]-i)&1;
            puts(ans? "First":"Second");
            return 0;
        }

    return 0;
} 

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

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;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] <= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) left = mid;
		else right = mid;
	}
	/* left は条件を満たす最大の値、right は条件を満たさない最小の値になっている */
	return left;
}
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;
}
int main() {
	int a, b, c,k;
	cin >> a >> b >> c >> k;
	int ans = 0;
	ans = ans + 1 * min(a, k);
	k = max(k - a, 0);
	k = max(k - b, 0);
	ans = ans + (-1) * min(c, k);
	cout << ans;
}

Measured memory_bytes: 3624
//This code is written by Anubhav Srivastava(anubhavsrivastavawebpage.wordpress.com)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n,flag=0;
    cin >> n;
    while(n--)
    {
        int a;
        cin >>  a;
        if(a%2==0)
        {
            if(a%3==0 || a%5 ==0)
            {
                flag=flag;
            }
            else    flag+=1;
        }
    }
    if(flag==0) cout <<"APPROVED";
    else    cout << "DENIED";
    return 0;
}

Measured memory_bytes: 256
// TogglingCases.c
// 与えられた文字列の小文字と大文字を入れ替えるプログラムを作成してください。
// 【入力】
// 文字列が1行に与えられます。
// 【出力】
// 与えられた文字列の小文字と大文字を入れ替えた文字列を出力して下さい。
// アルファベット以外の文字はそのまま出力して下さい。
// 【制約】
// 入力される文字列の長さ < 1200
// 【例】
// 入力：
// fAIR, LATER, OCCASIONALLY CLOUDY.
// 出力：
// Fair, later, occasionally cloudy.
#include<stdio.h>
#include<ctype.h>

int main( void) {
  char ch[1200];
  int counter = 0;

  for ( int i = 0; i < 1200 - 1; i++) {
    scanf( "%c", &ch[i]);
    if ( ch[i] == '\n') break;
    counter++;
  }

  for ( int i = 0; i < counter; i++) {
    if ( isupper( ch[i])) ch[i] = tolower( ch[i]);
    else if ( islower( ch[i])) ch[i] = toupper( ch[i]);

    printf( "%c", ch[i]);
  }
  printf( "\n");

  return 0;
}



Measured memory_bytes: 2064
fn read<T: std::str::FromStr>() -> T {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
  let n: u32 = read();
  let mut ds: Vec<u32> = read_vec();

  if n % 2 != 0 { println!("{}", 0) };

  ds.sort();
  let mut ans: Vec<u32> = Vec::new();
  for i in (ds[ds.len() / 2 - 1] + 1)..(ds[ds.len() / 2] + 1) {
    ans.push(i);
  }

  println!("{:?}", ans.len());
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    int x[n];
    for(int i=0; i<n; i++)cin >> x[i];
    sort(x, x+n);
    //for(const auto& e : x)cout << e << " ";
    int sum[100];
    for(int i=0; i<100; i++)sum[i]=0;
    for(int p=1; p<=100; p++)for(int i=0; i<n; i++)sum[p-1]+=pow(p-x[i], 2);
    sort(sum, sum+100);
    cout << sum[0];
    return 0;
}

Measured memory_bytes: 256
n, m = [int(i) for i in input().split()]
l = []
r = []
for _ in range(m):
    i, k = [int(i) for i in input().split()]
    l.append(i)
    r.append(k)

res = min(r) - max(l) + 1 if min(r) >= max(l) else 0
print(res)


Measured memory_bytes: 10996
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int a[4];
	cin >> a[0] >> a[1] >> a[2] >> a[3];
	sort(a, a + 4);
	if (a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
const int N=1e5+5;
typedef long long ll;
int main(){
		ll x,a=100;
		cin>>x;
		ll cnt=0;
		while(a<x){
			cnt++;
			a=(ll)(a*1.01);
		}
		cout<<cnt<<endl;
		return 0;
}

Measured memory_bytes: 3636
#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 =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
 
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);
    } 
    M mp;
    void factorize(lint x){
        while((x%2)==0){
            x/=2;
            mp[2]++;
        }
        lint g=x;
        for(lint i=3;i<=sqrt(g);i+=2){
            if(x%i==0){
                mp[i]++;
                x/=i;
                i-=2;
            }
        }
        if(primary(x))mp[x]++;
    }
  int main(){
    lint n,m;
    cin>>n>>m;
    factorize(m);
    lint ans=1;
    COMinit();
    for(auto x:mp){
        ans*=COM(x.second+n-1,x.second);
        ans%=MOD;
    }
    cout<<ans<<endl;
  }

Measured memory_bytes: 27092
N, A, B = map(int, input().split())
S = input()

ab = 0
b = 0
y = 'Yes'
n = 'No'

for s in S:
    if s == 'a':
        if ab < A+B:
            print(y)
            ab += 1
        else:
            print(n)
    elif s == 'b':
        if ab < A+B and b < B:
            print(y)
            ab += 1
        else:
            print(n)
        b += 1
    else:
        print(n)


Measured memory_bytes: 4016
import java.util.*;
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int days = sc.nextInt();
		int kokugo = sc.nextInt();
		int math = sc.nextInt();
		int kp = sc.nextInt();
		int mp = sc.nextInt();
		double result;
		
		double kdays = (double)kokugo/(double)kp;
		double mdays = (double)math/(double)mp;
		
		if(kdays>mdays){
			result = days - kdays;
		}else{
			result = days - mdays;
		}

		System.out.println((int)result);

	}

}

Measured memory_bytes: 17164
// 6/2
// 2-6-4. 素数のこすう
// エラトステネスの篩
#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 INF = 1e9;

// const int MAX_N = 1000000;

vector<int> prime;  // i番目の素数
vector<bool> is_prime;  // iが素数かどうか

void sieve(int n) {
    // 一旦全ての数字を素数に。
    prime.resize(n, 0);
    is_prime.resize(n + 1, true);

    // 0, 1は素数では無い。
    is_prime[0] = is_prime[1] = false;

    int p = 0;

    for (int i = 2; i < n; i++) {
        if (is_prime[i]) {
            prime[p++] = i;
            for (int j = 2 * i; j <= n; j += i) {
                is_prime[j] = false;
            }
        }
    }

    // return p;
}

int main() {
    sieve(1e6);

    int n;
    vector<int> ans;

    while (cin >> n) {
        int an = 0;
        rep(i, n + 1) {
            if (is_prime[i]) an++;
        }
        ans.push_back(an);
    }

    for (auto a : ans) cout << a << endl;
}



Measured memory_bytes: 6624
def main():
    h, w = map(int, input().split())
    a = [input() for _ in range(h)]

    need1 = 0
    need2 = 0
    need4 = 0
    for i in range(h):
        for j in range(w):
            if (h % 2 == 1 and i * 2 + 1 == h) and (w % 2 == 1 and j * 2 + 1 == w):
                need1 += 1
            elif (h % 2 == 1 and i * 2 + 1 == h) or (w % 2 == 1 and j * 2 + 1 == w):
                need2 += 1
            else:
                need4 += 1

    count = dict()
    for x in a:
        for y in x:
            if y not in count:
                count[y] = 1
            else:
                count[y] += 1

    for _, num in count.items():
        while num >= 4 and need4 > 0:
            num -= 4
            need4 -= 4
        while num >= 2 and need2 > 0:
            num -= 2
            need2 -= 2
        while num >= 1 and need1 > 0:
            num -= 1
            need1 -= 1

    if need4 == 0 and need2 == 0 and need1 == 0:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <algorithm>
#include <cstring>
#include <stdio.h>
#include <vector>;
using namespace std;
const int maxn = 1e6+100;
bool prim[maxn];
vector <int> ve;

void get_prim() {
    prim[0] = prim[1] = true;
    for(int i=2;i<maxn;i++) {
        if(prim[i])
            continue;
        ve.push_back(i);
        for(int j=i*2;j<maxn;j+=i) {
            prim[j] = true;
        }
    }
}

int main() {
    int n;
    get_prim();
    while(scanf("%d",&n) != EOF) {
        int pos = lower_bound(ve.begin(),ve.end(),n) - ve.begin();
        if(ve[pos] > n)
            pos--;
        printf("%d\n",pos+1);
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  for(int i=1;i<N;i++) {
    cin >> A.at(i);
    B.at(A.at(i)-1)++;
  }
  for(int i=0;i<N;i++) 
    cout << B.at(i) << endl;
}

Measured memory_bytes: 4756
N,A,B,C,D=map(int,input().split())
S=input()
S="."+S
S=list(S)

for i in range(A+1,C+1):
    if S[i]=="#" and S[i-1]=="#":
        print("No")
        exit()
for i in range(B+1,D+1):
    if S[i]=="#" and S[i-1]=="#":
        print("No")
        exit()
F=0
if D<C:
    F=1
    for i in range(B-1,D):
        if S[i]=="." and S[i+1]=="." and S[i+2]==".":
            F=0
            break
if F==1:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 4980
#include <bits/stdc++.h>
#define ll long long
using namespace std;
char s[1005];
char t[1005];
int main()
{
    scanf("%s%s",s+1,t+1);
    int lens=strlen(s+1);
    int lent=strlen(t+1);
    int ans=1005;
    for(int i=1;i+lent-1<=lens;i++)
    {
        int cnt=0;
        for(int j=1;j<=lent;j++)
        {
            if(s[i+j-1]!=t[j]) cnt++;
        }
       // printf("%d %d\n",i,cnt);
        ans=min(ans,cnt);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3816
n,m,x=list(map(int,input().split()))
c=[]
for i in range(n):
  c.append(list(map(int,input().split())))

min_c=10000000
for i in range(2**n):
  u=[0 for j in range(m)]
  cost=0
  for j in range(n):
    if i & 2**j:
      cost+=c[j][0]
      for k in range(m):
        u[k]+=c[j][k+1]
  f=True
  if min_c<cost:
    continue
  for j in range(m):
    if u[j]<x:
      f=False
      break
  if f:
    min_c=cost
    
if min_c==10000000:
  print(-1)
else:
  print(min_c)

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

using namespace std;
typedef long long ll;

ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//for(int i = ; i < ; i++){}

int main(){
  string s;
  cin>>s;
  sort(s.begin(),s.end());
  int a[4];
  for(int i = 0; i < 4; i++){
    a[i]=1;
  }
  int j = 0;
  for(int i = 0; i < 3; i++){
    if(s[i]==s[i+1]){
      a[j]++;
    }
    else{
      j++;
    }
  }
  if(a[0]==2&&a[1]==2) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}




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

int main() {
	

	int H, W, a[501][501];
	cin >> H >> W;
	rep1(i, H) {
		rep1(ii, W) {
			cin >> a[i][ii];
		}
	}

	int coin[501] = {};
	int gyou = 0;
	string S = "";
	rep1(i, H) {
		rep1(ii, W - 1) {
			coin[i] += a[i][ii];
			if (coin[i] % 2) {
				S += to_string(i) + " " + to_string(ii) + " " + to_string(i) + " " + to_string(ii + 1) + "\n";
				gyou++;
			}
		}
		coin[i] += a[i][W];
	}

	rep1(i, H - 1) {

		if (coin[i] % 2) {
			S += to_string(i) + " " + to_string(W) + " " + to_string(i + 1) + " " + to_string(W) + "\n";
			gyou++; 
			coin[i + 1]++;
		}
		
	}

	cout << gyou << "\n";
	cout << S << "\n";

	Would you please return 0;

}


Measured memory_bytes: 5124
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define cout (cout<<fixed<<setprecision(15))
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define out(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define out2(v) for(auto i:v)output(i);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define sum(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
int main(){
    lint x;
    cin>>x;
    x=abs(x);
    irep(i){
        if(x<=i*(i+1)/2){
            cout<<i;
            return 0;
        }
    }
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

ll rec(int n, ll x) {
  if (n == 0) return 1;
  ll barg = (1LL << (n + 1)) - 3;
  ll Patty = (1LL << n) - 1;
  if (x == 1)
    return 0;
  else if (x <= barg + 1)
    return rec(n - 1, x - 1);
  else if (x == barg + 2)
    return Patty + 1;
  else if (x <= (barg + 1) * 2)
    return Patty + 1 + rec(n - 1, x - barg - 2);
  else
    return Patty * 2 + 1;
}

int main() {
  int n;
  ll x;
  cin >> n >> x;
  cout << rec(n, x) << endl;
}

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

void Main()
{
    int n;
    cin >> n;
    vector<string> a = {"AC", "WA", "TLE", "RE"};
    vector<int> b(4);
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        for (int i = 0; i < 4; i++)
        {
            if(s == a[i]) b[i]++;
        }
        
    }
    for (int i = 0; i < 4; i++)
    {
        cout << a[i] << " x " << b[i] << endl;
    }
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


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

#include <iostream>
using namespace std;
int main() {
  string N_str;
  cin >> N_str;
  bool lucky = false;
  for (auto ni : N_str) {
    if (ni == '7') {
      lucky = true;
      break;
    }
  }
  if(lucky){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


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

long long MOD = 1000000007;
long long TWO = 500000004;

int main() {
  int n;
  long long k;
  cin >> n >> k;
  int a[n];
  for ( int i = 0; i < n; i++ ) { cin >> a[i]; }
  
  long long ans = 0;
  long long s1 = (((k+1)*k)%MOD*TWO)%MOD;
  long long s2 = (((k-1)*k)%MOD*TWO)%MOD;
  for ( int i = 0; i < n; i++ ) {
    for ( int j = i+1; j < n; j++ ) {
      if ( a[i] > a[j] ) { ans = (ans+s1)%MOD; }
    }
    for ( int j = 0; j < i; j++ ) {
      if ( a[i] > a[j] ) { ans = (ans+s2)%MOD; }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//for(int i = 0; i<n; i++)
 
 
int main()
{
    string s, t;
    cin>>s>>t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<int>());
    for(int i = 0; i < min(s.size(), t.size()); i++){
        if(s[i] == t[i]) continue;
        if(s[i] < t[i]){
            cout << "Yes" << endl;
            return 0;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << (s.size() < t.size() ? "Yes" : "No") << endl;   
    return 0;
}



Measured memory_bytes: 256
import sys
n = int(input())
if n == 0:
  print(0)
  sys.exit()
s = ""
while n!= 0:
  if ((n<0 and (-n)%2==0) or (n>0 and n%2==0)):
    s = "0" + s
  else:
    s = "1" + s
    n-=1
  n/=-2
print(s)

Measured memory_bytes: 2940
#include <cstdio>
#include <algorithm>
#include <cstring>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 100010;

struct Edge{ int to, next;} edge[N * 2];
int head[N], num;
void add_edge(int a, int b) { edge[++ num] = (Edge){b, head[a]}, head[a] = num;}

int tl[N], tr[N], p[N];
bool flag = false;

void dfs(int x, int fa)
{
	tl[x] = -2e9, tr[x] = 2e9;
	RepG(i, x) if (v != fa) {
		dfs(v, x);
		tl[x] = max(tl[x], tl[v] - 1), tr[x] = min(tr[x], tr[v] + 1);
	}
	if (tl[x] > tr[x]) flag = true;
	else if (p[x] != -1) {
		if (tl[x] <= p[x] && p[x] <= tr[x]) tl[x] = tr[x] = p[x];  
		else flag = true;
	}
	//printf("%d %d %d\n", x, tl[x], tr[x]);
}

void dfs1(int x, int fa)
{
	if (p[x] != -1) {
		if (fa && p[x] == p[fa]) {flag = true;}
	}
	else{
		if (tl[x] <= p[fa] + 1 && p[fa] + 1 <= tr[x])
			p[x] = p[fa] + 1;
		else if (tl[x] <= p[fa] - 1 && p[fa] - 1 <= tr[x])
			p[x] = p[fa] - 1;
		else flag = true;
	}
	RepG(i, x) if (v != fa) dfs1(v, x);
}

int main()
{
	int n, k, x, y;
	scanf("%d", &n);
	Rep(i, n - 1) {
		scanf("%d%d", &x, &y);
		add_edge(x, y); add_edge(y, x);
	}
	Rep(i, n) p[i] = -1;
	scanf("%d", &k);
	Rep(i, k) {
		int x, y;
		scanf("%d%d", &x, &y);
		p[x] = y;
	}
	dfs(1, 0);
	if (flag) printf("No\n");
	else {
		p[1] = tl[1];
		dfs1(1, 0);
		if (flag) printf("No\n");
		else {
			printf("Yes\n");
			Rep(i, n) printf("%d\n", p[i]);
		}
	}
	
	return 0;
}
/*
5
1 2
3 1
4 3
3 5
2
2 6
5 7
*/

Measured memory_bytes: 8704
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<int>v(N);
	for (auto &i : v)cin >> i;
	sort(v.begin(), v.end());
	v.push_back(MOD);
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			L = j, R = N;
			while (R - L > 1) {
				int mid = (L + R) / 2;
				if (v[mid] >= v[i] + v[j])R = mid;
				else L = mid;
			}
			K += L - j;
		}
	}
	cout << K << endl;
}

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
int main() {
  string s;cin>>s;
  int len=0;
  int ans=0;
  REP(i,s.size()){
    if(s[i]=='A'||
      s[i]=='C'||
      s[i]=='G'||
      s[i]=='T'){
      len++;
    }else{
      ans=max(ans,len);
      len=0;
    }
  }
  cout << max(ans,len) << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	Q, H, S, D = MAP()
	N = INT()

	# 単価、価格、容量
	A = [[Q/0.25, Q, 0.25], [H/0.5, H, 0.5], [S/1.0, S, 1.0], [D/2.0, D, 2.0]]
	A.sort()
	# print(A)

	ans = 0
	for a in A:
		cost, price, amt = a
		if N >= amt:
			ans += int(N//amt) * price
			N -= int(N//amt) * amt
		# print(N, ans, amt, N//amt)
	
	print(int(ans))
	
	

if __name__ == '__main__':
	main()

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<string.h>

struct Edge
{
	int vx_a;
	int vx_b;
	int w;

	bool operator < (const Edge& e) const{
		return w > e.w;
	}
};

const int MAXN = 10000;
int uset[MAXN];
int V, E;
std::priority_queue<Edge> eq;

void init() {
	memset(uset, -1, sizeof(uset));
}

int find_root(int x) {
	if (uset[x] == -1) {
		return x;
	}
	else {
		int root = find_root(uset[x]);
		uset[x] = root;
		return root;
	}
}

void unite(int x, int y) {
	int rx = find_root(x);
	int ry = find_root(y);
	if (rx != ry) {
		uset[rx] = ry;
	}
}

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

int mst_cost() {
	int cost = 0;
	int v = V - 1;
	while (v) {
		Edge edge = eq.top();
		if (!same(edge.vx_a, edge.vx_b)) {
			unite(edge.vx_a, edge.vx_b);
			cost += edge.w;
			v--;
		}
		eq.pop();
	}
	return cost;
}

int main() {
	scanf("%d%d", &V, &E);
	init();
	for (int i = 0; i < E; i++) {
		int s, t, w;
		scanf("%d%d%d", &s, &t, &w);
		eq.push({ s, t, w });
	}
	printf("%d\n", mst_cost());

	return 0;
}


Measured memory_bytes: 4100
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    N = int(sys.stdin.readline())

    if N < 10:
        print(N)
    elif 10 <= N <= 99:
        print(9)
    elif 99 < N <= 999:
        print(9 + (N - 99))
    elif 999 < N <= 9999:
        print(9 + 900)
    elif 9999 < N <= 99999:
        print(909 + (N - 9999))
    else:
        print(90909)

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

ll mpower(ll a,ll b,ll c){
  int z;
  if(b==0){
    z=1;
    z%=c;
    return z;
  }
  if(b==1){
    z=a;
    z%=c;
    return z;
  }
  else{
    return (((mpower(a,b/2,c))*(mpower(a,b/2,c))%c)*mpower(a,b%2,c)%c);
  }
}

int main() {
  int n,k;
  cin>>n>>k;
  ll mod=1e9+7;
  ll vec[k+1];
  for(int i=k;i>0;i--){
    vec[i]=mpower(k/i,n,mod);
    for(int j=2;j<k+10;j++){
      if(i*j>k){
        break;
      }
      vec[i]-=vec[i*j];
    }
  }
  ll ans=0;
  for(int i=1;i<=k;i++){
    ans+=i*vec[i];
    ans%=mod;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4320
#include <bits/stdc++.h>
#define x first
#define y second
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define pbb pair<bool,bool>
#define mp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define xmod (ll)(1e9+7) 
#define hmod 1286031825167LL
using namespace std;

int n,ans,pt,grp,ct;
char s;
vector <int> edge[205];
int num[205];
bool vis[205];
queue <pii> q;
int main(){	
    ios::sync_with_stdio(false);
	cin >> n; ans=-1;
	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++){
			cin >> s;
			if (s == '1')
			edge[i].pb(j);
		}
	}
	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++){
			num[j]=0;
			vis[j]=false;
		}
		q.push(mp(i,1)); ct=0;
		while (!q.empty()){
			pt=q.front().x; grp=q.front().y; 
			if (!vis[pt]){
				vis[pt]=true; num[pt]=grp;
				ct=max(ct,grp);
				for (int j=0;j<edge[pt].size();j++){
					if (num[edge[pt][j]] == grp)
					goto out;
					if (!vis[edge[pt][j]])
					q.push(mp(edge[pt][j],grp+1));
					if (num[edge[pt][j]] > 0 && num[edge[pt][j]] != grp-1)
					goto out;
				}
			}
			q.pop();
		}
		for (int j=1;j<=n;j++){
			if (num[j] == 0)
			ct++;
		}
		ans=max(ans,ct);
		out:;
	}
	cout << ans << "\n";
    return 0;
}	

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

string a,b="CF";
int al,bl;

int main(){
	getline(cin,a);
	al=a.length();
	for(int i=0;i<al;i++)
		if(a[i]==b[bl]){
			bl++;
		    if(bl==2)
		        break;
		}
	if(bl==2) cout<<"Yes";
	else cout<<"No";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

const int MAX = 1e6;
const int INF = 2e9;
typedef long long ll;


int a[101];


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

    int n, m;

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

    sort(a, a + n, [](const auto & a, const auto & b) {
        return a > b;
    });

    double threshold = (1.0 / (4.0 * m)) * (double)total;

    for (int i = 0; i < m; ++i)
    {
        if ((double)a[i] < threshold) {
            cout << "No";
            return 0;
        }
    }

    cout << "Yes";

    return 0;
}


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

ans = 0
tmp = 0
if a == b == c :
    ans = "No"
elif a == b:
    ans = "Yes"
elif a == c:
    ans = "Yes"
elif b == c:
    ans = "Yes"
else:
    ans = "No"
print(ans)

Measured memory_bytes: 2940
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)));
        int N = scan.nextInt();
        int A = scan.nextInt();
        int x = N / 500;
        int remain = N - 500 * x;
        if (remain <= A) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pi pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/

signed main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(min(a,c)>0){
    c-=b;
    if(c<=0){
      cout<<"Yes"<<endl;
      break;
    }
    a-=d;
    if(a<=0) {
      cout<<"No"<<endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 3636
h = {}
gets.chomp.each_char do |c|
    h[c] ||= 0
    h[c] += 1
end
k = 0
until h.empty?
    seq = [h.keys.min]
    while h[seq[-1].next]
        seq << seq[-1].next
    end
    if seq.size >= 3
        k += 3
    else
        k += seq.size
    end
    seq.each do |c|
        h[c] -= 1
        h.delete(c) if h[c] == 0
    end
end
p k


Measured memory_bytes: 6880
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n, x , ma = -1 , sum = 0;
  	cin >> n;
  	for(int i = 0 ; i < n ; i++)
    {
		cin >> x;
      	ma = max(ma , x);
      	sum += (x);
    }
	if(sum - ma > ma )
      cout << "Yes" << endl;
  	else
      cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

int** table;

void recursive(int sum,bool checkTable[10],int count){
	if(count == 10)return;

	bool new_table[10-count][10];

	for(int i = 0; i < 10-count;i++){
		for(int k = 0; k < 10; k++)new_table[i][k] = checkTable[k];
	}

	int index = 0;
	for(int i = 0; i <= 9; i++){
		if(checkTable[i] == false){
			new_table[index][i] = true;
			table[count+1][sum+(count+1)*i]++;
			recursive(sum+(count+1)*i,new_table[index],count+1);
			index++;
		}
	}
}

int main(){

	table = new int*[11];
	for(int i = 1; i <= 10; i++){
		table[i] = new int[10001];
		for(int k = 0; k <= 10000; k++)table[i][k] = 0;
	}

	bool checkTable[10];
	for(int i = 0; i < 10; i++)checkTable[i] = false;

	recursive(0,checkTable,0);

	int n,s;

	while(scanf("%d %d",&n,&s) != EOF){
		printf("%d\n",table[n][s]);
	}

	return 0;
}

Measured memory_bytes: 2968
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 100005
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)

ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<pair<ll, ll>> V;
vector<ll> adj[MAX_INT];

int main() {
	scanf("%lld %lld", &N, &M);
	fi(i, 0, N, 1) {
		scanf("%lld", &arr[i]);
		V.push_back({arr[i], i});
	}	
	fi(i, 0, M, 1) {
		scanf("%lld %lld", &A, &B);
		A--;
		B--;
		adj[A].push_back(B);
		adj[B].push_back(A);
	}
	ll cnt = 0;
	fi(i, 0, N, 1) {
		ll ok = 1;
		fi(j, 0, adj[i].size(), 1) {
			if(arr[adj[i][j]] >= arr[i]) {
				ok = 0;
			} 
		}
		if(ok) {
			// cout << i << "\n";
			cnt++;
		} 
	}
	printf("%lld\n", cnt);
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 11300
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <array>

using namespace std;
constexpr int kMaxN = 3e5;
vector<int> graph[kMaxN];
std::array<bool, kMaxN> used;

void Dfs(int v, int& best_v, int& best_dist, int cur_dist) {
  used[v] = true;
  if (best_dist < cur_dist) {
    best_dist = cur_dist;
    best_v = v;
  }
  for (const auto& to : graph[v]) {
    if (!used[to]) {
      Dfs(to, best_v, best_dist, cur_dist + 1);
    }
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;

  if (n == 1) {
    cout << "First" << endl;
    return 0;
  }
  
  for (int i = 0; i < n - 1; i++) {
      int a, b;
      cin >> a >> b;
      a--;
      b--;
      graph[a].push_back(b);
      graph[b].push_back(a);
  }
  int best_v = 0;
  int best_dist = 0;
  Dfs(0, best_v, best_dist, 0);
  best_dist = 0;
  int best_v2 = 0;
  for (int i = 0; i < n; i++) {
    used[i] = false;
  }
  Dfs(best_v, best_v2, best_dist, 0);
  cout << ((best_dist % 3 == 1) ? "Second" : "First") << endl;
}

Measured memory_bytes: 29436
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define M 2005
#define N 1005
#define ll long long
#define mod 1000000007
int A[M], B[M], C[M], idx[M];
int fir[N], nex[M << 1], tar[M << 1], len[M << 1], cnt;
int dep[N], bel[N], vis[M];
int m, n, f[15][N], g[15][N];
ll s;
bool E[M];
bool cmp(int u, int v){return C[u] < C[v];}
int Getbel(int x){return bel[x] ? bel[x] = Getbel(bel[x]) : x;}
void Add(int a, int b, int c)
{
	++cnt;
	tar[cnt] = b;
	nex[cnt] = fir[a];
	len[cnt] = c;
	fir[a] = cnt;
}
void Dfs(int r)
{
	for (int i = fir[r]; i; i = nex[i])
	{
		int v = tar[i];
		if (v != f[0][r])
		{
			dep[v] = dep[r] + 1;
			f[0][v] = r;
			g[0][v] = len[i];
			Dfs(v);
		}
	}
}
int main()
{
	scanf("%d%d%lld", &n, &m, &s);
	for (int i = 1; i <= m; i++)
	{
		scanf("%d%d%d", &A[i], &B[i], &C[i]);
		idx[i] = i;
	}
	sort(idx + 1, idx + m + 1, cmp);
	for (int i = 1; i <= m; i++)
	{
		int x = Getbel(A[idx[i]]), y = Getbel(B[idx[i]]);
		if (x != y)
		{
			vis[idx[i]] = 1;
			s -= C[idx[i]];
			bel[x] = y;
			Add(A[idx[i]], B[idx[i]], C[idx[i]]);
			Add(B[idx[i]], A[idx[i]], C[idx[i]]);
		}
	}
	Dfs(1);
	for (int i = 1; i <= 12; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			f[i][j] = f[i - 1][f[i - 1][j]];
			g[i][j] = max(g[i - 1][j], g[i - 1][f[i - 1][j]]);
		}
	}
	int x = s ? 0: n - 2, y = 1;
	for (int i = 1; i <= m; i++)
		if (!vis[i])
		{
			int u = A[i], v = B[i], mx = 0;
			if (dep[u] < dep[v])
				swap(u, v);
			for (int j = 0; j <= 12; j++)
				if ((dep[u] - dep[v]) & (1 << j))
					mx = max(mx, g[j][u]), u = f[j][u];
			if (u == v)
			{
				if (s == C[i] - mx)x++;
				if (s < C[i] - mx)y++;
				continue;
			}
			for (int j = 12; j >= 0; j--)
				if (f[j][u] != f[j][v])
				{
					mx = max(mx, max(g[j][u], g[j][v]));
					u = f[j][u], v = f[j][v];
				}
			mx = max(mx, max(g[0][u], g[0][v]));
			if (s == C[i] - mx)x++;
			if (s < C[i] - mx)y++;
		}
	int ans = 0;
	for (int i = 0; i < x; i++)
		ans = (ans * 2ll + 1) % mod;
	for (int i = 0; i < y; i++)
		ans = (ans * 2ll) % mod;
	printf("%d\n", ans);
}

Measured memory_bytes: 512
using System;
class cal{
    public static void Main(){
        String[] str;
        str = Console.ReadLine().Split(' ');
        int n = int.Parse(str[0]);
        int m = int.Parse(str[1]);
        int[,] num = new int[n,m];
        for(int i=0; i<n; i++){
            String[] temp = Console.ReadLine().Split(' ');
            for(int j=0; j<m; j++){
                num[i,j] = int.Parse(temp[j]);
            }
        }
        int[] vec = new int[m];
        for(int i=0; i<m; i++){
            vec[i] = int.Parse(Console.ReadLine());
        }
        int[] ans = new int[n];
        for(int i=0; i<n; i++){
            ans[i] = 0;
            for(int j=0; j<m; j++){
                ans[i] += vec[j] * num[i,j];
            }
        }
        for(int i=0; i<n; i++){
            Console.WriteLine("{0}",ans[i]);
        }
    }
}


Measured memory_bytes: 18008
/*
        @uthor: Kashish Gilhotra
        user: CodeChef, CodeForces, HackerEarth, HackerRank, SPOJ: kashish001
*/

#include <bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
  
#define int long long int 
typedef vector<int> vi;
const int mod = 1e9 + 7; 

//#define CI cpp_int
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define debug(...) cerr << "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " 
#define EB emplace_back
#define ALL(v) v.begin(), v.end() 
#define size(v) (int)v.size() 
#define endl "\n"
#define UMO unordered_map
#define USO unordered_set
#define setBits(n) __builtin_popcountll(n)
#define TC int t; cin >> t; while (t--) 

void Panda() {
    int n;
    cin >> n;
    for(int i = 1; i <= 9; i++) {
    	if(n % i == 0) {
    		if(n / i <= 9 and i <= 9) {
    			cout << "Yes" << endl;
    			return ;
    		}
    	}
    }
    cout << "No" << endl;
}
  
int32_t main() {
 
    FAST;

  
    
    Panda();

    return 0; 
} 

Measured memory_bytes: 3616
N, x = map(int, input().split())
a = map(int, input().split())
a_sorted = sorted(a)
if sum(a_sorted) == x:
  print(N)
elif sum(a_sorted) <= x:
  print(N - 1)
else:
  i = 0
  a_sum = 0
  while a_sum <= x:
    a_sum += a_sorted[i]
    i += 1
  print(i - 1)

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


int main(){long X;
cin >> X;
long tmp = 0;
while(X > 0){
    tmp++;
    X -= tmp;
}


cout << tmp << endl;
return 0;
}




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

using namespace std;

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

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int N;
int H,W,h,w;

int main(){
    cin >> N;
    vector<int> H(N);

    REP(i, N) cin >> H.at(i);

    int nowTopHeight = H.at(0);
    int ans = 1;
    FOR(i, 1, N){
        if(nowTopHeight <= H.at(i)) {
            nowTopHeight = H.at(i);
            ans++;
        }
    }
    cout << ans;


//    REP(i,5)cin>>v[i];
//    cin>>k;
//    bool ok = true;
//    REP(i,5){
//        REP(j,i){
//            int d = v[i]-v[j];
//            if(d>k)ok=false;
//        }
//    }
//    puts(ok ? "Yay!" : ":(");
//    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < n; i++)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };

int main() {
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    int g[h][w];
    rep (i, h) {
        rep (j, w) {
            if ((i < b && j < a) || i >= b && j >= a) g[i][j] = 1;
            else
                g[i][j] = 0;
        }
    }
    rep (i, h) {
        rep (j, w) cout << g[i][j];
        cout << "\n";
    }
}

Measured memory_bytes: 5120