akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
import heapq
from collections import deque


def solve(N: int, M: int, work: "List[List[int]]"):
    wq = deque(work)
    paytree = []
    ans = 0

    for day in range(M + 1):
        while len(wq) > 0 and wq[0][0] <= day:
            heapq.heappush(paytree, wq.popleft()[1] * (-1))
        if len(paytree) > 0:
            ans -= heapq.heappop(paytree)

    print(ans)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    work = [] # type: "List[List[int]]"
    for _ in range(N):
        work.append([int(next(tokens)), int(next(tokens))])
    solve(N, M, sorted(work))

if __name__ == '__main__':
    main()


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

string rec(int n) {
  if(n == 0) return "";
  int k = n % 8;
  return rec(n/8) + "01235789"[k];
}

int main() {
  int n;
  while(1) {
    cin >> n;
    if(n == 0) break;
    cout << rec(n) << endl;
  }

  return 0;
}

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

int typ, a, b;

int main()
{
    scanf("%d", &typ);
    if (typ == 1) printf("Hello World\n");
    else {
        scanf("%d %d", &a, &b);
        printf("%d\n", a + b);
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int n, a[100], i, j, sum=0, ans=1000000000;
    scanf("%d", &n);
    for(i=0;i<n;i++){
        scanf("%d", &a[i]);
    }

    for(i=-100;i<=100;i++){
        sum=0;
        for(j=0;j<n;j++){
            sum=sum+(a[j]-i)*(a[j]-i);
        }
        if(ans>sum) ans=sum;
    }

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

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

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = sc.nextInt();
      	String line = sc.next();
      	String[] mozi = line.split("");
      	String output = "";

      	if (mozi.length > count){
          	for(int i=0; i<count; i++){
          		output += mozi[i];
        	}
			output += "...";
        }else{
            for(int i=0; i<mozi.length; i++){
          		output += mozi[i];
        	}
        }
        System.out.println(output);
    }

}

Measured memory_bytes: 39708
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int w = sc.nextInt();
    if(n+m+w >= 22){
      System.out.print("bust");
    }else{
      System.out.print("win");
    }
  }
}


Measured memory_bytes: 22100
#include <stdio.h>
#include <stdlib.h>

// 節点の構造体を定義
struct Node {
  int key;
  struct Node *right, *left, *parent;
};

// rootとNILの構造体を初期化
struct Node *root, *NIL;

