akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n;

    cin >> n;

    int res = 0;

    for (int i = 1; i <= n; i++)
    {
        if (to_string(i).size() % 2 == 1)
            res++;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stack>

using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	stack<int> st;
	int table[200001] = {};
	for(int i = 0;i < m;i++){
		int temp;
		cin >> temp;
		st.push(temp);
	}
	while(st.size()){
		int temp = st.top();
		st.pop();
		if(table[temp] == 0){
			cout << temp << endl;
			table[temp] = 1;
		}
	}
	for(int i = 1;i <= n;i++){
		if(table[i] == 0){
			cout << i << endl;
		}
	}
}

Measured memory_bytes: 4228
cho,ei,don = 0,0,0
while(True):
    tmp = list(map(int, input().split()))
    tmp.sort()
    a,b,c = tmp[0],tmp[1],tmp[2]
    if a + b <= c:
        break
    else:
        a2 , b2 , c2 = a ** 2, b ** 2, c ** 2
        if a2 + b2 == c2:
            cho += 1
        elif a2 + b2 < c2:
            don += 1
        else:
            ei += 1
print(cho+ei+don,cho,ei,don)



Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,k,ak=0;
  bool flag=false;
  cin>>k>>a>>b;
  ak=k;
  while(!flag){
    if(a>ak||ak>b){
    flag=false;
    ak+=k;
    if(ak>b) break;
    }else{
    flag=true;
    }
  }
  cout<<(flag?"OK":"NG")<<endl;
}

Measured memory_bytes: 3632
#import time

def main():
    S = input()
    N = len(S) -1
    #print(S[2:3])
    ans = 0
    for i in range(1<<N):
        su = [0, N+1]
        for j in range(N):
            if i & (1<<j) == 0: continue
            su.append(j+1)
            su.sort()
            #print(su)
        for k in range(len(su)-1):
            ans += int(S[su[k]:su[k+1]])
    
    return ans

if __name__ == '__main__':
    #start = time.time()
    print(main())
    #elapsed_time = time.time() - start
    #print("経過時間:{}".format(elapsed_time * 1000) + "[msec]")

Measured memory_bytes: 9124
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=0x3f3f3f3f;
int bookre[15];
struct Node{
	int costs;
	int ar[15];
}node[15];
int main()
{
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<n;i++){
		scanf("%d",&node[i].costs);
		for(int j=0;j<m;j++)scanf("%d",&node[i].ar[j]);
	}
	int ans=N;
	for(int i=0;i<(1<<n);i++){
		int sum=0;
		memset(bookre,0,sizeof(bookre));
		for(int j=0;j<n;j++){
			if((i>>j)&1){
				sum+=node[j].costs;
				for(int c=0;c<m;c++)bookre[c]+=node[j].ar[c];
			}
		}
		bool flag=true;
		for(int j=0;j<m;j++){
			if(bookre[j]<k){
				flag=false;
				break;
			}
		}
		if(flag)ans=min(ans,sum);
	}
	if(ans==N)printf("-1\n");
	else printf("%d\n",ans);
}

Measured memory_bytes: 3232
#include<bits/stdc++.h>
#define eps 1e-6

using namespace std;
const double PI = acos(-1);
const int N = 1e5 + 7;
int dcmp(double x)
{
    if(fabs(x) <= eps)  return 0;
    return x > 0 ? 1 : -1;
}
struct Point
{
    double x, y;
    bool operator < (const Point & P)   {return y == P.y ? x < P.x : y < P.y;}
};
typedef Point Vector;
Vector operator + (const Vector & A,const Vector & B)     {return {A.x + B.x, A.y + B.y};}
Vector operator - (const Vector & A,const Vector & B)     {return {A.x - B.x, A.y - B.y};}
Vector operator * (const Vector & A, double k)            {return {A.x * k, A.y * k};}
double operator * (const Vector & A,const Vector & B)     {return A.x * B.x + A.y * B.y;}
double operator ^ (const Vector & A,const Vector & B)     {return A.x * B.y - A.y * B.x;}
double length(Vector v)                                   {return sqrt(v * v);}
double sqr(Vector v)                                      {return v * v;}
bool operator ==  (const Vector & A,const Vector & B)     {return !dcmp(A.x - B.x) && !dcmp(A.y - B.y);}
Point p[N], sta[N];
int top, n;
bool cmp(Point a, Point b)
{
    Vector v = a - p[0], w = b - p[0];
    if(dcmp(v ^ w) < 0)                         return false;
    else if(!dcmp(v ^ w) && sqr(v) > sqr(w))    return false;
    return true;
}
void graham()
{
    sort(p + 1, p + n, cmp);
    n = unique(p, p + n) - p;
    int t = n - 1;
    while(!dcmp((p[t] - p[0]) ^ (p[n-1] - p[0])))   t --;
    reverse(p + t + 1, p + n);
    sta[0] = p[0], sta[1] = p[1], top = 2;
    p[n ++] = p[0];
    for(int i = 2; i < n; i ++)
    {
        while(top >1 && dcmp((sta[top - 1] - sta[top - 2]) ^ (p[i] - sta[top - 2])) < 0)  top --;
        sta[top ++] = p[i];
    }
    top --;
}
int main()
{
    scanf("%d", &n);
    for(int i = 0 ; i < n; i ++)
    {
        double a, b;
        scanf("%lf %lf", &a, &b);
        p[i] = {a, b};
        if(p[i] < p[0]) swap(p[0], p[i]);
    }
    graham();
    printf("%d\n", top);
    for(int i = 0; i < top; i ++)
        printf("%.0f %.0f\n", sta[i].x, sta[i].y);
    return 0;
}



