akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
typedef long long ll;

bool g[2005][2005];
bool dp1[2005][2005]; // dp1[i][j]: [i,j]でjが勝てる
bool dp2[2005][2005]; // dp2[j][i]: [i,j]でiが勝てる

char buf[3000];
int main(void) {
  int n = 2000;
  scanf("%d", &n);
  REP(i, n-1) {
    scanf("%s", buf);
    REP(j, i+1) {
      bool b;
      b = buf[j] == '1';
      g[i+1][j] = b;
      g[j][i+1] = !b;
    }
  }
  REP(i, n) {
    g[i][i] = true;
    dp1[i][i] = true;
    dp2[i][i] = true;
  }
  for(int d = 1; d < n; ++d) {
    REP(i, n-d) {
      int j = i + d;
      bool f1 = false;
      bool f2 = false;
      for(int k = i; k < j; ++k) {
        f1 |= g[j][k] & dp1[i][k] & dp2[j-1][k];
      }
      for(int k = i+1; k <= j; ++k) {
        f2 |= g[i][k] & dp1[i+1][k] & dp2[j][k];
      }
      dp1[i][j] = f1;
      dp2[j][i] = f2;
    }
  }
  int res = 0;
  REP(i, n) {
    if(dp1[0][i] & dp2[n-1][i]) {
      ++res;
    }
  }
  
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 12032
#include <stdio.h>
int main(void){
  int a,b,match = 0;
  scanf("%d %d",&a,&b);
  char A[a][a],B[b][b];
  for(int i = 0;i < a;i++){
    scanf("%s",&A[i]);
  }
  for(int i = 0;i < b;i++){
    scanf("%s",&B[i]);
  }
  for(int i = 0;i < a;i++){
    for(int ii = 0;ii < a;ii++){
      int flag = 1;
      for(int j = 0;j < b;j++){
        for(int k = 0;k < b;k++){
          if(A[i + j][ii + k] != B[j][k]){
            flag = 0;
          }
        }
      }
      if(flag == 1){
        match = 1;
      }
    }
  }
  if(match == 0){
    printf("No");
  }else{
    printf("Yes");
  }
  return 0;
}

Measured memory_bytes: 128
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

map<ll,ll> mp;

const int MOD = 1000000007;

void prime_factorial(int N) {
    for(int i = 2; i * i <= N; i++) {
        if(N % i == 0) {
            ll ex = 0;
            while(N % i == 0) {
                ex++;
                N /= i;
            }
            if(mp.count(i)) mp[i] += ex;
            else mp[i] = ex;
        }
    }
    if(N != 1) {
        if(mp.count(N)) mp[N]++;
        else mp[N] = 1;
    }
}

int main() {
    ll N; cin >> N;
    for(ll n = 1; n <= N; n++) {
        prime_factorial(n);
    }
    ll ans = 1;
    for(auto p : mp) {
        ans *= p.second+1;
        ans %= MOD;
    }
    cout << ans << endl;
}


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

int main(){
	int n;
	cin >> n;
	bool judge[n];
	for(int i = 0; i < n; i++){
		int length[3];
		for(int j = 0; j < 3; j++){
			cin >> length[j];
		}
		sort(length,length+3);
		if(length[0]*length[0]+length[1]*length[1] == length[2]*length[2]){
			judge[i] = true;
		}
		else{
			judge[i] = false;
		}
	}
	for(int i = 0; i < n; i++){
		if(judge[i] == true){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
}

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

int main()
{
    string x;
    cin>>x;
    int a;
    int z;
        for(int i=0;i<x.length();i++){
        if(x.at(i)=='A'){
            a=i;
break;
        }}
                for(int i=0;i<x.length();i++){
        if(x.at(i)=='Z'){
                z=i;
        }
    }
 
        cout<<z-a+1;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int main(void)
{
	
	int a,b,c,d,e;
	scanf("%d %d",&a,&b);
	c=a/b;
	d=a%b;
	d=d/1;
	e=c+d;
	printf("%d\n",e);
	
	return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N, K;
    cin >> N >> K;
    if (N - K * (N / K) != 0)
    {
        cout << (N - K * (N / K))/(N - K * (N / K)) << endl;
    }
    else
    {
        cout << (N - K * (N / K)) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;

struct Data{
    int A;
    string S;
    
    bool operator<( const Data& right ) const {
        return A == right.A ? S < right.S : A < right.A;
        //return A < right.A;
    }
};

int Func(){
    int x = 0;
    return x;
}

int main(){
    int X, Y;
    
    cin >> X >> Y;
    
    int total = 0;
    
    if (X<=3) {
        total += (4-X)*100000;
    }
    
    if (Y<=3) {
        total += (4-Y)*100000;
    }
    
    if (X==1 and Y==1) {
        total += 400000;
    }
    
    // 出力
    cout << total << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int N;

ll calc(ll x,ll y){
	if(y == 0){
		return x;
	}else{
		return calc(y,x%y);
	}
}

void func(){

	vector<ll> GU,KI;
	ll tmp;

	int limit = (N*(N+1))/2;

	for(int i = 0; i < limit; i++){
		scanf("%lld",&tmp);
		if(tmp%2 == 0)GU.push_back(tmp);
		else{
			KI.push_back(tmp);
		}
	}

	sort(GU.begin(),GU.end());
	sort(KI.begin(),KI.end());

	ll GU_0 = GU[0],GU_1 = GU[1],KI_0 = KI[0];

	ll common;
	if(GU_0 >= KI_0){
		common = calc(GU_0,KI_0);
	}else{
		common = calc(KI_0,GU_0);
	}

	GU_0 /= common;
	KI_0 /= common;

	if(GU_1 >= KI_0){
		common = calc(GU_1,KI_0);
	}else{
		common = calc(KI_0,GU_1);
	}

	GU_1 /= common;
	KI_0 /= common;

	ll ans_GU = sqrt((GU_0*GU_1)/KI_0);

	printf("%lld\n",ans_GU);
	printf("%lld",GU[0]/ans_GU);
	for(int i = 1; i < GU.size();i++){
		printf(" %lld",GU[i]/ans_GU);
	}
	printf("\n");

}

int main(){

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 3420
"""
データの特徴と定義域に注目
- 全体のデータ数は10^10で計算時間がありえない
- データ特徴としては同じ値が連続（圧縮可能）
- データを圧縮した場合のデータ数は10^5になり、空間的に許容範囲、線形探査も時間的に許容範囲
- 「空間的にも」→全要素分の配列を準備してハッシュでソート(=インデックスの場所に格納すればソートされる)
"""
(n, k) = map(int, input().split())

num = [0 for _ in range(100000 + 1)]

for _ in range(n):
    (a, b) = map(int, input().split())
    num[a] += b

count = 0
for i, j in enumerate(num):
    if count + j >= k:
        print(i)
        break
    else:
        count += j


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

using namespace std;

int main(void)
{
	int a,b; cin>>a>>b;
	if(a <= 0 && b >= 0) cout<<"Zero"<<endl;
	else if(a == 0 || b == 0) cout<<"Zero"<<endl;
	else if(b < 0){
		if((b-a)%2 == 0) cout<<"Negative"<<endl;
		else cout<<"Positive"<<endl;
	}
	else cout<<"Positive"<<endl;
	return 0;
}



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

#define ll long long
#define ull unsigned long long
#define ld long double

#define tiii tuple < int, int, int >
#define pii pair < int, int >
#define pll pair < ll, ll >
#define pci pair < char, int >
#define psi pair < string, int >
#define pis pair < int, string >

#define vi vector < int >
#define vd vector < double >
#define vld vector < ld >
#define vll vector < ll >
#define vs vector < string >
#define vc vector < char >
#define vpi vector < pii >
#define vpll vector < pll >
#define vpis vector < pis >

#define pb push_back
#define mt make_tuple
#define gt0 get < 0 >
#define gt1 get < 1 >
#define gt2 get < 2 >

#define pi acos(-1)

#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

const int maxn = 1e5 + 5;
const int mod = 1e9 + 9;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    fast;

    string s;

    cin >> s;

    if(s.back() == 's') cout << s << "es" << endl;
    else cout << s << 's' << endl;

    return 0;
}


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

using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
//最終奥義 #define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void put_double(double obj){printf("%.12f\n",obj);};
//lambda: [](int x, int y){return x<y;}


signed main(void){
    int n;cin>>n;
    vector<vector<string>> ans(10);
    ans[0].push_back("a");
    repi(i,1,n){
        rfor(str,ans[i-1]){
            set<char> s;
            rfor(c,str) s.insert(c);
            rep(j,s.size()+1){
                string tail={(char)('a'+j)};
                ans[i].push_back(str+tail);
            }
        }
    }
    sort(all(ans[n-1]));
    rfor(str,ans[n-1]) cout << str << endl;
    return 0;
}


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

int main(void)
{
    long long N;
    int K;
    cin >> N >> K;

    int cnt = 1;
    while (true) {
        if (N < K) {
            break;
        }
        N /= K;
        cnt++;
    }

    cout << cnt << endl;
    return 0;
}

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

int main()
{
  int h, w; cin >> h >> w;
  int wCount = 0;
  vector<vector<char>> mp(h, vector<char>(w));
  rep(i, h)
    rep(j, w)
    {
      cin >> mp[i][j];
      if (mp[i][j] == '.')
        wCount++;
    }
  vector<vector<int>> l(h, vector<int>(w, 0));
  l[0][0] = 1;
  queue<pair<int, int>> q;
  q.emplace(0, 0);
  while (!q.empty())
  {
    int y, x;
    y = q.front().first;
    x = q.front().second;
    q.pop();
    if (y > 0 && mp[y-1][x] == '.' && l[y-1][x] == 0)
    {
      l[y-1][x] = l[y][x] + 1;
      q.emplace(y - 1, x);
    }
    if (y < h - 1 && mp[y+1][x] == '.' && l[y+1][x] == 0)
    {
      l[y+1][x] = l[y][x] + 1;
      q.emplace(y + 1, x);
    }
    if (x > 0 && mp[y][x-1] == '.' && l[y][x-1] == 0)
    {
      l[y][x-1] = l[y][x] + 1;
      q.emplace(y, x - 1);
    }
    if (x < w - 1 && mp[y][x+1] == '.' && l[y][x+1] == 0)
    {
      l[y][x+1] = l[y][x] + 1;
      q.emplace(y, x + 1);
    }
  }
  if (l[h-1][w-1] == 0)
  {
    cout << -1 << endl;
    return 0;
  }
  cout << wCount - l[h-1][w-1] << endl;
}

Measured memory_bytes: 256
while True:
    X, Y = map(int, input().split())
    if X == 0:
        break
    a = [[1]+list(map(int, input().split()))+[1] for _ in [0]*Y] + [[0]*(X+2)]
    dp = [list(map(lambda x: x^1, a[0]))] + [[0]*(X+2) for _ in [0]*Y]

    for y in range(Y-1):
        for x, (square, cnt) in enumerate(zip(a[y][1:], dp[y][1:-1]), start=1):
            if square == 0:
                for tx in range(x-1, x+2):
                    if a[y+1][tx] == 0 or a[y+1][tx] == 2 and x == tx:
                        dp[y+1][tx] += cnt
            elif square == 2:
                dp[y+2][x] += cnt
    for x in range(1, X+1):
        if a[Y-1][x] != 1:
            dp[Y][x] += dp[Y-1][x]

    print(sum(dp[-1]))


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

s1 = 0
#全体の通過者
s2 = 1
#海外の順位

for x in range(N):
    if S[x] == "a":
        if s1 < A + B:
            print("Yes")
            s1 += 1
        else:
            print("No")

    elif S[x] == "b":
        if s1 < A + B and s2 <= B:
            print("Yes")
            s1 += 1
        else:
            print("No")
        s2 += 1

    elif S[x] == "c":
        print("No")


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

int main(){
    string s; cin>>s;

    int ans=0;
    for(int i=1;i<s.length();i++){
        if(s[i-1]==s[i]){
            s[i]=(s[i]=='0'?'1':'0');
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int[] a = new int[n];
		HashMap<Integer, Long> b = new HashMap<>();
		for (i = 0; i < n; i++) {
			a[i] = parseInt(sc.next());
			if(b.get(a[i])==null) {
				b.put(a[i], 1L);
			} else {
				b.put(a[i], b.get(a[i])+1L);
			}
		}
		sc.close();
		long sumAll=0;
		for (Integer ii : b.keySet()) {
			sumAll+=b.get(ii)*(b.get(ii)-1);
		}
		PrintWriter pw = new PrintWriter(System.out);
		for(i = 0; i < n; i++) {
			pw.println((sumAll-2*(b.get(a[i])-1))/2);
		}
		pw.flush();
	}
}


Measured memory_bytes: 72068
s = input()
s_h = s[:(len(s)-1)//2]
s_h_b = s[(len(s)+3)//2-1:]

if s==s[::-1] and s_h==s_h[::-1] and s_h_b == s_h_b[::-1]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
def count(lis, n):
    num = n
    keta = len(str(n))
    shurui = len(lis)
    ans = 0
    for i in range(1,keta):
        ans += shurui ** i
    while keta>=0:
        if keta == 0:
            ans += 1
            break
        keta -= 1
        kami = num // (10**keta)
        ok = sum(x<kami for x in lis)
        ans += ok * (shurui ** keta)
        if kami in lis:
            num = num % (10**keta)
        else:
            break
    return ans

N = int(input())

ans = count([7,5,3],N)-count([7,5],N)-count([5,3],N)-count([7,3],N)+count([7],N)+count([5],N)+count([3],N)
print(ans)

Measured memory_bytes: 3064
def main():
    import sys
    sys.setrecursionlimit(10 ** 6)
    input = sys.stdin.readline
    X = int(input())
    Y = 100
    i = 0
    while Y < X:
        i += 1
        Y = int(Y * 1.01)
    print(i)
if __name__ == '__main__':
    main()

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll s; cin>>s;
    ll v = 1000000000;
    ll x = (v - s % v) % v;
    ll y = (s+x)/v;
    cout<<"0 0 1000000000 1 "<<x<<' '<<y<<endl;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;


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

    ll ans = 1LL << 60;
    for(int i = 0; i <= max(x, y) * 2; i+=2){
        ll sum = i * c;
        if(0 < x - i / 2) sum += ((x - i / 2) * a);
        if(0 < y - i / 2) sum += ((y - i / 2) * b);
        ans = min(ans, sum);
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
	long long n, ans = 1e9;
	cin >> n;
	for(long long a = 1; a * a <= n; a++) if(n % a == 0){
		ans = min(ans, (long long)(to_string(n / a).size()));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
char number[1001];
int main(){
  int x,sum;
  sum=1;
  while(sum!=0){
    sum=0;
    while((x=getchar())!='\n'){
      sum+=x-'0';
    }
    if(sum==0){
      break;
    }
    printf("%d\n",sum);
  }
  return 0;
}

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

int N,M;

void solve(){
    int can=M/N;
    for(int i=can; i>=1; i--){
        if(M%i==0){
            cout<<i<<endl;
            return;
        }
    }
}

int main(){
    cin>>N>>M;
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int mod=1e9+7;
inline int powmod(int a,int b){
	int res=1;for(;b;b>>=1){
		if(b&1)res=1ll*res*a%mod;
		a=1ll*a*a%mod;
	}return res;
}
int n,k;
inline int getlen(int x){
	return powmod(k,(x+1)/2);
}
map<int,int> F;
inline int f(int n){
	if(F.count(n))return F[n];
	int &res=F[n];res=getlen(n);
	int tmp=sqrt(n);
	rep(i,1,tmp){
		if(n%i==0){
			if(i!=n)res=(res-f(i)+mod)%mod;
			if(n/i!=i&&n/i!=n)res=(res-f(n/i)+mod)%mod;
		}
	}return res;
}
inline int g(int n){
	if(n%2==0)
		return 1ll*f(n)*powmod(2,mod-2)%mod;
	else
		return f(n);
}
int main(){
	read(n);read(k);
	int tmp=sqrt(n),ans=0;
	rep(i,1,tmp)if(n%i==0){
		ans=(ans+1ll*i*g(i))%mod;
		if(n/i!=i)ans=(ans+1ll*(n/i)*g(n/i))%mod;
	}printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
#define code                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(0);
// #define int long long
#define MM(a, b) memset(a, b, sizeof(a))
const ll MOD = 1000000007;
using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	cout.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}


struct ds
{
	/* data */
	int a,b,c;
};

bool comp(ds x,ds y){
	if(x.a==y.a){
		return x.b<y.b;
	}
	return x.a<y.a;
}

int32_t main()
{
	code;
	cout<<fixed<<setprecision(12);
	int n,k; cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++) cin>>arr[i];
	double sum = 0;
	int cur =0;
	for(int i=0;i<k-1;i++){
		cur += arr[i];
	}
	// trace(cur);
	for(int i=k-1;i<n;i++){
		cur += arr[i];
		double x = (1.0*(cur+k))/2.0;
		// trace(x);
		sum = max(sum,x);
		cur-=arr[i-k+1];
		// cur+=arr[i];
	}
	cout<<sum<<endl;
	
	
}

Measured memory_bytes: 1024
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)			a.begin(), a.end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF				2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define	MAX_QWORD		((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<ll, ll>	P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	char c[3][3];
	REP(i, 3) REP(j, 3) cin >> c[i][j];
	cout << c[0][0] << c[1][1] << c[2][2]<< endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char st1[11],st2[11],st3[11],ch1,ch2,ch3;
    scanf("%s",st1);
    scanf("%s",st2);
    scanf("%s",st3);
    ch1=toupper(st1[0]);
    ch2=toupper(st2[0]);
    ch3=toupper(st3[0]);
    printf("%c%c%c\n",ch1,ch2,ch3);
    return 0;
}


Measured memory_bytes: 256
import math
a, b, h, m = list(map(int, input().split()))

shita = (-h / 6 - m / 360 + 1 / 2) * math.pi
phi = (-m + 15) / 30 * math.pi

print(math.sqrt( math.pow(a * math.cos(shita) - b * math.cos(phi), 2) + math.pow(a * math.sin(shita) - b * math.sin(phi), 2) ))

Measured memory_bytes: 9584
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long long int gcd(long long a,long long b){
  if(b==0){
    return a;
  }
  else{
    return gcd(b,a%b);
  }
}
long long int lcm(long long a,long long b){
  return a/gcd(a,b)*b;
}
int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll e=lcm(c,d);
  a--;
  cout << (b-a)-((b/c+b/d-b/e)-(a/c+a/d-a/e)) << endl;
  return 0;
}

Measured memory_bytes: 3596
import sys

def main():
    line = sys.stdin.readline()
    lst = line.split()
    n = int(lst[0])
    k = int(lst[1])

    line = sys.stdin.readline()
    lst = line.split()
    l_lst = sorted([int(l) for l in lst], reverse=True)

    print(sum(l_lst[:k]))


    return 0

if __name__ == '__main__':
    sys.exit(main())


Measured memory_bytes: 3060
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0 }, dy[] = { 0,1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑


long long n, mon;
int main() {
	cin >> n;
	vector<long long>v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
		if (v[i] < 0) {
			++mon;
			v[i] = abs(v[i]);
		}
	}
	switch (mon % 2) {
	case 0:
		cout << accumulate(all(v), 0LL) << endl;
		break;
	case 1:
		sort(all(v));
		cout << accumulate(v.begin() + 1, v.end(), 0LL) - v[0] << endl;
		break;
	}
}

Measured memory_bytes: 1024
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 



int main(){
    long long N,K;
    cin >> N >> K;
    long long num=0;
    while(N>0){
        N=N/K;
        ++num;
    }
    cout << num;
    }

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

constexpr int MAXN = 1e3 + 3;
constexpr double down = 0.996;

long long n, sum;

int main() {
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			for (int k = 1; k <= n; k++)
				sum += __gcd(i, __gcd(j, k));
	cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N;
 
int main(void){
    
    scanf("%d", &N);
    string s = to_string(N);
    
    int num = 0;
    for(int i = 0; i < s.size(); ++i) num += s[i] - '0';
    printf("%s\n", (N % num == 0) ? "Yes" : "No");
    
    return 0;
}

Measured memory_bytes: 256
S = input()
L = len(S)
a, b = 0, 0

if L % 2 == 0:
  A = "01" * (L//2)
  B = "10" * (L//2)
else:
  A = "01" * (L//2) + "0"
  B = "10" * (L//2) + "1"
for i in range(L):
  if A[i] != S[i]:
    a += 1
  if B[i] != S[i]:
    b += 1
  
print(min(a, b))

Measured memory_bytes: 3316
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	double a_d,b_d;
	scanf("%d %d",&a,&b);
	a_d = static_cast<double>(a);
	b_d = static_cast<double>(b);
	printf("%d %d %.5f\n",a/b,a%b,a_d/b_d);
}



Measured memory_bytes: 2740
// https://ei1333.github.io/luzhiled/
// http://beet-aizu.hatenablog.com/entry/2017/01/04/113233
// http://www.prefield.com/algorithm/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << endl;} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#define in1(A) REP(i,A.size()) in(A[i]);
#define in2(A,B) REP(i,A.size()) in(A[i],B[i]);
#define in3(s,t,u) REP(i,sz(s)){in(s[i] , t[i] , u[i]);}
#define in4(s,t,u,v) REP(i,sz(s)){in(s[i] , t[i] , u[i] , v[i]);}
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-------------------------------------------------------------------------------------------------
int main(){
    init();
    inl(n,k);
    
    
    out(min(n%k,k-n%k));
}

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

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

    string S; cin >> S;
    string t = S.substr(5, 2);
    int x = t[0] == '0' ? t[1]-'0' : stoi(t);
    cout << (x <= 4 ? "Heisei" : "TBD") << "\n";
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

namespace LogicSummoner
{
    class Program
    {
        static void Main(string[] args)
        {
            var nums = GetNumbersInt();
            var r = nums[0];
            var c = nums[1];

            var lines = new List<List<int>>();

            for (int i = 0; i < r; i++)
            {
                var line = GetNumbersInt().ToList();
                line.Add(line.Sum());
                lines.Add(line);
                System.Console.WriteLine(string.Join(" ", line.Select(x => x.ToString()).ToArray()));
            }

            var last = new List<string>();
            for (int i = 0; i < c + 1; i++)
            {
                var sum = 0;
                for (int j = 0; j < r; j++)
                {
                    sum += lines[j][i];
                }
                last.Add(sum.ToString());
            }

            System.Console.WriteLine(string.Join(" ", last.ToArray()));
        }

        //static StreamReader Console = new StreamReader("input.txt");

        static int GetNumber()
        {
            return int.Parse(Console.ReadLine().Trim());
        }

        static double GetDounble()
        {
            return double.Parse(Console.ReadLine().Trim());
        }

        static int[] GetNumbersInt(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
        }

        static long[] GetNumbersLong(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToArray();
        }

        static double[] GetNumbersDouble(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => double.Parse(x)).ToArray();
        }

        static string[] GetStrings(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).ToArray();
        }
    }
}

Measured memory_bytes: 10356
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 2e18;

signed main() {
    int Q;
    cin >> Q;
    multiset<int> left, right;
    int middle = -1, leftSum = 0, rightSum = 0, delta = 0;
    pair<int, int> ans;
    auto update = [&](int a, int b) {
        delta += b;
        auto calc = [&]() {
            int mid = middle;
            if (mid == -1) mid = *left.rbegin();
            int temp = mid * (int)left.size() - leftSum;
            temp += rightSum - mid * (int)right.size();
            ans.first = mid;
            ans.second = temp + delta;
        };
        if (middle == -1) {
            if (left.empty() && right.empty()) {
                middle = a;
            } else {
                multiset<int> temp;
                temp.insert(a);
                {
                    // left
                    auto itr = left.end();
                    --itr;
                    temp.insert(*itr);
                    left.erase(itr);
                    leftSum -= *itr;
                }
                {
                    // right
                    auto itr = right.begin();
                    temp.insert(*itr);
                    right.erase(itr);
                    rightSum -= *itr;
                }
                left.insert(*temp.begin());
                leftSum += *temp.begin();
                right.insert(*temp.rbegin());
                rightSum += *temp.rbegin();
                middle = *next(temp.begin(), 1);
            }
            calc();
        } else {
            int down = min(a, middle);
            int up = max(a, middle);
            left.insert(down);
            leftSum += down;
            right.insert(up);
            rightSum += up;
            middle = -1;
            calc();
        }
    };

    for (int i = 0; i < Q; i++) {
        int q;
        cin >> q;
        if (q == 1) {
            int a, b;
            cin >> a >> b;
            update(a, b);
        } else {
            cout << ans.first << " " << ans.second << endl;
        }
    }
}


Measured memory_bytes: 9600
import java.util.Scanner;
import java.util.HashMap;

public class Main {
	public static void main(String args[]){
		Scanner in=new Scanner(System.in);
    HashMap<Integer,Integer> map =new HashMap<Integer,Integer>();
		int counter = 0;
		int n=in.nextInt();
    int tmp=0;
    int ans=0;
    for (int i=0;i<n;i++) {
      tmp=in.nextInt();
      if (!map.containsKey(tmp)) {
        map.put(tmp,i);
      }else{
        map.remove(tmp);
      }
    }

		System.out.printf("%d%n",map.size());
	}
}


Measured memory_bytes: 63840
n = int(input())
a = list(map(int, input().split()))

sequence = []
j = 1
for i in range(1, n):
    if a[i] == a[i - 1]:
        j += 1
    else:
        sequence.append(j)
        j = 1
sequence.append(j)

ans = 0
for i in range(len(sequence)):
    ans += (sequence[i] // 2)

print(ans)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {

    static int N;
    static int[] A;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        A = sc.nextIntArray(N);
        System.out.println( solve() );
    }

    private static long solve() {
        long[] P = new long[N];
        P[0] = A[0];
        for (int i = 1; i < N; i++) {
            P[i] = P[i-1] + A[i];
        }

        Map<Long, Integer> counter = new HashMap<>();
        for (int i = 0; i < N; i++) {
            Integer cnt = counter.get(P[i]);
            if( cnt != null ) {
                counter.put(P[i], cnt + 1);
            } else {
                counter.put(P[i], 1);
            }
        }

        if( counter.containsKey(0L) ) {
            counter.put(0L, counter.get(0L) + 1);
        }

        long ans = 0;
        for (Map.Entry<Long, Integer> entry : counter.entrySet()) {
            int cnt = entry.getValue();
            ans += sigma(cnt-1);
        }
        return ans;
    }

    private static long sigma(long n) {
        if( n % 2 == 0 ) {
            return (n / 2) * (n + 1);
        } else {
            return (n / 2) * (n + 1) + (n / 2 + 1);
        }
    }

    static class FastScanner {

        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 52240
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	char a[10],b[10];
	while(true){
	cin>>a>>b;
	if(strcmp(a,"0")==0&&strcmp(b,"0")==0)break;
	int x=0,y=0;
	for(int i=0;i<4;i++){
		for(int j=0;j<4;j++){
			//if(i<j)continue;
			if(a[i]==b[j]){
			if(i==j)x++;
			else y++;
			}			

		}
	}
	cout<<x<<" "<<y<<endl;
	}
	return 0;
}

Measured memory_bytes: 1140
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
    int N;
    cin >> N;
    bool ct = false;
    rep1(i,9) rep1(j,9) if(N == i*j) ct = true;
    if(ct) pr("Yes");
    else pr("No");
    
    
}


Measured memory_bytes: 256
#include <assert.h>
main(a,b,c,p,q,r,s,i){for(;scanf("%d%d%d",&a,&b,&c),a;){
	if(c==0){
		if(a==1&&b<0)printf("1 0 %d %d\n",a,b);
		else printf("%d %d 1 0\n",a,b);
		continue;
	}
	for(r=1;r*r<=a;r++)if(a%r==0){
		for(p=a/r,s=1;s<=abs(c);s++)if(c%s==0){
			
			for(i=0;i<2;i++,s=-s)if(q=c/s,p*s+q*r==b){
				if(p==r&&q<s)printf("%d %d %d %d\n",r,s,p,q);
				else printf("%d %d %d %d\n",p,q,r,s);
				goto next;
			}
		}
	}
	puts("Impossible");
	next:;
}exit(0);}

Measured memory_bytes: 612
#include <stdio.h>

int main()
{ int W,H,r;
	float x,y;
	scanf("%d %d %f %f %d",&W,&H,&x,&y,&r);
	if(x+r>W || x-r<0){printf("No\n");}
	else if(y+r>H || y-r<0){printf("No\n");}
	else{printf("Yes\n");}
	
	
	return 0;
}


Measured memory_bytes: 2040
N,M=map(int,input().split())
H=list(map(int,input().split()))
A=[0]*N
for i in range(M):
    a,b=map(int,input().split())
    A[a-1]=max(A[a-1],H[b-1])
    A[b-1]=max(A[b-1],H[a-1])
res=sum([H[i]>A[i] for i in range(N)])
print(res)


Measured memory_bytes: 19972
using System;
using System.Collections.Generic;
using System.Linq;
					
public class Program
{
	static int[] parent;
	static int[] rank;
	
	public static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		int[,] A = new int[n,n];
		
		for(int i = 0; i < n; i++) {
			var cells = Console.ReadLine().Trim(" ".ToCharArray()).Split(" ".ToCharArray());
			
			for(int j = 0; j < n; j++) {
				A[i,j] = int.Parse(cells[j]);
			}
		}
		
		List<Side> S = new List<Side>();
		
		//?\?????¨?§???¨?????§?´???£???¨?\???????????\?????\?????????\?\?????£?????¨?????£???¨?£?????£?????\?????\?????£?????£?????£????
		for(int i = 0; i < n; i++) {
			for(int j = i +1; j < n; j++) {
				if(A[i,j] != -1) S.Add(new Side(i,j,A[i,j]));
			}
		}
		
		S.Sort((a,b) => a.len - b.len);
		
		InitializeUnionFind(n);
		int ans = 0;
		for(int i = 0; i < S.Count(); i++) {
			Side e = S[i];
			
			if(!Same(e.a, e.b)) {
				Unite(e.a, e.b);
				ans += e.len;
			}
		}
		
		Console.WriteLine(ans);
	}
	
	public static bool Same(int x, int y)
	{
		return (Find(x) == Find(y));
	}
	
	public static int Find(int x)
	{
		if(parent[x] == x) return x;
		else return parent[x] = Find(parent[x]);
	}
	
	public static void Unite(int x, int y)
	{
		x = Find(x);
		y = Find(y);
		
		if(x == y) return;
		
		if(rank[x] < rank[y]) {
			parent[x] = y;
		} else {
			parent[y] = x;
			
			if(rank[x] == rank[y]) rank[x]++;
		}
	}
	
	public static void InitializeUnionFind(int n)
	{
		parent = new int[n];
		rank = new int[n];
		
		for(int i = 0; i < n; i++) {
			parent[i] = i;
		}
	}
}

public class Side
{
	public int a { private set; get; }
	public int b { private set; get; }
	public int len { private set; get; }
	
	public Side (int v1, int v2, int v3)
	{
		a	= v1;
		b	= v2;
		len	= v3;
	}
}

Measured memory_bytes: 9676
def solve():
    N = int(input())
    S = input()
    MOD= int(1e9)+7

    from collections import Counter
    c = Counter(S)
    ans = 1
    for k in c.keys():
        ans = (ans * (c[k] + 1)) % MOD
    ans = (ans - 1) % MOD

    print(ans % MOD)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3444
n = int(input())
s = list(map(int, input().split()))

q = int(input())
t = list(map(int, input().split()))

c = 0

for target in t:
    left = 0
    right = n-1

    while left <= right:
        mid = (left + right) // 2

        if s[mid] > target:
            right = mid - 1

        elif s[mid] < target:
            left = mid + 1

        else:
            c += 1
            break

print(c)



Measured memory_bytes: 16708
/*
      author : Nishikawa
      created: 05.08.2020 14:32:38
*/

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


int main(){
    int N;
    cin >> N;
    cout << (1000*(N/1000+1)-N) % 1000 <<endl;
    return 0;
}

Measured memory_bytes: 3552
n = int(input())
a = []
for i in range(n):
    a.append(input())
m = int(input())
b = []
for i in range(m):
    b.append(input())

c = 0
for i in a:
    d = a.count(i)-b.count(i)
    c = max(c,d)
print(c)

Measured memory_bytes: 3060
#include <iostream>
#include<algorithm>
#include <vector>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
typedef long long ll;
#define max(x,y) (((x)>(y)) ? x:y)
#define min(x,y) (((x)<(y)) ? x:y)
#define FOR(a,b,c) for(b=(c);b<(a);b++)

int main() {
	string s, t;
	int w, count = 0;
	cin >> s;
	cin >> w;
	while (1)
	{
		if (count >( s.size()-1) ){
			break;
		}
		t.push_back(s[count]);
		count += w;
	}
	cout << t;
	cin >> t;
	return 0;
}



Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))

def div_two(n):
    tmp = n/2
    if tmp%1 != 0:
        return 0
    if (tmp/2)%1 != 0:
        return 1
    return 2

tmp = [0]*3
for i in map(div_two, a):
    tmp[i] += 1

flag = True

if tmp[0] > tmp[2]:
    if tmp[1] == 0:
        if tmp[0] != tmp[2]+1:
            flag = False
    else:
        flag = False

if tmp[1]:
    if tmp[1] == 1:
        flag == False

print("Yes" if flag else "No")

Measured memory_bytes: 14252
#include <stdio.h>
int main()
{
    int x1 , x2 , x3 , x4 , x5 ;
    scanf("%d %d %d %d %d",&x1,&x2,&x3,&x4,&x5);
    if (x1 == 0){
        printf("1\n");
    }
    else if (x2 == 0){
        printf("2\n");
    }
    else if (x3 == 0){
        printf("3\n");
    }
    else if (x4 == 0){
        printf("4\n");
    }
    else {
    printf("5\n");
    }
    return 0;
}



Measured memory_bytes: 1556
#include<iostream>
#include<vector>
#include<utility>
#include<queue>

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

int main(){
	int n;
	std::cin >> n;
	std::vector<std::vector<int>> seat(n, std::vector<int>(n));
	std::vector<std::vector<int>> me(n, std::vector<int>(n,1)); //自分が退席したら、0
	std::vector<std::pair<int, int>> p(n*n);
	for(int i=0; i<n*n; i++){
		int tmp;
		std::cin >> tmp;
		tmp--;
		p[i].first = tmp/n;
		p[i].second = tmp%n;
	}

	for(int i=0; i<n; i++){
		int yoko = std::min(i, (n-1) - i);
		for(int j=0; j<n; j++){
			int tate = std::min(j, (n-1) - j);
			seat[i][j] = std::min(yoko, tate);
		}
	}


	int ans = 0;
	for(int i=0; i<n*n; i++){
		int x = p[i].first;
		int y = p[i].second;
		//std::cout << i+1 << "回目:" << p[i].first << ", " << p[i].second <<std::endl;
		ans += seat[x][y];
		me[x][y]--;

		// seatの更新
		std::queue<std::pair<int, int>> q;
		q.emplace(x, y);
		while(!q.empty()){
			int x = q.front().first;
			int y = q.front().second;
			q.pop();
			int cost = seat[x][y] + me[x][y];
			for(int i=0; i<4; i++){
				int nx = x + dx[i];
				int ny = y + dy[i];
				if(nx<0 || nx>=n || ny<0 || ny>=n){
					continue;
				}
				if(seat[nx][ny] <= cost){
					continue;
				}
				seat[nx][ny] = cost;
				q.emplace(std::make_pair(nx, ny));
			}
		}
	}
	std::cout << ans << std::endl;
	
	return 0;
}

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

#define f first
#define s second
#define mp make_pair
#define all(x) x.begin(), x.end()

#define EPS 1e-9

#define X real()
#define Y imag()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;
using point = pair<double, double>;
using Vector = complex<double>;
int main() {

	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n, f[9];
	cin >> n;
	f[0] = 1;
	for(int k = 1; k <= 8; ++k) f[k] = f[k - 1] * k;
	vi p(n), q(n);
	for(int& x : p) cin >> x;
	for(int& y : q) cin >> y;
	bool pd[9] = {false}, qd[9] = {false};
	int a = 1, b = 1;
	for(int k = n - 1; k >= 0; --k) {
		for(int i = 1; i < p[k]; ++i)
			if(pd[i]) a += f[n - k - 1];
		for(int i = 1; i < q[k]; ++i) 
			if(qd[i]) b += f[n - k - 1];
		pd[p[k]] = true;
		qd[q[k]] = true;
	}
	cout << abs(a - b) << '\n';

    return 0;
}


Measured memory_bytes: 256