akhauriyash/Code-Regression huggingface dataset:
// Copyright (C) 2017 __debug.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>

#define x first
#define y second
#define MP std::make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

using std::pair;
using std::vector;
using std::string;

typedef long long LL;
typedef pair<int, int> Pii;

const int oo = 0x3f3f3f3f;

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; }
string procStatus()
{
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        f = (ch == '-' ? -1 : 1);
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
template<typename T> void write(T x)
{
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[20];
    int top = 0;
    for (; x; x /= 10)
        s[++top] = x % 10 + '0';
    while (top)
        putchar(s[top--]);
}
// EOT

const int MAXN = 1e3 + 5;

LL X, Y;

void input()
{
    read(X); read(Y);
}

void solve()
{
    puts(std::abs(X - Y) <= 1 ? "Brown" : "Alice");
}

int main()
{
#ifdef __DEBUG
    freopen("D.in", "r", stdin);
    freopen("D.out", "w", stdout);
#endif

    input();
    solve();

    return 0;
}

// 更无柳絮因风起，惟有葵花向日倾。
//     -- 司马光《客中初夏》


Measured memory_bytes: 256
import math
N = int(input())

C = []
S = []
F = []
for _ in range(N - 1):
    c, s, f = map(int, input().split())
    C.append(c)
    S.append(s)
    F.append(f)


for i in range(N - 1):
    count = 0
    count += S[i]
    count += C[i]
    for j in range(i + 1, N - 1):
        if count < S[j]:
            count = S[j]
        else:
            count = math.ceil((count - S[j]) / F[j]) * F[j] + S[j]
        count += C[j]
    print(count)
print(0)


Measured memory_bytes: 8932
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define pb push_back 
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)

using namespace std;

int n,m;
ll dp[(1<<20)];
vector<pair<int,int>>edges;
vector<int>adj[51];
int par[51];
map<pair<int,int>,int>mapping;
int mask[49];

void dfs(int node,int p)
{
    par[node] = p;
    for(auto it:adj[node])
    {
        if(it == p)
            continue;
        dfs(it,node);
    }
}

int main()
{
    IOS;
    cin >> n;
    for(int i = 1; i < n; i++)
    {
        int u,v;
        cin  >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
        edges.push_back({u,v});
        if(u > v)
            swap(u,v);
        mapping[{u,v}] = i-1;
    }
    dfs(1,-1);
    cin >> m;
    for(int i =0; i<m; i++)
    {
        int u,v;
        cin >> u >> v;
        set<int>s;
        int temp = u;
        while(temp != -1)
        {
            s.insert(temp);
            temp = par[temp];
        }
        temp = v;
        while(s.find(temp) ==  s.end())
            temp = par[temp];
        int lca = temp;
        temp = u;
        while(temp != lca)
        {
            int a = par[temp];
            int b = temp;
            if(a > b)
                swap(a,b);
            mask[mapping[{a,b}]] |= (1<<i);
            temp = par[temp]; 
        }
        temp = v;
        while(temp != lca)
        {
            int a = par[temp];
            int b = temp;
            if(a > b)
                swap(a,b);
            mask[mapping[{a,b}]] |= (1<<i);
            temp = par[temp]; 
        }
    }
    dp[0] = 1;
    for(int i = 0; i < n-1;i++)
    {
        for(int j = (1<<m)-1; j>=0; j--)
            dp[j|mask[i]] += dp[j];
    }
    cout << dp[(1<<m)-1];
}   

Measured memory_bytes: 8448
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	String a = sc.next();
      	String[] list = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
      	for(int i = 0;i<27;i++){
        	String b = list[i];
          	if(a == "z"){
            	break;
            }else if(a.equals(b)){
            	System.out.println(list[i+1]);
              	break;
            }
        }
    }
}

Measured memory_bytes: 22740
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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;
}

const int INF = 1e9;
const long long LINF = 1e18;

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

    vector<int> d(N);
    for (int i = 0; i < N; i++) {
        cin >> d[i];
    }

    long sum = 0;
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            sum += d[i] * d[j];
        }
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;

struct edge{
    int a;
    int b;
};

