akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
string st;
int main()
{
  cin>>st;
  for(int i=0;i<st.size();i++)
    if(st[i]=='C')
      for(int j=i+1;j<st.size();j++)
        if(st[j]=='F'){
          cout<<"Yes";return 0;}
  cout<<"No";
  return 0;
}

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

long long n;
long long arr[100005];

int main(){
	cin >> n;
	for(long long i = 0; i < n; i++){
		cin >> arr[i];
	}

	long long ans = LONG_MAX;

	long long tmp = 0;
	long long cur = 0;
	//positive start
	for(long long i = 0; i < n; i++){
		if(i%2 == 0){//have to be positive
			if(cur + arr[i] <= 0){
				long long addi = 1 - cur - arr[i];
				tmp += abs(addi);
				cur = 1;
			}else{
				cur = cur + arr[i];
			}
		}else{
			if(cur + arr[i] >= 0){
				long long addi = -1 - cur - arr[i];
				tmp += abs(addi);
				cur = -1;
			}else{
				cur = cur + arr[i];
			}
		}
	}
	ans = min(ans, tmp);

	tmp = 0;
	cur = 0;
	//negative start
	for(long long i = 0; i < n; i++){
		if(i%2 == 0){//negative
			if(cur + arr[i] >= 0){
				long long addi = -1 - cur - arr[i];
				tmp += abs(addi);
				cur = -1;
			}else{
				cur = cur + arr[i];
			}
		}else{
			if(cur + arr[i] <= 0){
				long long addi = 1 - cur - arr[i];
				tmp += abs(addi);
				cur = 1;
			}else{
				cur = cur + arr[i];
			}
		}
	}
	ans = min(ans, tmp);

	cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rp(i,j) for(long long i=0;i<j;i++)
#define rep(i,j,k) for(long long i=j;i<k;i++)
#define mod 1000000007
#define NIL -1
#define MAX 100000
typedef long long ll;
int n;
vector<int>a[MAX];
int color[MAX];
void dfs(int r,int c){
    stack<int>S;
    S.push(r);
    color[r]=c;
    while(!S.empty()){
        int u=S.top();S.pop();
        rp(i,a[u].size()){
            int v=a[u][i];
            if(color[v]==NIL){
                color[v]=c;
                S.push(v);
            }
        }
    }
}
void colordefine(){
    int id=1;
    rp(i,n)color[i]=NIL;
    rp(i,n){
        if(color[i]==NIL)dfs(i,id++);
    }
}
int main(){
    int m,s,t,q;
    cin>>n>>m;
    rp(i,m){
        cin>>s>>t;
        a[s].push_back(t);
        a[t].push_back(s);
    }
    colordefine();
    cin>>q;
    rp(i,q){
        cin>>s>>t;
        string ans;
        if(color[s]==color[t])ans="yes";
        else ans="no";
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 8948
#include <iostream>
#include <string>
#include <cmath>
#include <ctime>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <set>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(){
    int n, m, h[100010];
    int a[100010], b[100010];

    cin >> n >> m;
    rep(i, n){
        cin >> h[i];
    }
    rep(i, m){
        cin >> a[i] >> b[i];
    }

    bool ans[100010];

    rep(i, n){
        ans[i] = true;
    }

    rep(i, m){
        int atai = h[a[i]-1]-h[b[i]-1];
        if(atai <= 0) ans[a[i]-1] = false;
        if(atai >= 0) ans[b[i]-1] = false;
    }

    int cnt = 0;
    rep(i, n){
        if(ans[i] == true) cnt++;
    }

    cout << cnt << endl;





    return 0;
}

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

int main() {
  int r,g,b;
  cin >> r >> g >> b;
  if((r * 100 + g * 10 + b) % 4 == 0){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
def main():
    n = int(input())
    l = list(map(int,input().split()))
    cnt = 0

    for i in range(n):
        for j in range(i+1,n):
            for k in range(j+1,n):
                if l[i] + l[j] > l[k] and l[i] != l[j]:
                    if l[j] + l[k] > l[i] and l[j] != l[k]:
                        if l[k] + l[i] > l[j] and l[k] != l[i]:
                            cnt += 1
                
    print(cnt)
if __name__ == "__main__":
    main()


Measured memory_bytes: 9196
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  REP(i,n){
    cin >> s[i];
    sort(s[i].begin(),s[i].end());
  }
  sort(s.begin(),s.end());
  ll a = 1;
  ll ans = 0;
  REP(i,n){
    if(i != n-1){
      if(s[i] == s[i+1]){
        a++;
      }
      else{
        ans += a*(a-1)/2;
        a = 1;
      }
    }
  }
  ans += a*(a-1)/2;
  cout << ans << endl;
  

}

Measured memory_bytes: 6412
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		String s = sc.next();
		if (s.length() > k) {
			System.out.print(s.substring(0,k));
			System.out.println("...");
			return;
		} else {
			System.out.println(s);
		}
	}

}


Measured memory_bytes: 35776
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

## コンテスト中に書いたコード

N, M, Q = mi()
abcd = li2(Q)

a = '0' * N
m = str(M-1)
l = [a]

while True:
    i = N-1
    while i >= 0 and a[i] == m: #更新する桁を探索
        i -= 1
    if i == -1:
        break
    a = list(a) #strのままだと書き込めないから一旦リストに変換
    num = str(int(a[i]) + 1) #更新する桁を探索
    a[i] = num
    if i != N-1:
        for j in range(i+1, N): #更新する桁が新しくなった場合、それ以降の桁の値も揃える。Ex)11199 → 11222
            a[j] = num
    tmp = ''.join(a) #文字列に戻す
    l.append(tmp)

ans = 0
for num in l:
    cnt = 0
    #num = list(map(int, list(num)))
    for i in range(Q):
        if int(num[abcd[i][1]-1]) - int(num[abcd[i][0]-1]) == abcd[i][2]:
            cnt += abcd[i][3]
    ans = max(ans, cnt)

print(ans)

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

string s;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>s;
	for(int i=0;i<s.size();i++){
		if(i==3)
			cout<<8;
		else
			cout<<s[i];
	}
	return 0;
}

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