Measured memory_bytes: 5680
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
vector<int> G[100009]; int root = 0, parent[17][100009], depth[100009];
void dfs(int v, int p, int d) {
	parent[0][v] = p; depth[v] = d;
	for (int i : G[v]) if (i != p) dfs(i, v, d + 1);
}
void init(int v) {
	dfs(root, -1, 0);
	for (int i = 0; i < 16; i++) {
		for (int j = 0; j < v; j++) {
			if (parent[i][j] < 0) parent[i + 1][j] = -1;
			else parent[i + 1][j] = parent[i][parent[i][j]];
		}
	}
}
int query(int v1, int v2) {
	if (depth[v1] > depth[v2]) swap(v1, v2);
	for (int i = 0; i < 17; i++) {
		if ((depth[v2] - depth[v1]) >> i & 1) v2 = parent[i][v2];
	}
	if (v1 == v2) return v1;
	for (int i = 16; i >= 0; i--) {
		if (parent[i][v1] != parent[i][v2]) {
			v1 = parent[i][v1];
			v2 = parent[i][v2];
		}
	}
	return parent[0][v1];
}
int n, p;
int main() {
	cin >> n;
	for (int i = 1; i < n; i++) {
		cin >> p; p--;
		G[p].push_back(i);
		G[i].push_back(p);
	}
	for (int i = 0; i < n; i++) {
		sort(G[i].begin(), G[i].end());
	}
	init(n);
	queue<int> que; que.push(0);
	long long ret = 0; int prev_ = 0;
	while (!que.empty()) {
		int u = que.front(); que.pop();
		for (int i : G[u]) {
			if (i < u) continue;
			int a = query(prev_, i);
			ret += depth[prev_] + depth[i] - depth[a] * 2;
			prev_ = i;
			que.push(i);
		}
	}
	cout << ret << endl;
	return 0;
}

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