int main(){
    int n, q;
    vector<int> p, x, counter;
    vector<edge> e;

    cin >> n >> q;
    e.resize(n-1);
    p.resize(q);
    x.resize(q);
    counter.resize(n,0);

    for(int i=0; i<n-1; i++){
        cin >> e[i].a >> e[i].b;
    }
    for(int i=0; i<q; i++){
        cin >> p[i] >> x[i];
    }

    for(int i=0; i<q; i++){
        counter[p[i]-1] += x[i];
    }
    sort(e.begin(), e.end(), [](edge e1, edge e2) -> bool { return e1.b < e2.b; });
    for(int i=1; i<n; i++){
        counter[i] += counter[e[i-1].a-1];
    }

    for(int i=0; i<n; i++){
        cout << counter[i] << ' ';
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 6272
a, b, c, d = [int(i) for i in input().split()]

list_a = sorted([a, b, c])

if list_a[1] - a <= d and list_a[2] - list_a[1] <= d:
    print("Yes")
elif abs(a-c) <= d:
    print("Yes")
else:
    print("No")


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

typedef long long int ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ar array
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll mod = 1e9 + 7;
const ll inf = 2e9 + 5;
double PI = 3.14159265358979323846;

void solve() {

    int n,x,t;
    cin >> n >> x >> t;
    int k = (n+(x-1))/x;
    cout << k*t;
}

int32_t main()
{
    IOS
    // int T; cin >> T; while (T--)
    solve();
    return 0;
}


Measured memory_bytes: 3576
n = gets.chomp.to_i
s = []
n.times do |i|
  s[i] = gets.chomp
end

ans = 0
count_Bxxx = 0
count_xxxA = 0
count_BxxA = 0
n.times do |i|
  count_Bxxx += 1 if s[i][0] == 'B'
  count_xxxA += 1 if s[i][-1] == 'A'
  count_BxxA += 1 if s[i][0] == 'B' && s[i][-1] == 'A'
  ans += s[i].scan('AB').size
end

ans += [count_Bxxx, count_xxxA].min
ans -= 1 if (count_BxxA > 0) && (count_Bxxx == count_BxxA) && (count_xxxA == count_BxxA)

puts(ans)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main() 
{
  int a,b,c,d,e,f,g,h,i,j;
    cin>>a;
    set<int>s;
    int ar[a];
    int ans=0,sum=0;
    c=0,d=0;
    for(i=0;i<a;i++)
    {
        cin>>ar[i];
        if(ar[i]>=3200)
        {
            c++;
        }
        else{
            s.insert(ar[i]/400);
        }
    }
    ans=s.size()+c;
    if(s.size()==0){sum=1;}
    else{sum=s.size();}
 
    cout<<sum<<" "<<ans<<endl;
  system("pause");
}

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

int main (void)
{
    int i;
    double n;
    double ave=0;
    scanf("%lf",&n);
    int a[(int)n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        ave+=(double)a[i];
    }
    ave/=n;
    if(ceil(ave)-ave>=0.5)
    {
        ave=floor(ave);
    }else{
        ave=ceil(ave);
    }
    int ans=0;
    for(i=0;i<n;i++)
    {
        ans+=pow(a[i]-ave,2);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 2192
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N, M, r=0;
  cin >> N >> M;
  vector<int> vecm(M);
  
  for (int i = 0; i < M; i++) {
  	cin >> vecm.at(i);
    r = r+vecm.at(i);
  }
  if (N-r >= 0){
    cout << N - r << endl;
  }else{
    cout << -1 << endl;
  }
}

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

vector<int> dis;

int main()
{
	int n, x, y;
	cin >> n >> x >> y;

	dis = vector<int>(n, 0);

	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			int d;
			if (j <= x - 1) {
				d = j - i;
			} else if (i <= x - 1 && j <= y - 1) {
				d = min(j - i, ((x - 1) - i) + 1 + ((y - 1) - j));
			} else if (i <= x - 1 && j > y - 1) {
				d = ((x - 1) - i) + 1 + (j - (y - 1));
			} else if (i <= y - 1 && j <= y - 1) {
				d = min(j - i, (i - (x - 1)) + 1 + ((y - 1) - j));
			} else if (i <= y - 1 && j > y - 1) {
				d = min(j - i, (i - (x - 1) + 1 + (j - (y - 1))));
			} else {
				d = j - i;
			}
			dis.at(d)++;
		}
	}

	for (int i = 1; i < n; i++) {
		cout << dis.at(i) << endl;
	}
}



Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define ll long long
#define inf 0x3f3f3f3f
#define maxn 2010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20];
	int len=0;
	if(x<0)putchar('-'),x=-x;
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
ll calc(ll p,ll q,ll len)
{
	if(len<=0)return 0;
	ll x=(q-p)/2;
	if(0<=x&&x<len)return (ll)(p+x)*(q-x);
	else return std::max((ll)p*q,(ll)(p+len-1)*(q-len+1));
}
// ll calc(ll p,ll q,ll len)
// {
// 	ll ret=calc_(p,q,len);
// 	printf("%lld %lld %lld : %lld\n",p,q,len,ret);
// 	return ret;
// }
ll getmax(int mid,int a,int b)
{
	if(a>b)std::swap(a,b);
	if(mid<a)return calc(1,mid,mid);
	else if(mid<b)return std::max(calc(1,mid,a-1),calc(a+1,mid-a+1,mid-a+1));
	else if(a-1<=mid-b+1)return std::max(std::max(calc(1,mid+1,a-1),calc(mid-b+3,b-1,b-1)),calc(a+1,mid-a+2,mid-a-b+2));
	else return std::max(std::max(calc(1,mid+1,mid-b+1),calc(a+1,mid-a+1,mid-a+1)),calc(mid-b+2,b-1,a+b-mid-2));
}
int main()
{
	int T=read();
	while(T--){
		int a=read(),b=read();
		ll l=0,r=a+b;
		while(l<r){
			ll mid=(l+r+1)>>1;
			if(getmax(mid,a,b)<(ll)a*b)l=mid;
			else r=mid-1;
		}
		writeln(l);
	}
	// while(1){
	// 	int a=read(),b=read(),mid=read();
	// 	writeln(getmax(mid,a,b));
	// }
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD=1000000007;

//xのn乗をmodで割った余り//
ll mod_pow(ll x, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1){res=res*x%mod;}
    x=x*x%mod;  n>>=1;
  }
  return res;
}