int main() {
  int H, N;
  cin >> H >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += A.at(i);
  }
  
  if (sum >= H) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


ll n, a, ans, b, t = INF;
int main() {
	cin >> n >> a;
	REP(i, n) {
		b += a + i;
	}
	REP(i, n) {
		if (t > abs(a + i)) {
			t = abs(a + i);
			ans = b - (a + i);
		}
	}
		cout << ans << endl;
}	


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){
  int N;
  string S;
  cin >> N >> S;
  for(int i=0; i<S.size(); i++){
    if(isupper(S[i]+N)) S[i]+=N;
    else S[i]=S[i]+N-26;
  }
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD=1e9+7;
const long double Pi=acos(-1);
ll N,M,Q;
vector<vector<ll>> Alist;
vector<vector<ll>> vec;
void dfs(ll mm,ll count){
  
}
int main(){
  cin>>N>>M>>Q;
  Alist.resize(Q,vector<ll>(4));
  for(ll i=0;i<Q;i++){
    cin>>Alist.at(i).at(0)>>Alist.at(i).at(1)>>Alist.at(i).at(2)>>Alist.at(i).at(3);
  }
  ll maximum=0;
  for(ll a=0;a<M;a++){
    for(ll b=a;b<M;b++){
      for(ll c=b;c<M;c++){
        for(ll d=c;d<M;d++){
          for(ll e=d;e<M;e++){
            for(ll f=e;f<M;f++){
              for(ll g=f;g<M;g++){
                for(ll h=g;h<M;h++){
                  for(ll i=h;i<M;i++){
                    for(ll j=i;j<M;j++){
                      ll count=0;
                      ll maxforpairs=0;
                      vector<ll> vec(N);
                      if(count<N){count++;vec.at(count-1)=a+1;}
                      if(count<N){count++;vec.at(count-1)=b+1;}
                      if(count<N){count++;vec.at(count-1)=c+1;}
                      if(count<N){count++;vec.at(count-1)=d+1;}
                      if(count<N){count++;vec.at(count-1)=e+1;}
                      if(count<N){count++;vec.at(count-1)=f+1;}
                      if(count<N){count++;vec.at(count-1)=g+1;}
                      if(count<N){count++;vec.at(count-1)=h+1;}
                      if(count<N){count++;vec.at(count-1)=i+1;}
                      if(count<N){count++;vec.at(count-1)=j+1;}
                      for(ll k=0;k<Q;k++){
                        if(vec.at(Alist.at(k).at(1)-1)-vec.at(Alist.at(k).at(0)-1)==Alist.at(k).at(2)){
                          maxforpairs+=Alist.at(k).at(3);
                        }
                      }
                      maximum=max(maximum,maxforpairs);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout<<maximum<<endl;
}

Measured memory_bytes: 3636
while True:
    try:
        A = list(map(int, input().split()))
        B = list(map(int, input().split()))
        a = b = 0
        for i in range(4):
            if A[i] == B[i]:
                a+=1
            elif B[i] in A:
                b+=1
        print(a, b)
    except:
        break


Measured memory_bytes: 5592
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n;
  cin >> n;
  multiset<int> p;
  REP(i,n) {
    int d;
    cin>>d;
    p.insert(d);
  }
  bool ok = true;
  int m;
  cin>>m;
  REP(i,m) {
    int t;
    cin>>t;
    if (p.count(t) == 0) ok = false;
    else {
      p.erase(p.find(t));
    }
  }
  if (ok) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 9600
from fractions import gcd
#from math import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

n, m = map(int, input().split())
s = input()
t = input()
L = gcd(n,m)
ans = lcm(n,m)
for i in range(L):
    if not s[n//L*i] == t[m//L*i]:
        ans = -1
        break
print(ans)

Measured memory_bytes: 5344
#include <stdio.h>

int main(void)
{
    int x;
    scanf("%d", &x);
    int s = (x % 3600) % 60;
    int m = ((x % 3600) - s) /60;
    int h = (x - 60 * m - s) / 3600;
    printf("%d:%d:%d\n", h, m, s);
    return 0;
}

Measured memory_bytes: 592
#include <stdio.h>

int	main()
{
	int	A;
	int	B;
	int	sum;
	int	count;

	scanf("%d %d\n", &A, &B);
	sum = 1;
	count = 0;
	while (sum < B)
	{
		sum--;
		sum += A;
		count++;
	}
	printf("%d\n", count);
	return (0);
}


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

using namespace std;

int main(){
	int n;
	int l[101];

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

	int max = 0;
	int sum = 0;
	for(int i=0; i<n; i++){ 
		if(max<l[i]) max=l[i];
		sum += l[i];
	}

	if ((sum-max)>max){
		cout << "Yes";
	} else {
	cout << "No";
	}

	return 0;
}


Measured memory_bytes: 256
# D - .. (Double Dots)
from collections import deque


def main():
    N, M, *AB = map(int, open(0).read().split())

    graph = [[] for _ in range(N + 1)]
    for a, b in zip(*[iter(AB)] * 2):
        graph[a].append(b)
        graph[b].append(a)

    # bfs
    queue = deque([1])
    signposts = [0] * (N + 1)
    signposts[1] = 1
    while queue:
        u = queue.popleft()
        for v in graph[u]:
            if not signposts[v]:
                signposts[v] = u
                queue.append(v)

    print("Yes")
    print("\n".join(map(str, signposts[2:])))


if __name__ == "__main__":
    main()


Measured memory_bytes: 56676
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<algorithm>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	int i = 0;
	int count = 0;
	while(s[i]!='\0'){
		if (s[i] != t[i])
			count++;
		i++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3812
import itertools
import math

A= int(input())
B= int(input())
C= int(input())
D= int(input())
E= int(input())
food = list(itertools.permutations((A,B,C,D,E)))
time = 1000

for i in range(len(food)):
    temptime = 0
    for j in range(4):
        temptime += math.ceil(food[i][j]/10)*10
    temptime += food[i][4]
    time = min(temptime,time)

print(time)

Measured memory_bytes: 3064
n, m = map(int, input().split())
L = [[] for i in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    L[a-1].append(b-1)
    L[b-1].append(a-1)

ans = 0

def f(t, history):
    his = history[:]
    his[t] += 1
    global ans
    if sum(his)==n:
        ans += 1
    else:
        for i in L[t]:
            if his[i]==0:
                f(i, his)

f(0, [0]*n)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<i<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
using namespace std;

const ll INF=1e15;
const int MOD=1e9+7;

//{行先, 容量, 逆辺}
struct edge{ll to,cap,rev;};

const int MAX_V=120;
vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];

void add_edge(int from,int to,ll cap){
    G[from].PB((edge){to,cap,G[to].size()});
    G[to].PB((edge){from,0,G[from].size()-1});
}

void bfs(int s){
    memset(level,-1,sizeof(level));
    queue<int> que;
    level[s]=0;
    que.push(s);
    while(!que.empty()){
        int v=que.front(); que.pop();
        FOR(i,0,G[v].size()){
            edge &e=G[v][i];
            if(e.cap>0 && level[e.to]<0){
                level[e.to]=level[v]+1;
                que.push(e.to);
            }
        }
    }
}

int dfs(int v,int t,ll f){
    if(v==t) return f;
    for(int &i=iter[v]; i<G[v].size(); i++){
        edge &e=G[v][i];
        if(e.cap>0 && level[v]<level[e.to]){
            int d=dfs(e.to,t,(ll)min(f,e.cap));
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}

ll max_flow(int s,int t){
    ll flow=0;
    for(;;){
        bfs(s);
        if(level[t]<0) return flow;
        memset(iter,0,sizeof(iter));
        ll f;
        while((f=dfs(s,t,INF))>0){
            flow+=f;
        }
    }
}

int main(){
    int n,a[100];
	ll sm=0;
    cin>>n;
    FOR(i,0,n) cin>>a[i];
	
	int S=100,T=101;//S...使う側
	FOR(i,0,n){
		sm+=max(a[i],0);
		if(a[i]>=0) add_edge(S,i,a[i]);
		else add_edge(i,T,-a[i]);
	}
	FOR(i,0,n){
		FOR(j,i+1,n){
			if((j+1)%(i+1)==0) add_edge(j,i,INF);
		}
	}
	co(sm-max_flow(S,T));
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, std::vector<long long> V, std::vector<long long> C){
    LL ans = 0;
    REP(i, N) {
        if(V[i] - C[i] > 0) ans += V[i] - C[i];
    }

    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> V(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&V[i]);
    }
    std::vector<long long> C(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&C[i]);
    }
    solve(N, std::move(V), std::move(C));
    return 0;
}


Measured memory_bytes: 256
def resolve():
    '''
    code here
    '''
    N = int(input())
    starts = [[int(item) for item in input().split()] for _ in range(N-1)]

    for i in range(N):
        temp_time = 0
        if i == N-1:
            print(0)
        else:
            for j in range(i,N-1):
                c, s, f = starts[j]
                if temp_time <= s:
                    temp_time = s

                if temp_time % f == 0:
                    pass
                else:
                    temp_time = (temp_time // f + 1) * f
            
                temp_time += c
            print(temp_time)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9136
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define RREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const long long INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
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 solve(){
  int A,B,M;
  cin>>A>>B>>M;
  vector<ll>a(A),b(B),x(M),y(M),c(M);
  rep(i,A)cin>>a[i];
  rep(i,B)cin>>b[i];
  rep(i,M){
    cin>>x[i]>>y[i]>>c[i];
  }
  ll ans = INF;
  rep(i,M){
    ll tmp = a[x[i] - 1] - c[i] + b[y[i] - 1];
    ans = min(ans,tmp);
  }
  sort(all(a));
  sort(all(b));
  cout << min(ans,a[0] + b[0]) << endl;
  return 0;
}
int main(){
  ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n;

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

    #ifdef Local
        freopen("../IO/int.txt","r",stdin);
        freopen("../IO/out.txt","w",stdout);
    #endif

    cin>>n;
    bool cn = 1;
    for(int i = 0; i < n; i++){
        int tmp;
        cin>>tmp;
        if(tmp % 2 == 0){
            if(tmp % 3 && tmp % 5){
                cn = 0;
                break;
            }
        }
    }
    if(cn) cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;

    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(0);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define E endl
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
int  pow1(int  x, int  y){
int  ans = 1;
  while(y>0){
    if (y&1)
    {
      ans*=x;
    }
    x *= x;
    y>>=1;
  }
return ans;
} 
signed main(){
  // #ifndef ONLINE_JUDGE
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  // #endif
  IOS;
  int T=1;
  // cin >> T;
  while(T--){
    string s;
    cin>>s;
    int k;
    cin >> k;
    if(k==1){
        int q= s.size()-1, ans = 0;    
        ans+=9*q;
        ans+=(int)(s[0]-'0')-1;
        ans+=1ll;
        return cout << ans,0;
    }
    int n =s.size();
    string t(n-1,'0');
    for(int i=0 ;i <k-1;i++) t[n-2-i]='1';
    int cnt=0;
    vector<int>C;
    for(int i=pow1(10ll,k-1)+1;i<pow1(10ll,k);i++){
        int ii=i;
        int flag=1;
        while(ii){
            if((ii%10)==0) flag=0;
            ii/=10;
        }
        if(flag) cnt++;
        if(flag) C.pb(i);
    }
    int mul=1,den=1;
    for(int i=0 ;i < k;i++){
        mul*=(n-1-i);
        den*=(i+1);
    }
   int ans=1ll*(mul/den)*cnt;
    do{
        vector<int>p;
        p.pb(0);
       for(int i= 0;i<n-1;i++) if(t[i]=='1') p.pb(i+1);
        string t1="1";
        t1+=t;
        int ss = t1.size();
        vector<int>d(k);
        for(int i:C){
            int ii=i;
            for(int j =0 ;ii>0 && j < k;j++){
                d[k-1-j]=ii%10;
                ii/=10;
            }
            int ok = 0 ;
            for(int j =0 ;j < k;j++){
            	if(p[j]>ss ){
            		 ok =1;
            		 break;
            		}

           	 t1[p[j]]='0'+d[j];	
            } 
            if(!ok && t1<=s) ans++;
        }
    }while(next_permutation(all(t)));
    cout << ans;
  
  
  }
  cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
  return 0;
}


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

#define first  fs
#define second se
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, char s = '\n') { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int main() {
	int n, r;
	while (cin >> n >> r, n) {
		vi v;
		rep(i, n) v.push_back(n - i);

		rep(_, r) {
			int p = in(), c = in();
			vi beet, ei;
			for (int i = p - 1; i < p + c - 1; ++i) beet.push_back(v[i]);
			rep(i, p - 1) beet.push_back(v[i]);

			rep(i, beet.size()) v[i] = beet[i];
		}

		print(v[0]);
	}
}

Measured memory_bytes: 3016
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> ii;
typedef pair<long long, pair<int, int>> iii;
typedef pair<ii, ii> iiii;

const double PI = acos(-1.0), EPS = 1e-6;
const int N = 200005, M = 100005, mod = 998244353 , mxLog = 20;

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(6), cout << fixed;

    int n, m;
    cin >> n >> m;
    vector<int> v(m);
    for (int i = 0; i < m; ++i) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    vector<int> pq;
    int ans = 0;
    for (int i = 1; i < m; ++i) {
        ans += v[i] - v[i - 1];
        pq.push_back(v[i] - v[i - 1]);
    }

    sort(pq.begin(), pq.end());
    while (n > 1 && pq.size()) {
        ans -= pq.back();
        pq.pop_back();
        n--;
    }

    cout << ans << '\n';


    return 0;
}

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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int n,a;

main() {
    cin >> n;
    int x = n;
    while(x) {
        a += x%10;
        x/=10;
    }
    if(n%a) ct("No")
    else ct("Yes")
}

Measured memory_bytes: 256
# ABC166 
from collections import Counter

N=int(input())
A=[0]+list(map(int,input().split()))

Ai=[]
Aj=[]

for i in range(1,N+1):
    Ai.append(i+A[i])
    Aj.append(i-A[i])
    
ci=Counter(Ai).items()
cj=Counter(Aj)
res=0
for c,n in ci:
    m=cj[c]
    res+=m*n
print(res)



Measured memory_bytes: 145396
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
#include <chrono>
#include <thread>
#include <thread>
#include <fstream>

using namespace std;

//const bool debug = false;

#ifndef M_PI
    const double M_PI = acos(-1.0);
#endif // M_PI

#define y1 roman_kaban
#define rank oryshych_konb
#define ull unsigned long long
#define ll long long
const int mod = int(1e9) + 7;
//const int inf = 1e7;
//const long long infLL = 1e16;
//const int MX2 = 10100500; //  e7
//const long long INF = 1e18 + 0.5;
const int MX = 100500; //       e6

int a[MX];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    //freopen("/Users/ozzy/Documents/in.txt","r", stdin);
    string s;
    cin >> s;
    long long ans = 0;
    for(int i = 0; i < s.size(); i++){
        ans += i - a[ s[i] ];
        a[s[i] ]++;
    }
    cout << ans + 1 << endl;
    return 0;
}


Measured memory_bytes: 720
import math
h,w = map(int,input().split())
count = 0


#１,３,５...
s = math.ceil(w/2)

#2,4,6..
t = math.floor(w/2)

g = s+t


if(h%2 != 0):
    count =  (math.floor(h/2)) * g + s
elif(h%2 == 0):
    count = (h/2) * g
if(w == 1 or h == 1):
    count = 1



print(int(count))

Measured memory_bytes: 3064
def main():
  N = int(input())
  A = list(map(int, input().split()))
  prod = 1

  for a in A:
    if a == 0:
      print(0)
      return

  for a in A:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      return

  print(prod) 

main()

Measured memory_bytes: 21428
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int N=1e5+1;
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    string s;
    cin>>s;
    int c=0;
    int ls=s.length()-3;
    for (int i=0;i<=ls;i++){
        if (s[i]=='A'&s[i+1]=='B'&s[i+2]=='C')
            c++;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
const config = {
    input: '/dev/stdin',
    newline: '\n'
};

const line = require('fs').readFileSync(config.input, 'utf-8').split(config.newline);
const list = line[1].split(' ').map(x => parseInt(x));

const sort = arr => {
    for (let i = 1; i < arr.length; i++) {
        const v = arr[i];
        j = i - 1;
        console.log(arr.map(x => x.toString()).join(' '));
        while (j >= 0 && arr[j] > v) {
            arr[j+1] = arr[j];
            j--;
        }
        arr[j+1] = v;
    }

    console.log(arr.map(x => x.toString()).join(' '));
    return arr;
};

sort(list);



Measured memory_bytes: 17404
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	if N < 1200 {
		fmt.Println("ABC")
	} else if N < 2800 {
		fmt.Println("ARC")
	} else {
		fmt.Println("AGC")
	}
}


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

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            bool ret=false;
            var s = Console.ReadLine();
            int X = int.Parse(s);
            int min = (int)((X / 1.1));
            for(;min<=X;min++){
                if (getX(min) == X)
                {
                    ret = true;
                    break;
                }
            }

            if (ret)
            {
                Console.WriteLine(min);
            }
            else
            {
                Console.WriteLine(":(");
            }
            Console.ReadLine();

        }
        static int getX(int def)
        {
            return (int)(def * 1.08);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll x;cin>>x;
    ll res=1,now=100;
    while(x>now){
        now+=(now/100);
        if(x>now)res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll N;
  cin>>N;
  string A,B;
  cin>>A>>B;
  for(ll i=0;i<N;i++){
    cout<<A.at(i)<<B.at(i);
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
//??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
//??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
//??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
 
 
 
void rep(){
  int a,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,u,b,w,x,y,z;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
using namespace std;
#define MAX_MOD 1000000007
long long dp[2000][2000] = {};//1???????????????->?????????t???????????????§???????????????2???????????????->?????????s???¨????????????§??????´?????????
int main() {
    string t, b;
    cin >> t >> b;
    dp[0][0] = 1;//t????????????????????????¶??????§????????????¶b???¨??????´?????????????????????????????????
    for (int i = 0;i < t.length();++i) {
        //t[i]?????????????????????
        //????????????§??????????????????£???????????????????????????????????\???????????????
        dp[i + 1][b.length()] += dp[i][b.length()];
        dp[i + 1][b.length()] %= MAX_MOD;
        for (int q = 0;q < b.length();++q) {
            //b[q]???¨t[i]?????????´??????????????????
            if (b[q] == t[i]) {
                //t[i]???????????????¨??????????????????¨???§???s[q]???¨??????´????????????§??¬????????????????¢????????????
                dp[i + 1][q + 1] += dp[i][q];
                dp[i + 1][q + 1] %= MAX_MOD;//????????????¨???
            }
            //t[i]??????????????????????????????£??????¨?????????????????¶????s[q]???¨??????´??????????????????¢???
            dp[i + 1][q] += dp[i][q];
        }
    }
    //t??????¨?????????????????????§????????????b???¨???????????????????????????´?????????????????????°?????????
    cout << dp[t.length()][b.length()] << endl;
    return 0;
}

Measured memory_bytes: 14876
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
N,M = map(int,input().split())
 
A = [[] for i in range(N)]
 
for i in range(N):
    A[i] = list(map(int,input().split()))
 
B = [[0]*1 for i in range(M)]
 
for i in range(M):
    B[i] = int(input())
 
 
for row in range(N):
    tmp = 0
    for col in range(M):
        tmp += A[row][col]*B[col]
    print("%d"%(tmp))


Measured memory_bytes: 6032
#python 3.7.1

n=int(input())
a=list(map(int,input().split()))
dp=[int(0) for _ in range(n+1)]
dp[1]=abs(a[0]-a[1])

for i in range(2,n):
  dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]))
print(dp[n-1])

Measured memory_bytes: 20464
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;

struct SegTree {
  struct TreeNode {
    int max;
  };
  int n;
  vector<TreeNode> st;
  void build(int cur, int s, int e, TreeNode node) {
    if(s == e) {
      st[cur] = node;
      return;
    }
    int mid = (s + e) / 2;
    int l = 2 * cur + 1, r = 2 * cur + 2;
    build(l, s, mid, node);
    build(r, mid + 1, e, node);
    st[cur] = merge(st[l], st[r]);
  }
  void init(int n, TreeNode node) {
    this->n = n;
    st.resize(n << 2);
    build(0, 0, n - 1, node);
  }
  TreeNode merge(TreeNode a, TreeNode b) {
    return { max(a.max, b.max) };
  }
  void update(int cur, int s, int e, int idx, int val) {
    if(s > idx || e < idx) return;
    if(s == e) {
      st[cur].max = val;
      return;
    }
    int mid = (s + e) / 2;
    int l = 2 * cur + 1;
    int r = 2 * cur + 2;
    update(l, s, mid, idx, val);
    update(r, mid + 1, e, idx, val);
    st[cur] = merge(st[l], st[r]);
  }
  void update(int idx, int val) {
    update(0, 0, n - 1, idx, val);
  }
  TreeNode query(int cur, int s, int e, int i, int j) {
    if(s > j || e < i) return {0};
    if(s >= i && e <= j) return st[cur];
    int mid = (s + e) / 2;
    int l = 2 * cur + 1;
    int r = 2 * cur + 2;
    return merge(query(l, s, mid, i, j), query(r, mid + 1, e, i, j));
  }
  TreeNode query(int i, int j) {
    return query(0, 0, n - 1, i, j);
  }
};

const int N = 3e5 + 5;

int n, m, q;
vector<pair<int, int>> a;
SegTree st;
int ys[N];

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

  cin >> n >> m >> q;
  st.init(m, {0});

  for(int i = 0; i < q; i++) {
    int x, y;
    cin >> x >> y;
    a.push_back({--x, --y});
    ys[y]++;
  }

  for(int i = 0; i < m; i++) {
    st.update(i, ys[i]);
  }

  sort(all(a));
  int best = 0;
  for(int i = 0; i < sz(a); i++) {
    int j = i;
    while(j < sz(a) && a[i].first == a[j].first) {
      st.update(a[j].second, 0);
      ++j;
    }
    int cur = j - i + st.query(0, m - 1).max;
    best = max(best, cur);
    for(int k = i; k < j; k++) {
      best = max(best, ys[a[k].second] + j - i - 1);
    }
    while(i < j) {

      st.update(a[i].second, ys[a[i].second]);
      i++;
    }
    i--;
  }
  cout << best << endl;
  return 0;
}



Measured memory_bytes: 13272
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
import math

ans = 0
a, b, x = map(int, input().split())
S = x / a
if S >= (a * b / 2):
    h = ((a * b - S) * 2) / a
    deg = math.atan2(h, a) / (math.pi * 2) * 360
else:
    w = 2 * S / b
    deg = math.atan2(b, w) / (math.pi * 2) * 360
print(deg)

Measured memory_bytes: 77632
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 100001;
static const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline T int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int n; cin >> n;

	int cnt = 0;
	bool ok = false;
	rep(i, n){
		int d1, d2; cin >> d1 >> d2;
		if(d1 == d2) cnt++;
		else cnt = 0;
		if(cnt == 3) ok = true;
	}
	if(ok )  cout << "Yes" << endl;
	else  cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z = 40000;
    cin>>n;
    vi a(n),b(n),p;
    for(int i=0;i<n;i++){
        a[i] = 30000*(i+1);
        b[i] = 30000*(n-i);
    }
    in(p,n);
    for(int i=0;i<n;i++){
        b[p[i]-1]+=i;
    }
    print(a);
    print(b);
    


    return 0;
}

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

vector<int> graph[100010];

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

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

  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    a--, b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
    }

  int ans = 0;

  for(int i = 0; i < n; i++){
    bool good = true;
    for(long unsigned int j = 0; j < graph[i].size(); j++){
      int c = graph[i][j];
      if(h[i] <= h[c])  good = false;
    }
    if(good)  ans++;
  }

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


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

int main() {
  int ans[7];
  while(true) {
    int n, a;
    cin >> n;
    if(n==0) break;
    fill(ans, ans+7, 0);
    while(n--) {
      cin >> a;
      ans[min(a/10, 6)]++;
    }
    for(int i=0; i<7; ++i) {
      cout << ans[i] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3016
N, M = map(int, input().split())
H = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(M)]

ans = [True for _ in range(N)]

for l in S:
    if H[l[0]-1] == H[l[1]-1]:
        ans[l[1]-1] = False
        ans[l[0]-1] = False
    elif H[l[0]-1] > H[l[1]-1]:
        ans[l[1]-1] = False
    else:
        ans[l[0]-1] = False

print(ans.count(True))

Measured memory_bytes: 101376
#include <stdio.h>

int lowerBound(int [], int, int);
int upperBound(int [], int, int);

int main(void)
{
    int i, n, q, k, A[100000];

    scanf("%d", &n);
    for (i = 0; i < n; i++)
        scanf("%d", A + i);

    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d", &k);
        printf("%d %d\n", lowerBound(A, n, k), upperBound(A, n, k));
    }

    return 0;
}


int lowerBound(int A[], int N, int k)
{
    int low, mid, high;
    low = 0;
    high = N;
    while (low < high) {
        mid = (low + high) / 2;
        if (A[mid] == k) {
            while (mid > 0 && A[mid - 1] == k)
                mid--;
            return mid;
        } else if (A[mid] < k) {
            low = mid + 1;
        } else {
            high = mid;
        }
    }
    if (A[mid] < k)
        return mid + 1;
    else
        return mid;
}


int upperBound(int A[], int N, int k)
{
    int low, mid, high;
    low = 0;
    high = N;
    while (low < high) {
        mid = (low + high) / 2;
        if (A[mid] == k) {
            while (mid < N - 1 && A[mid + 1] == k)
                mid++;
            return mid + 1;
        } else if (A[mid] < k) {
            low = mid + 1;
        } else {
            high = mid;
        }
    }
    if (A[mid] < k)
        return mid + 1;
    else
        return mid;
}


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


int main(){

    int q,x=0,ch;
    scanf("%d",&q);
    vector<int> v1;
    for(int k=0;k<q;k++){

        scanf("%d",&ch);


       if (ch==0){

            scanf("%d",&x);
            v1.push_back(x);
        }
        else if (ch==1 && !v1.empty()){

             scanf("%d",&x);
             cout << v1[x] <<endl;
    
        }
        else if (ch==2 && !v1.empty()){
            v1.pop_back();
            
        }

    }


    return 0;
}


Measured memory_bytes: 3980
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
typedef pair<int, int> p;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9

int X[100000];
int dif[100000];

int main() {
	int N, M; cin >> N >> M;
	for (int i = 0; i < M; i++) cin >> X[i];
	sort(X, X + M);

	/*
	for (int i = 0; i < M; i++) cout << X[i] << " ";
	cout << endl;
	*/

	for (int i = 1; i < M; i++) dif[i] = X[i] - X[i - 1];
	dif[0] = 0;
	sort(dif, dif + M);
	int ans = 0;
	if (N < M) {
		for (int i = 1; i <= M - N; i++) ans += dif[i];
	}
	cout << ans << endl;
	

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 int main() {
	int n;cin>>n;
   int temp;
   while(n--) {
   	cin>>temp;
     if(temp%2==0) {
     	if(temp%3!=0 && temp%5!=0) {cout<<"DENIED"; return 0; } 
     }
   	}
   cout<<"APPROVED";
 }

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

int main(int argc, char *argv[]) {
    int N;
    std::string s;
    std::cin >> N;

    int sum = 0;
    int dummy = N;
    while(dummy > 0) {
        sum += dummy % 10;
        dummy /= 10;
    }

    if (N % sum == 0) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No"  << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL<<60LL)
typedef long long ll;

using namespace std;


int main() {
	ll age, ans; cin >> age >> ans;
	if (age <= 5) ans = 0;
	else if (age <= 12) ans /= 2;
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
constexpr long long int NINF = std::numeric_limits<long long int>::min();
#define int long long int

const int cost[10] = {INF, 2, 5, 5, 4, 5, 6, 3, 7, 6};

int dp[10][10001];
int log[10][10001];

enum WAY {
  UP = 1,
  REFT,
  UPREFT,
};

void solve() {
  int N, M;
  cin >> N >> M;

  vector<int> A(M);
  for (int &a : A) {
    cin >> a;
  }

  sort(A.begin(), A.end());

  for (int i = 0; i <= A.size(); i++) {
    for (int p = 0; p <= N; p++) {
      if (p == 0 && i > 0) {
        dp[i][p] = 0;
      } else {
        dp[i][p] = -1;
      }
    }
  }

  for (int i = 1; i <= A.size(); i++) {
    int a = A[i - 1];
    int c = cost[a];

    for (int p = 1; p <= N; p++) {
      int x = dp[i - 1][p];
      int l = REFT;

      if (p - c >= 0) {
        int upreft = dp[i - 1][p - c];
        if (upreft >= 0 && x <= upreft + 1) {
          x = upreft + 1;
          l = UPREFT;
        }

        int up = dp[i][p - c];
        if (up >= 0 && x <= up + 1) {
          x = up + 1;
          l = UP;
        }
      }

      dp[i][p] = x;
      log[i][p] = l;
    }
  }

  const string s = "0123456789";
  int len = dp[A.size()][N];
  int i = A.size();
  int p = N;
  string ans = "";
  while (len > 0) {
    int a = A[i - 1];
    int c = cost[a];
    if (log[i][p] == UP) {
      len--;
      p -= c;
      ans.push_back(s[a]);
    } else if (log[i][p] == UPREFT) {
      len--;
      i--;
      p -= c;
      ans.push_back(s[a]);
    } else if (log[i][p] == REFT) {
      i--;
    }
  }

  cout << ans << endl;

  // for (int i = 0; i <= A.size(); i++) {
  //   for (int p = 0; p <= N; p++) {
  //     cout << dp[i][p] << " ";
  //   }
  //   cout << endl;
  // }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 1792