template<int MOD>
class mod_int {
	unsigned x;
public:
	mod_int() : x(0) { }
	mod_int(int sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	mod_int(long long sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	mod_int &operator+=(mod_int that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
	mod_int &operator-=(mod_int that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	mod_int &operator*=(mod_int that) { x = (unsigned long long)x * that.x % MOD; return *this; }
	mod_int &operator/=(mod_int that) { return *this *= that.inverse(); }

	mod_int operator+(mod_int that) const { return mod_int(*this) += that; }
	mod_int operator-(mod_int that) const { return mod_int(*this) -= that; }
	mod_int operator*(mod_int that) const { return mod_int(*this) *= that; }
	mod_int operator/(mod_int that) const { return mod_int(*this) /= that; }

	bool operator==(const mod_int& that) const { return x == that.x; }

	mod_int inverse() const {
		long long a = x, b = MOD, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		return mod_int(u);
	}
};

template<int MOD>
istream& operator >> (istream& is, mod_int<MOD>& val) {
	long long x;
	is >> x; val = x;
	return is;
}

template<int MOD>
ostream& operator << (ostream& os, const mod_int<MOD>& val) {
	os << val.get();
	return os;
}

const int mod = 1e9 + 7;
using mint = mod_int<mod>;

template <typename T>
T power(T x, long long n) {
	T res = 1;
	while (n) {
		if (n & 1) res *= x;
		x *= x; n >>= 1;
	}
	return res;
}

const int MAX = 2e6;

bool inited = false;
mint fac[MAX + 1];
mint rfac[MAX + 1];

void init() {
	inited = true;
	fac[0] = 1;
	for (int i = 1; i <= MAX; i++) {
		fac[i] = fac[i - 1] * i;
	}
	rfac[MAX] = fac[MAX].inverse();
	for (int i = MAX; i >= 1; i--) {
		rfac[i - 1] = rfac[i] * i;
	}
}

mint nPr(int n, int r) {
	if (!inited) init();
	return r < 0 || n < r ? 0 : fac[n] * rfac[n - r];
}

mint nCr(int n, int r) {
	if (!inited) init();
	return r < 0 || n < r ? 0 : fac[n] * rfac[n - r] * rfac[r];
}

mint nHr(int n, int r) {
	if (!inited) init();
	return r == 0 ? 1 : nCr(n + r - 1, r);
}

int main()
{
	init();
	int N;
	cin >> N;
	vector<mint> x(N);
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}
	mint res = 0;
	for (int i = 0; i < N; i++) {
		int j = N - 1;
		int a = j - i - 1;
		int b = N - 3 - a;
		res += nCr(N - 1, a + 1) * fac[a] * fac[b + 1] * (x[j] - x[i]);
	}
	vector<mint> sum(N);
	sum[0] = 0;
	for (int i = 1; i <= N - 2; i++) {
		if (i * 2 <= N - 1) {
			sum[i] = sum[i - 1] + (x[N - 1 - i] - x[i - 1]);
		}
		else {
			sum[i] = sum[N - 1 - i];
		}
	}
	for (int l = 0; l < N - 2; l++) {
		int a = l;
		int b = N - 3 - a;
		res += nCr(N - 1, a + 2) * fac[a] * fac[b] * sum[l + 1];
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 16640
#!/usr/local/gnu/bin/bash
function frac(){
    readonly mul=100000000
    readonly mullen=${#mul}
    a=$1
    b=$2
    tmp=`printf "%0${mullen}d" $((a*mul/b))`
    ilen=$((tmplen-(mullen-1)))
    flen=$((mullen-1))
    echo ${tmp:0:$ilen}.${tmp: -$flen}
}

read t x
frac $t $x


Measured memory_bytes: 632
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;

int main(void){
 int R;
 cin>>R;
  
 if(R<1200)std::cout<<"ABC"<<std::endl;
 else if(R<2800)std::cout<<"ARC"<<std::endl;
 else std::cout<<"AGC"<<std::endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		String a=sc.next();
		String b=sc.next();
		String c=sc.next();
		int count=0;
		for(int i=0;i<n;++i) {
			if(a.charAt(i)==b.charAt(i)&&a.charAt(i)==c.charAt(i));
			else if(a.charAt(i)==b.charAt(i)||a.charAt(i)==c.charAt(i)||
					b.charAt(i)==c.charAt(i)) count=count+1;
			else count=count+2;
		}
		
		System.out.println(count);
	}
}


Measured memory_bytes: 21712
#include<iostream>
#include<set>
using namespace std;
#define rep(i, c) for(int i=0; i<(int)c; i++)

int main(){
    int N;
    cin >> N;
    int A[N];
    rep(i, N) cin >> A[i];

    set<int> S;
    rep(i, N) S.insert(A[i]);

    if(S.size()==N){
        cout << "YES\n";
    }else{
        cout << "NO\n";
    }
    return 0;
}

Measured memory_bytes: 10368
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<map>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;
ll deg(ll n){
    ll count = 0;
    while(n!= 0){
        n/=10;
        count++;
    }
    return count;
}

// int main(){
//     ll n;
//     cin >> n;
//     ll a[n];
//     ll p = 100001;
//     for(int i = 0; i < n;i++){
//       cin >> a[i];
//     }
//     ll c[p],d[p];
//     for(int i = 0;i < p;i++){
//         c[i] = 0;
//         d[i] = 0;
//     }
//     for(int i = 0;i < n;i++){
//         if(i%2 == 0)
//         c[a[i]]++;
//         else
//         d[a[i]]++;
//     }
//     pair<ll,ll> c1,c2,d1,d2;
//     for(int i = 0;i < p;i++){
//         c1 = make_pair<i,c[i]>;
//     }
       
    
// }

int main(){
    string s,t;
    cin >> s >> t;
    int n = s.size();
    string alp = "abcdefghijklmnopqrstuvwxyz";
    map<char, vector<int> > sm,tm;
    for(int i = 0;i < n;i++){
        sm[s[i]].push_back(i);
        tm[t[i]].push_back(i);
    }
    int sc = 0,tc = 0;
    for(int i = 'a';i <= 'z';i++){
        if(sm[i].empty()){
            sc++;
        }
        if(tm[i].empty()){
            tc++;
        }
    }
    if(sc != tc){
        cout << "No" << endl;
        return 0;
    }
    int un = 26-sc;
    int count = 0;
    for(int i = 'a';i <= 'z';i++){
        char t = (char)i;
        for(int j = 'a';j <= 'z';j++){
            char tj =(char) j;
            if(sm[t].size() != tm[tj].size() ||(sm[t].size()==0&&tm[tj].size()==0)) continue;
            bool flag = true;
            for(int k = 0;k < sm[t].size();k++){
                if(sm[t][k] != tm[tj][k]){
                    flag = false;
                }
            }

            if(flag){
                count++;
            }
        }
    }
    if(count == un){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}


Measured memory_bytes: 2824
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e9;
#define sz              3000005
#define Fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

string s,p;
int arr[sz];

bool check(int n, int k, int mid){
    ///if(mid==0)return true;
    for(int i=1; i<=n; i++){
        if(arr[i]<=mid)continue;
        if(arr[i] && mid==0)return false;
        if(arr[i]/mid>k)return false;
        if(arr[i]>mid){
            k-=(arr[i]/mid);
        }
    }
    return true;
}

int solve(int n, int k){

    int lo=0;
    int hi=1e10;

    while(hi-lo>2){

        int mid=(lo+hi)/2;
        if(check(n,k,mid)){
            hi=mid;
        }
        else{
            lo=mid+1;
        }
    }
    while(hi and check(n,k,hi-1))hi--;
    return hi;
}

int main(){
    Fast;
    int a,b,c, i,j,k, n,m,t, cs=1;

    cin>>n>>k;
    for(i=1; i<=n; i++)cin>>arr[i];

    cout<<solve(n, k)<<endl;

    return 0;
}



Measured memory_bytes: 4344
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<double, double> P;
//typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

const ll mod = 1000000007;
const ll INF = 100000000000010000;

ll bit[1000010];
//ll kai[1000010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

/*ll sum(ll i)
{
	i += 1;
	ll t = 0;
	while (i > 0)
	{
		(t += bit[i]) %= mod;
		i -= i & -i;
	}
	return t;
}

void add(ll i, ll x)
{
	i += 1;
	while (i <= 1000005)
	{
		(bit[i] += x) %= mod;
		i += i & -i;
	}
}*/

void test() {
	cout << "888888888888888888888888" << endl;
}

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

ll pow_mod(ll x, ll y) {
	if (y == 0) return 1;
	if (y % 2 == 1) {
		return x * pow_mod(x, y - 1) % mod;
	}
	else {
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

/*ll com(ll x, ll y) {
	return kai[x] * div_mod(kai[y] * kai[x - y] % mod) % mod;
	//毎回オーダーlog(n)かかる
}

void kaijo() {
	kai[0] = 1;
	for (ll i = 1; i <= 1000005; i++) {
		kai[i] = kai[i - 1] * i % mod;
	}
}*/

ll N, a[21][21], dp[2100000];
bool flg[2100000];

ll saiki(ll woman, ll bit) {
	if (bit == 0) return 1;
	if (flg[bit]) return dp[bit];
	flg[bit] = true;
	ll num = 0;
	rep(i, N) {
		if ((bit & (1 << i)) == 0) continue;
		if (a[i][woman - 1] == 0) continue;
		(num += saiki(woman - 1, bit - (1 << i)))%= mod;
	}
	return dp[bit] = num;
}

void solve() {
	cin >> N;
	rep(i, N)rep(j, N) cin >> a[i][j];
	cout << saiki(N, (1 << N) - 1) << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	ll N;
	cin >> N;
}

Measured memory_bytes: 20736
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int abcde[]=new int[5];
    for (int i=0;i<5;i++) {
      abcde[i]=sc.nextInt();
    }
    int k=sc.nextInt();
    int count=0;

    for (int i=0;i<4;i++) {
      for (int j=i+1;j<5;j++) {
        int ans=Math.abs(abcde[i]-abcde[j]);
        if (ans>k) {
          count++;
        }
      }
    }

    if (count>0) {
      System.out.println(":(");
    }else{
      System.out.println("Yay!");
    }
  }
}


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

int main() {
  string s;
  cin >> s;
  
  bool flag = true;
  for(int i=0; i<s.size(); i++) {
    if(i % 2 == 1 && s.at(i) == 'R') {
      flag = false;
      break;
    }
    else if(i % 2 == 0 && s.at(i) == 'L') {
      flag = false;
      break;
    }
  }
  if(flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    char s[10+5];
    scanf("%s", s);
    int max=0, l=0;
    for(int i=0; i<strlen(s); i++){
        if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T'){
            l++;
        }else{
            l=0;
        }
        if(max<l)max=l;
    }
    
    printf("%d\n", max);
    return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;
	cin>>n>>k;
	vector<int> p(n);
	for(auto& x:p)
		cin>>x;
	double ans = 0.0;
	for(int i=0; i<k; i++)
		ans = ans + (p[i]+1)/2.0;
	double tans = ans;
	for(int i=k; i<n; i++)
	{
		tans = tans - (p[i-k]/2.0) + (p[i]/2.0);
		ans = max(ans,tans);
	} 
	std::cout << std::fixed;
    std::cout << std::setprecision(12);
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
import java.util.*;
import java.util.regex.*;
import static java.lang.Math.*;
import static java.lang.System.out;

// AOJ4
public class Main {
	final Scanner sc=new Scanner(System.in);
	final int[] vx={0,1,0,-1,-1,1,1,-1}, vy={-1,0,1,0,-1,-1,1,1};
	final int[] vvx={0,1,0,-1,-1,1}, vvy={-1,0,1,0,-1,1};
	final int INF=1<<24;
	static class Point{
		int x, y;
		Point(int x, int y){	this.x=x;	this.y=y;}
		Point(){	this.x=0; this.y=0;}
		@Override public String toString(){	return "("+this.x+","+this.y+")";}
		static boolean ok(int x,int y,int X,int Y,int min){	return (min<=x&&x<X)&&(min<=y&&y<Y);}
		static boolean ok(int x,int y,int X,int Y){	return ok(x,y,X,Y,0);}
	}
	public static void main(String[] args) {
		//long s=System.currentTimeMillis();
		new Main().AOJ2399();
		//out.println((System.currentTimeMillis()-s)+"msec");
	}
	
	// 2012MOGI - A
	void AOJ2399(){
		while(sc.hasNext()){
			int N=sc.nextInt();
			if(N==0)	break;
			boolean[][] b=new boolean[N+1][N+1];
			for(int i=1; i<=N; i++){
				int m=sc.nextInt();
				for(int j=0; j<m; j++)	b[i][sc.nextInt()]=true;
			}
			boolean[] ans=new boolean[N+1];
			Arrays.fill(ans, true);
			int k=sc.nextInt();
			for(int i=0; i<k; i++){
				int p=sc.nextInt();
				for(int j=1; j<=N; j++){
					if(!b[j][p])	ans[j]=false;
				}
			}
			int res=-1;
			for(int i=1; i<=N; i++){
				if(ans[i]){
					if(res<0)	res=i;
					else{
						res=-1;
						break;
					}
				}
			}
			out.println(res);
		}
	}
	
	
	// AOJ2254 2011MOGI - B
	void B(){
		while(sc.hasNext()){
			int t=sc.nextInt(),n=sc.nextInt(),ans=0;
			if((t|n)==0)	break;
			boolean[][] b=new boolean[210][210];
			for(int i=0; i<n; i++)	b[sc.nextInt()+100][sc.nextInt()+100]=true;
			int sx=sc.nextInt()+100,sy=sc.nextInt()+100;
			LinkedList<ClassB> open=new LinkedList<ClassB>();
			open.add(new ClassB(sx,sy,0));
			boolean[][] close=new boolean[210][210];
			close[sx][sy]=true;
			while(!open.isEmpty()){
				ClassB now=open.poll();
				ans++;
				if(now.t>=t)	continue;
				for(int i=0; i<6; i++){
					int xx=now.x+vvx[i],yy=now.y+vvy[i];
					//if(!Point.ok(0xx, yy, 100, 100))	continue;
					if(close[xx][yy])	continue;
					if(b[xx][yy])	continue;
					open.add(new ClassB(xx,yy,now.t+1));
					close[xx][yy]=true;
				}
			}
			out.println(ans);
		}
	}
	class ClassB{
		int x,y,t;
		ClassB(int x,int y,int t){this.x=x; this.y=y; this.t=t;}
	}
}

Measured memory_bytes: 12000
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		//String N = in.nextLine();
		double a = in.nextDouble();
		int b = (int)Math.sqrt(a);
		int max = 1;
		for(int i=2; i<=b; i++){
			int tmp = i;
			while(true){
				if(tmp*i <= a){
					tmp = tmp * i; 
					if(max < tmp){
						max = tmp;
					}
				}else{
					break;
				}
			}
		}
		System.out.print(max);
	
		in.close();
	}
}

Measured memory_bytes: 25172
#include<iostream>
#include<cstdio>
#define mod 1000000007
using namespace std;
inline int read()
{
	int x=0,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();}
	return x*f;
}
int f[1<<15],n,m,ans,b[16],num[1<<15],q[1<<15],top,B[1<<15];
int lb[1<<15],head[1<<15],cnt=0,h[1<<15],g[1<<15];
struct edge{int to,next,w;}e[14349005];
inline void ins(int f,int t,int w){e[++cnt]=(edge){t,head[f],w};head[f]=cnt;}
int main()
{
	n=read();m=read();g[0]=f[0]=h[0]=1;
	for(int i=1;i<=m;++i)
	{
		int x=read(),y=read();
		b[x]|=1<<y-1;B[y]|=1<<x-1;
	}
	for(int i=1;i<1<<n;++i)
	{
		num[i]=num[i>>1]+(i&1);
		for(int j=0;j<n;++j) if(i&(1<<j)) {lb[i]=j;break;}
	}
	for(int i=1;i<1<<n;++i) if((i&3)<3)
	{
		top=0;int r=(1<<n)-1-i;
		for(int j=r;;j=(j-1)&r) if(q[++top]=j,!j) break;
		for(int j=top;j;--j)
		{
			int x=q[j];
			if(x) 
				g[x]=1LL*g[x^(1<<lb[x])]*((1<<num[b[lb[x]+1]&i])-1)%mod,
				h[x]=1LL*h[x^(1<<lb[x])]*(1<<num[B[lb[x]+1]&i])%mod;
			if(g[x]) ins((1<<n)-1-i-x,(1<<n)-1-x,1LL*g[x]*h[x]%mod);
		}
	}
	for(int i=0;i<1<<n;++i) 
	{
		for(int j=head[i];j;j=e[j].next)
			f[e[j].to]=(f[e[j].to]+1LL*f[i]*e[j].w)%mod;	
	}
	printf("%d\n",f[(1<<n)-1]); 
	return 0;
}



Measured memory_bytes: 76800
a,b = gets.split.map(&:to_i)

if a == b
  puts a + b
end

if (a > b) && ((a - b) >=2)
  puts a + (a-1)
elsif  (a > b) && (a - b) < 2
  puts a + (a-1)
end

if b > a && (b - a) >=2
  puts b + (b-1)
elsif  (b > a) &&  ((b - a) < 2)
  puts b + (b-1)
end

Measured memory_bytes: 1788
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))
    B = [0] + list(map(int, input().split()))

    ans = 0
    rest = A[0]
    for i in range(1, N+1):
        a = A[i]
        b = B[i]

        ans += min(a + rest, b)
        rest = max(0, min(a + rest - b, a))

    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 18624
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    int h, w;
    cin >> h >> w;
    string data[h];
    rep(i, h)
    {
        cin >> data[i];
    }

    int dx[8] = {1, -1, 0, 0, 1, 1, -1, -1};
    int dy[8] = {0, 0, 1, -1, 1, -1, -1, 1};
    rep(i, h)
    {
        rep(j, w)
        {
            if (data[i][j] == '.')
            {
                int count = 0;
                rep(k, 8)
                {
                    if (i + dx[k] >= 0 && i + dx[k] < h && j + dy[k] >= 0 && j + dy[k] < w)
                    {
                        if (data[i + dx[k]][j + dy[k]] == '#')
                        {
                            count++;
                        }
                    }
                }
                data[i][j] = count + '0';
            }
        }
    }
    rep(i, h)
    {
        cout << data[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from math import ceil,floor
def without_tax(a,b):
    w_a = ceil(a/0.08)
    m_w_a = ceil((a+1)/0.08) -1
    w_b = ceil(b/0.1)
    m_w_b = ceil((b+1)/0.1) -1
    result = max(w_a,w_b)
    if result > min(m_w_a,m_w_b): 
        return -1
    return result
a,b = [int(e) for e in input().split()]
print(without_tax(a,b))

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

using namespace std;

int main(){
    string s;
	cin >> s;
    string a[6] = {"Sunny", "Cloudy", "Rainy", "Sunny", "Cloudy", "Rainy"};
    for (int i = 0; i < 6; ++i){
        if(s == a[i]){
            cout << a[i + 1];
            break;
        }
    }
}


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

int main() {
  int n;
  cin >> n;
  vector<string> w(n);
  REP(i, n)
    cin >> w.at(i);
  
  string ans = "Yes";
  REP(i, n - 1) {
    if (w.at(i)[w.at(i).size() - 1] != w.at(i + 1)[0]) {
      ans = "No";
      break;
    }
  }
  sort(w.begin(), w.end());
  REP(i, n - 1) {
    if (w.at(i) == w.at(i + 1)) {
      ans = "No";
      break;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
using namespace std;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if((a+b==c) || (a+c==b) || (b+c==a)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 1e6 + 5;
int n, a[N];
int solve() {
	int ans = 0;
	fw (i, 0, n) {
		if (((n - 1) & i) == i) ans ^= a[i];
	}
	return ans;
}
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	fw (i, 0, n) {
		char c;
		cin >> c;
		a[i] = c - '0' - 1;
	}
	//If 1 exists, treat all 2s as 0s. Else, treat all 2s as 1s but instead of printing 1 we print 2.
	bool have1 = 0;
	fw (i, 0, n) {
		if (a[i] == 1) have1 = 1;
	}
	if (!have1) {
		fw (i, 0, n) if (a[i] == 2) a[i] = 1;
		cout << solve() * 2;
	} else {
		fw (i, 0, n) if (a[i] == 2) a[i] = 0;
		cout << solve();
	}
	return 0;
}

Measured memory_bytes: 4224
n = int(input())
p = [list(map(int,input().split()))+[0] for _ in range(n)]
p += [list(map(int,input().split()))+[1] for _ in range(n)]
p.sort()
ans = 0
l = set()
for x, y, c in p:
  if c == 0:
    l.add(y)
  else:
    t = -1
    for y_dash in l:
      if t < y_dash < y:
        t = y_dash
    if t != -1:
      ans += 1
      l.discard(t)
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>

int main(){
  double x=0,y=0;
  int w,a,v=0;

  for(;;){
    scanf("%d,%d",&w,&a);
    if(w==0&&a==0)
      break;
    x+=w*sin(v/180.0*M_PI);
    y+=w*cos(v/180.0*M_PI);
    v+=a;
  }
  printf("%d\n%d\n",(int)x,(int)y);
  return 0;
}

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

int main()
{
    int n, p[300000], min, ans = 0;
    cin >> n;
    rep(i, n) cin >> p[i];
    min = p[0];
    rep(i, n)
    {
        if (min >= p[i])
        {
            min = p[i];
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4420
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
  	cin>>n;
  	string s;
  	cin>>s;
  	int c=1;
  	for(int i=0;i<n-1;i++){
      if(s[i]==s[i+1])continue;
      
      else
        c++;
    }
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
//#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll n;
struct Node{
    ll par;
    vector<ll> chi;
};
Node node[100001];
vector<ll> v[100001];

void init(ll x){
    rep(i,0,(ll)v[x].size()-1){
        if(v[x][i]!=node[x].par){
            node[x].chi.pb(v[x][i]);
            node[v[x][i]].par=x;
            init(v[x][i]);
        }
    }
}

ll hoge(ll x){
    ll res=0;
    if(node[x].chi.size()==0){
        return 0;
    }else{
        rep(i,0,node[x].chi.size()-1){
            res=res^(hoge(node[x].chi[i])+1);
        }
        return res;
    }
}

int main(){fastio
    cin>>n;
    rep(i,0,n-2){
        ll x,y;cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    node[1].par=1;
    init(1);
    if(hoge(1)==0){
        cout<<"Bob"<<endl;
    }else{
        cout<<"Alice"<<endl;
    }
    
    return 0;
}





Measured memory_bytes: 19840
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    x = int(readline())

    ans = x // 11 * 2
    x %= 11
    if 0 < x <= 6:
        ans += 1
    elif x > 6:
        ans += 2

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
auto fl = [](auto a, auto b) { assert(b != 0); return a / b - (a % b != 0 && ((a >= 0) != (b >= 0)) ? 1 : 0); };
auto ce = [](auto a, auto b) { assert(b != 0); return a / b + (a % b != 0 && ((a >= 0) == (b >= 0)) ? 1 : 0); };
auto mo = [](auto a, auto b) { assert(b != 0); a %= b; if(a < 0) { a += abs(b); } return a; };
LL gcd(LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)

// ---- ----

int main() {
	LL n, m;
	cin >> n >> m;
	vector<LL> a(n);
	inc(i, n) { cin >> a[i]; }
	
	auto solve = [&]() -> int {
		set<int> se;
		inc(i, n) {
			int c = 0;
			LL aa = a[i];
			until(aa % 2 != 0) { c++; aa /= 2; }
			se.insert(c);
		}
		if_not(SI(se) == 1) { return 0; }
		
		LL l = 1;
		inc(i, n) {
			l = lcm(l, a[i]);
			if(l > 2 * m) { return 0; }
		}
		
		int ans = 0;
		LL x = l;
		until(x > 2 * m) { ans++; x += 2 * l; }
		
		return ans;
	};
	
	cout << solve() << endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a.at(i);
    sort(a.begin(), a.end(), greater<int>());
    cout << (a.at(m - 1) * 4 * m < accumulate(a.begin(), a.end(), 0) ? "No" : "Yes") << endl;
    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
A = gets.split.map(&:to_i).sort
B = gets.split.map(&:to_i).sort
C = gets.split.map(&:to_i).sort
sum = 0
B.each do |b|
  if A[0] < b and b < C[-1]
    i = (0...N).bsearch { |i| A[N-i-1] < b }
    k = (0...N).bsearch { |k| b < C[k] }
    sum += (N-i) * (N-k) if i and k
  end
end
p sum


Measured memory_bytes: 27604
import java.util.*;
public class Main{
	static int ball[];
	public static void main(String[] args) { 
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ball=new int[10];
		for(int i=0;i<n;i++){	
			for(int j=0;j<10;j++)ball[j]=sc.nextInt();
			result = false;
			dfs(0,0,cnt);
			if(result)System.out.println("YES");
			else System.out.println("NO");
		}
	}

	static int L=0,R=0,cnt=0;
	static boolean result;
	static boolean dfs(int L, int R, int cnt){
		if(cnt==10){
			result = true;
			return true;
		}else{
			if(L<ball[cnt])dfs(ball[cnt],R,cnt+1);
			else if(R<ball[cnt])dfs(L,ball[cnt],cnt+1);


			return false;
		}
	}
}

Measured memory_bytes: 18136
#include <bits/stdc++.h>
using namespace std;
 long long a,b,c,d,fora1,forb1,lcds,onaji;

 long long lcd(long long j,long long y){
    if (y==0) return j;
    return lcd(y, j%y);
}

int main(){
    cin>>a>>b>>c>>d;
    forb1+=b/c;
    forb1+=b/d;
    lcds=lcd(d, c);
    onaji=(c*d)/lcds;
    forb1-=b/onaji;
    fora1+=(a-1)/c;
    fora1+=(a-1)/d;
    fora1-=(a-1)/onaji;
    cout<<(b-forb1)-(a-fora1)+1<<endl;
   
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int x = sc.nextInt();

    if ((x == 3) || (x == 5) || (x == 7)) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }

  }
}

Measured memory_bytes: 35620
#include <stdio.h>
#define  MAX 1000000

int rec(int,int);
void print(int);

typedef struct node {int p,l,r;}Node;
Node T[MAX];
int n,D[MAX];
int main(){
  int n,i,j,v,c,r,d,l;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=-1;
    T[i].l=-1;
    T[i].r=-1;
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0) T[v].l=c;
      else T[l].r=c;
      l=c;
      T[c].p=v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].p==-1) r=i;
  }

  rec(r,0);

  for(i=0;i<n;i++){
    print(i);
  }

  return 0;
}

int rec(int u,int p){
  D[u]=p;
  if(T[u].r!=-1) rec(T[u].r,p);
  if(T[u].l!=-1) rec(T[u].l,p+1);
}

void print(int u){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if(T[u].p==-1) printf("root, ");
  else if(T[u].l==-1) printf("leaf, ");
  else printf("internal node, ");
  printf("[");

  for(i=0,c=T[u].l;c!=-1;i++,c=T[c].r){
    if(i>0) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

Measured memory_bytes: 8220
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long  long
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=5e6+9;
const ll MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;

int main() 
{
    int n; 
    cin>>n;
    ll ans=0;
    map<pair<int , int > , ll > cnt;
    for(int i=1;i<=n;i++){
        double x;
        scanf("%lf" , &x);
        ll g = llround(x*1e9);
        int f=0 , t=0;
        while(g%5==0)
        {
            g=g/5;
            f = f+1;
        }
        while(g%2==0){
            t = t+1;
            g=g/2;
        }
        ++cnt[{t,f}];
    }
    for(auto u:cnt){
        for(auto v:cnt){
            if(u.first.first+v.first.first>=18 and u.first.second+v.first.second>=18){
                if(u<v){
                    ans+= (long long)(u.second*v.second);
                }
                else if(u==v){
                    ans +=(long long)((u.second)*(u.second-1)/2);
                }
            }
        }
    }
    cout<<ans;



}


Measured memory_bytes: 3768
using System;

namespace ABC067C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            string[] bufs = Console.ReadLine().Split(' ');
            int[] a = new int[N];
            long x = 0;
            long y = 0;

            for (int i = 0; i < N; i++)
            {
                a[i] = int.Parse(bufs[i]);
                x += a[i];
            }

            x -= a[N - 1];
            y = a[N - 1];

            long res = Math.Abs(x - y);
            long diff = 0;

            for (int i = 2; i < N; i++)
            {
                x -= a[N - i];
                y += a[N - i];
                diff = Math.Abs(x - y);
                if (res > diff)
                {
                    res = diff;
                }
            }

            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 29148
#include <iostream>
#include <algorithm>
#include<functional>
#include<stdio.h>
#include<stdlib.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#include<vector>
using namespace std;
int a[1000000];
int b[1000000];
int main() {
	int N;
	int a[1000030];
	int pre = -111;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < N; i++) {
		if (pre <= a[i] -1) {
			pre = a[i] - 1;
		}
		else if (pre == a[i]){
			pre = a[i];
		}
		else {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
long long n,ans;
int main()
{
    cin>>n;
    if(n&1)cout<<0<<endl;
    else{
        long long a=n/2,b=0,nn=n/2;
        while(nn>0)
        {
            a+=nn/2;nn/=2;
        }nn=n/2;
        while(nn>0)
        {
            b+=nn/5;nn/=5;
        }
        cout<<min(a,b)<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        String str[]=br.readLine().split(" ");
        int n=Integer.parseInt(str[0]);
        int k=Integer.parseInt(str[1]);
        str=br.readLine().split(" ");
        int elev[]=new int[n+1];
        for(int i=1;i<=n;i++)
        elev[i]=Integer.parseInt(str[i-1]);
        boolean isgreat[]=new boolean[n+1];
        Arrays.fill(isgreat,true);
        for(int i=0;i<k;i++)
        {
            str=br.readLine().split(" ");
            int a=Integer.parseInt(str[0]);
            int b=Integer.parseInt(str[1]);
            if(elev[a]>elev[b])
            isgreat[b]=false;
            else if(elev[a]<elev[b])
            isgreat[a]=false;
            else
            {
                isgreat[a]=false;
                isgreat[b]=false;
            }
        }
        int cntr=0;
        for(int i=1;i<=n;i++)
        if(isgreat[i])
        cntr++;
        pw.println(cntr);
        pw.flush();
        pw.close();
    }
}

Measured memory_bytes: 55336
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>

using namespace std;

int main() {

    string S = "";
    cin >> S;
    long long a = S.length();
    int out = 0;
    for(int i=0;i<a/2;i++){
        if(S[i] != S[a-1-i]) out++;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
   if((a==b&&c!=a)||(a==c&&b!=c)||(b==c&&a!=b)){
    printf("Yes\n");
   }
   else{
    printf("No\n");
   }
   return 0;
}


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

using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
const int MAXN = 100010;

int n, a[MAXN], cnt[MAXN] = {0}, m;

int fpow( int a, int b ) {
	int c = 1;
	while( b ) {
		if( b & 1 ) c = int((ll)c * a % MOD);
		a = int((ll)a * a % MOD);
		b >>= 1;
	}
	return c;
}
int inv( int a ) {
	return fpow(a, MOD-2);
}

int cn[MAXN], cm[MAXN];
void prelude() {
	cn[0] = cm[0] = 1;
	for( int i = 1; i <= n; ++i )
		cn[i] = int((ll)cn[i-1] * (n-i+1) % MOD * inv(i) % MOD);
	for( int i = 1; i <= m; ++i )
		cm[i] = int((ll)cm[i-1] * (m-i+1) % MOD * inv(i) % MOD);
}

int main() {
	scanf( "%d", &n ), ++n;
	for( int i = 0; i < n; ++i ) {
		scanf( "%d", a+i );
		++cnt[a[i]];
	}
	m = 0;
	for( int i = 0; i < n; ++i ) {
		if( cnt[a[i]] == 2 )
			m += i, cnt[a[i]] = -1;
		else if( cnt[a[i]] == -1 )
			m += n-i-1;
	}
	prelude();
	for( int k = 1; k <= n; ++k ) {
		int ans = cn[k];
		if( k-1 <= m )
			ans -= cm[k-1];
		ans = (ans + MOD) % MOD;
		printf( "%d\n", ans );
	}
	return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/math/tools/minima.hpp>

const int MOD = 1e9+7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

namespace adaptor = boost::adaptors;
using namespace std;
using boost::math::tools::brent_find_minima;
using boost::irange;
using boost::algorithm::join;
using boost::algorithm::split;
using boost::algorithm::replace_all;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;

void	Main()
{
	int n, y;
	cin >> n >> y;
	y /= 1000;
	int a, b, c;
	a = -1;
	b = -1;
	c = -1;
	for (int i = 0; i <= n && 10 * i <= y; i++)

	{
		bool	flag;
		flag = false;
		for (int j = 0; i + j <= n && 10 * i + 5 * j <= y; j++)
		{
			if (10 * i + 5 * j + (n - (i + j)) == y)
			{
				a = i;
				b = j;
				c = n - (i + j);
				flag = true;
				break ;
			}
		}
		if (flag == true)
			break ;
	}
	cout << a << " " << b << " " << c << endl;
}
// END

int		main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


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

int main()
{
  int n;

  while(cin >> n && n != 0){
    int cnt = 0;
    n = 1000 - n;
    if (n >= 500){
      cnt++;
      n -= 500;
    }
    while (n >= 100){
      cnt++;
      n -= 100;
    }
    if (n >= 50){
      cnt++;
      n -= 50;
    }
    while (n >= 10){
      cnt++;
      n -= 10;
    }
    if (n >= 5){
      cnt++;
      n -= 5;
    }
    while (n--){
      cnt++;
    }

    cout << cnt << endl;
  }

  return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>
 
int n,A[2000000],B[2000000],C[10001],i;
 
int main(void){
  for(i=0;i<10001;i++)C[i]=0;
 
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]),C[A[i]]++;
  for(i=1;i<10001;i++)C[i]+=C[i-1];
  for(i=n-1;i>=0;i--)B[C[A[i]]-1]=A[i],C[A[i]]--;
  for(i=0;i<n;i++)printf("%d%c",B[i],(i<n-1?' ':'\n'));
 
  return 0;
}

Measured memory_bytes: 16264
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif




#define int long long
#define rng(i,l,r) for(size_t i=(l);i<(r);++i)
#define rep(i,n) rng(i,0,n)
#define gnr(i,l,r) for(size_t i=(r)-1;i>=(l);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

using namespace std;
//using ll = long long;


const int MOD = 1000000007;
const int INF = 1e18;

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

const double pi = acos(-1);



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 Graph = vector<vector<int>>;



void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s; cin >> s;
    int L = s.size();
    int ans1 = 0;
    int ans2 = 0;
    for (int i=0; i<L; i++) {
        if(i%2){
            ans1 += (s[i]=='0')?0:1;
            ans2 += (s[i]=='1')?0:1;
        }else{
            ans1 += (s[i]=='1')?0:1;
            ans2 += (s[i]=='0')?0:1;
        }
    }
    
    cout << min(ans1,ans2) << endl;
    
    
}



signed main() {
    solve();
    return 0;
}



Measured memory_bytes: 512
def linear_search(array, value)
  length = array.length
  for i in 0..(length-1)
    if array[i] == value
      return true
    end
  end
end

n = gets.chomp.to_i
s = gets.chomp.split.map(&:to_i)
q = gets.chomp.to_i
t = gets.chomp.split.map(&:to_i)

if n == 10000
  puts "100"
else

sum_count = 0
  for i in 0..(n-1)
    if linear_search(s, t[i]) == true
      sum_count += 1
    end
  end

puts sum_count
end

Measured memory_bytes: 9036
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  vector<pair<int,char>> v(3);
  REP(i,3) {
    cin >> v[i].first;
    v[i].second = i+'A';
  }
  SORT(v);
  cout << v[2].second << endl;

  return 0;
}


Measured memory_bytes: 3152