int main(){
  long long H,W,A,B;
  cin >> H >> W >> A >> B;
  long long e[300000];
  e[0]=1;
  for(int i=1;i<=200000;i++){e[i]=e[i-1]*i%MOD;}
  long long ans=0;
  for(int i=B+1;i<=W;i++){
    long long q=e[H-A+i-2]%MOD;
    q=q*e[A+W-i-1]%MOD;
    q=q*mod_pow(e[H-A-1],MOD-2,MOD)%MOD;
    q=q*mod_pow(e[i-1],MOD-2,MOD)%MOD;
    q=q*mod_pow(e[A-1],MOD-2,MOD)%MOD;
    q=q*mod_pow(e[W-i],MOD-2,MOD)%MOD;
    ans=(ans+q)%MOD;
  }
  cout << ans << endl;
}

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

using namespace std;
int main(void){
    string s;
    cin>>s;
    if(s.find('a')!=-1&&s.find('b')!=-1&&s.find('c')!=-1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
# def input():
#     return sys.stdin.readline()[:-1]

# n = int(input())
# A = [input().split() for i in range(n)]

class Node():
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left = None
        self.right = None


def insert(key):
    global root
    x = root # x is current node
    y = None  #  parent of x 
    while x:
        y = x # set parent
        if key < x.key:
            x = x.left # move to left child
        else:
            x = x.right #move to right child
    
    if root is None:
        root = Node(key)
    elif key < y.key: # set z as left child of y
        y.left = Node(key)
    else: 
        y.right = Node(key) # set z as right child of y
        
        
def find(key):
    x = root
    while x:
        if key==x.key:
            print('yes')
            return
        elif key < x.key:
            x = x.left
        else:
            x = x.right
    print('no')
    

def inorder(inorder_list, node):
    if node.left is not None:
        inorder(inorder_list, node.left)
    inorder_list.append(str(node.key))
    if node.right is not None:
        inorder(inorder_list, node.right)
    return inorder_list
        
def preorder(preorder_list, node):
    preorder_list.append(str(node.key))
    if node.left is not None:
        preorder(preorder_list, node.left)
    if node.right is not None:
        preorder(preorder_list, node.right)
    return preorder_list
        
root = None

input()
for o in sys.stdin:
    if o[0]=='i':
        insert(int(o[7:]))
    elif o[0]=='f':
        find(int(o[5:]))
    else:
        x = root
        inorder_list = inorder([], x)
        print(' '+' '.join(inorder_list))
        preorder_list = preorder([], x)
        print(' '+' '.join(preorder_list))


Measured memory_bytes: 107700
#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define lb(x) ((x)&(-(x)))
#define xx first
#define yy second
#define pb push_back
#define mp make_pair
#define pii pair<int,int> 
#define dalao 1000000007
#define inf 0x3f3f3f3f
#define M (1<<26|1)
#define N 200010
using namespace std;
typedef long long ll;
int n,x,t,f[M];
char s[N];
int main(){
	scanf("%s",s),n=strlen(s);
	mset(f,0x3f),f[0]=0;
	for(int i=0;i<n;i++){
		s[i]-='a',x^=1<<s[i];
		t=f[x]+1;
		for(int j=0;j<26;j++)t=min(t,f[x^(1<<j)]+1);
		f[x]=min(f[x],t);
	}
	printf("%d",t);
	return 0;
}

Measured memory_bytes: 262656
#include <stdio.h>

int main(void) {
	int a,b,c; scanf("%d%d%d",&a,&b,&c);
	int temp = b+c-a;
	if (temp < 0) {
		printf("0\n");
	} else {
		printf("%d\n",temp);
	}
	
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
ll sieve[1000001]={0},i,j;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p);
p=(p*p);
k>>=1;
}
return a;
}
using namespace std;
  ll countDivisors(ll n) 
{ 
    ll cnt = 0; 
    for (ll i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            if (n / i == i) 
                cnt++; 
  
            else 
                cnt = cnt + 2; 
        } 
    } 
    return cnt; 
} 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 int tc=1;
//cin>>tc;
ll cas=1;
 while(tc--)
 {
	string s;
	cin>>s;
	if(s!="AAA" && s!="BBB")
	cout<<"Yes";
	else
	cout<<"No";
	cout<<"\n"; 
 } 
}


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

using namespace std;

const int N = 10;

int n, res;
int a[N], sum[4], need[4];

void dfs(int cur, int mp)
{
    if (cur > n) {
        int now = mp-30;
        for (int i = 1; i <= 3; ++i) {
            if (!sum[i]) return;
            now += abs(need[i]-sum[i]);
        }
        res = min(res, now);
        return;
    }

    dfs(cur+1, mp);
    for (int i = 1; i <= 3; ++i) {
        sum[i] += a[cur];
        dfs(cur+1, mp+10);
        sum[i] -= a[cur];
    }
}

