akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>

int n, *p, *q, front, ans;

int main() {
	scanf("%d", &n);
	p = new int[n];
	q = new int[n];
	for (int i = 0; i < n; ++i) {
		scanf("%d", p + i);
		q[--p[i]] = i;
	}
	for (int i = n - 2; i >= 0; --i) {
		if(q[i] > q[i + 1]) {
			front = i + 1;
			ans = 1;
			while(i--) {
				if(!(q[front] < q[i] && q[i] < q[i + 1]) && !(q[i] < q[i + 1] && q[i + 1] < q[front]) && !(q[i + 1] < q[front] && q[front] < q[i])) {
					++ans;
					front = i + 1;
				}
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

string a;

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cin >> a;
    int rsum = 0;
    for (int i = 0; i < n; i++)
        if (a[i] == 'R')
            rsum++;
    int ans = 0;
    for (int i = 0; i < rsum; i++)
        if (a[i] == 'W')
            ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3772
#include<stdio.h>
#include<string.h>
int main(){
  int n,i,j,mi,d[110],c[110],f[110]={0};
  char s[110][110];
  scanf("%d%*c",&n);
  for(i=0;i<n;i++){
    fgets(s[i],100,stdin);
    s[i][strlen(s[i])-2]=0;
  }
  for(i=0;i<n;i++){
    d[i]=i+1;
    if(s[i][4]==' '){
      for(j=0;strcmp(s[i]+5,s[j]);j++);
      d[i]=j;
    }
  }
  //for(i=0;i<n;i++)printf("%s %d\n",s[i],d[i]);
  for(i=0;i<110;i++)c[i]=1e9;
  c[mi=0]=0;
  for(i=0;i<n;i++){//printf("%d %d\n",mi,c[mi]);
    f[mi]=1;
    if(c[d[mi]]>c[mi])c[d[mi]]=c[mi];
    if(c[mi+1]>c[mi])c[mi+1]=c[mi]+1;
    for(j=0;j<n;j++){
      if(f[j]==0&&(f[mi]||c[mi]>c[j]))mi=j;
    }
  }
  printf("%d\n",c[n]);
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mypair;
int main(){
int n;
cin>>n;
cout<<"AB";
if(n>=1000)cout<<'D';
else cout<<'C';
cout<<endl;


return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class project
{
    static void Main()
    {
        int num = int.Parse(Console.ReadLine());

        var result = new Dictionary<string, long>();

        for (long i = 1; i < num + 1; i++)
        {
            char[] input = Console.ReadLine().ToCharArray();
            Array.Sort(input);
            string sortedInput = string.Join("", input);

            if (!result.ContainsKey(sortedInput))
            {
                result.Add(sortedInput, 1);
            }
            else
            {
                result[sortedInput]++;
            }
        }

        long count = 0;
        foreach (long val in result.Values)
        {
            if (val != 0)
            {
                count += val * (val - 1) / 2;
            }
        }
        Console.WriteLine(count);
    }

}

Measured memory_bytes: 30396
#include<iostream>
#include <algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

int main() {
  ll N;
  int K;
  cin >> N >> K;

  int ans = 1;
  ll k = K;
  while(k<=N) {
    k *= K;
    ans++;
  }

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


Measured memory_bytes: 256
import sys
import math 
import bisect

n,m,k=map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))



a=[0]
b=[0]
ans=0
for i in range(n):
    a.append(A[i]+a[i])
for i in range(m):
    b.append(B[i]+b[i])

for i in range(n+1):
    tmp = k - a[i]
    if tmp < 0:
        break
    else:
        j=bisect.bisect_right(b,tmp)
        ans= max(ans,i+j-1)
print(ans)

    

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

#define sc second
#define fr first

#define ll long long
#define pi pair<int,int>
#define ppi pair<pi,pi>
#define mp make_pair
using namespace std;


int main()
{

	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);


	int a, b; cin >> a >> b;
	
	if (a == b)
		cout << a + b;
	else
		cout << max(a, b) * 2 - 1;


	return 0;
}


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

int n;
std::vector<int> v;


int main() {
    std::cin >> n;
    v.assign(n, 0);
    std::vector<int> resv;
    for (int i = 0; i < n; i++) {
        std::cin >> v[i];
    }
    for (int p = 1; p <= 100; p++) {
        int res = 0;
        for (int x = 0; x < v.size(); x++) {
            res += std::pow((v[x] - p), 2);
        }
        resv.push_back(res);
    }
    std::cout << *std::min_element(resv.begin(), resv.end()) << std::endl;
}



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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(2000005);

int main() {
    ll X, Y;
    cin >> X >> Y;
    ll mx3 = 2 * X - Y;
    if (mx3 < 0 || mx3 % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    ll m = mx3 / 3;

    ll nx3 = 2 * Y - X;
    if (nx3 < 0 || nx3 % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    ll n = nx3 / 3;

    cout << c(m + n, m) << endl;
    return 0;
}


Measured memory_bytes: 34212
{-Prelude> let delete x xs = filter (/= x) xs
Prelude> delete 3 [1..9]
[1,2,4,5,6,7,8,9]
-}
import Data.List

main :: IO ()
main = do
    n <- getLine
    as <- map read . words <$> getLine
    putStrLn $ show(tensa as)

tensa :: [Int] -> Int
tensa xs =  if xs == [] then 0
            else maximum xs - tensa ( delete (maximum xs) xs)

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, mn, mx, mn_count, mx_count;
  mn_count = mx_count = 0;
  mx = -1;
  mn = 2000 * 1000 * 1000;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (a > mx) {
      mx = a;
      mx_count = 0;
    }
    if (a < mn) {
      mn = a;
      mn_count = 0;
    }
    if (a == mn)
      mn_count++;
    if (a == mx)
      mx_count++;
  }
  //cerr << mx << ' ' << mn << endl;
  if (mx - mn > 1) {
    cout << "No";
    return 0;
  }
  if (mx - mn == 1) {
    if (mx <= mn_count || mx > mn_count + mx_count / 2) {
      cout << "No";
      return 0;
    }
  }
  if (mn == mx) {
    if (mx > n / 2 && mx != n - 1) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}

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

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

  int n;
  cin>>n;

  string s;
  cin>>s;
  int cntr[n],cntg[n],cntb[n];
  memset(cntr,0,sizeof(cntr));
  memset(cntb,0,sizeof(cntb));
  memset(cntg,0,sizeof(cntg));
  
  for(int i=0;i<n;i++){
    if(s[i]=='R'){
      cntr[i]++;
    }
    else if(s[i]=='G'){
      cntg[i]++;
    }
    else if(s[i]=='B'){
      cntb[i]++;
    }
    if(i>0){
      cntr[i]+=cntr[i-1];
      cntb[i]+=cntb[i-1];
      cntg[i]+=cntg[i-1];
    }
  }


  long long ans=0;

  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
       
       if((s[i]=='R'&& s[j]=='G')|| (s[i]=='G'&& s[j]=='R')){
           ans+=cntb[n-1]-cntb[j-1];
           
           if(j+j-i<n && s[j+j-i]=='B')ans--;
       }
       else if((s[i]=='R'&& s[j]=='B')|| (s[i]=='B'&& s[j]=='R')){
           ans+=cntg[n-1]-cntg[j-1];
           
           if(j+j-i<n && s[j+j-i]=='G')ans--;
       }
        else if((s[i]=='G'&& s[j]=='B')|| (s[i]=='B'&& s[j]=='G')){
           ans+=cntr[n-1]-cntr[j-1];
           
           if(j+j-i<n && s[j+j-i]=='R')ans--; 
       }
     }
  }

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

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,W,sum=0;
  cin >> n >> W;
  long long w[n],v[n];
  for(int i=0;i<n;i++){
    cin >> w[i] >> v[i];
    sum+=v[i];
  }
  long long dp[n+5][sum+5];
  for(int i=0;i<n+5;i++){
    for(int j=0;j<sum+5;j++){
      dp[i][j]=((j==0)?0:1e15);
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<=sum;j++){
      dp[i+1][j+v[i]]=min(dp[i+1][j+v[i]], dp[i][j]+w[i]);
      dp[i+1][j]=min(dp[i+1][j], dp[i][j]);
    }
  }
  for(int i=sum;i>=0;i--){
    if(dp[n][i]<=W){
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 82304
import java.util.Scanner;


public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		boolean[][] deck = new boolean[4][];
		String sootS[] = {"S", "H", "C", "D"};
		for (int i = 0; i < 4; i++) {
			deck[i] = new boolean[13];
		}
		for (int i = 0; i < n; i++) {
			String soot = scan.next();
			int rank = scan.nextInt();
			deck[sootNumber(soot)][rank - 1] = true;
		}
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 13; j++) {
				if (deck[i][j] == false) {
					System.out.println(sootS[i] + " " + (j + 1));
				}
			}
		}
	}
	int sootNumber(String soot) {
		if (soot.equals("S")) {
			return 0;
		} else if (soot.equals("H")) {
			return 1;
		} else if (soot.equals("C")) {
			return 2;
		} else if (soot.equals("D")) {
			return 3;
		} else {
			return -1;
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 26260
#include <iostream>
#include <algorithm>
long n,a[200005],m;
long long ans=0;
int main(){
	using namespace std;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i],a[i]-=i;
	sort(a,a+n);
	m=a[n/2];
	for(int i=0;i<n;i++)
		ans+=abs(a[i]-m);
	cout<<ans<<endl;
}

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

typedef complex<double> Point;

double cross(Point a, Point b){
//    return (conj(a)*b).imag();
    return a.real() * b.imag() - a.imag() * b.real();
}

int main(){
    Point V[3], P;
    while(true){
        for(int i=0; i<3; i++){
            double x, y;
            if(!(cin >> x >> y))
                return 0;
            V[i] = {x, y};
        }
        double x, y; cin >> x >> y;
        P = {x, y};
        
        int sum1 = 0, sum2 = 0;
        for(int i=0; i<3; i++){
            double x = cross(V[(i+1)%3]-V[i], (P-V[i]));
            sum1 += x<0;
            sum2 += x>0;
        }
        cout << (sum1==3 || sum2==3? "YES": "NO") << endl;
    }
    return 0;
}



Measured memory_bytes: 3204
#include <iostream>

using namespace std;

#define MOD 1000000007
long long C[2005][2005] = {};

void ncr() {
	for (int i = 0; i <= 2000; ++i) C[i][0] = C[i][i] = 1, C[i][1] = i;
	for (int i = 1; i <= 2000; ++i) {
		for (int j = 2; j < i; ++j) {
			C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
		}
	}
}

int main() {
	ncr();
	int n, k; cin >> n >> k;
	for (int i = 1; i <= k; ++i)
		cout << (C[n - k + 1][i] * C[k - 1][i - 1]) % MOD << endl;

	return 0;
}

Measured memory_bytes: 30208
#include <iostream>
#include <cstring>
#include <cstdio>
#define MAXN 303
using namespace std;

int N;								//number of dishes 
//int a[4];							//number of dishes with i pieces of sushi in it
bool vis[MAXN][MAXN][MAXN];			//visited
long double dp[MAXN][MAXN][MAXN];		//expected number of steps to finish dp[i][j][k]

long double solve(int n1,int n2,int n3){
	
	if(vis[n1][n2][n3])
		return dp[n1][n2][n3];
	
	vis[n1][n2][n3]=true;
	
	if(n1==0&&n2==0&&n3==0)
		return dp[n1][n2][n3]=0;

	long double occ = (long double)n1+n2+n3;
	long double exp = (N-occ)/occ;
	
	if(n1>0)	exp += n1*(1+solve(n1-1,n2,n3))/occ;
	if(n2>0)	exp += n2*(1+solve(n1+1,n2-1,n3))/occ;
	if(n3>0) 	exp += n3*(1+solve(n1,n2+1,n3-1))/occ;

	return dp[n1][n2][n3] = exp;

}

int main(){
 	int a[]={0,0,0,0};
	cin>>N;
	int currPiece;
	for(int i=0;i<N;i++){
		cin>>currPiece;
		a[currPiece]++;
	}
	printf("%.10llf",solve(a[1],a[2],a[3]));
}


Measured memory_bytes: 228652
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> c(h);
    for (int i = 0; i < h; ++i) {
        cin >> c[i];
    }
    vector<vvi> cost(w - 1, vvi(h + 1, vi(h + 1, 0)));
    for (int i = 0; i < w - 1; ++i) {
        for (int j = h - 1; j >= 0; --j) {
            for (int k = h - 1; k >= 0; --k) {
                cost[i][j][k] = cost[i][j + 1][k + 1] + (c[h - 1 - j][i] == c[h - 1 - k][i + 1] ? 1 : 0);
            }
        }
    }
    ll ret = 0;
    for (int i = 0; i < w - 1; ++i) {
        vvi dp(h + 1, vi(h + 1, 1 << 29));
        dp[0][0] = 0;
        for (int j = 0; j <= h; ++j) {
            for (int k = 0; k <= h; ++k) {
                if (j != 0)
                    chmin(dp[j][k], dp[j - 1][k] + cost[i][j - 1][k]);
                if (k != 0)
                    chmin(dp[j][k], dp[j][k - 1] + cost[i][j][k - 1]);
            }
        }
        ret += dp[h][h];
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 109824
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define int long long int
using namespace std;
#define pii pair <int, int>
#define mii map<int, int>
#define pb push_back
#define deb(x) cout << #x << " " << x << endl
#define deb2(x, y) cout << #x << " " << x << " " << #y << " " << y << endl
#define Loop(s, e, itr) for (int itr = s; itr < e; itr++)
#define loop(n) for(int i = 0; i < n; i++)
#define vin vector<int>
#define w(t) int tc; cin >> tc; for(int t = 1; t <= tc; t++)
#define vec vector
#define mod 1000000007
#define all(x) x.begin(), x.end()


int n;
int arr[405];
int length[405][405];

int dp[405][405];

int get(int i, int j, int tab){
    if(i == j) return 0;
    if(dp[i][j] == -1){
        int ans = INT64_MAX;
        for(int k = i; k < j; k++){
            // loop(tab) printf("    "); cout << i << k << " " << k+1 << j << endl;
            int temp = 0;
            temp += (int)length[i][k];
            temp += (int)length[k+1][j];
            temp += (int)get(i, k, tab+1);
            temp += (int)get(k+1, j, tab+1);
            ans = min(ans, temp);   
        }
        dp[i][j] = ans;
    }
    return dp[i][j];
}



int32_t main(){
    cin >> n;
    loop(n) cin >> arr[i];
    memset(dp, -1, sizeof(dp));
    loop(n) 
        length[i][i] = arr[i];
    
    loop(n)
        for(int j = i+1; j < n; j++) 
            length[i][j] = length[i][j-1] + arr[j];

    int ans = get(0, n-1, 0);
    cout << ans << endl;
}

Measured memory_bytes: 6132
#include<iostream>
#include<vector>
#include<string.h>
using namespace std;
int main(){
    vector<vector<int> >bo(5);
    int n;
    while(cin>>n,n){
        for(int i=0;i<5;i++)
            bo[i].clear();
        for(int i=0;i<n;i++){
            for(int j=0;j<5;j++){
                int t;
                cin>>t;
                bo[j].push_back(t);
            }
        }
        int tot=0;
        while(1){
            vector<pair<pair<int,int>,int> >vec;
            int so=0;
            for(int i=0;i<3;i++){
                for(int j=0;j<bo[i].size();j++){
                    if(j<bo[i+1].size()&&j<bo[i+2].size()){
                        if(bo[i][bo[i].size()-1-j]==bo[i+1][bo[i+1].size()-1-j]&&bo[i+1][bo[i+1].size()-1-j]==bo[i+2][bo[i+2].size()-1-j]){
                            so=1;
                            int x=bo[i][bo[i].size()-1-j];
                            int k;
                            for(k=i;k<5;k++){
                                if(bo[k][bo[k].size()-1-j]==x){
                                    tot+=x;
                                    bo[k][bo[k].size()-1-j]=100+k;
                                }
                                else {
                                    break;
                                }
                            }
                            vec.push_back(make_pair(make_pair(i, k),j));
                        }
                    }
                        
                }
            }
            for(int i=0;i<5;i++){
                for(int j=0;j<bo[i].size();j++){
                    if(bo[i][j]>30){
                        bo[i].erase(bo[i].begin()+j, bo[i].begin()+j+1);
                        j--;
                    }
                }
            }
            
            vec.clear();
            
            if(so==0)break;
        }
        
        cout<<tot<<endl;
    }
}

Measured memory_bytes: 1216
#include <iostream>
 
int main()
{
    int h, w;
    while (true)
    {
        std::cin >> h >> w;
        if (h == 0 && w == 0)break;
        for (int i = 0; i < h; ++i)
        {
            for (int j = 0; j < w; ++j)
            {
                if ((i+j)%2==0)
                    std::cout << "#";
                else
                    std::cout << ".";
            }
            std::cout << std::endl;
        }
        std::cout << std::endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include<cstring>
#include <algorithm>
#include <cmath>
typedef  long long LL;
using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;

    a=a-c;


    cout<<a/(b+c)<<endl;
    return 0;
}


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

using namespace std;

int main(){
    int N, K; cin >> N >> K;
    vector<int> h(N);
    for(int i=0; i<N; ++i) cin >> h[i];
    int res = 0;

    sort(h.begin(), h.end(), greater<int>());

    for(int i=0; i<N; ++i){
        if(h[i]<K) break;
        else res++;
    }

    cout << res << endl;
    return 0;
}

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

using namespace std;

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


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()


int main(){
    int A,B;
    cin>>A>>B;
    int C;
    if(A==1){
        if(B==2)C=3;
        else C=2;
    }else if(A==2){
        if(B==1)C=3;
        else C=1;
    }else if(A==3){
        if(B==2)C=1;
        else C=2;
    }

    cout<<C<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
use proconio::{fastout, input};

use proconio::marker::Chars;

#[fastout]
fn main() {
    input! {
        n: usize,
        s: Chars,
    }
    let mut ans = 0;
    for a in 0..=9 {
        let mut i = 0;
        while i < n && s[i].to_digit(10) != Some(a) {
            i += 1;
        }
        if i == n {
            continue;
        }
        for b in 0..=9 {
            let mut j = i + 1;
            while j < n && s[j].to_digit(10) != Some(b) {
                j += 1;
            }
            if j == n {
                continue;
            }
            for c in 0..=9 {
                let mut k = j + 1;
                while k < n && s[k].to_digit(10) != Some(c) {
                    k += 1;
                }
                if k == n {
                    continue;
                }
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2284
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> vec;
	while(n!=0){
		int r = n % 10;
		if(r == 1){
			vec.push_back(9);
		}
		else if(r == 9){
			vec.push_back(1);
		}
		else{
			vec.push_back(r);
		}
		n /= 10;
	}
	string s = "";
	for(int i = 0; i < vec.size(); ++i){
		s += vec[i] + '0';
	}
	reverse(s.begin(), s.end());
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
S = list(input())
T = input()
s_tmp = S.copy()
if ''.join(S) == T:
  print('Yes')
else:
  while True:
    s_reversed = s_tmp[:-1]
    s_reversed.insert(0, s_tmp[-1])
    if ''.join(s_tmp) == T:
      print('Yes')
      break
    elif S == s_reversed:
      print('No')
      break
    s_tmp = s_reversed


Measured memory_bytes: 2940
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = Tuple{Int,Int}[(0,0) for i in 1:n]
	for i in 1:n
		x,l = readline() |> split |> parseMap
		a[i] = (x-l,x+l)
	end
	a = sort(a,by=x->x[2])
	r = -10^18
	k = 0
	for i in 1:n
		if r<=a[i][1]
			k += 1
			r = a[i][2]
		end
	end
	println(k)
end
main()

Measured memory_bytes: 212696
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String [] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String temp[] = br.readLine().split(" ");
        
        long n = Long.parseLong(temp[0]);
        int count = 0;
        int ans = 0;
        if(n==1){System.out.println(0); return;}
        Set<Integer> set = new HashSet<>();
        while (n%2==0) 
        { 
            n /= 2; 
            if(!set.contains(count)){ ans+=1; set.add(count); count = 0;}
            else count+=1;
        } 
  
       
        
        for (int i = 3; i <= Math.sqrt(n); i+= 2) 
        {
            set = new HashSet<>();
            count = 0;
            while (n%i == 0) 
            { 
               
                n /= i; 
                if(!set.contains(count)){ ans+=1; set.add(count); count = 0;}
                else count+=1;
            } 

        }
         if(n>2) ans+=1;
        

        System.out.println(ans);
       

    }
}


Measured memory_bytes: 48732
#088B
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
#print(a)

player_a=[]
player_b=[]

for i in range(len(a)):
	if(i==0 or i%2==0):
		player_a.append(a[i])
	else:
		player_b.append(a[i])

sum_a=sum(player_a)
sum_b=sum(player_b)

ans=sum_a-sum_b

print(ans)

Measured memory_bytes: 3064
#undef NDEBUG
#include <bits/stdc++.h>

using namespace std;

#define all(v) (v).begin(), (v).end()

using li = long long;
using ld = long double;

void solve(bool);

int main() {
#ifdef YA
    auto s = clock();
    assert(freopen("input.txt", "r", stdin));
    // assert(freopen("output.txt", "w", stdout));
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif

    cout << fixed << setprecision(20);

    solve(true);

#ifdef YA1
    while (true) solve(false);
#endif

#ifdef YA
    cout << endl << endl << "time = " << (clock() - s) / (double)CLOCKS_PER_SEC << endl;
#endif

    return 0;
}

#define int li

int ans, n, x[55], y[55], t[55];

void check(int dx, int dy) {
    if (dx == 0 && dy == 0)
        return;
    memset(t, 0, sizeof t);
    int res = 0;
    for (int ti = 0; ti < n; ++ti) {
        if (t[ti])
            continue;
        t[ti] = 1;
        ++res;
        vector <int> q;
        q.push_back(ti);
        while (q.size()) {
            int i = q.back();
            q.pop_back();
            for (int j = 0; j < n; ++j) {
                if ((x[j] == x[i] + dx && y[j] == y[i] + dy) ||
                    (x[j] == x[i] - dx && y[j] == y[i] - dy)) {
                    if (!t[j])
                        q.push_back(j);
                    t[j] = 1;
                }
            }
        }
    }
    ans = min(res, ans);
}

void solve(bool __attribute__((unused)) read) {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
    }
    ans = n;   
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            check(x[i] - x[j], y[i] - y[j]);
        }
    }
    cout << ans << "\n";
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    cout << A[N-1] - A[0] << endl;
}


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

int main(){
int N;
  int sum=0;
  
  cin>>N;
  int tmp=N;//Nは複数の場所で操作をするため数値が重ならないようにTMPを用意する
  while(tmp>0){
  sum+=tmp%10; //１の位が順々に足されていく。
    tmp/=10; //上の式で１の位を足した分、１０で割る事で１の位を繰り下げていく
  }//以上のアルゴリズムがN=0になるまで続く
  if(N%sum==0){//NがSUMで割り切れるなら実行
  cout<<"Yes"<<endl;
  }
  else{
  cout<<"No"<<endl;
  }
}

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

using namespace std;

int main()
{
    string s,t;

    cin>>s;

    for(int i=0; i<s.size(); i++)
    {
        if(s[i]!='B')
        {
            t+=s[i];
        }

        else if(t.size()!=0)
        {
            t.erase(--t.end());
        }
    }

    cout<<t<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int maxn = 1 << 20;
constexpr int mod = 1e9 + 7;
int A[maxn], B[maxn], DP[maxn], S0[maxn], L[maxn], SS[maxn], SSS[maxn];
vector<int> v;
void add(int &x, int y){
	x += y;
	if(x >= mod) x -= mod;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int N, ans = 0;
	cin >> N;
	DP[0] = 1;
	for(int i = 1; i <= N; i += 1){
		cin >> A[i];
		B[i] = B[i - 1] ^ A[i];
		S0[i] = S0[i - 1] + (B[i] == 0);
	}
	for(int i = 1; i <= N; i += 1){
		if(B[i]){
			SSS[B[i]] = (SSS[B[i]] + 1LL* SS[B[i]] * (S0[i] - S0[L[B[i]]]) % mod) % mod;
			DP[i] = SSS[B[i]] + 1;
			SS[B[i]] = (SS[B[i]] + DP[i]) % mod;
		}
		else{
			if(L[B[i]]) DP[i] = DP[L[B[i]]] * 2 % mod;
			else DP[i] = 1;
		}
		L[B[i]] = i;
	}
	//for(int i = 1; i <= N; i += 1) cout << setw(3) << B[i] << " ";
	//cout << endl;
	//for(int i = 1; i <= N; i += 1) cout << setw(3) << DP[i] << " ";
	//cout << endl;
	ans = DP[N];
	if(B[N] == 0) for(int i = 1; i <= N; i += 1) if(B[i]) add(ans, DP[i]);
	cout << ans;
}

Measured memory_bytes: 20736
// #pragma GCC target("avx")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

// int dp[3010][3010][4] = {};

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

int main() {
    // cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    int R, C, K; cin >> R >> C >> K;

    // map<pair<int, int>, int> mp;
    vector<vector<int>> mp(R, vector<int>(C, 0));
    REP(i, 0, K) {
        int r, c, v; cin >> r >> c >> v;
        mp[--r][--c] = v;
        // mp[{--r, --c}] = v;
    }

    vector<vector<vector<ll>>> dp(R + 1, vector<vector<ll>>(C + 1, vector<ll>(5, -(1LL << 60))));
    if (mp[0][0]) dp[0][0][1] = mp[0][0];
    dp[0][0][0] = 0;

    REP(i, 0, R) {
        REP(j, 0, C) {
            REP(k, 0, 4) {
                if (dp[i][j][k] > -(1LL << 60)) {
                    // cout << "# r : " << i << ", c : " << j << ", k : " << k << ", v : " << dp[i][j][k] << endl;
                    REP(l, 0, 2) {
                        int nr = i + dx[l];
                        int nc = j + dy[l];
                        if (nr < 0 || nr >= R || nc < 0 || nc >= C) continue;
                        // int plus = mp.count({nr, nc});
                        int plus = mp[nr][nc] > 0;
                        int nk = ((dx[l]) ? plus : k + plus);
                        dp[nr][nc][nk] = max(dp[nr][nc][nk], dp[i][j][k] + mp[nr][nc]);

                        dp[nr][nc][k] = max(dp[nr][nc][k], dp[i][j][k]);
                    }
                }
            }
        }
    }
    ll ans = 0;
    REP(i, 0, 4) ans = max(ans, dp[R - 1][C - 1][i]);
    cout << ans << endl; 
    return 0;
}

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

template<class T>
T lcm(T a,T b){
    return a/__gcd(a,b)*b;
}

int main(){
    long n,k;cin >> n >> k;
    map<long,long> a;
    for(int i=0;i<n;i++){
        long x,y;
        cin >> x >> y;
        a[x]+=y;
    }
    long q=0;
    for(auto i:a){
        q+=i.second;
        if(k<=q){
            cout << i.first;
            return 0; 
        }
    }
    return 0;
}

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

int main(){
    int N;
    int64_t M, K;
    cin >> N >> M >> K;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    int64_t S = accumulate(A.begin(), A.end(), 0LL);
    int64_t need = S-M;
    if(need <= 0){
        cout << 0 << endl;
        return 0;
    }

    vector<int64_t> num(M+1);
    for(int a : A){
        if(need > a){
            need -= a;
            num[a]++;
        }else{
            num[a]++;
            num[a-need]--;
            break;
        }
    }
    for(int i=M; i>0; i--) num[i-1] += num[i];
    int64_t ans = 0;
    for(int i=M; i>0; i--){
        int64_t dec = min(num[i], K);
        K -= dec;
        num[i] -= dec;
        ans += num[i]*i;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 10900
// {Ai}に奇数が含まれていない場合、答えはP=1で0, P=0でpow(2,N);
// {Ai}に奇数が含まれている場合、ある奇数Ak (1 <= k <= N)について、
// Ak以外の(N-1)個を選んだ和がSのとき、
// Sが奇数なら、Akを選ぶことで偶数、選ばなければ奇数にできる
// Sが偶数なら、Akを選ぶことで奇数、選ばなければ偶数にできる
// よって、Sの偶奇に問わず、Akによって最終的な和を奇数/偶数にできることがわかる。
// よって、{Ai}に奇数が含まれている場合、Pに問わず答えはpow(2,N-1)となる。
#include <bits/stdc++.h>
using namespace std;

long long Pow(long long a, long long x) {
    long long res = 1LL;
    while(x>0LL) {
        if(x&1) res *= a;
        a *= a, x >>= 1;
    }
    return res;
}

int main() {
    long long N, P;
    cin >> N >> P;
    bool OddisContain = false;
    for(int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        if((A&1)^0) OddisContain = true;
    }
    if(OddisContain)
    {
        cout << Pow(2,N-1) << endl;
    }
    else
    {
        cout << ((P==1) ? 0 : Pow(2,N)) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
$_ = <>;
$_ = <>;
chmop;
@a = split(" ");

$ans = 1;

$commax_left[0] = $a[0];
for($i = 1; $i <= $#a -1; $i++){
  $commax_left[$i] = commax($commax_left[$i -1], $a[$i]);
}
$commax_right[$#a] = $a[$#a];
for($i = $#a -1; $i >= 1; $i--){
  $commax_right[$i] = commax($commax_right[$i +1], $a[$i]);
}

if($#a >= 2){
  $ans = max($commax_left[$#a -1], $commax_right[1]);
  for($i = 1; $i <= $#a -1; $i++){
    $ans = max($ans, commax($commax_left[$i -1], $commax_right[$i +1]));
  }
}else{
  $ans = max($a[0], $a[1]);
}

print "$ans\n";

sub max(){
  my($a) = $_[0];
  my($b) = $_[1];
  if($a > $b){
    $a;
  }else{
    $b;
  }
}

sub min(){
  my($a) = $_[0];
  my($b) = $_[1];
  if($a > $b){
    $b;
  }else{
    $a;
  }
}

sub commax(){
  my($x) = $_[0];
  my($y) = $_[1];

  # print "commax $x $y\n";
  while(){
    $x = $x % $y;
    if($x == 0){
      return $y;
    }
    $z = $x;
    $x = $y;
    $y = $z;
  }
}


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

int main(){
  int r,g,b,n;
  int count = 0;
  cin >> r >> g >> b >> n;
  
  for(int i=0; i<n+1; i++){
    for(int j=0; j<n+1-i; j++){
      if((n-i*r-j*g) % b == 0){
        if(n-i*r-j*g >= 0){
          count++;
        }
      }
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
a,b,c = map(int,input().split())
s = a+b+c
m = max(a,b,c)
if s%2 == 0 and (m*3)%2 == 0:
  print(((m*3)-s)//2)
elif s%2 != 0 and (m*3)%2 != 0:
  print(((m*3)-s)//2)
else:
  print(((m+1)*3-s)//2)

Measured memory_bytes: 9192
H, W = map(int, input().split())
data = [list(map(str, input())) for _ in range(H)]


def g(m):
    if data[0][0] == '.':
        a = 0
    else:
        a = 1

    for i in range(1, m, 1):
        if data[0][i] == '.':
            continue
        elif data[0][i] == '#' and data[0][i - 1] == '.':
            a += 1
        else:
            continue
    return a


def h(n):
    if data[0][0] == '.':
        a = 0
    else:
        a = 1

    for i in range(1, n, 1):
        if data[i][0] == '.':
            continue
        elif data[i][0] == '#' and data[i - 1][0] == '.':
            a += 1
        else:
            continue
    return a

A = [0] + [g(i) for i in range(1,W+1)]
B = [0] + [h(i) for i in range(1,H+1)]
C = [[0]*(W+1) for i in range(H+1)]

for n in range(1,H+1):
    for m in range(1,W+1):
        if n == 1:
            C[n][m] = A[m]
        elif m == 1:
            C[n][m] = B[n]
        else:
            if data[n - 1][m - 1] == '.':
                C[n][m] = min(C[n - 1][m], C[n][m - 1])
            elif data[n - 2][m - 1] == '.':
                if data[n - 1][m - 2] == '.':
                    C[n][m] = min(C[n - 1][m] + 1, C[n][m - 1] + 1)
                else:
                    C[n][m] =  min(C[n - 1][m] + 1, C[n][m - 1])
            else:
                if data[n - 1][m - 2] == '.':
                    C[n][m] = min(C[n - 1][m], C[n][m - 1] + 1)
                else:
                    C[n][m] = min(C[n - 1][m], C[n][m - 1])


print(C[H][W])

Measured memory_bytes: 43632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin>>n;
  long long sum = 0;
  for(int i = 1 ; i <= n ; i++){
    for(int j = 1 ; j <= n ; j++){
      for(int k = 1 ; k <= n ; k++){
        sum += __gcd(__gcd(i,j),k);
      }
    }
  }
  cout<<sum;
}


Measured memory_bytes: 3604
a=list(map(int,input().split(" ")))
rr=a[0]
rg=a[1]
rb=a[2]
N=a[3]
count=0
for nr in range(0,N//rr+1):
    for ng in range(0,N//rg+1):
        tb=N-rr*nr-rg*ng
        if tb>=0 and tb%rb==0:
            count+=1
print(count)


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

int main() {
  int n, k;
  cin>>n>>k;
  int a[n];
  for (int i=0; i<n; i++) cin>>a[i];
  vector<long long> b;
  vector<int> idx;
  int cnt = 0;
  for (int i=0; i<n; i++) {
    long long tmp = 0;
    for (int j=i; j<n; j++) {
      tmp += a[j];
      b.push_back(tmp);
      idx.push_back(cnt);
      ++cnt;
    }
  }

  long long ans = 0;
  for (int i=63; i>=0; i--) {
    if (idx.size() < k) {
      break;
    }
    vector<int> new_idx;
    for (int j: idx) {
      long long bj = b[j];
      if ((bj >> i) & 1) {
        new_idx.push_back(j);
      }
    }
    if (new_idx.size() >= k) {
      ans += pow(2, i);
      idx = new_idx;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 8432
let n = Scanf.scanf " %d" (+) 0
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let c, p, m, i = ref 0, ref a_s.(0), ref 0, ref 0
let f d = Printf.printf "%d\n" d; exit 0
let g i a = if i = 1 then f @@ !m * a else m := a
let _ = Array.(sort (fun x y -> y - x) a_s; iter (fun a -> if a = !p then (incr c; if !i = 0 && !c >= 4 then f @@ a * a) else (if !c >= 2 then (g !i !p; incr i); c := 1; p := a)) a_s); if !c >= 2 then g !i !p; f 0

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REP2(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
typedef long long ll;

int main() {
    int n, k, q; cin >> n >> k >> q;
    ll d = k - q;
    vector<int> vec(n + 1);

    REP2(i, 1, n){
        vec[i] = d;
    }
    rep(i, q){
        int a; cin >> a;
        vec[a] += 1;
    }
    REP2(i, 1, n){
        if(vec[i] > 0){
            OP("Yes");
        }else{
            OP("No");
        }
    }
}


Measured memory_bytes: 1024
#include <stdio.h>

/** Application main entry point. */
int main (
  int argc,
  char *argv[ ]
  )
{
  int n;

  scanf ( "%d", &n );

  while ( n )
  {
    int pa = 0, pb = 0;

    while ( n-- )
    {
      int a, b;

      scanf ( " %d %d", &a, &b );

      if ( a > b )
      {
        pa += a + b;
      }
      else if ( b > a )
      {
        pb += a + b;
      }
      else
      {
        pa += a;
        pb += b;
      }
    }
    printf ( "%d %d\n", pa, pb );

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

  return ( 0 );
}

Measured memory_bytes: 0
n,m=[int(i) for i in input().split()]
ab = []
for i in range(n):
  ab.append([int(j) for j in input().split()])
ab.sort()

cost = 0
for i in range(n):
  if m == 0:
    break
  buy_num = min(m,ab[i][1])
  m -= buy_num
  cost += buy_num * ab[i][0]
print(cost)

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

int main(){
  string S;
  cin >> S;
  string R = "None";
  map<char, int> map;
  for(int i = 0; i < S.size(); i++){
    char c = S.at(i);
    if(!map.count(c)){
    	map[c] = 1;
    }
    else{
    	map.at(c)++;
    }
  }
  bool f = false;
  for(char i = 'a'; i <= 'z'; i++){
    if(!map.count(i)){
    	cout << i << endl;
      	f = true;
      	break;
    }
  }
  if(!f) cout << "None" << endl; 
}


Measured memory_bytes: 512
#include<stdio.h>

int main(void){
  int a,b,x,j,i=0,count;
  scanf("%d",&x);
  scanf("%d",&a);
  scanf("%d",&b);
  j=x-a;
  while(1){
          j=j-b;
          if(j<b)
            break;
  }
  printf("%d\n",j);
  return 0;
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;
import java.lang.*;

public class Main
{
	public static void main(String args[]) throws java.lang.Exception,FileNotFoundException
	{
		Scanner sc = new Scanner(System.in);

		// PrintStream obj = new PrintStream(new File("Output.txt"));
		// System.setOut(obj);

		int N,K;

		N = sc.nextInt();
		K = sc.nextInt();

		int P[] = new int[N];

		for(int i = 0;i<N;i++)
		{
			P[i] = sc.nextInt();
		}

		Arrays.sort(P);

		int price = 0;

		for(int i = 0;i<K;i++)
		{
			price = price + P[i];
		}

		System.out.print(price);

		sc.close();
		System.out.flush();
	}
}

Measured memory_bytes: 30308
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 130000, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = ((tmp & ma0) ^ ma0) ? 68 - __builtin_ctzll((tmp & ma0) ^ ma0) : 0;
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (64 - dig >> 3);
	while ((ct = *ci++) >= '0') tmp = tmp * 10 + ct - '0';
	return tmp;
}

int H[100001];
bool NG[100001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint(), M = getint();
	rep1(i, N) H[i] = getint();
	rep(i, M) {
		int a = getint(), b = getint();
		if (H[a] >= H[b]) NG[b] = 1;
		if (H[a] <= H[b]) NG[a] = 1;
	}
	int kotae = N;
	rep1(i, N) kotae -= NG[i];

	printf("%d", kotae);

	Would you please return 0;
}

Measured memory_bytes: 2192
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let S: String = sc.get();
    println!("{}", &S[..3]);
}


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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) for(int i = 0 ; i < n ; ++i)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int n;
vector<int> a;

bool add(map<int, lint> &mp, lint mid, int d){
    if(mp[d] < mid - 1){
        ++mp[d];
        return true;
    }
    auto it1 = mp.end();
    --it1;
    while(it1 != mp.begin()){
        auto it2 = it1--;
        if((*it1).first + 1 < (*it2).first){
            if((*it2).second < mid - 1){
                ++mp[(*it2).first];
            }else{
                ++mp[(*it2).first - 1];
                mp.erase(it2);
            }
            return true;
        }else if((*it2).second < mid - 1){
            ++mp[(*it2).first];
            return true;
        }else{
            mp.erase(it2);
        }
    }
    if((*mp.begin()).second < mid - 1){
        ++(*mp.begin()).second;
        return true;
    }
    return false;
}

bool check(lint mid){
    map<int, lint> mp;
    mp[0] = 0;
    REP(i, 1, n){
        if(a[i - 1] >= a[i]){
            mp.erase(mp.upper_bound(a[i]), mp.end());
            if(mid <= 1 || !add(mp, mid, a[i])){
                return false;
            }
        }
    }
    return true;
}

lint meguruSearch(lint ok, lint ng){
    while(abs(ok - ng) > 1){
        lint mid = (ok + ng) / 2;
        if(check(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    return ok;
}

int main(){
    cin >> n;
    a.resize(n);
    rep(i, n){
        cin >> a[i];
        --a[i];
    }
    lint ans = meguruSearch(1e15, 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
while n=gets
	n=n.to_i
	count=0
	
	a=0
	
	
	if n<0 || n>36
		puts "0"
		next
	elsif n== nil 
		break
	end



	while a < 10
	b=0
		while b < 10
	c=0
			while c < 10
	d=0
				while d < 10
					if a+b+c+d == n
						count += 1
#						puts "#{a} #{b} #{c} #{d} #{count}"
					end
					d+=1
				end
				c+=1
			end
			b+=1
		end
		a+=1
	end
	puts count
end

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

int main(){
  int n, l;
  cin >> n >> l;
  
  int sum = n*(2*l+n-1)/2;
  
  if(l*(l+n-1) <= 0) {
  	cout << sum << endl;
  }
  
  else if(l > 0) {
  	cout << sum - l << endl;
  }
  
  else{
  	cout << sum - l-n+1 << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
//#include <algorithm>
#include <vector>

using namespace std;

int main(){
    int X, Y, Z;
    cin >> X >> Y >> Z;

    int nokori = X - 2*Z;

    int a = nokori/(Y+Z);
    int mod = nokori%(Y+Z);

    if(mod >= Y){
        a++;
    }

    cout << a << endl;

    return 0;
}


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


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

//#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

#define mod 1000000007

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}

int h, w;
char a[50][50];
typedef pair<int, int>point;
typedef pair<point, int>ppl;

queue < ppl >que;

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

int bfs(point s,point g) {
	que.push(ppl(s,0));

	while (!que.empty()) {
		int x = que.front().first.first;
		int y = que.front().first.second;
		int dist = que.front().second;
		//cout << "x=" << x << "y=" << y << endl;
		que.pop();
		if (point(x, y) == g)return dist;
		rep(i, 4) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if (nx < 0 || h <= nx)continue;
			if (ny < 0 || w <= ny)continue;
			if (a[nx][ny] == '.') {
				que.push(ppl(point(nx, ny),dist+1));
				a[nx][ny] = '#';
			}
		}
	}
	return -1;
}

int main(){
	cin >> h >> w;
	int count = 0;
	rep(i, h)rep(j, w) {
		cin >> a[i][j];
		if (a[i][j] == '.')count++;
	}
	int ans = bfs(point(0,0),point(h-1,w-1));
	if (ans == -1)print(-1);
	else print(count - ans - 1);
	return 0;
}

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

using namespace std;

int main() {
    int i=0, l, j, n, m;
    string s,c;

    while(1){
        cin >> s;
        if(s[0] == '-') break;
        cin >> n;

        c = s;
        l = s.length();
        for(i =0; i < n; i++) {
            cin >> m;
            for(j = 0; (j + m) < l;j++){
                c[j] = s[j+m];
            }
            for(j = 0;j < m;j++) {
                c[l-m+j] = s[j];
            }
            s = c;
        }
        cout << c << endl;
    }
}




Measured memory_bytes: 3100