akhauriyash/Code-Regression huggingface dataset:
import re
import sys
input = sys.stdin.readline

s = input()
a = '[0][1-9]' if '0' in s[0] else '[1][0-2]'
b = '[0][1-9]' if '0' in s[2] else '[1][0-2]'
if re.search(b,s[2:4]):
    if re.search(a,s[0:2]):
        ans = 'AMBIGUOUS'
    else:
        ans = 'YYMM'
elif re.search(a,s[0:2]):
    ans = 'MMYY'
else:
    ans = 'NA'
print(ans)

Measured memory_bytes: 3188
N = int(input())
X = []
x = 1
i = 1
while x<10**9+1:
    X.append(x)
    i += 1
    x += i
X.append(x)
    
for i,x in enumerate(X):
    if x < N:
        continue
    else:
        print(i+1)
        break
    

Measured memory_bytes: 4888
#include <iostream>
#include <string>
#include <set>

using namespace std;

int b[200555];
int f[200555];

int main() {

  int n;
  cin >> n;
  for(int i = 2;i <= n;i++){
    cin >> b[i];
  }
  for(int i = n;i >= 2;i--){
    f[b[i]] += 1;
  }
  for(int i = 1;i <= n;i++){
    cout << f[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 5184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;


int main(){
  ll N, D;
  cin>>N>>D;
  vector<ll> X(N), Y(N);
  ll count=0;
  rep(i, N){
    cin>>X[i]>>Y[i];
    ll S=X[i]*X[i]+Y[i]*Y[i];
    if(S<=D*D)count++;
  }
  cout<<count<<endl;
} 

Measured memory_bytes: 6420
class TreeNode:
  def __init__(self, val):
    self.val = val
    self.left = None
    self.right = None

class Bst:
  def __init__(self):
    self.root = None

  def insert(self, val):
    node = TreeNode(val)
    if self.root is None: 
      self.root = node
      return

    cur_parent = None
    cur_root = self.root

    while cur_root is not None:
      cur_parent = cur_root
      if val > cur_root.val:
        cur_root = cur_root.right
      else:
        cur_root = cur_root.left

    if val > cur_parent.val:
      cur_parent.right = node
    else:
      cur_parent.left = node

  def print(self):
    self.inorder = []
    self.preorder = []
    self.inorder_dfs(self.root)
    self.preorder_dfs(self.root)

    print(" " + " ".join([ str(i) for i in self.inorder ]))
    print(" " + " ".join([ str(i) for i in self.preorder ]))

  def inorder_dfs(self, root):
    if not root: return

    self.inorder_dfs(root.left)
    self.inorder.append(root.val)
    self.inorder_dfs(root.right)

  def preorder_dfs(self, root):
    if not root: return

    self.preorder.append(root.val)
    self.preorder_dfs(root.left)
    self.preorder_dfs(root.right)


n = int(input())
bst = Bst()
for _ in range(n):
  ins = list(map(str, input().split()))
  order = ins[0]
  if order == "insert":
    val = int(ins[1])
    bst.insert(val)
  elif order == "print":
    bst.print()


Measured memory_bytes: 147724
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
string s;
int n;
ll d[110][5][2];
ll res;
int main()
{
	cin >>s>>n;
	for (int i=1;i<s.size();i++)
	{
		ll r=1;
		for (int j=0;j<n-1;j++) r*=i-1-j;
		for (int j=0;j<n-1;j++) r/=j+1;
		for (int j=0;j<n;j++) r*=9;
		res+=r;
		//cout <<i<<" "<<r<<" ##\n";
	}
	d[0][1][1]=s[0]-'0'-1;
	d[0][1][0]=1;
	for (int i=1;i<s.size();i++)
	{
		for (int j=1;j<=n;j++)
		{
			d[i][j][0]=d[i-1][j-(s[i]!='0')][0];
			d[i][j][1]=d[i-1][j][1]+d[i-1][j-1][1]*9;
			d[i][j][1]+=d[i-1][j-1][0]*max(0,s[i]-'0'-1);
			if (s[i]!='0') d[i][j][1]+=d[i-1][j][0];
			//cout <<i<<" "<<j<<" "<<d[i][j][0]<<" "<<d[i][j][1]<<" ##\n"; 
		}
	}
	cout <<d[s.size()-1][n][0]+d[s.size()-1][n][1]+res;
	return 0;
}

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

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

using namespace std;

int main(){
	int n,k; cin>>n>>k;
	vector<int> a(n);
	rep(i,n) cin>>a[i];

	int ans=0;
	rep(k1,k+1) rep(k2,k-k1+1) if(k1+k2<=n) {
		vector<int> b;
		rep(i,k1) b.emplace_back(a[i]);
		rep(i,k2) b.emplace_back(a[n-i-1]);
		sort(b.begin(),b.end(),greater<int>());
		int r=k-(k1+k2);
		while(r>0 && !b.empty() && b.back()<0) b.pop_back(), r--;
		ans=max(ans,accumulate(b.begin(),b.end(),0));
	}
	cout<<ans<<endl;

	return 0;
}


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

int main() {
  int N, K;
  cin >> N;
  cin >> K;
  int A = 0;
  
  int i = 0;
  while (i < N) {
    int x;
    cin >> x;
    if (abs(K - x) >= x)
      A += x;
    else
      A += abs(K - x);
    i++;
  }
  cout << 2 * A << endl;
}    
    

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

int n = 0, q = 0, a[21] = { 0 }, m = 0;

bool ps(int i, int s)
{
	if (i == n) return s == m;

	if(ps(i + 1, s))
		return true;
	
	if (ps(i + 1, s + a[i]))
		return true;
	
	return false;
}

int main()
{	
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	cin >> q;
	
	for (int i = 0; i < q; i++) {
		cin >> m;

		if(ps(0, 0))
			cout << "yes" << endl;
		else
			cout << "no" << endl;
	}

	return 0;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=1000000007;
int fact[1111111];
int inv[1111111];
int mpow(int n,int m){
    int ret=1;
    while(m){
        if(m&1)ret=ret*n%mod;
        n=n*n%mod;
        m>>=1;
    }
    return ret;
}

int C(int n,int k){
    return fact[n]*inv[k]%mod*inv[n-k]%mod;
}

struct BIT{
    int N;
    vector<int>dat;
    void init(int n){
        N=n;
        dat.resize(N+1);
    }
    BIT(){}
    BIT(int n){init(n);}

    void add(int k,int x){
        for(k++;k<=N;k+=k&-k)dat[k]+=x;
    }
    int sum(int k){
        int ret=0;
        for(k++;k;k-=k&-k)ret+=dat[k];
        return ret;
    }
};

int N;
int P[555555];

bool ex[555555];
int acc[555555];
signed main(){
    fact[0]=1;
    for(int i=1;i<1111111;i++)fact[i]=fact[i-1]*i%mod;
    inv[1111111-1]=mpow(fact[1111111-1],mod-2);
    for(int i=1111111-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;

    cin>>N;
    rep(i,N)cin>>P[i];
    rep(i,N)ex[P[i]]=true;
    for(int i=1;i<=N;i++){
        acc[i]=acc[i-1];
        if(!ex[i])acc[i]++;
    }


    int ans=0;
    int emp=0;

    int allemp=acc[N];
    BIT bit;bit.init(N+114);
    int sum=0;
    for(int i=N-1;i>=0;i--){
        int f=fact[N-i-1];
        if(P[i]){
            ans=(ans+bit.sum(P[i])*fact[allemp]%mod*f)%mod;
            int s=acc[P[i]];
            if(s){
                ans=(ans+fact[allemp-1]*emp%mod*s%mod*f)%mod;
            }
            bit.add(P[i],1);
            if(allemp)sum=(sum+fact[allemp-1]*(acc[N]-acc[P[i]]))%mod;
            continue;
        }
        int tmp=allemp*(allemp-1)/2;
        tmp%=mod;
        if(emp)ans=(ans+tmp*fact[allemp-2]%mod*emp%mod*f)%mod;
        ans=(ans+sum*f)%mod;
        emp++;
    }
    ans=(ans+fact[allemp])%mod;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 29824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int 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)1E16;
#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 fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

struct mini{ ll a,kosu;};
struct maxi{ ll a,kosu;};
            
int main(){
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    sort(a,a+n);
    ll b[n];rep(i,0,n-1)b[i]=0;
    b[0]++;
    ll c=0;
    rep(i,1,n-1){
        if(a[i]!=a[i-1]){
            c++;
        }
        b[c]++;
    }
    ll ans=0;
    rep(i,0,c){
        ans+=(b[i]-1);
    }
    if(ans%2==0){
        cout<<n-ans<<endl;
    }else{
        cout<<n-ans-1<<endl;
    }
    
    return 0;
}


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

#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcd(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  int r, d, x;
  cin >> r >> d >> x;
  rep(i, 0, 10) {
    x = r * x - d;
    cout << x << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[1000];
int use[26];
int main(){
	printf("?wolf\n");fflush(stdout);
	bool one=false;
	while(1){
		scanf("%s",str);
		if(str[0]!='f'){printf("!OUT\n");break;}
		if(str[1]==0&&one){
			printf("!OUT\n");break;
		}else if(str[1]==0){
			one=true;
			printf("?f");
			for(int i=0;i<8;i++)printf("%c",'a'+rand()%26);
			printf("f\n");fflush(stdout);
		}
		if(use[str[1]-'a']){
			printf("!OUT\n");break;
		}else if(str[1]){
			use[str[1]-'a']=true;
			printf("?%c",str[1]);
			for(int i=0;i<8;i++)printf("%c",'a'+rand()%26);
			printf("f\n");fflush(stdout);
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

const int MAXN = 100;
int n;
int arr[MAXN];

void output();

void insertion_sort() {
	for(int i = 1; i < n; i++) {
		int k = arr[i];
		int j = i - 1;
		while( j >= 0 && arr[j] > k){
			arr[j + 1] = arr[j];
			j--;
		}
		arr[j + 1] = k;
		output();
	}
} 

void input() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		scanf("%d", arr + i);
	}
}

void output() {
	printf("%d",arr[0]);
	for(int i = 1; i < n; i++) {
		printf(" %d", arr[i]);
	}
	puts(""); 
}

int main() {
	input();
	output();
	insertion_sort(); 
	return 0;
}


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

using namespace std;

int main() {
	int N;
	cin >> N;
	int A[200000];
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		A[i] -= i + 1;
	}

	sort(A, A + N);

	long b; // median

	if (N % 2) {
		b = A[N / 2];
	}
	else {
		b = (A[N / 2 - 1] + A[N / 2]) / 2;
	}

	long ans = 0;

	for (int i = 0; i < N; ++i)
		ans += abs(A[i] - b);

	cout << ans;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    int n;cin>>n;
    vector<int> a(n);
    double sum = 0;
    rep(i,n){
        cin >>a[i];
        sum+=a[i];
    }
    double ave = sum/(double)n;

    int ans = 0;
    double mn = INF;
    int pos = 0;
    rep(i,n){
        double dx = abs(ave-a[i]);
        if(mn>dx) {
            mn = dx;
            pos = i;
        }

    }
    cout << pos <<endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    const unsigned int M = 1000000007; 
    ll h,w,i,j,k;
    cin>>h>>w;
     vector <string> v;
    
    
     ll dp[h][w];
      
     for(i=0;i<h;i++){
         string x;
         
            cin>>x;
            v.push_back(x);
         
         
     }
     
     for(i=0;i<h;i++){
         for(j=0;j<w;j++){
             if(i==0&&j==0)
             dp[0][0]=1;
             else{
             if(v[i][j]=='#')
             dp[i][j]=0;
             else{
                 if(i==0)
                 dp[i][j]=(dp[i][j-1])%M;
                 else if(j==0)
                 dp[i][j]=(dp[i-1][j])%M;
                 else{
                     dp[i][j] = ((dp[i-1][j])%M + (dp[i][j-1])%M)%M;
                 }
             }
             
         }
         }     
     }
    cout<<dp[h-1][w-1]<<endl;
    
    return 0;
}

Measured memory_bytes: 9088
//¹Ø¼üÐÔÖÊ£ºÁ½¸öÉî¶ÈÏàÍ¬µÄµãµÄÂ·¾¶ÉÏ±ØÓÐÒ»¸öÉî¶È¸üÐ¡µÄµã 
#include<bits/stdc++.h>
using namespace std;

const int MaxN=1e5+5;

int N,Ans;
int Cnt[MaxN][20];

vector<int> To[MaxN];

void DFS(int u,int fa){
	int i,k=0;
	for(auto v:To[u])
		if(v^fa){
			DFS(v,u);
			for(i=0;i<20;i++)
				Cnt[u][i]+=Cnt[v][i];
		}
	for(i=19;~i;i--)
		if(Cnt[u][i]>1){
			k=i+1;
			break;
		}
	for(;Cnt[u][k];k++);
	Ans=max(Ans,k);
	for(i=0;i<k;i++)
		Cnt[u][i]=0;
	Cnt[u][k]++;
}

int main(){
	int i,u,v;
	scanf("%d",&N);
	for(i=1;i<N;i++){
		scanf("%d%d",&u,&v);
		To[u].push_back(v);
		To[v].push_back(u);
	}
	DFS(1,0);
	printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 19200
import scala.io.{StdIn => in}

object Main extends App {
  val Array(a, b) = in.readLine.split(" ").map(_.toLong)

  def rec(a:Long, b:Long):Long = {
    if(b == 0) a
    else rec(b, a % b)
  }

  val ans = a / rec(a, b) * b
  println(ans)
}

Measured memory_bytes: 25524
#include<stdio.h>
#include<string.h>
#define N 100000

typedef struct p{
  char name[11];
  int time;
}P;

P Q[N+1];
int head, tail, n;

void enqueue(P x){
    int next = (tail + 1) % N;
    Q[tail] = x;
    tail = next;
}

P dequeue(){
    P x;
    x = Q[head];
    head = (head + 1) % N;
    return x;
}
int min(int a, int b) { 
    if(a < b) return a;
    else return b; 
}
int main(){
  int time = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].time);
  }
  head = 1;
  tail = n + 1;
  while(head != tail){
    u = dequeue();
    c = min(q, u.time);
    u.time -= c;
    time += c;
    if ( u.time > 0 ) enqueue(u);
    else printf("%s %d\n", u.name,time);
  }
  
  return 0;
}


Measured memory_bytes: 3248
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
map<string,int>sad;
int main()
{
    _SAD()
    string s,k;
    cin>>s;
    VSRT(s);
    set<char>ch;
    int cnt=1;
    for(int i=0;i<SZ(s);i++)
    {
        ch.insert(s[i]);
        if(SZ(ch)==cnt)
        {
            k+=s[i];
            cnt++;
        }
    }
    char a='a';
    for(int i=0;i<SZ(k);i++)
    {
        if(k[i]!=a)
        {
            cout<<a<<NL;
            return 0;
        }
        else
        {
            a++;
        }
    }
    if(SZ(k)!=26)
    {
        cout<<a<<NL;
        return 0;
    }
    cout<<"None"<<NL;
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>
#include <limits.h>         // INT_MIN

#define MAX_N 5000

int
main(int argc, char** argv)
{
	int i, j;

	while (true)
	{
		int a[MAX_N];
		int b[MAX_N + 1];
		int n;

		scanf("%d", &n);
		if (n == 0)
			break;

		b[0] = 0;
		for (i = 0; i < n; ++i)
		{
			scanf("%d", &a[i]);
			b[i + 1] = b[i] + a[i];
		}

		int max = INT_MIN;
		for (i = 0; i < n; ++i)
		{
			for (j = i + 1; j <= n; ++j)
			{
				int s = b[j] - b[i];
				if (s > max)
					max = s;
			}
		}

		printf("%d\n", max);
	}

	return 0;
}

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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> p(N);
  for(int i=0; i<N; i++){
    cin >> p[i];
  }
  sort(p.begin(), p.end());
  int sum=0;
  for(int i=0; i<K; i++){
  	sum += p[i];
  }
  cout << sum;
  return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, m, a, b, c, d; cin >> n;
	int test[222] = { 0 }, uiop[222] = { 0 };
	for (int h = 0; h < n; h++) {
		cin >> a >> b;
		test[h] = a; uiop[h] = b;
	}
	cin >> m;
	for (int h = 0; h < m; h++) {
		cin >> c >> d;
		test[n + h] = c; uiop[n + h] = d;
	}
	for (int s = 0; s < n + m - 1; s++) {
		for (int t = s + 1; t < n + m; t++) {
			if (test[s] > test[t]) {
				int uio = test[s];
				test[s] = test[t];
				test[t] = uio;
				int iop = uiop[s]; 
				uiop[s] = uiop[t];
				uiop[t] = iop;
			}
			if (test[s] == test[t] && uiop[s] > uiop[t]) {
				int uio = test[s];
				test[s] = test[t];
				test[t] = uio;
				int iop = uiop[s];
				uiop[s] = uiop[t];
				uiop[t] = iop;
			}
		}
	}
	for (int h = 0; h < n + m; h++) {
		if ((test[h + 1] != test[h] || uiop[h + 1] != uiop[h]) && h != n + m - 1) {
			if (uiop[h] < 10) {
				cout << test[h] << ':' << 0 << uiop[h] << ' ';
			}
			else {
				cout << test[h] << ':' << uiop[h] << ' ';
			}
		}
		if ((test[h + 1] != test[h] || uiop[h + 1] != uiop[h]) && h == n + m - 1) {
			if (uiop[h] < 10) {
				cout << test[h] << ':' << 0 << uiop[h];
			}
			else {
				cout << test[h] << ':' << uiop[h];
			}
		}
	}
	cout << endl;
	cin >> n;
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  string s;
  cin >> s;

  string sinv=s;
  reverse(sinv.begin(),sinv.end());

  int n=s.size();
  if(s==sinv
     && s.substr(0,(n-1)/2)==sinv.substr(n-(n-1)/2,(n-1)/2)
     && s.substr((n+3)/2-1,n-(n+3)/2+1)==sinv.substr(0,n-(n+3)/2+1)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  
  return 0;
}


Measured memory_bytes: 256
import sys
import math
from collections import deque

N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]

mydict = {}
for i in AB:
    if i[0] not in mydict:
        mydict[i[0]] =[i[1]]
    else:
        mydict[i[0]].append(i[1])

    if i[1] not in mydict:
        mydict[i[1]] =[i[0]]
    else:
        mydict[i[1]].append(i[0])


cnt = 0
for i in range(1,N+1):
    if i not in mydict.keys():
        cnt += 1
        continue

    top_flag = True
    for k in list(set(mydict[i])):
        if i == k:
            continue
        if H[i-1] <= H[k-1]:
            top_flag = False
            break
    if top_flag == True:
        cnt += 1

print(cnt) 


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

int main()
{
    long n, x;
    long i;
    long D = 0;
    long cnt = 1;
    vector<long> l(n);

    cin >> n >> x;
    for(i = 0; i < n; i++){
        cin >> l[i];
        D += l[i];
        if(D <= x) { cnt++; }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>
#include <tuple>



typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define FOR(i,a,b) for(int i=(int)(a) ; i < (int) (b) ; ++i )
#define rep(i,n) FOR(i,0,n)
#define sz(x) int(x.size())

const int N = 1001002;

int main(){
    int a,n; cin >>n;
    vector<int> v;
    rep(i,n) {
        cin >>a;
        v.push_back(a);
    }
    sort(v.begin(), v.end());
    vector<int> m(N,0);
    rep(i,n){
        int k = v[i];
        if (i>0){
            if (k== v[i-1]) {
                m[k] = N;
                continue;
            }
        }
        for (int j=k; j<N; j+=k){
            m[j] +=1;
        }
    }
    int ans=0;
    rep(i,n){
        if (m[v[i]] ==1) ans++;
    }
    printf("%d", ans);
    
    return 0;
}

Measured memory_bytes: 7924
n,x,y = map(int,input().split())
m = {}
for i in range(1,n):
    m[i] = 0
for i in range(1,n):
    for j in range(i+1,n+1):
        dif = min(abs(j-i),(abs(x-i)+1+abs(j-y)),(abs(y-i)+1+abs(j-x)))
        m[dif]+=1
[print(m[i]) for i in range(1,n)]

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

int main() {
  int a, b;
  string op;

  while(1) {
    cin >> a >> op >> b;

    if (op == "+") {
      cout << a + b << endl;
    }
    else if (op == "-") {
      cout << a - b << endl;
    }
    else if (op == "*") {
      cout << a * b << endl;
    }
    else if (op == "/") {
      cout << a / b << endl;
    }
    else if (op == "?") {
      break;
    }
  }
  
}


Measured memory_bytes: 3156
using Atcoder;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        { 
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var dif = input[0] - input[1] * 2;
            if (dif <= 0)
            {
                Console.Write(0);
            }
            else
            {
                Console.Write(dif);
            }

        }
        //static void Main(string[] args)
        //{
        //    var temp = new Atcoder.ABC130.D();
        //    temp.Run();
        //}

    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;
const int di[4] = {1, 0, -1, 0};
const int dj[4] = {0, 1, 0, -1};


signed main(){

    vector<bool> a(10);
    for(int i = 0; i < 4; i++){
        int in; cin >> in;
        a[in] = true;
    }

    if(a[1] && a[7] && a[9] && a[4]) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,l,sum=0,ret=0,mini=INT_MAX;
	cin >> n >> l;
	for (int i=0; i<n; ++i) sum += l+i;
	for (int i=0; i<n; ++i){
		if (mini > abs(l+i)){
			mini=abs(l+i);
			ret=l+i;
		}
	}
	cerr << sum << endl;
	cout << sum-ret;
	return 0;
}


Measured memory_bytes: 256
# import sys
# input = sys.stdin.readline
n = int(input())
b = list(map(int,input().split()))
a = [0]*n
a[0] = b[0]
a[n-1] = b[n-2]
# print(a)
for i in range(1,n-1):
    a[i] = min(b[i-1],b[i])
# print(a)
print(sum(a))

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;i++)
    cin >> a[i];
  sort(a.begin(), a.end(), greater<ll>());
  ll alice = 0, bob = 0;
  for(int i=0;i<n;i++) {
    if(i%2 == 0)
      alice += a[i];
    else
      bob += a[i];
  }
  cout << alice - bob << endl;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc069/tasks/arc080_b

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int H_MAX = 100;
const int W_MAX = 100;
const int N_MAX = H_MAX * W_MAX;

int H, W;
int N;
int a[N_MAX];

int c[H_MAX][W_MAX];

void solve() {
  int k = 0;
  REP(i, N) REP(j, a[i]) {
    int y = k / W;
    int x = k % W;
    if (y % 2) x = W - 1 - x;
    c[y][x] = i + 1;
    k++;
  }
  REP(y, H) REP(x, W) printf("%d%c", c[y][x], x + 1 == W ? '\n' : ' ');
}

void input() {
  scanf("%d%d", &H, &W);
  scanf("%d", &N);
  REP(i, N) scanf("%d", a + i);
}

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


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

std::vector<int> to[200005];
std::vector<int> ans;

void dfs(int v,int p=-1){
    for (int u:to[v]){
      if(u==p)continue;
      ans[u]+=ans[v];
      dfs(u,v);
    }
}

int main(){
  int n,q;
  std::cin >> n>>q;
  for (int i = 0; i < n-1; i++) {
    int a,b;
    std::cin >> a>>b;
    --a;--b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans.resize(n);
  for (int i = 0; i < q; i++) {
    int p,x;
    std::cin >> p>>x;
    --p;
    ans[p]+=x;
  }
  dfs(0);
  for (int i = 0; i < n; i++) {
    std::cout << ans[i] << '\n';
  }
  return 0;
}


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

const int N = 100009;
int f[N], dp[N];


int main(){

        int n, k; scanf("%d %d", &n, &k);
        for(int i = 1; i <= n; i++){
                scanf("%d", &f[i]);
        }

        for(int i = 0; i < N; i++)dp[i] = INT_MAX;

        dp[0] = dp[1] = 0;
        for(int i = 1; i < n; i++){
                for(int j = 1; j <= k; j++){
                        if(i + j > n)break;
                        dp[i + j] = min(dp[i + j], dp[i] + abs(f[i] - f[i + j]));
                }
        }

        cout << dp[n] << endl;




        return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
const int INF = 1e9;
const int MO = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define rt return
#define ENDL cout<<endl
#define MAXE(a,b) a=max(a,b)
#define MINE(a,b) a=min(a,b)
#define s second
#define f first

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
int gcd(int a, int b) {
    if(b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a / gcd(a, b) * b ;
}
int main(){
    LL K,A,B;cin >> K >> A >> B;
    if(A < B){
        LL can =K- (A-1);
        can--;
        if(can %2 == 0){
           // COUT("A");
            COUT(max(K+1,can/2 * (B-A)+A+1));
        }else{
         //   COUT("B");
            COUT(max(K+1,(can/2) * (B-A)+B));
        }
    }else{
        COUT(1+K);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c=0,d,e,f,g,h,k,n,m,t,pre=0;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>d;
        if(d>=pre){
            pre=d;
            c++;
        }
    }
    cout<<c<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;
#define INF 0x7fffffff
#define Max 200000
#define eps 1e-10

double l, r, p, e, t, ans;
int c;

void dfs (double L, double R, int days, double pp)
{
	if (R < (t - e) || L > (t + e))
		return ;
	if (L >= t - e && R <= t + e)
	{
		ans += pp;
		return ;
	}
	double mid = (L + R) / 2.0;
	if (days > c) 
	{
		if (abs(mid - t) <= e) ans += pp;
		return ;
	}
	if (mid >= t)
	{
		dfs (L, mid, days + 1, pp * (1 - p));
		dfs (mid, R, days + 1, pp * p);
	}
	else
	{
		dfs (mid, R, days + 1, pp * (1 - p));
		dfs (L, mid, days + 1, pp * p);
	}
}

int main ()
{
	int i, j;
	while (scanf ("%d%lf%lf", &c, &l, &r) == 3)
	{
		scanf ("%lf%lf%lf", &p, &e, &t);
		ans = 0;
		dfs (l, r, 1, 1);
		printf ("%.20lf\n", ans);
	}
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>

int main(void)
{
    int i, j, c, k=0, max, n, m;
    char a[200][11];

    scanf("%d", &n);
    for (i=0; i<n; i++) scanf("%s", a[k++]);

    scanf("%d", &m);
    for (i=0; i<m; i++) scanf("%s", a[k++]);

    max = 0;
    for (i=0; i<k; i++) {
        c=0;
        for (j=0; j<k; j++) {
            if (strcmp(a[i], a[j])==0) {
                if (j<n)    c++;
                else        c--;
            }
        }

        if (c>max)  max = c;
    }

    printf("%d\n", max);

    return 0;
}

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

int main()
{

    long long int a,b,c,d;

    cin>>a>>b>>c>>d;
    long long int mul = -1000000000000000009;
    long long int sum;
     sum= a*c;
    if(mul<sum)
        mul=sum;
    sum = a*d;
    if(mul<sum)
        mul=sum;
   sum= b*c;
    if(mul<sum)
        mul=sum;
    sum= b*d;
    if(mul<sum)
        mul=sum;
        cout<<mul<<endl;
    return 0;
}




Measured memory_bytes: 3624
#include <stdio.h>

int main(){
	int m,d,count=0;
	scanf("%d%d",&m,&d);
	for(int i=1;i<=m;i++){
		for(int j=1;j<=d;j++){
			int d1=j%10;
			int d10=j/10;
			if(d1*d10==i && d1>=2 && d10>=2 )count++;
		}
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a % 2 == 0 || b % 2 == 0)
			System.out.println("No");
		else
			System.out.println("Yes");
	}

}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 1e5 + 50;
const int mod = 1e9+7;
int dp[maxn][3];
int a[maxn], b[maxn], c[maxn];
int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    dp[1][0] = a[1];
    dp[1][1] = b[1];
    dp[1][2] = c[1];
    for(int i = 2; i <= n; i++){
        dp[i][0] = max(dp[i-1][1] + a[i], dp[i-1][2] + a[i]);
        dp[i][1] = max(dp[i-1][0] + b[i], dp[i-1][2] + b[i]);
        dp[i][2] = max(dp[i-1][0] + c[i], dp[i-1][1] + c[i]);
    }
    cout << max(dp[n][0],max(dp[n][1], dp[n][2]));
    return 0;
}

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

using namespace std;

int main() {
	int n, k, c;
	string s;
	cin >> n >> k >> c >> s;
	
	vector<int> L, R;
	int inserted = 0;
	for(int i = 0; i < n && L.size() != k; i++) {
		if(s.at(i) == 'o') {
			L.push_back(i);
			i += c;
		}
	}
	
	inserted = 0;
	for(int i = n - 1; i >= 0 && R.size() != k; i--) {
		if(s.at(i) == 'o') {
			R.push_back(i);
			i -= c;
		}
	}
	
	for(int i = 0; i < k; i++) {
		if(L[i] == R[k - i - 1]) cout << L[i] + 1 << endl;
	}
}

Measured memory_bytes: 3448
n = int(input())
A = list(map(int, input().split()))
b = [0]*(n-1)
a_sum = 1000
num1 = 0
num2 = 0
for i in range(n-1):
  if A[i+1] >= A[i]:
    b[i] = 1
for i in range(n-1):
  if b[i] == 1:
    num1 = a_sum // A[i]
    num2 = a_sum % A[i]
    a_sum = num2 + num1*A[i + 1]
print(a_sum)
    

Measured memory_bytes: 9048
#include <iostream>
#include <vector>

using namespace std;

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

    long long m = 1000;
    long long s = 0;

    for(int i=0; i<N-1; i++){
        if(A[i] <= A[i+1]){
            s += m/A[i];
            m -= A[i] * (m/A[i]);
        }else{
            m += A[i] * s;
            s = 0;
        }
    }

    m += A[N-1] * s;

    cout << m << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    for (int i = 0; i < T.size(); ++i) {
        if (T[i] == '?') {
            T[i] = 'D';
        }
    }

    cout << T << endl;

    return 0;
}


Measured memory_bytes: 3356
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M=map(int,input().split())
H=list(map(int,input().split()))
AB=[list(map(int,input().split())) for i in range(M)]

data=[1 for i in range(N)]
for a,b in AB:
    a-=1
    b-=1
    if data[a]:
        if H[a]<=H[b]:
            data[a]=0
    if data[b]:
        if H[a]>=H[b]:
            data[b]=0

print(sum(data))


Measured memory_bytes: 104184
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using vi  = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
  int N;
  cin >> N;
  map<int, int> map;
  int a;
  rep(i,N) {
    cin >> a;
    map[a] += 1;
  }
  int ans, curr;
  ans = 0;
  rep(i, 100001) {
    curr=map[i-1]+map[i]+map[i+1];
    ans = curr > ans ? curr : ans;
  }

  cout << ans << endl;
}


Measured memory_bytes: 8288
N, D = map(int, input().split())
XX = [list(map(int, input().split())) for _ in range(N)]
ans = 0

for i1 in range(N):
    for i2 in range(i1+1, N):
        total = 0
        for index in range(D):
            total += (XX[i1][index] - XX[i2][index])**2
        val = total ** (1/2)
        if isinstance(val, complex):
            val = val.real
        if val.is_integer():
            ans += 1

print(ans)


Measured memory_bytes: 3188
h,w = map(int,input().split())
l = [['*']*(w+2)]
for i in range(h):
    l.append(['*']+list(input())+['*'])
l.append(['*']*(w+2))


for i in range(1,h+1):
    s = ''
    for j in range(1,w+1):
        directions = [(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1),(-1,0),(-1,1)]
        alist = [(i+dir[0],j+dir[1]) for dir in directions]
        cnt = 0
        for a in alist:
            if l[a[0]][a[1]] == '#':
                cnt += 1
        if l[i][j] == '#':
            s += '#'
        else:
            s += str(cnt)
    print(s)


Measured memory_bytes: 68264
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;



    void solve()
    {
        int N = cin.nextint;
        int C = cin.nextint;
        var S = new int[N];
        var T = new int[N];
        var CH = new int[N];

        var H = new int[C, 114514 * 2];
        for (int i = 0; i < N; i++)
        {
            S[i] = cin.nextint;
            T[i] = cin.nextint;
            CH[i] = cin.nextint - 1;
            H[CH[i], S[i] * 2 - 1]++;
            H[CH[i], T[i] * 2]--;
        }
        var D = new int[114514 * 2];
        for (int i = 0; i < C; i++)
        {
            for (int j = 0; j < 114514 * 2; j++)
            {
                if (j != 0)
                {
                    H[i, j] += H[i, j - 1];
                }
                if (H[i, j] >= 1) D[j]++;
            }

        }
        WriteLine(D.Max());
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 46144
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func check753(v int) bool {
	x3 := 0
	x5 := 0
	x7 := 0
	for v > 0 {
		x := v % 10
		if x == 3 {
			x3 = 1
		}
		if x == 5 {
			x5 = 1
		}
		if x == 7 {
			x7 = 1
		}
		v /= 10
	}
	if x3+x5+x7 == 3 {
		return true
	}
	return false
}

func rec(v, N int) int {
	if v > N {
		return 0
	}
	ret := 0
	if check753(v) {
		ret = 1
	}
	ret += rec(v*10+3, N)
	ret += rec(v*10+5, N)
	ret += rec(v*10+7, N)

	return ret
}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()

	out(rec(0, N))
}


Measured memory_bytes: 640
'use strict'

function main(input) {
    let date = input.split('/').map(v => ~~v)
    
    if (date[1] > 4) {
        console.log('TBD')
    }
    else {
        console.log('Heisei')
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 7372
/*He who forgives and acknowledges himself... that is what it truly means to be strong!*/
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
#include <list>
#include <deque>
#include <bitset>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <sstream>
#include <complex>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <climits>
#include <utility>
#include <ctime>
#include <tuple>
#include <fstream>
#define T int test_case; scanf("%d",&test_case); while(test_case--)
#define FOR(i,a,n) for(i=a;i<n;i++)
#define FORD(i,a,n) for(i=a;i>=n;i--)
#define FORS(i,a) for(i=0;a[i];i++)
#define si(x) scanf("%d",&x)
#define sc(x) cin>>x
#define sd(x) scanf("%lf",&x)
#define sll(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define prs(x) printf("%d ",x)
#define pls(x) printf("%lld ",x)
#define pc(x) printf("%c",x)
#define pi(x) printf("%d\n",x)
#define pd(x) cout.precision(10),cout<<fixed<<x<<endl;
#define pll(x) printf("%lld\n",x)
#define ps(x) printf("%s\n",x)
#define M 1000000007
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define pb push_back
#define fr first
#define se second
#define in insert
#define er erase
#define pii pair<int, int>
#define plll pair<long long, long long>
#define tr(x,it) for(auto it : x)
#define INF 1ll<<60
#define PI 3.14159265358979323846264338327950288419716939937510582097494459230
#define bs(x,lo,hi,mid) cout<<x<<" "<<lo<<" "<<hi<<" "<<mid<<endl;
using namespace std;
ll gcd (ll a, ll b) {return ( a ? gcd(b%a, a) : b );}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n&1) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n&1) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
vector<int> prime;
bool primee[10000000];
void primegen(ll x) { for(ll i=2;i*i<=x;i++) if(!primee[i]) for(ll j=i*i;j<=x;j+=i) primee[j]=true; for(ll i=2;i<=x;i++) if(!primee[i]) prime.push_back(i);}

ll a[100005];

int main()
{
   int i,j;
   int n;
   si(n);
   FOR(i,0,3*n)
   	sll(a[i]);
   sort(a,a+3*n);
   ll x=0;
   j=n;
   i=3*n-2;
   while(j>0)
   {
   	x+=a[i];
   	j--;
   	i-=2;
   }
   pll(x);
   return 0;
}


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

int main(){
    int n, x;
    cin >> n >> x;
    while(n != 0 ||x != 0){
        int un=0;
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                for(int k=j+1;k<=n;k++){
                    if(i + j + k == x) un++;
                }
            }
        }
        cout << un << endl;
        cin >> n >> x;
    }

return 0;
}


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

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while (true) {
    c -= b;
    if (c <= 0) {
      cout << "Yes\n";
      exit(0);
    }
    a -= d;
    if (a <= 0) {
      cout << "No\n";
      exit(0);
    }
  }
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/01/29  Problem: ARC 090 A / Link: http://arc090.contest.atcoder.jp/tasks/arc090_a  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	cin >> N;

	VVL a(2, VL(N));
	VVL dp(2, VL(N + 1, 0));
	FOR(i, 0, 2) {
		FOR(j, 0, N) {
			cin >> a[i][j];
		}
	}


	FOR(i, 0, N) {
		dp[0][i + 1] = max(dp[0][i + 1], dp[0][i] + a[0][i]);
		dp[1][i] = max(dp[1][i], dp[0][i] + a[0][i]);
		dp[1][i + 1] = max(dp[1][i + 1], dp[1][i] + a[1][i]);
	}
	ans = dp[1][N];
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(void)
 
{
 
double r,a,b ;
 
 scanf("%lf",&r) ;
 
 a = r*r*3.14159265359 ;
 
 b = 2*r*3.14159265359 ;
 
 printf("%lf %lf",a,b) ;
 
 return 0 ;
 
}
 
 



 

Measured memory_bytes: 648
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9

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

    ans = 0
    for i in range(1, n+1):
        tmp = 0
        S = str(i)
        for s in S:
            tmp += int(s)
        if a <= tmp and tmp <= b:
            ans += i
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 71236
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N_MAX = 1e+5;

//グローバルに持っていく
// グローバルに持っていく
using Graph = vector<vector<int>>;


int main(){
    int N;
    cin >> N;
    vector<int> a(N-1),b(N-1);
    vector<int> color(N),parent(N);
    Graph G(N);
    for(int i=0;i<N-1;i++){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        G[a[i]].push_back(b[i]);
    }

    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    parent[0]=0;
    color[0]=0;
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    int ans=0;
    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();
        int cnt=1;
        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない
            if(cnt==color[v]) cnt++;
            parent[nv]=v;
            color[nv]=cnt;
            ans=max(ans,cnt);
            cnt++;
            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }



    int tmp1,tmp2;
    cout<<ans<<endl;
    for(int i=0;i<N-1;i++){
        tmp1=a[i];
        tmp2=b[i];
        if(parent[tmp1]==tmp2){
            cout<<color[tmp1]<<endl;
        }else{
            cout<<color[tmp2]<<endl;
        }
    }
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Mll = M<ll, ll>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin(),ie=(c).rend();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, m;

int main() {
    cin >> n >> m;
    cout << (n-1)*(m-1) << '\n';

    return 0;
}


Measured memory_bytes: 256
a=int(input())
b=input().rstrip().split()
l=[]
SUM = 0
for i in range(a):
    l.append(int(b[i]))
    SUM+=int(b[i])
ave=SUM//a
ave1=SUM//a+1

def keisan(ave,l):
    y=0
    for i in range(len(l)):
        y+=(int(l[i])-ave)**2
    return y

if (keisan(ave,l)<keisan(ave1,l)):
    print(keisan(ave,l))
else:
    print(keisan(ave1,l))

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

long long X, Y;
int ans = 0;

int main(){
	scanf("%lld %lld", &X, &Y);
	long long tmp = X;
	while(tmp <= Y){
		ans++;
		tmp *= 2;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256