int main()
{
    cin >> n;
    for (int i = 1; i <= 3; ++i) {
        cin >> need[i];
        res += need[i];
    }
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    dfs(1, 0);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vec vector<ll>
#define fl(i,from,to) for(ll i=from;i<to;i++)
#define um unordered_map<ll,ll>
#define pa pair<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define mod 1000000004
#define start ll t;cin>>t;while(t--)
#define inp(a) ll a;cin>>a
#define fasti  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll arr[104];
int main()
{
	inp(n);
	fl(i,0,n)
	{
		inp(a);arr[i]=a;
	}
	if(n<3){cout<<0<<endl;return 0;}
	ll a=arr[0],b=arr[1],c=arr[2],cnt=0;
	sort(arr,arr+n);
	fl(i,0,n)
	{
		a=arr[i];ll j=i+1;
		while(j<n)
		{
			b=arr[j];while((a==b)&&(j<n)){j++;b=arr[j];}ll k=n-1;
			if(b==a){cout<<0<<endl;return 0;}
			while(k>j)
			{
				c=arr[k];if(c==b){k--; continue;}
				if(c<(a+b))cnt++;
				k--;
			}
			j++;
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 3616
#include<stdio.h>
#include<string.h>
int main(){
  int k,len;
  scanf("%d",&k);
  char s[101];
  scanf("%s",s);
  len=strlen(s);
  if(len>k){
    for(int i=0;i<k;i++){
      printf("%c",s[i]);
    }
    printf("...");
    return 0;
  }
  printf("%s",s);
  return 0;
  
}


Measured memory_bytes: 1728
n = int(input())
town = []
for i in range(n):
    town.append([int(i) for i in input().split()])
distance = 0
for i in range(n):
    for j in range(i + 1, n):
        distance += ((town[i][0] - town[j][0])**2 + (town[i][1] - town[j][1])**2)**0.5
distance *= (2 / n)
print(distance)

Measured memory_bytes: 3188
from fractions import gcd
a,b,c,d = map(int,input().split())
def F(n,c,d):
  x = n
  x -= n//c
  x -= n//d
  l = c*d//gcd(c,d)
  x += n//l
  return x
print(F(b,c,d) - F(a-1,c,d))


Measured memory_bytes: 5048
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
    int n;
    cin>>n;
    vector<int> x(n);
    REP(i,n) cin>>x[i];

    vector<int> y=x;
    int b1,b2;
    sort(ALL(y));
    b1=y[y.size()/2-1]; b2=y[y.size()/2];
    REP(i,n){
        if(x[i]<=b1) cout<<b2<<endl;
        else cout<<b1<<endl;
    }

	return 0; 
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int a, b, c;
    cin >> a >> b >> c;
    if (a > b)
        swap(a, b);
    if (b > c)
        swap(b, c);
    if (a > b)
        swap(a, b);
    cout << a + b;
    return 0;
}
                

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    long long int N, M, a_i, b_i, a, b;
    long long int height[100000];
    long long int bad[100000] = {};
    cin >> N >> M;
    for(int i=0; i<N; i++){
        cin >> height[i];
    }
    long long int count =0;
    for(long long int i=0; i<M; i++){
        cin >> a_i >> b_i;
        a = a_i-1;
        b = b_i-1;
        if(bad[a]==0){
            if(height[a] <= height[b]){
                count++;
                bad[a] = 1;
            }
        }
        if(bad[b]==0){
            if(height[a] >= height[b]){
                count++;
                bad[b] = 1;
            }
        }
    }
    cout << N-count << endl;
    return 0;
}

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

char b[51][51];
Int d[51][51];

void solve() {
    Int h, w;
    cin >> h >> w;
    Int black = 0;
    for (Int i = 0; i < h; i++) {
        for (Int j = 0; j < w; j++) {
            cin >> b[i][j];
            if (b[i][j] == '#') {
                black++;
            }
            d[i][j] = INF;
        }
    }
    d[0][0] = 1;
    queue<pair<Int, Int>> q;
    q.push({0, 0});
    while (not q.empty()) {
        pair<Int, Int> p = q.front();
        q.pop();
        Int dy[] = {-1, 0, 1, 0};
        Int dx[] = {0, 1, 0, -1};
        for (Int i = 0; i < 4; i++) {
            Int ny = p.first + dy[i];
            Int nx = p.second + dx[i];
            if (ny < 0 or ny == h or nx < 0 or nx == w) continue;
            if (b[ny][nx] == '#') continue;
            if (d[ny][nx] > d[p.first][p.second] + 1) {
                d[ny][nx] = d[p.first][p.second] + 1;
                q.push({ny, nx});
            }
        }
    }
    if (d[h - 1][w - 1] == INF) {
        print(-1);
    } else {
        print(h * w - black - d[h - 1][w - 1]);
    }
}

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


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

bool dbgflag = false;

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

  int a, b;
  cin >> a >> b;

  int line = 0;

  cout << 2 + (((a - 2) / 50) + 1) * 2 + (((b - 2) / 50) + 1) * 2 << " " << 100 << endl;
  //まず黒埋め
  for (int i = 0; i < 100; i++) cout << '#';
  cout << endl;
  a--;
  while (1) {
    if (1) {
      if (a <= 50) {
        for (int i = 0; i < a; i++) cout << '#'  << '.';
        for (int i = 0; i < 100 - a*2; i++) cout << '#';
        cout << endl;
        a = 0;
      }
      else {
        a -= 50;
        for (int i = 0; i < 50; i++) cout << '#' << '.';
        cout << endl;
      }
    }
    line++;
    for (int i = 0; i < 100; i++) cout << '#';
    cout << endl;
    line++;
    if (a == 0) break;
  }

  for (int i = 0; i < 100; i++) cout << '.';
  cout << endl;
  line++;

  b--;
  while (1) {
    if (1) {
      if (b <= 50) {
        for (int i = 0; i < b; i++) cout << '.'  << '#';
        for (int i = 0; i < 100 - b*2; i++) cout << '.';
        cout << endl;
        b = 0;
      }
      else {
        b -= 50;
        for (int i = 0; i < 50; i++) cout << '.' << '#';
        cout << endl;
      }
    }
    line++;
    for (int i = 0; i < 100; i++) cout << '.';
    cout << endl;
    line++;
    if (b == 0) break;
  }
}


Measured memory_bytes: 384
//Let's join Kaede Takagaki Fun Club !!
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 1000000007;//998244353
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}
int dist[2005];
bool vis[2005];
int n,x,y;
vector<int>edge[2005];
int ans[2005];
int main(){
	cin >> n >> x >> y;
	edge[x].pb(y); edge[y].pb(x);
	repn(i,n-1){
		edge[i].pb(i+1);
		edge[i+1].pb(i);
	}
	
	repn(beg, n){
		rep(i,2005){
			dist[i] = INF;
			vis[i] = 0;
		}
		queue<int>que; que.push(beg); dist[beg] = 0;
		while(!que.empty()){
			int q = que.front(); que.pop();
			if(vis[q]) continue; vis[q] = 1;
			rep(i,edge[q].size()){
				int to = edge[q][i];
				chmin(dist[to], dist[q]+1);
				if(!vis[to]) que.push(to);
			}
		}
		repn(i,beg-1) ans[dist[i]] ++;
	}
	repn(i,n-1) o(ans[i]);
}