void insert(int k) {

  struct Node *y =  NIL;
  struct Node *x = root;
  struct Node *z;

  z = (struct Node *)malloc(sizeof(struct Node));

  // insertする節点のフィールドを初期化
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL) {
    // 親を設定
    y = x;
    if (z->key < x->key) {
      // zのkeyがxのkeyより小さければ、左へ移動
      x = x->left;
    } else {
      //zのkeyがxのkeyより大きければ、右へ移動
      x = x->right;
    }
  }
  // zの親候補
  z->parent = y;
  if (y == NIL) {
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void preParse(struct Node *u) {
  if (u == NIL) return;
  preParse(u->left);
  printf(" %d", u->key);
  preParse(u->right);
}

void inParse(struct Node *u) {
  if (u == NIL) return;
  printf(" %d", u->key);
  inParse(u->left);
  inParse(u->right);
}

int main() {

  int n, x;
  char com[10];
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s%d", com, &x);
    if (com[0] == 'i') {
      insert(x);
    } else {
      preParse(root);
      printf("\n");
      inParse(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 25136
N=int(input())
*A,=map(int,input().split())

def gcd(a,b):
  if b==0:return a
  return gcd(b, a%b)

def cum(array, merge, unit):
    new=[unit]
    for i in range(len(array)):
        new.append(merge(new[-1], array[i]))
    return new
  
cum1 = cum(A,gcd,A[0])
cum2 = cum(A[::-1],gcd,A[-1])[::-1]

res=[]
for i in range(N):
  if i == 0:
    tmp = cum2[i+1]
  elif i == N-1:
    tmp = cum1[i]
  else:
    tmp = gcd(cum1[i],cum2[i+1])
  res.append(tmp)
  
print(max(res))

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

#define size(v) v.size()

template <class U, class C> struct ssp {
  struct edge {
    int to;
    U cap;
    C cost;
  };
  const U inf = numeric_limits<U>::max(), eps = 1e-10;
  int n, s, t;
  vector<edge> es;
  vector<vector<int>> g;
  vector<C> d;
  vector<int> pe;
  ssp(int _n, int _s, int _t) : n(_n), s(_s), t(_t), g(n), d(n), pe(n) {}
  void add(int from, int to, U cap, C cost) {
    g[from].push_back(size(es)), es.push_back({to, cap, cost});
    g[to].push_back(size(es)), es.push_back({from, 0, -cost});
  }
  bool spfa() {
    static vector<bool> in(n);
    static vector<int> que;
    fill(begin(d), end(d), numeric_limits<C>::max());
    que.clear();
    d[s] = 0, in[s] = true, que.push_back(s);
    for (int bg = 0; bg < (int)size(que); ) {
      int v = que[bg++];
      in[v] = false;
      for (int id : g[v]) {
        auto&& e = es[id];
        if (e.cap > eps and d[v] + e.cost < d[e.to]) {
          d[e.to] = d[v] + e.cost, pe[e.to] = id;
          if (not in[e.to]) in[e.to] = true, que.push_back(e.to);
        }
      }
    }
    return d[t] < numeric_limits<C>::max();
  }
  vector<pair<U, C>> min_cost_max_flow() {
    U flow = 0;
    C cost = 0;
    vector<pair<U, C>> res;
    while (spfa()) {
      U df = inf;
      for (int v = t; v != s; v = es[pe[v] ^ 1].to) df = min(df, es[pe[v]].cap);
      for (int v = t; v != s; v = es[pe[v] ^ 1].to)
        es[pe[v]].cap -= df, es[pe[v] ^ 1].cap += df;
      flow += df, cost += df * d[t];
      res.emplace_back(flow, cost);
    }
    return res;
  }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int n, m, p, s, t;
  cin >> n >> m >> p >> s >> t;
  --s, --t;
  ssp<int, int> g(n, s, t);
  while (m--) {
    int v, w, d, c;
    cin >> v >> w >> d >> c;
    --v, --w;
    g.add(v, w, c, d);
  }
  double res = 1e10;
  for (auto e : g.min_cost_max_flow()) {
    double x, y;
    tie(x, y) = e;
    res = min(res, (y + p) / x);
  }
  cout << res << '\n';
}



Measured memory_bytes: 3404
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

vector<pair<char,int> > rfe_tuple(string S){
  vector<pair<char,int> > ff;
  int sum=1;
  for (int i=1;i<S.length();i++){
    while(S[i]==S[i-1]){
      sum++;
      i++;
    }
    ff.push_back(make_pair(S[i-1],sum));
    sum=1;
  }
  if(S[S.length()-1]!=S[S.length()-2]) ff.push_back(make_pair(S[S.length()-1],1));
  return ff;
}

int main(){
  string S;
  cin >> S;
  int len = S.length();
  vector<pair<char,int> > f;
  f=rfe_tuple(S);
  int sum=0;
  int ans[len];
  for(int i=0;i<len;i++){
    ans[i]=0;
  }
  for(int i=0;i<f.size();i++){
    if(f[i].first=='R'){
      sum += f[i].second;
      if((f[i].second+f[i+1].second)%2==0){
	ans[sum-1]=(f[i].second+f[i+1].second)/2;
	ans[sum]=(f[i].second+f[i+1].second)/2;
      }
      else if(f[i].second%2==0) {
	ans[sum-1]=(f[i].second+f[i+1].second)/2;
	ans[sum]=(f[i].second+f[i+1].second)/2+1;
      }
      else{
	ans[sum-1]=(f[i].second+f[i+1].second)/2+1;
	ans[sum]=(f[i].second+f[i+1].second)/2;
      }
    }
    sum += f[i+1].second;
    i++;
  }
  for(int i=0;i<len;i++){
    cout << ans[i] << " ";
  }
}


Measured memory_bytes: 4072
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main(){
    int n,i,j=1;
    scanf("%d",&n);
    char s[n][11];
    for(i=0; i<n; i++){
        scanf("%s",s[i]);
    }
    qsort(s,n,11,strcmp);
    for(i=0; i<n-1; i++){
        if(strcmp(s[i],s[i+1])!=0)j++;
    }
    printf("%d",j);
    return 0;
}

Measured memory_bytes: 5740
x,k,d = map(int,input().split())
x = abs(x)
if x > d:
	if x - k*d >= 0:
		print(x - k*d)
	else:
		if (k-(x//d))%2 == 0:
			print(x%d)
		else:
			print(min(x%d + d,abs(x%d - d)))
if x <= d:
	if k%2 == 0:
		print(min(abs(x - 2*d),x))
	else:
		print(min(d-x,x+d))

Measured memory_bytes: 9056
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<int,int>
#define endl "\n"
#define MAXN 100005
#define mod 1000000007
using namespace std;

void solve()
{
    
}
ll counter[120001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    solve();
    ll n;
    cin>>n;
    if(n==1)
    {
        cout<<0<<'\n';
        return 0;
    }
    cout<<0<<'\n';
    cout<<0<<'\n';
    ll res = (ll)ceil(sqrt(n - 2));
    ll ans = 0;
    for(ll i=1; i<=100; i++)
    {
        for(ll j=1; j<=100; j++)
        {
            for(ll k=1; k<=100; k++)
            {
                ll sum = i*i + j*j + k*k + i*j + k*i + k*j;
                counter[sum]++;
            }
        }
    }
    for(ll i=3; i<=n; i++)
    {
        cout<<counter[i]<<'\n';
    }
}

Measured memory_bytes: 3980
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
#include <list>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;

vector<vector<ll>> field(3, vector<ll>(3, 0));
vector<ll> coord1 = {0, 4, 8};
vector<ll> coord2 = {2, 4, 6};
void Main(){
    ll N, a;
    cin >> N;
    ll ans = 0;
    rep(i, N){
        cin >> a;
        ans += ((i+1) % 2==1) && (a%2==1);
    }

    cout << ans << endl;

}

int main(){
    Main();
}

Measured memory_bytes: 3148
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>

#include <climits>
#include <cmath>
#include <cstring>

#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;

int main()
{
	FAST;
	int alpha[26]={0},alpha1[26]={0};
	string str,t;
	cin >> str >> t;

	if(str == t)
	{
	    cout << "Yes";
		return 0;
	}

	for(int i=0 ; i<str.size() ; i++)
		alpha[str[i]-'a']++;
	for(int i=0 ; i<t.size() ; i++)
		alpha1[t[i]-'a']++;

	int notpresent = 0;
	int arr[100005] = {0};
	for(int i=0 ; i<26 ; i++)
	{
	    if(alpha[i] == alpha1[i] && alpha[i] > 0)
	    {
	        
	    }
	    else
		    arr[alpha[i]]++;
    }
	for(int i=0 ; i<26 ; i++)
	{
		if(alpha[i] != alpha1[i])
		{
				if(arr[alpha1[i]] >= 1)
				{
					arr[alpha1[i]]--;
				}
				else
				{
					cout << "No";
					return 0;
				}
		}
	}
	
	cout << "Yes";
	return 0;
}

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


int main(){
	int a[9],b[9];
	int t;
	cin>>t;
	while(t--){
		double fact9=362880;
		int cnt=0;
		for(int i=0;i<9;i++)cin>>a[i];
		for(int i=0;i<9;i++)cin>>b[i];
		sort(b,b+9);
		do{
			int sa=0,sb=0;
			for(int i=0;i<9;i++)(a[i]>b[i]?sa:sb)+=a[i]+b[i];
			if(sa>sb)cnt++;
		}while(next_permutation(b,b+9));
		printf("%.5f %.5f\n", cnt/fact9,1-cnt/fact9);
	}
	return 0;
}

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

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

int main(){
    string s;cin >>s;
    ll n=s.size();
    ll win=0,lose=0;
    for (int i = 0; i < n; ++i) {
        if(i%2==0){
            if(s[i]=='p')lose++;
        }
        else {
            if(s[i]=='g')win++;
        }
    }
    cout <<win-lose<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define llv vector< ll >
#define mp make_pair
#define endl "\n"
const int N = (int)1e5+10 ;
const int M = (int)1000000007;


int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    ll n , i ;
    cin >> n ;
    ll a[n] , b[n] , c[n] ;
    for(i=0 ; i<n ; i++){
        cin >> a[i] >> b[i] >> c[i] ;
    }
    ll dp[n][2][2][2] ;
    dp[0][0][1][1] = a[0] ;
    dp[0][1][0][1] = b[0] ;
    dp[0][1][1][0] = c[0] ;
    for(i=1 ; i<n ; i++){
       dp[i][0][1][1] = a[i] + max(dp[i-1][1][0][1] , dp[i-1][1][1][0] ) ;
       dp[i][1][0][1] = b[i] + max(dp[i-1][0][1][1] , dp[i-1][1][1][0] ) ;
       dp[i][1][1][0] = c[i] + max(dp[i-1][0][1][1] , dp[i-1][1][0][1] ) ; 
    }

    cout << max(dp[n-1][0][1][1] , max(dp[n-1][1][1][0] , dp[n-1][1][0][1] ) ) ;
    return 0 ;
}

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

//***********************************************************************
int MAXNUM = 5e3+5;
vector <int>vis(MAXNUM);
vector<int> pr;
void sieve() {
	pr.push_back(2);
	for(ll i=3;i<MAXNUM;i+=2) if(!vis[i]) {
		pr.push_back(i);
		for(ll j=i*i;j<MAXNUM;j+=2*i) vis[j]=true;
	}
}
//************************************************************************

void explore(vector<vector<int>> &graph,vector<int> &vis,int s,vector<int> &toposort)
{
    vis[s]=1;
    for(int i=0;i<graph[s].size();i++)
    {
        int v=graph[s][i];
        if(vis[v]==0)
        {
            explore(graph,vis,v,toposort);
        }
    }
    toposort.push_back(s);
}

void solve()
{
    int n,m;
    cin >> n >> m;
    vector<vector<int>> graph(n+1);
    for(int i=0;i<m;i++)

    {
        int u,v;
        cin >> u >> v;
        graph[u].push_back(v);
    }
    vector<int> toppsort;
    vector<int> vis(n+1);
    for(int i=1;i<n+1;i++)
    {
        if(vis[i]==0)
        {
            explore(graph,vis,i,toppsort);
        }
    }
	reverse(toppsort.begin(),toppsort.end());
    /*for(int i=0;i<toppsort.size();i++)
    {
        cout << toppsort[i] << " ";
    }
    cout << endl;
*/

    vector<int> dp(n+1);
    int ans=0;
    for(int i=0;i<n;i++)
    {
        int u=toppsort[i];
        for(int j=0;j<graph[u].size();j++)
        {
            int v=graph[u][j];
            dp[v]=max(dp[v],dp[u]+1);
            if(dp[v]>ans)
            ans=dp[v];
        }
    }
    cout << ans << endl;
}


int main()
{ 
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	ll t;
	//cin >> t;
	t=1;
	while(t--)
	{
		solve();
	}

	return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7;
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

ll N;
ll A[200005];
ll check[1000005];
ll cnt;

int main(){

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

cin>>N;
rep(i,N){
	cin>>A[i];
	check[A[i]]++;
}
rep(i,N){
	ll n=A[i];
	if(check[n]>1) continue;
	bool ok=true;
	for(ll k=1; k*k<=n; k++){
		if(n%k==0){
			if(check[k]) if(k!=n) ok=false;
			if(k!=n/k){
				if(check[n/k]) if(n/k!=n) ok=false;
			}
		}
	}
	if(ok) cnt++;
}
cout<<cnt<<endl;

}
	

Measured memory_bytes: 12928
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let k: usize = itr.next().unwrap().parse().unwrap();
    let mut a: Vec<usize> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    for _ in 0..min(100, k) {
        let mut b = vec![0i64; n * 4];
        for j in 0..n {
            b[n + j - a[j]] += 1;
            b[n + j + a[j] + 1] -= 1;
        }
        for j in 0..n * 2 {
            b[j + 1] += b[j];
        }
        for j in n..n * 2 {
            a[j - n] = b[j] as usize;
        }
    }
    let mut out = Vec::new();
    for i in 0..n {
        write!(out, "{}", a[i]).ok();
        if i == n - 1 {
            writeln!(out, "").ok();
        } else {
            write!(out, " ").ok();
        }
    }
    stdout().write_all(&out).unwrap();
}


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

long long d[10][10];

int main() {
	long long n;
	cin >> n;
	for(long long i=1;i<=n;i++){
		long long a,b;
		b=i%10;
		string str = to_string(i);
		a=str[0]-'0';
		d[a][b]++;
	}
	long long res=0;
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++){
			res += d[i][j]*d[j][i];
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#C - City Savers(ABC135)
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
ans=0
for i in range(N):
    if A[i]<B[i]:
        S=A[i+1]-(B[i]-A[i])
        if S>=0:
            A[i+1]=S
            ans+=B[i]
        else:
            ans+=A[i]+A[i+1]
            A[i+1]=0
    else:
        ans+=B[i]
print(ans)

Measured memory_bytes: 19156
#include<iostream>
#include<vector>
#include<list>
#include<map>
#include<utility>
#include<algorithm>
using namespace std;


int main () {
  int N,M;
  cin >> N >> M;
  int H[N];
  for (int i =0;i< N ;i++) {
      cin >> H[i];
  }
  int A,B;
  multimap<int,int> m;
  for (int j=0;j<M;j++){
    cin >> A >> B;
    A--;B--; //1つずれてる
    m.emplace(A,B);
    m.emplace(B,A);
  }
  int ans=0;
  for (int i=0;i<N;i++) {
    if (m.count(i)==0) {
      ans++;
      continue;
    }
    auto p = m.equal_range(i);
    bool flag=true;
    for (auto it =p.first; it !=p.second; ++it ) {
      if (H[it -> first] <= H[it -> second]) {
        flag=false;
        break;
      }
    }
    if (flag){
      ans++;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 13396
#define _DEBUG 1
#define _GLIBCXX_DEBUG

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

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

const ll LINF = 2e18;
const int INF = 1e9;

void solve(std::string T) {
  for (char c : T) {
    if (c == 'P') {
      cout << c;
    } else {
      cout << "D";
    }
  }
  cout << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  std::string T;
  std::cin >> T;
  solve(T);
  return 0;
}


Measured memory_bytes: 3952
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;

  const int m=4;
  vector<int> ps(m),ts(m);
  for(int i=0;i<m;i++) cin>>ps[i];
  for(int i=0;i<m;i++) cin>>ts[i];

  const int INF = 1e9;
  vector<int> dp(1000,INF);
  dp[0]=0;
  for(int i=0;i<m;i++)
    for(int j=0;j+ts[i]<(int)dp.size();j++)
      chmin(dp[j+ts[i]],dp[j]+ps[i]);

  cout<<*min_element(dp.begin()+n,dp.end())<<endl;
  return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <math.h>

int main(){
	int Num;//要素数
	std::cin >> Num;

	int* Elem = new int[Num];//要素代入
	for (int i = 0; i < Num; ++i){
		std::cin >> Elem[i];
	}

	int primecount = 0;//約数の存在を調べ素数判定
	bool isprime = false;
	for (int i = 0; i < Num; ++i){//約数の存在判定
		if (Elem[i] % 2 == 0){//数値が偶数
			if (Elem[i] == 2)++primecount;//数値が2
			continue;
		}

		//数値が奇数
		isprime = true;
		for (int j = 3; j <= sqrt(Elem[i]); j += 2){
			if (Elem[i] % j == 0){
				isprime = false;
				break;
			}
		}
		if (isprime)++primecount;
	}

	std::cout << primecount << std::endl;

	return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for(auto v:(V))cout<<v<<" "<<endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const int MOD = 1000000007;

int main()
{
    ll n, y;
    cin >> n >> y;
    rep(i, n+1)
    {
        rep(j, n+1-i)
        {
            ll k = n - i - j;
            if(10000*i+5000*j+1000*k == y)
            {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 998244353;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;

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

    int n, q; cin >> n >> q;
    string s; cin >> s;
    s = '0' + s;
    vector<int> l(q), r(q);
    for(int i=0; i<q; ++i) cin >> l[i] >> r[i];

    vector<int> cum(n+5, 0);
    for(int i=1; i<=n; ++i){
        if(s[i] == 'C' && s[i-1] == 'A') cum[i] = cum[i-1]+1;
        else cum[i] = cum[i-1];
    }

    for(int i=0; i<q; ++i){
        int left=l[i], right=r[i];
        cout << cum[right]-cum[left] << endl;
    }

    

    return 0;
}

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

void printVector(vector<int> v) {
    for (auto x : v) {
        cout << x << ' ';
    }
    cout << '\n';
}

void printArray(ll A[], int size) {
    for (int i = 0; i <= size - 1; i++) cout << A[i] << ' ';
}

int main() {
    int n;
    cin >> n;
    ll A[n];
    for (int i = 0; i <= n - 1; i++) cin >> A[i];
    //printArray(A, n);
    ll L[n];
    ll R[n];
    L[0] = A[0];
    R[n - 1] = A[n - 1];
    for (int i = 1; i <= n - 1; i++) {
        L[i] = __gcd(L[i - 1], A[i]);
    }
    for (int i = n - 2; i >= 0; i--) {
        R[i] = __gcd(R[i + 1], A[i]);
    }
    //printArray(L, n);
    //cout << '\n';
    //printArray(R, n);
    ll M[n];
    M[0] = R[1];
    M[n - 1] = L[n - 2];
    for (int i = 1; i <= n - 2; i++) {
        M[i] = __gcd(L[i - 1], R[i + 1]);
    }
    ll ans = 1;
    for (int i = 0; i <= n - 1; i++) {
        ans = max(ans, M[i]);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 6768
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let a: Vec<i64> = (0..n).map(|_| it.next().unwrap().parse().unwrap()).collect();
    let mut dp = vec![0; n + 1];
    for len in 1..(n + 1) {
        let mut next = vec![0; n + 1];
        for l in 0..(n + 1 - len) {
            let r = l + len - 1;
            next[l] = std::cmp::max(a[l] - dp[l + 1], a[r] - dp[l]);
        }
        dp = next;
    }
    println!("{}", dp[0]);
}

fn main() {
    run();
}


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

using namespace std;

const int maxn = 100000 + 5;

int n;
char s[maxn];

void inline Init()
{
	scanf("%s", s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; ++i) s[i] -= '0';
}

int ans1, ans2;

void inline Solve()
{
	bool want = 0;
	for(int i = 1; i <= n; ++i, want = !want) {
		if(s[i] != want) ++ans1;
	}
	want = 1;
	for(int i = 1; i <= n; ++i, want = !want) {
		if(s[i] != want) ++ans2;
	}
	printf("%d\n", min(ans1, ans2));
}

int main()
{
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

template<typename Monoid>
struct SegmentTree{
    int n;
    vector<Monoid> node;

    SegmentTree(vector<Monoid> v){
        int k = v.size();
        n = 1; while(n < k) n *= 2;
        node.resize(2*n-1,0); //単位元で初期化
        for(int i = 0; i < k; i++) node[i+n-1] = v[i];
        for(int i = n-2; i >= 0; i--) node[i] = node[2*i+1]+node[2*i+2]; //書き換える
    }

    SegmentTree(int k){
        n = 1; while(n < k) n *= 2;
        node.resize(2*n-1,0); //書き換える
    }

    void update(int k, Monoid x){
        k += n-1;
        node[k] += x;
        while(k > 0){
            k = (k-1)/2;
            node[k] = node[2*k+1]+node[2*k+2]; //書き換える
        }
    }

    //[a,b)のクエリに答える
    Monoid query(int a, int b, int k = 0, int l = 0, int r = -1){
        if(r < 0) r = n;
        if(b <= l || a >= r) return 0;
        if(a <= l && b >= r) return node[k];
        else{
            Monoid s = query(a,b,2*k+1,l,(l+r)/2);
            Monoid t = query(a,b,2*k+2,(l+r)/2,r);
            return s+t; //書き換える
        }
    }
};


int main(){
    int n,q; cin >> n >> q;
    vector<int> c(n);
    rep(i,n) cin >> c[i],c[i]--;
    vector<int> before(n,-1);
    vector<tuple<int,int,int>> v; 
    rep(i,n){
        if(before[c[i]] == -1) before[c[i]] = i;
        else{
            v.emplace_back(before[c[i]],INF,i);
            before[c[i]] = i;
        }
    }
    rep(i,q){
        int l,r; cin >> l >> r; 
        l--; r--;
        v.emplace_back(l,i,r);
    }
    sort(v.begin(),v.end());
    int m = v.size();
    SegmentTree<int> st(n);
    vector<int> ans(q);
    for(int i = m-1; i >= 0; i--){
        int a,b,c;
        tie(a,b,c) = v[i];
        if(b == INF){
            st.update(c,1);
        }
        else{
            ans[b] = c-a+1-st.query(0,c+1);
        }
    }
    rep(i,q) cout << ans[i] << endl;
}



Measured memory_bytes: 24948
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	char  s[n];
	long long sum=0;
	for(int i=1;i<=n;i++)
	{
		if(i%3==0 && i%5==0)
		{
			continue;
		}
		else{
			if(i%3==0){
				continue;
			}
			else{
				if(i%5==0)
				{
				continue;	
				}
				else{
					sum=sum+i;
				}
			}
		}
	}
	cout<<sum<<"\n";
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
  	int a[n];
  	for (int i = 0; i < n; i++) {
		cin >> a[i];
    }
  	sort(a, a + n);
  	for (int i = 1; i < n; i++) {
     	a[i] += a[i - 1]; 
    }
  	cout << (a[n-1] < 2 * a[n-2] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    N = input()
    d = []
    for _ in xrange(N):
        A, B = map(int, raw_input().split())
        d.append((A,B))
    
    d.sort()

    A1, B1 = d[0]
    AN, BN = d[-1]

    print AN + BN 

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

int main(){
  int p,q,r;
  cin >> p >> q >> r;
  int ans = min(min(q+r, p+q), p+r);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

#define INF (1ll << 60)
int main(int argc, char const *argv[])
{
    int n, m;
    string s;
    cin >> n >> m >> s;
    vector<ll> dp(n + 1, INF);
    vector<int> diff(n + 1, -1);
    dp[0] = 0;

    int mmove = 0;

    rep(i, n)
    {
        if (mmove < i)
        {
            break;
        }
        if (dp[i] == INF || s[i] == '1')
        {
            continue;
        }
        //auto newdp = dp;
        rep(j, mmove - i, m + 1)
        {
            if (i + j > n)
                break;
            if (s[i + j] == '1' || dp[i + j] != INF)
            {
                continue;
            }
            if (dp[i] + 1 < dp[i + j])
            {
                dp[i + j] = dp[i] + 1;
                diff[i + j] = j;
                mmove = max(mmove, (int)(i + j));
            }
        }
        //dp = newdp;
        if (dp[n] != INF)
        {
            break;
        }
    }
    if (dp[n] == INF)
    {
        cout << -1 << endl;
        return 0;
    }
    else
    {
        int cur = n;
        vector<int> ans(dp[n], 0);
        rep(i, dp[n])
        {
            //cerr << cur << endl;
            ans[i] = diff[cur];
            cur -= diff[cur];
        }
        //rep(i, dp[n]) cerr << ans[i] << endl;
        for (int i = ans.size() - 1; i >= 0; i--)
        {
            cout << ans[i] << " ";
        }
        cout << endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 2176
n = int(input())

playlists = []
playlists_num = []
ans = 0

for i in range(n):
    a = input()
    a, b = a.split(' ')
    b = int(b)
    playlists.append(a)
    playlists_num.append(b)


s = input()

for i in range(n):
    if playlists[i] == s:
        break

for j in range(i+1, n):
    ans += playlists_num[j]

print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

using namespace std;
typedef long long ll;

int main(void) {
  double x, t;
  cin >> x >> t;
  printf("%.10f\n", x / t);
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,h,w;
    cin>>n>>h>>w;
    cout<<(n-h+1)*(n-w+1)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 1<<29
#define LLINF 1LL<<60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

ll N;
 
int main() {
    cin >> N;
    if(N==0) {
        cout << 0 << endl;
        return 0;
    }
    int b = 0;
    string s = "";
    while(N != 0){
        s += (N&1) ? "1" : "0";
        if((b%2)&(N&1)) N += 2;
        N >>= 1;
        b++;
    }
    reverse(ALL(s));
    cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
/*
* @Author: dnhirapara
* @Date: 2020-04-27 21:46
* @Name: dp_e
*/
#include <bits/stdc++.h>

using namespace std;

/************defination************/

#define endl "\n"
#define log(x) cerr << __LINE__ << ": " << #x << " -> " << (x) << endl;
#define ll long long int
#define ull unsigned long long int

void in_out_file(){
    #ifdef _DEBUG
        freopen("F:/Coding/CompetitiveProg/static/input.txt", "r", stdin);
        freopen("F:/Coding/CompetitiveProg/static/output.txt", "w", stdout);
        freopen("F:/Coding/CompetitiveProg/static/debug.txt", "w", stderr);
    #endif
}

int main(){
    // cin.ignore(); must be there when using getline(cin, s)
    #ifndef AUTO
        in_out_file();
    #endif
    ll n, w;
    cin>>n>>w;
    ll weights[n+1];
    ll values[n+1];
    ll sum = 0;
    for(ll i=0;i<n;i++){
        cin>>weights[i];
        cin>>values[i];
        sum+=values[i];
    }
    ll dp[sum+1];
    for(ll i=0;i<sum+1;i++){
        dp[i] = INT_MAX;
    }
    dp[0] = 0;
    for(ll i=0;i<n;i++){
        for(ll value=sum;value>=values[i];value--){
            dp[value] = min(dp[value], dp[value-values[i]]+weights[i]);
            // log(dp[value])
        }
    }
    ll maxi = 0;
    for(ll i=0;i<sum+1;i++){
        if(dp[i]<=w){
            maxi = max(maxi, i);
        }
    }
    cout<<maxi<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
  int n,sa1,sa2;
  int w[101];
  int s1=0,s2=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&w[i]);
    s2+=w[i];
  }
  for(int i=0;i<n;i++){
    if(s1<s2){
      sa1=s2-s1;
      s1+=w[i];
      s2-=w[i];
    }else{
      sa2=s1-s2;
      break;
    }
  }
  printf("%d",(sa1<sa2)?sa1:sa2);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <vector>
#include <cstdlib>
#include <queue>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define STEP(i, n, step) for(int i=0; i < n; i+=step)
#define RANGE(n) for(int _=0; _<n ; _++)
#define FOR(i, m, n) for(int i = m; i < n; i++)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;
const int INT_INF = 1 << 29;

const int MAX = 100010;

void solve() {
  string S;
  cin >> S;
  if(S[S.size()-1] == 's') cout << S << "es" << endl;
  else cout << S << 's' << endl;
  return;
}
 
int main() {
    solve();
    return 0;
}




Measured memory_bytes: 3632
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#include <cstdio>
using namespace std;
int main(int argc, char const *argv[]) {
int N;
cin>>N;
map<unsigned long long,unsigned long long> a;
vector <unsigned long long> a_list;
for(size_t i=0;i<N;i++){
  unsigned long long temp=0;
  cin>>temp;
  a[temp]++;
  if(a[temp]==1) a_list.push_back(temp);
}
int ans=0;
for(auto p:a){
  int x=p.first;
  int n=p.second;
  if(n<x)ans+=n;
  else ans+=n-x;
}
cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 7028
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main(){
    Hello
    int n, m;
    cin >> n >> m;
    int mx = 0, mn = 1e9;
    for(int i = 0, l, r; i < m; i++){
        cin >> l >> r;
        mx = max(mx, l);
        mn = min(mn, r);
    }
    cout << max(0, mn - mx + 1);
    return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	int a[3];
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}
	sort(a, a + 3);
	if (a[0] + a[1] == a[2]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int h[100100];
bool use[100100];
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	int n,m;
	cin>>n>>m;
	rep(i,n)
		cin>>h[i];
	rep(i,m)
	{
		int a,b;
		cin>>a>>b;
		a--,b--;
		if(h[a]>h[b])use[b]=1;
		else if(h[a]<h[b]) use[a]=1;
		else use[a]=use[b]=1;
	}
	int cnt=0;
	rep(i,n)
		if(!use[i])cnt++;
	cout<<cnt;
	return 0;
}



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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    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;
    }
}
ll 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;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int counter(int x){
    if(!x)return 0;
    return counter(x>>1)+(x&1);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    string S=in<string>();
    int ans;ans=0;
    for(int i=1;i<S.length();i++){
        if(S[i]!=S[i-1]){
            ans++;
        }
    }
    ans++;
    print(ans);
    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	string t;
	cin >> s;
	cin >> t;
	int ans = t.size();
	for (int i = 0; i <= s.size() - t.size(); i++) {
		int cnt = 0;
		for (int j = 0; j < t.size(); j++)
			cnt += (s[i + j] != t[j]);
		ans = min(ans, cnt);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int has[26];
int main(){
	int i;
	string s;
	cin>>s;
	for(i=0;i<s.size();i++){
		int x=s[i];
		has[x-'a']++;
	}
	for(i=0;i<=25;i++){
		if(has[i]%2!=0){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll,ll> pii;
typedef vector<pii> vpii;
typedef pii point;
using namespace std;

int main(){
  ll N; cin>>N;
  string S; cin>>S;
  vi w(N+1),e(N+1);
  REP(i,N){
    w[i+1]=w[i]; e[i+1]=e[i];
    if(S[i]=='W') w[i+1]++;
    if(S[i]=='E') e[i+1]++;
  }
  ll ans=min(e[N]-e[1],w[N-1]-w[0]);
  FOR(i,1,N-1){
    ans=min(ans,(e[N]-e[i+1])+(w[i]-w[0]));
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 5380
def mod_power(x,y,p):
    if y == 1:
        return x % p
    elif y % 2 == 0:
        return (mod_power(x,y/2,p)**2) % p
    else:
        return (mod_power(x,y-1,p) * x ) % p

def mod_inv(x,p):
    return mod_power(x,p-2,p)

def mod_nCa(n,a,p):
    num = 1
    den = 1
    for i in range(a):
        num = (num * (n-i)) % p
        den = (den * (a-i)) % p
    return (num * mod_inv(den,p)) % p


n,a,b = map(int,input().split())

m = 10**9 + 7

print((mod_power(2,n,m) - mod_nCa(n,a,m) - mod_nCa(n,b,m) - 1) % m)

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

int n,k;
long long t[100000];

int check(long long p){
  int i=0;
  for(int j=0;j<k;j++){
    long long s=0;
    while(s+t[i]<=p){
      s+=t[i];
      i++;
      if(i==n)return n;
    }
  }
  return i;
}

int solve(){
  long long left=0;
  long long right=n*10000;
  long long mid;
  while(right-left>1){
    mid=(left+right)/2;
    int v=check(mid);
    if(v>=n)right=mid;
    else left=mid;
  }
  return right;
}

int main(){
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>t[i];
  }
  cout<<solve()<<endl;
}

Measured memory_bytes: 1948
local ior = io.input()
local n = ior:read("*n")
local lines = {}
for i = 1, n do lines[i] = {} end
for i = 1, n - 1 do
  local a, b, c = ior:read("*n", "*n", "*n")
  lines[a][b] = c
  lines[b][a] = c
end
local tasks = {1}
local map = {}
map[1] = 0
for i = 2, n do map[i] = -1 end
local tasknum, done = 1, 0
while(done < tasknum) do
  done = done + 1
  local taskidx = tasks[done]
  for k, v in pairs(lines[taskidx]) do
    if(map[k] == -1) then
      map[k] = (map[taskidx] + v) % 2
      table.insert(tasks, k)
      tasknum = tasknum + 1
    end
  end
end
for i = 1, n do
  print(map[i])
end


Measured memory_bytes: 14580
/*
 * Author: RainAir
 * Time: 2019-07-20 13:48:09
 */
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define fi first
#define se second
#define U unsigned
#define P std::pair
#define Re register
#define LL long long
#define pb push_back
#define MP std::make_pair
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(Re int i = a;i <= b;++i)
#define ROF(i,a,b) for(Re int i = a;i >= b;--i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
#define int LL
const int MAXN = 3e5 + 5;
const int ha = 998244353;
int n,a,b,k;
int fac[MAXN],inv[MAXN];

inline int qpow(int a,int n=ha-2){
    int res = 1;
    while(n){
        if(n & 1) res = 1ll*res*a%ha;
        a = 1ll*a*a%ha;
        n >>= 1;
    }
    return res;
}

inline void prework(){
    fac[0] = 1;
    FOR(i,1,MAXN-1) fac[i] = 1ll*fac[i-1]*i%ha;
    inv[MAXN-1] = qpow(fac[MAXN-1]);
    ROF(i,MAXN-2,0) inv[i] = 1ll*inv[i+1]*(i+1)%ha;
}

inline int C(int n,int m){
    if(n < m) return 0;
    return 1ll*fac[n]*inv[m]%ha*inv[n-m]%ha;
}

int ans = 0;

signed main(){
    prework();
    scanf("%lld%lld%lld%lld",&n,&a,&b,&k);
    FOR(x,0,n){
        int t = k-a*x;if(t < 0) break;
        if(t%b) continue;
        int y = t/b;//DEBUG(x);DEBUG(y);
        if(y > n) continue;
        (ans += C(n,x)*C(n,y)%ha) %= ha;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main() {
    int bingo[3][3];
    for(int i = 0; i < 3; ++i){
        for(int j = 0; j < 3; ++j){
            scanf("%d",&bingo[i][j]);
        }
    }
    int N;
    scanf("%d",&N);
    int S[N];
    for(int i = 0; i < N; ++i){
        scanf("%d",&S[i]);

        for(int j = 0; j < 3; ++j){
            for(int k = 0; k < 3; ++k){
                if(bingo[j][k] == S[i]){
                    bingo[j][k] = 0;
                }
            }
        }
    }

    if(bingo[0][0]==bingo[0][1]&& bingo[0][1]==bingo[0][2]){
        printf("Yes");
        return 0;
    }
    else if(bingo[1][0] == bingo[1][1] &&bingo[1][1]== bingo[1][2] ){
        printf("Yes");
        return 0;
    }
    else if(bingo[2][0] == bingo[2][1] && bingo[2][1]== bingo[2][2] ){
        printf("Yes");
        return 0;
    }
    else if(bingo[0][0] == bingo[1][0] && bingo[1][0]== bingo[2][0] ) {
        printf("Yes");
        return 0;
    }
    else if(bingo[0][1] == bingo[1][1]&&bingo[1][1] == bingo[2][1] ){
        printf("Yes");
        return 0;
    }
    else if(bingo[0][2] == bingo[1][2] && bingo[1][2]== bingo[2][2] ){
        printf("Yes");
        return 0;
    }
    else if(bingo[0][0]== bingo[1][1]&&bingo[1][1] == bingo[2][2] ) {
        printf("Yes");
        return 0;
    }
    else if(bingo[0][2] == bingo[1][1]&&bingo[1][1] == bingo[2][0] ) {
        printf("Yes");
        return 0;
    }
    else {
        printf("No");
        return 0;
    }
}

Measured memory_bytes: 128