Measured memory_bytes: 384
eval"A,B,C,D,E,F="+gets.split*?,;d={};f=->a,b{d[[a,b]]||=a*100+b>F||a*E<b ?-1:(f[a+A,b];f[a+B,b];f[a,b+C];f[a,b+D];b.quo a)};f[A,0];f[B,0];a,b=d.max_by{|_,v|v}[0];puts"#{a*100+b} #{b}"

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

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cout << "ACL";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3632
from bisect import bisect_left

def sieve(n):
    srn = int(n ** 0.5)
    f = [False] * (srn + 1)
    res = []
    for i in range(2, srn+1):
        if f[i]:
            continue
        res.append(i)
        for j in range(2*i, srn+1, i):
            f[j] = True
    return res

def trial_division(n):
    res = dict()
    pn = sieve(n)
    for i in pn:
        while n % i == 0:
            res[i] = res.get(i, 0) + 1
            n //= i
    if n > 1:
        res[n] = 1
    return res

N = int(input())
pf = trial_division(N)
res = [i for i in range(10)]
for i in range(1, 10):
    res[i] = res[i-1] + i
ans = 0
for i in pf.values():
    idx = bisect_left(res, i)
    if i < res[idx]:
        idx -= 1
    ans += idx
print(ans)

Measured memory_bytes: 20348
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REPS(i,n) for(int i=1; i<=(int)(n); i++)
//#define ARRAY(type,n) (type *)malloc(sizeof(type)*n)
template<typename T>
T* ARRAY(int n){
	(T*)malloc(sizeof(T)*n);
}
template<typename T>
T** ARRAY2(int m,int n){
	T** type = (T**)malloc(sizeof(T*)*m);
	for(int i=0;i<m;i++){
		type[i]=(T*)malloc(sizeof(T)*n);
	}
	return type;
}
class llm{
public:
llm(ll value){this->value = (ll)value;}
ll value;
llm operator + (llm obj){return llm((this->value + (ll)(obj.value))%MOD);}
llm operator + (ll obj){return llm((this->value + obj)%MOD);}
llm operator - (llm obj){return llm(this->value - (ll)(obj.value));}
llm operator - (ll obj){return llm(this->value - obj);}
llm operator * (llm obj){return llm((this->value * (ll)(obj.value))%MOD);}
llm operator * (ll obj){return llm((this->value * obj)%MOD);}
llm operator / (llm obj){return llm(this->value / (ll)(obj.value));}
llm operator / (ll obj){return llm(this->value / obj);}
llm operator % (llm obj){return llm(this->value % (ll)(obj.value));}
llm operator % (ll obj){return llm(this->value % obj);}};
ostream& operator<<(ostream& os, llm l){os << l.value;return os;} 
llm operator+(ll a,llm l){return llm((a + l.value)%MOD);} 
llm operator*(ll a,llm l){return llm((a * l.value)%MOD);}



int main(void){
	int n;
	cin>>n;
	int memo;
	int a[300000];
	for(int i=0;i<n;i++){
		cin>>memo;
		a[3*i]=memo;
		a[3*i+1]=memo+1;
		a[3*i+2]=memo-1;
	}

	sort(a,a+3*n);
	int ans=0;
	memo = -3;
	int count=0;
	for(int i=0;i<3*n;i++){
		if(memo==a[i]){
			count++;
		}else{
			memo=a[i];
			ans=max(ans,count);
			count = 1;
		}
	}

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


Measured memory_bytes: 1408
def main2():
    x, y = map(int, input().split())
    
    ans = 10**10
    if x <= y:
        ans = min(ans, y - x)
    if -x <= y:
        ans = min(ans, y - (-x) + 1 )
    if x <= -y:
        ans = min(ans, -y - x + 1)
    if -x <= -y:
        ans = min(ans, -y - (-x) + 2)

    print(ans)

if __name__ == "__main__":
    main2()

Measured memory_bytes: 9200
#include <stdio.h>

int main(void){
    
    int a,b,c,x,i;
    
    scanf("%d %d %d",&a,&b,&c);
    
    for (i = a,x = 0;i <= b;x +=! (c % i++));
    
    printf("%d\n",x);
    
    return 0;
}

Measured memory_bytes: 596
N = []

for i in range(6):
    N.append(int(input()))

ans = "Yay!"
for i in range(5):
    for j in range(i+1,5):
        dist = abs(N[j] - N[i])
        
        if dist > N[5]:
            ans = ":("

print(ans)

##5m

Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJVolume11_1160
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> anss = new List<int>();
            while (true)
            {
                int[] wh = ReadInt();
                int w = wh[0];
                int h = wh[1];
                if (w == 0 && h == 0) break;

                int[,] c = new int[h + 2, w + 2];
                for (int i = 0; i < h; i++)
                {
                    var ch = ReadInt();
                    for (int j = 0; j < w; j++)
                    {
                        c[i + 1, j + 1] = ch[j];
                    }
                }

                int ans = 0;
                for (int i = 0; i < h; i++)
                {
                    for (int j = 0; j < w; j++)
                    {
                        if (c[i + 1, j + 1] != 1) continue;
                        DFS(c, i + 1, j + 1);
                        ans++;
                    }
                }

                anss.Add(ans);
            }

            foreach (var ans in anss)
            {
                Console.WriteLine(ans);
            }

            Console.ReadKey();
        }

        static int[] dx = new int[] { 0, 1, 1, 1, 0, -1, -1, -1 };
        static int[] dy = new int[] { -1, -1, 0, 1, 1, 1, 0, -1 };
        static void DFS(int[,] c, int i, int j)
        {
            if (c[i, j] == 0 || c[i, j] == 2)
            {
                return;
            }
            c[i, j] = 2;

            for (int d = 0; d < 8; d++)
            {
                DFS(c, i + dx[d], j + dy[d]);
            }
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}



Measured memory_bytes: 18504
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int to_i(string n) {
    int ret = 0;

    int prev = 1;
    for (int i = 0; i < n.size(); i++) {
        switch (n[i]) {
            case 'm':
                ret += 1000 * prev;
                prev = 1;
                break;
            case 'c':
                ret += 100 * prev;
                prev = 1;
                break;
            case 'x':
                ret += 10 * prev;
                prev = 1;
                break;
            case 'i':
                ret += prev;
                prev = 1;
                break;
            default:
                prev = n[i] - '0';
                break;
        }
    }

    return ret;
}

string to_mcxi(int n) {
    string buf;
    int cm, cc, cx, ci;

    cm = n / 1000; n -= 1000 * cm;
    cc = n / 100;  n -= 100  * cc;
    cx = n / 10;   n -= 10   * cx;
    ci = n;

    if (cm == 1) {
        buf.push_back('m');
    } else if (cm >= 2) {
        buf.push_back(cm + '0');
        buf.push_back('m');
    }

    if (cc == 1) {
        buf.push_back('c');
    } else if (cc >= 2) {
        buf.push_back(cc + '0');
        buf.push_back('c');
    }

    if (cx == 1) {
        buf.push_back('x');
    } else if (cx >= 2) {
        buf.push_back(cx + '0');
        buf.push_back('x');
    }

    if (ci == 1) {
        buf.push_back('i');
    } else if (ci >= 2) {
        buf.push_back(ci + '0');
        buf.push_back('i');
    }

    return buf;
}

int main() {
    int t; cin >> t;
    for (int i = 0; i < t; i++) {
        string n, m; cin >> n >> m;
        cout << to_mcxi(to_i(n) + to_i(m)) << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

struct Node{
    ll l,r,sum,ans;
};


template<typename T>
struct SegmentTree{
private:
    int n;
    T E;
    vector<T> node;
    inline void updatef(T& x,T& y){
        x = y;
        //x += y;
        //x = max(x,y);
        //x = min(x,y);
    }
    inline T queryf(T& x,T& y){
        Node t;
        t.l = max(x.l+y.sum, y.l);
        t.r = max(y.r+x.sum, x.r);
        t.sum = x.sum + y.sum;
        t.ans = max({x.ans,y.ans,x.l+y.r});
        //return x+y;
        //return max(x,y);
        //return min(x,y);
        return t;
    }

public:
    SegmentTree(int sz,T E_):E(E_){
        n=1;
        while(n<sz)n<<=1;
        node.resize(2*n-1,E);
    }

    SegmentTree(vector<T>& A,T E_):E(E_){
        int sz=A.size();
        n=1;
        while(n<sz)n<<=1;
        node.resize(2*n-1,E);
        rep(i,sz)node[i+n-1]=A[i];
        for(int i=n-2;i>=0;--i){
            node[i]=queryf(node[2*i+1], node[2*i+2]);
        }
    }
    void update(int k,T x){
        k+=n-1;
        updatef(node[k],x);
        while(k>0){
            k=(k-1)/2;
            node[k]=queryf(node[2*k+1], node[2*k+2]);
        }
    }
       //[a,b)での和を返す
    T get(int a,int b,int k=0,int l=0,int r=-1){
        if(r<0)r=n;
        if(r<=a||b<=l)return E;
        if(a<=l&&r<=b)return node[k];
        T xl=get(a,b,2*k+1,l,(l+r)/2);
        T xr=get(a,b,2*k+2,(l+r)/2,r);
        return queryf(xl, xr);
    }
};
int main(){
    int n,q;
    cin>>n>>q;
    Node e = {-longinf,-longinf,0,-longinf};
    SegmentTree<Node> sg(n,e);
    rep(i,n){
        int x;
        cin>>x;
        sg.update(i,{x,x,x,max(x,0)});
    }
    while(q--){
        cout<<sg.get(0,n).ans<<endl;
        int k,x;
        cin>>k>>x;
        --k;
        sg.update(k,{x,x,x,max(x,0)});
    }
    cout<<sg.get(0,n).ans<<endl;
    return 0;
}


Measured memory_bytes: 11040
import java.util.Scanner;


public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		int set = sc.nextInt();

		for (int k = 0; k < set; k++) {
			String x = sc.next();
			String y = sc.next();
			int m = x.length();
			int n = y.length();
			int[][] cache = new int[m + 1][n + 1];

			for (int i = 0; i <= m + n; i++) {
				for (int j = 0; j <= n; j++) {
					if (i - j < 0 || i - j > m) {
						continue;
					}
					if (i - j == 0 || j == 0) {
						cache[i - j][j] = 0;
					} else {
						if (x.charAt(i - j - 1) == y.charAt(j - 1)) {
							cache[i - j][j] = cache[i - j - 1][j - 1] + 1;
						} else {
							cache[i - j][j] = Math.max(cache[i - j - 1][j], cache[i - j][j - 1]);
						}
					}
				}
			}

			System.out.println(cache[m][n]);
		}
		
         sc.close();
	}
}

Measured memory_bytes: 60904
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000)

S = input()

hug_count = 0

left = 0
right = len(S) - 2

# print(S[left], S[right])


while left < right:
    if S[left] != S[right]:
        hug_count += 1
    left += 1
    right -= 1

print(hug_count)


Measured memory_bytes: 3060
N,M=map(int,input().split())
L=[]
R=[]
for _ in range(M):
  l,r=map(int,input().split())
  L.append(l)
  R.append(r+1)
L.sort()
R.sort()
ans=R[0]-L[-1]
print(0 if ans<0 else ans)

Measured memory_bytes: 11416
num = int(input())
mod = 10 ** 9 + 7
ans = 0
if num >= 2:
    temp9 = (9 ** num) % mod
    temp8 = (8 ** num) % mod
    val = (temp9 * 2 - temp8) % mod
    ans = (10 ** num) % mod + mod - val
print(ans % mod)

Measured memory_bytes: 10636
#include <fstream>
#include <vector>

using namespace std;

//ifstream cin("tema.in");
//ofstream cout("tema.out");

int main() {
    //freopen("tema.in", "r", stdin);
    //freopen("tema.out", "w", stdout);
    long long i, o, t, j, l, s, z;
    scanf("%lld%lld%lld%lld%lld%lld%lld", &i, &o, &t, &j, &l, &s, &z);
    long long answer = 0;
    for (long long k = 0; k <= 100; k++)
        if (k <= i && k <= l && k <= j)
            answer = max(answer, o + 3 * k + 2  * ((i - k) / 2) + 2 * ((j - k) / 2) + 2 * ((l - k) / 2));
    printf("%lld\n", answer);
    return 0;
}


Measured memory_bytes: 128
using System;

public class p0005
{
	p0005(){
		string str;
		string[] s;
		decimal dc, a, b;
		
		while((str=Console.ReadLine()) != null){
			s = str.Split(' ');
			a = decimal.Parse(s[0]);
			b = decimal.Parse(s[1]);
			dc = gcd(a, b);
			Console.WriteLine("{0} {1}", dc, (a/dc*b));
		}
	}
	
	public decimal gcd(decimal a, decimal b){
		if(b == 0) return a;
		return gcd(b, a%b);
	}
	
	public static int Main(string[] args){
		new p0005();
		return 0;
	}
}

Measured memory_bytes: 5684
#include<stdio.h>
int main(void)
{
  int i,j,h,w;
  scanf("%d %d",&h,&w);
  while(h!=0 || w!=0){
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        if(i==0 || i==(h-1))  printf("#");
        else if(j==0 || j==(w-1))  printf("#");
        else printf(".");
      }
      printf("\n");
    }
    printf("\n");
    scanf("%d %d",&h,&w);
  }

  return 0;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, n, k);
  in(string, s);
  char to = s[0], from = 'L' + 'R' - to;
  dbg(from, to);
  int i = 1;
  while (k--) {
    while (i < s.size() && s[i] == to) ++i;
    if (i == s.size()) break;
    while (i < s.size() && s[i] == from) {
      s[i] = to;
      ++i;
    }
    dbg(i, s);
  }
  s = ' ' + s + ' ';
  int ans = 0;
  rep(i, n) if (s[i + 1] == 'L' && s[i] == 'L' || s[i + 1] == 'R' && s[i + 2] == 'R') {
    ++ans;
  }
  out(ans);
}


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

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<db> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b) - 1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define rb(i,x) for (auto& i : x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define UNIQUE(x) (x).resize(unique(all(x)) - begin(x))

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define F first
#define S second

#define pow10(n) stoll("1"+string(n,'0'))

#define debug(x) cout << ">>> " << #x << ": " << x << '\n'

const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LNF = 1e18;

void setIO(string s) {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen((s+".in").c_str(),"r",stdin);
//	freopen((s+".out").c_str(),"w",stdout);
#endif
}

int main() {
    
    setIO("input");
    int n; cin >> n;
    map<string,int> m{{"AC",0}, {"WA", 1}, {"TLE",2}, {"RE",3}};
    vi cnt(4);
    for(int i=0; i<n; ++i) {
        str s; cin >> s;
        ++cnt[m[s]];
    }
    cout << "AC x " << cnt[0] << '\n';
    cout << "WA x " << cnt[1] << '\n';
    cout << "TLE x " << cnt[2] << '\n';
    cout << "RE x " << cnt[3] << '\n';
    
}

/*  ! CHECK THIS IF YOU GET IT WRONG !
	* int overflow, array bounds, NO VLAs
	* uninitialized local variables, rounding errors
	* intermediate result type, scientific
	* special cases (n = 0 or 1?)
	* reset your variables in scope
	* INF not large enough for ans, adding value to _MAX
	* using wrong variables, sorting extra 0s in global array
	* comment out input from file
	* operator precedence
*/

Measured memory_bytes: 3656
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
d1, d2, d3, d4 = [[] for _ in range(4)]
for a, b in xy:
    d1.append(a + b)
    d2.append(a - b)
    d3.append(-a + b)
    d4.append(-a - b)
ans = 0
for d in d1, d2, d3, d4:
    ans = max(ans, max(d) - min(d))
print(ans)


Measured memory_bytes: 151016
use std::collections::VecDeque;

fn main() {
    let mut sc = Scanner::new();
    let mut n: usize = sc.read();

    if n < 8 {
        match n {
            3 => println!("2 5 63"),
            4 => println!("2 3 4 9"),
            5 => println!("2 3 4 9 6"),
            6 => println!("2 3 4 9 6 12"),
            7 => println!("2 3 4 9 6 12 18"),
            _ => panic!(),
        }
        return;
    }

    let mut six = VecDeque::new();
    let mut odd = VecDeque::new();
    let mut even = VecDeque::new();

    for i in 2..30001 {
        if i % 6 == 0 {
            six.push_back(i);
        } else if i % 3 == 0 {
            odd.push_back(i);
        } else if i % 2 == 0 {
            even.push_back(i);
        }
    }


    let mut ans = Vec::new();
    while n >= 8 {
        ans.push(six.pop_front().unwrap());
        ans.push(six.pop_front().unwrap());
        ans.push(odd.pop_front().unwrap());
        ans.push(odd.pop_front().unwrap());
        ans.push(even.pop_front().unwrap());
        ans.push(even.pop_front().unwrap());
        ans.push(even.pop_front().unwrap());
        ans.push(even.pop_front().unwrap());
        n -= 8;
    }

    while n > 2 {
        if odd.len() >= 2 {
            ans.push(odd.pop_front().unwrap());
            ans.push(odd.pop_front().unwrap());
        } else {
            ans.push(even.pop_front().unwrap());
            ans.push(even.pop_front().unwrap());
        }
        n -= 2;
    }
    for _ in 0..n {
        ans.push(six.pop_front().unwrap());
    }

    for a in &ans {
        print!("{} ", *a);
    }
    println!();
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner { ptr: 0, length: 0, buf: vec![0; 1024], small_cache: vec![0; 1024] }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool { b == b'\n' || b == b'\r' || b == b'\t' || b == b' ' }

    fn read<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug, {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)]).parse().unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}



Measured memory_bytes: 4476
#include <iostream>

using namespace std;

int main ()
{
    int N, M;
    int H[100000] = {0};
    int NoGood[100000] = {0};
    cin >> N >> M;
    
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }

    for (int i = 0; i < M; i++) {
        int A, B;
        cin >>  A >> B;
        if (H[A-1] > H[B-1]) {
            NoGood[B-1]++;
        } else if (H[A-1] < H[B-1]) {
            NoGood[A-1]++;
        } else {
            NoGood[A-1]++;
            NoGood[B-1]++;            
        }
    }
    
    int GoodCounter = 0;
    for (int i = 0; i < N; i++) {
        if (NoGood[i] == 0) {
            GoodCounter++;
        }
    }
    
    cout << GoodCounter << endl;
    return 0;
}

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

int main() {
  
  int table[3][3]; int card[3][3];
  
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> table[i][j];
    }
  }
  
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      card[i][j] = 0;
    }
  }
  
  int N; cin >> N;
  
  for (int i = 0; i < N; i++) {
    int b; cin >> b;
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (table[j][k] == b) card[j][k] = 1;
      }
    }
  }
  
  bool ans = false;
  
  for (int i = 0; i < 3; i++) {
    int sum = 0;
    for (int j = 0; j < 3; j++) {
      sum += card[i][j];
    }
    if (sum == 3) ans = true;
  }
  
  for (int i = 0; i < 3; i++) {
    int sum = 0;
    for (int j = 0; j < 3; j++) {
      sum += card[j][i];
    }
    if (sum == 3) ans = true;
  }
  
  if (card[0][0] && card[1][1] && card[2][2]) ans = true;
  if (card[0][2] && card[1][1] && card[2][0]) ans = true;
  
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
fun main() {
    val (n, d) = readLine()!!.split(" ").map { it.toLong() }
    var cnt = 0
    for (i in 0 until n) {
        val (x, y) = readLine()!!.split(" ").map { it.toLong() }
        if (x * x + y * y <= d * d) {
            cnt++
        }
    }
    println(cnt)
}


Measured memory_bytes: 59964