akhauriyash/Code-Regression huggingface dataset:
Anntena=[]
for _ in range(5):
    Anntena.append(int(input()))

k = int(input())

from itertools import combinations

c = list(combinations(Anntena,2))

flg=0
for a in c:
    dist = abs(a[1] - a[0])

    if dist>k:
        flg+=1

if flg==0:
    print('Yay!')
else:
    print(':(') 

Measured memory_bytes: 3064
n=int(input())
a=[0]+list(map(int,input().split()))
inf=float("inf")

for i in range(1,n+1):
    a[i]+=a[i-1]

left=1
right=0
ans=inf
for mid in range(2,n-1):
    right=max(right,mid+1)
    while a[left]<a[mid]-a[left]:
        left+=1
    data_1=[[a[left-1],a[mid]-a[left-1]],[a[mid]-a[left],a[left]]]
    while a[right]-a[mid]<a[n]-a[right]:
        right+=1
    data_2=[[a[right-1]-a[mid],a[n]-a[right-1]],[a[n]-a[right],a[right]-a[mid]]]

    for x,y in data_1:
        for z,w in data_2:
            ans=min(ans,max(y,w)-min(x,z))

print(ans)

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

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

    double ans = 0;
    for (int i = 0; i < n; i++) {
        ans += 1 / a[i];
    }
    ans = 1 / ans;

    cout << ans << endl;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n; cin>>n;
    long long a[n]; rep(i,n) cin>>a[i];
    sort(a,a+n);
    long long l=a[n-1];
    long long r=-1;
    long long mid=l/2;
    if(l%2==0){
        rep(i,n){
            if(abs(mid-a[i])<abs(mid-r)){
                r=a[i];
            }
        }
    }else{
        rep(i,n){
            if(min(abs(mid-a[i]),abs(mid+1-a[i]))<min(abs(mid-r),abs(mid+1-r))){
                r=a[i];
            }
        }
    }
    cout<<l<<" "<<r<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <unordered_map>

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

using namespace std;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main(){
    ll n,k,s; cin >> n >> k >> s;
    if  (n==k) {
        for(int i = 0; i < n-1; i++) {
            cout << s << " ";
        }
        cout << s << endl;
        return 0;
    }
    if(s != 1000000000) {
        for(int i = 0; i < k; i++) {
            cout << s << " ";
        }
        for(int i = 0; i < n-k-1; i++) {
            cout << 1000000000 << " ";
        }
        cout << 1000000000 << endl;
        return 0;
    }
    for(int i = 0; i < k; i++) {
        cout << s << " ";
    }
    for(int i = 0; i < n-k-1; i++) {
        cout << 1 << " ";
    }
    cout << 1 << endl;
    return 0;

}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define eb emplace_back
#define precision(n) cout << fixed << setprecision(n);
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
int main()
{
    int n;
    cin>>n;
    // vector<int>v;
    int a[n];
    for(int i=0; i<n-1; i++)
    {
        cin>>a[i];

    }
    int ans=a[0];
    for(int i=1; i<n-1; i++)
    {
        ans+=min(a[i],a[i-1]);
    }

    cout<<ans+a[n-2]<<endl;
    return 0;
}




Measured memory_bytes: 3616
#include <stdio.h>
#include <stdlib.h>

#define int long long
#define datatype int

typedef struct {
	int A;
	int num;
}pair;

//比較関数
int compare(datatype a, datatype b){
	return b - a;
}

//昇順
void sort_sub(datatype *origin, int left, int right, datatype *tmp){
	if(right - left > 1){
		int i, j, k, half = (left + right) / 2;
		sort_sub(origin, left, half, tmp);
		sort_sub(origin, half, right, tmp);
		for(i = left; i < right; i++){
			tmp[i] = origin[i];
		}
		for(i = left, j = left, k = half; i < right; i++){
			if((compare(tmp[j], tmp[k]) <= 0 && j < half) || k == right){
				origin[i] = tmp[j];
				j++;
			}
			else{
				origin[i] = tmp[k];
				k++;
			}
		}
	}
}

void sort(datatype *origin, int N){
	datatype *tmp = (datatype *)malloc(sizeof(datatype) * N);
	sort_sub(origin, 0, N, tmp);
	free(tmp);
}

signed main(){
	int N, i, j, ans = -1;
	scanf("%lld", &N);
	int *A = (int *)malloc(sizeof(int) * N);
	pair *P = (pair *)malloc(sizeof(pair) * N);
	for(i = 0; i < N; i++){
		scanf("%lld", &A[i]);
		P[i].A = -1;
		P[i].num = 0;
	}
	sort(A, N);
	P[0].A = A[0];
	P[0].num++;
	for(i = 1, j = 0; i < N; i++){
		if(A[i] == P[j].A){
			P[j].num++;
		}
		else{
			j++;
			P[j].A = A[i];
			P[j].num++;
		}
	}
	for(i = 0; i <= j; i++){
		if(P[i].num >= 4){
			if(ans == -1){
				printf("%lld\n", P[i].A * P[i].A);
				return 0;
			}
			else{
				printf("%lld\n", ans * P[i].A);
				return 0;
			}
		}
		if(P[i].num >= 2){
			if(ans == -1){
				ans = P[i].A;
			}
			else{
				printf("%lld\n", ans * P[i].A);
				return 0;
			}
		}
	}
	printf("0\n");
	return 0;
}

Measured memory_bytes: 3328
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<par<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    vi h(n);
    rep(i,n)cin>>h[i];
    vi dp(n+1);
    dp[1]=abs(h[1]-h[0]);
    Rep(i,2,n){
        dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
    }
    cout<<dp[n-1]<<endl;
}

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

int G[200][200];
int tmp[200][200];

map<string,int> mp;

int func(string s){
  if(mp.count(s)==0){
    int res=mp.size();
    mp[s]=res;
    return res;
  }else{
    return mp[s];
  }
}

int getNum(string s){
  for(int i=0;i<(int)s.size();i++)
    if(s[i]=='^')s[i]=' ';
  stringstream ss(s);
  int res;
  ss>>res;
  ss>>res;
  return res;
}

void init(){
  fill(G[0],G[200], 1e9);
  mp.clear();
  for(int i=0;i<200;i++)
    G[i][i]=0;
}

int main(){
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    init();
    bool ans=true;
    for(int i=0;i<n;i++){
      string A,B,C,D,E;
      cin>>A>>B>>C>>D>>E;
      int a=func(B);
      int b=func(E);
      int c=getNum(D);
      if(G[b][a]!=1e9&&G[b][a]!=c)ans=false;
      G[b][a]=c;
      G[a][b]=-c;
    }
    int size=mp.size();
    for(int i=0;i<size;i++){
      for(int j=0;j<size;j++){
        tmp[i][j]=G[i][j];
      }
    }
    
    for(int k=0;k<size;k++)
      for(int i=0;i<size;i++)
        for(int j=0;j<size;j++)
          G[i][j]=min(G[i][j],G[i][k]+G[k][j]);

    for(int i=0;i<size;i++)
      for(int j=0;j<size;j++)
        if(tmp[i][j]!=1e9 && G[i][j]!=tmp[i][j])ans=false;

    cout<< (ans?"Yes":"No") <<endl;
  }
  return 0;
}

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

int main() {
	int N, K, count = 0;
	cin >> N >> K;
	for (int a = 1; a <= N; a += 2) {
		count++;
	}
	if (count >= K) {
		cout << "YES";
	}
	else
		cout << "NO";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long x = sc.nextLong();
		
		int year = 0;
		long deposit = 100;
		while (deposit < x) {
			deposit = deposit + deposit / 100;
			year++;
		}
		
		System.out.println(year);
	}
	
}


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

using namespace std;
#define ll long long
#define int long long

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif


int N;
int a[300000];
int A[100100];
int B[100100];

signed main()
{
	cin >> N;
	rep(i,3*N) cin >> a[i];
	int sum = 0;
	priority_queue<int, vector<int>, greater<int> > q;
	rep(i, N) {
		sum += a[i];
		q.push(a[i]);
	}
	A[0] = sum;
	reps(i, N, 2*N) {
		q.push(a[i]);
		sum += a[i];
		sum -= q.top();
		A[i-N+1] = sum;
		q.pop();
	}
	sum = 0;
	while (!q.empty()) q.pop();
	reps(i, 2*N, 3*N) {
		sum -= a[i];
		q.push(-a[i]);
	}
	B[N] = sum;
	rreps(i, 2*N, N) {
		q.push(-a[i]);
		sum += -a[i];
		sum -= q.top();
		B[i-N] = sum;
		q.pop();
	}
	int ma = A[0]+B[0];
	rep(i, N+1) ma = max(ma, A[i]+B[i]);
	cout << ma << endl;
}


Measured memory_bytes: 5108
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 1e5 + 10;
char s[N] , t[N];
int sums[N] , sumt[N] , lens , lent;
int q,a,b,c,d;
void prepare(char*s,int*sum,int len){
  len=strlen(s+1);
  rep(i,1,len+1) sum[i]=sum[i-1]+(s[i]=='A'?1:2);
}
int get(int*sum,int l,int r){
  return sum[r]-sum[l-1];
}

int main(){
  scanf("%s%s",s+1,t+1);
  prepare(s,sums,lens);prepare(t,sumt,lent);
  scanf("%d",&q);
  rep(i,0,q) {
    scanf("%d%d%d%d",&a,&b,&c,&d);
    puts((get(sums,a,b)-get(sumt,c,d))%3?"NO":"YES");
  }
  return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#include<ctime>
#define R(i, n) for(int i = 0;i < n;i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define SA(i, n, a) R(i, n) scanf("%d", a + i)
#define SAL(i, n, a) R(i, n) scanf("%lld", a + i)
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a)
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;
const int INF = 1e+9;

int N, K, H[100000], DP[100000];

int main() {
	S2(N, K);
	SA(i, N, H);
	fill(DP, DP + N, INF);
	DP[0] = 0;
	R(i, N) {
		for (int j = 1; j <= K; j++) {
			if (i + j < N) DP[i + j] = min(DP[i + j], DP[i] + abs(H[i + j] - H[i]));
		}
	}
	P(DP[N - 1]);
}
	

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

int  main()
{
	int r,g,b; cin >> r >> g >> b;
	int n = (r*100) + (g*10) + b;
	if (n % 4 == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;using vb=vector<bool>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template <typename T> T read() {T t; cin >> t; return t;}

int solve() {
  int n = read<int>();
  int k = read<int>();

  vector<int> A(k);
  rep(i, k) {
    A[i] = read<int>();
  }
  sort(all(A));

  int ma = A[k-1];

  int r = n - ma;
  ma -= r;
  if (ma < 1) return 0;
  return ma - 1;
}

void Main() {
  cout << solve() << endl;
}
int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }


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

int main() {
  vector<int> vec(5);
  vector<int> amari(5);
  int tibi=10;
  int wa=0;
  int count=0;
  for (int i=0 ; i<5 ; i++){
    cin >> vec.at(i);
    amari.at(i)=vec.at(i)%10;
    if(amari.at(i)==0){
      count=count+1;
    }
    else{
      tibi=min(amari.at(i),tibi);
    }
    if(amari.at(i)==0){
      wa=wa+vec.at(i);
    }
    else{
      wa=wa+vec.at(i)-amari.at(i)+10;
    }
  }
  if(count==5){
    cout << wa << endl;
  }
  else{
    cout << wa + tibi -10 << endl;
  }
}

  
    


Measured memory_bytes: 256
#include <stdio.h>

struct node{
    int pnod;
    int l;
    int r;
};

struct node Node[25];

void preParse(int u){
    if(u == -1) return;

    printf(" %d", u);
    preParse(Node[u].l);
    preParse(Node[u].r);
}

void inParse(int u){
    if(u == -1) return;

    inParse(Node[u].l);
    printf(" %d", u);
    inParse(Node[u].r);
}

void postParse(int u){
    if(u == -1) return;
    
    postParse(Node[u].l);
    postParse(Node[u].r);
    printf(" %d", u);
}


int main(){
    int i, nm, n, l, r, init;

    for(i = 0; i < 26; i++){
        Node[i].l = Node[i].l = Node[i].pnod = -1;
    }

    scanf("%d", &nm);

    for(i = 0; i < nm; i++){
        scanf("%d", &n);
        scanf("%d%d", &Node[n].l, &Node[n].r);
        Node[Node[n].l].pnod = n;
        Node[Node[n].r].pnod = n;
    }

    for(i = 0; i < nm; i++){
        if(Node[i].pnod == -1){
            init = i;
            break;
        }
    }

    printf("Preorder\n");
    preParse(init);
    printf("\nInorder\n");
    inParse(init);
    printf("\nPostorder\n");
    postParse(init);
    printf("\n");

    return 0;
}



Measured memory_bytes: 2036
x,y = map(int,raw_input().strip().split(' '))
follow = [[] for i in range(x)]
for i in range(y):
    s,t = map(int,raw_input().strip().split(' '))
    follow[s].append(t)
    follow[t].append(s)
 
color = {}
c = 0

for i in range(x):
    if not i in color:
        que = [i]
        color[i] = c
        while len(que) > 0:
            u = que[0]
            for v in follow[u]:
                if not v in color:
                    color[v] = c
                    que.append(v)
            del que[0]
        c += 1
 
 
q = int(raw_input())
for i in range(q):
    s,t = map(int,raw_input().strip().split(' '))
    if color[s] == color[t]:
        print 'yes'
    else:
        print 'no'

Measured memory_bytes: 32056
#include <stdio.h>
#define N 100001

int A[100000];

void swap(int* a, int* b){
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

void partition(int p, int r){
  int x;
  int i,j;
  x = A[r];
  i = p - 1;
  for(j=p;j<=r-1;j++){
    if(A[j] < x+1){
      i=i+1;
      swap(&A[i], &A[j]);
    }
  }
  swap(&A[i+1], &A[r]);
  for(j=p;j<r+1;j++){
    if(j!= p) printf(" ");
    if(j == i+1) printf("[%d]", A[j]);
    else printf("%d", A[j]);
  }
  printf("\n");
}

int main(){
  int s, i;
  scanf("%d", &s);
  for(i=0;i<s;i++) scanf("%d", &A[i]);
  partition(0, s-1);
  return 0;
}



Measured memory_bytes: 2156
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string str1,str2;
    cin>>str1>>str2;
    cout<<str2+str1<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner sc;
    public static void main(String[] args) {
        sc=new Scanner(System.in);
        //a();
        //b();
        c();
        //d();
    }
    public static void a(){
        int a=sc.nextInt();int b=sc.nextInt();
        System.out.println((a>9||b>9)?-1:a*b);
    }
    public static void b(){
        int n=sc.nextInt();
        int po[]=new int[81];
        boolean b=false;
        for(int i=0;i<9;i++)
        for(int j=0;j<9;j++)if((i+1)*(j+1)==n)b=true;
        System.out.println(b?"Yes":"No");
    }
    public static void c(){
        long n=sc.nextLong();
        long q=(long)Math.sqrt(n);
        long index=n;
        for(int i=2;i<=q;i++){
            if(n%i==0)index=i;
        }
        System.out.println(index+(n/index)-2);
    }
    public static void d(){
        int a=sc.nextInt();
        int b=sc.nextInt();
        int x=sc.nextInt();
        if((double)2*x/(a*a)-b>=0){
            double bb=((double)2*x)/(a*a)-b;
            System.out.println(Math.atan((-bb+b)/a)*180/Math.PI);
        }
        else{
            double aa=((double)2*x)/(a*b);
            System.out.println(Math.atan(((double)b)/aa)*180/Math.PI);
        }
        
    }
}


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

typedef long long ll;
#define PB push_back

char alphabet[26] = {'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'};

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	string s; cin >> s;
	string result = "";
	for (char u : s) {
		result += alphabet[(distance(alphabet, find(alphabet, alphabet + 26, u)) + n) % 26];
	}
	cout << result; 
}

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


int main() {
    int d, n;
    cin >> d >> n;
    int ans = pow(100, d) * n;
    if (n == 100) ans += pow(100, d);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mem(a, b) memset(a, b, sizeof(a))
#define inf (1e9 + 7)
using namespace std;

int num[100005], n;

int main()
{
    scanf("%d", &n);
    for(int i = 1;i <= n;i++)
        scanf("%d", &num[i]);
    sort(num + 1, num + 1 + n);
    if(num[n] - num[1] > 1)
    {
        puts("No");
        return 0;
    }
    if(num[1] == n - 1)
    {
        puts("Yes");
        return 0;
    }
    int tmp = 0, tmp2 = 0;
    for(int i = 1;i <= n;i++)
    {
        if(num[i] == num[1])
            tmp++;
        else
            break;
    }
    for(int i = 1;i <= n;i++)
    {
        if(num[i] == num[n])
            tmp2++;
    }
    if(num[1] == num[n])
    {
        if(num[1] * 2 <= n)
            puts("Yes");
        else
            puts("No");
        return 0;
    }
    if(tmp < num[n]&&tmp2 <= (n - num[n]) * 2)
    {
        puts("Yes");
        return 0;
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
		if(a<b){
			cout<<"a < b"<<endl;
		}
		else if(a==b){
			cout<<"a == b"<<endl;
		}
		else{
			cout<<"a > b"<<endl;
		}
		return 0;

}

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

int main(){
    int N;
    cin >> N;
    
    vector<int> d(N);
    for(int i = 0; i < N ; i++){
        cin >> d.at(i);
    }
    sort(d.begin() , d.end());
    reverse(d.begin(), d.end());

    int count = 0;
    int max = 101;
    for(int n : d){
        if(n < max){
            count++;
            max = n;
        }
    }

    cout << count << endl;

}

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

using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, n) for (int i = 1; i < (int)(n+1); i++)
#define rep4(i, s, n) for (int i = (s); i < (int)(n+1); i++)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
int main() {
const ll INF = 100100100100100100;
int N;
cin >>N;
if((N%10==2)||(N%10==4)||(N%10==5)||(N%10==7)||(N%10==9)) cout<<"hon"<<endl;
if((N%10==0)||(N%10==1)||(N%10==6)||(N%10==8)) cout<<"pon"<<endl;
if(N%10==3) cout<<"bon"<<endl;
return 0;
}


Measured memory_bytes: 3644
using System;
using System.Linq;

class RollerCoaster
{
	public static void Main(string[] args)
    {
        string[] str1 = Console.ReadLine().Split(' ');
        int n = int.Parse(str1[0]);
        int k = int.Parse(str1[1]);

        string[] str2 = Console.ReadLine().Split(' ');
        int[] h = str2.Select(int.Parse).ToArray();

        int count = h.Count(value => value >= k);

        Console.WriteLine(count);
    }
}

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

int main(int argc, char const *argv[]) {
  int a,b,c;
  cin>>a>>b>>c;
  for(int i=1;i<=b;i++){
    if((a*i)%b==c){
      cout<<"YES"<<endl;
      break;
    }
    if(i==b){
      cout<<"NO"<<endl;
    }
  }
  return 0;
}


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

#define ll              long long
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             (int)(1e18)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define rep(i,j,n)      for(int i=j;i<n;i++)
#define all(p)          p.begin(),p.end()
#define ub(a,b)         upper_bound(all(a),b)
#define lb(a,b)         lower_bound(all(a),b)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

void run()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
vector<int> a;
vector<vector<int>> dp;
vector<int> sum;
int solve(int i, int j)
{
	if (dp[i][j] != -1)
	{
		return dp[i][j];
	}
	if (i == j)
	{
		dp[i][j] = a[i];
	}
	else {
		int x = solve(i + 1, j);
		int y = solve(i, j - 1);
		x = sum[j] - sum[i + 1] + a[i + 1] - x;
		y = sum[j - 1] - sum[i] + a[i] - y;
		x += a[i];
		y += a[j];
		dp[i][j] = max(x, y);
	}
	return dp[i][j];
}
int32_t main()
{
	run();
	int n;
	cin >> n;
	a.resize(n);
	sum.resize(n);
	dp.assign(n, vector<int>(n, -1));
	rep(i, 0, n)
	{
		cin >> a[i];
	}
	sum[0] = a[0];
	rep(i, 1, n)
	{
		sum[i] = sum[i - 1] + a[i];
	}
	int ans = solve(0, n - 1);
	// for (int i = 0; i < n; i++)
	// {
	// 	for (int j = 0; j < n; j++)
	// 	{
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	int ans2 = sum[n - 1] - ans;
	cout << ans - ans2 << endl;
	return 0;
}

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

typedef long long ll;

ll N, A, B, C, D, E;

int main() {
    cin >> N >> A >> B >> C >> D >> E;

    printf("%lld\n", (ll)ceil((double) N / min({A, B, C, D, E})) + 4);
}

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

using namespace std;

#define MOD 1000000007

typedef unsigned long long ull;

vector<int> prime;
bool isprime(int n) {
        for (int i = 2; i * i <= n; i++) {
                if (n % i == 0)
                        return false;
        }
        return true;
}

void makeprime() {
        for (int i = 2; i < 1000; i++) {
                if (isprime(i)) {
                        prime.push_back(i);
                }
        }
}

int main() {
        int n;
        cin >> n;
        makeprime();
        map<int, int> fact;
        for (int i = 2; i <= n; i++) {
                vector<int>::iterator it = prime.begin();
                int tmp = i;
                while (tmp > 1 && it != prime.end()) {
                        while (tmp % *it == 0) {
                                fact[*it]++;
                                tmp /= *it;
                        }
                        it++;
                }
        }
        ull ans = 1;
        vector<int>::iterator it = prime.begin();
        while (it != prime.end()) {
                ans = ans * (fact[*it] + 1) % MOD;
                it++;
        }
        cout << ans << endl;

        return 0;
}




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

using namespace std;

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

    sort(l, l + N, greater<int>());
    int ans = 0;
    for (i = 0; i < K; i++) {
        ans += l[i];
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

#define MOD 1000000007
typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;


int main()
{
int n;cin>>n;
int ans =0;

int i = 0;
while(i*i<=n)
{
    i++;
}
cout<<(i-1)*(i-1)<<endl;
 return 0;
}


Measured memory_bytes: 3668
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC083A {
    class Program {
        static void Main(string[] args) {
            int[] input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int A = input[0];
            int B = input[1];
            int C = input[2];
            int D = input[3];
            if (A + B > C + D) {
                Console.WriteLine("Left");
            } else if (A + B == C + D) {
                Console.WriteLine("Balanced");
            } else {
                Console.WriteLine("Right");
            }
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin>>n>>s;
    for(auto it:s){
        int x = it + n;
        if(x>'Z')
            x -= 26;
        cout << char(x);
    }
    cout << endl;
}

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

#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int inf = 1e9;

int N;
int A,B,C;
vector<int> l;

int dfs(int cur, int a, int b, int c) {
  if (cur == N) {
    if (min(a, min(b,c))>0) {
      return abs(a-A)+abs(b-B)+abs(c-C)-30;
    } else {
      return inf;
    }
  }
  int ret = dfs(cur+1, a, b, c);
  ret = min(ret, dfs(cur+1, a+l[cur], b, c) + 10);
  ret = min(ret, dfs(cur+1, a, b+l[cur], c) + 10);
  ret = min(ret, dfs(cur+1, a, b, c+l[cur]) + 10);
  return ret;
}

void solve()
{
  cin>>N;
  cin>>A>>B>>C;
  for (int i=0; i<N; i++) {
    int tmp; cin>>tmp;
    l.push_back(tmp);
  }
  int ans = dfs(0, 0, 0, 0);
  cout << ans << endl;
}

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


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val edges = Array<Pair<Int, Int>>(m) { 0 to 0 }
    val graph = Array(n + 1) { mutableListOf<Int>() }

    repeat(m) {
        val (a, b) = readLine()!!.split(' ').map { it.toInt() }
        edges[it] = a to b
        graph[a].add(b)
        graph[b].add(a)
    }

    var ans = 0

    for (edge in edges) {

        val visited = BooleanArray(n + 1) { false }
        val stack = ArrayDeque<Int>()

        visited[edge.first] = true
        stack.addFirst(edge.first)

        while (stack.isNotEmpty()) {
            val v = stack.removeFirst()
            for (u in graph[v]) {
                if (v == edge.first && u == edge.second) continue
                if (visited[u]) continue
                visited[u] = true
                stack.push(u)
            }
        }

        if (!visited[edge.second]) ans++
    }

    println(ans)
}


Measured memory_bytes: 38180
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = null;
		try {
			input = br.readLine();
			br.close();
		} catch (IOException e) {
		}

		String[] ab = input.split(" ");

		int a = Integer.parseInt(ab[0]);
		int b = Integer.parseInt(ab[1]);

		System.out.println(a * b + " " + 2 * (a + b));
	}
}


Measured memory_bytes: 24312
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
int main() {
  int n, m, Sum;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end(), greater<int>());
  Sum = accumulate(a.begin(), a.end(), 0);
  if (a[m-1]>=(double)Sum/(4*m)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

void test(long& a, long b) {
  if (a > b) a = b;
}

int main() {
  int n;

  cin >> n;

  vector<long> h(n), ans(n);

  for (int i = 0; i < n; i++) {
    cin >> h[i];
    ans[i] = 1e9;
  }

  ans[0] = 0;
  ans[1] = abs(h[0] - h[1]);
  for (int i = 2; i < n; i++) {
    // for (int j = 1; j < 2 + 1; j++) {
    // ans[i] = min(ans[i], abs(h[i] - h[i - j]) + ans[i - j]);
    test(ans[i], abs(h[i] - h[i - 1]) + ans[i - 1]);
    test(ans[i], abs(h[i] - h[i - 2]) + ans[i - 2]);
    //}
  }

  cout << ans[n - 1];

  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
string m[12]={"01","02","03","04","05","06","07","08","09","10","11","12"};
int main()
{
	string s;
	int m1=0,m2=0;
	cin>>s;
	string a=s.substr(0,2),b=s.substr(2,2);
	for(int i=0;i<12;i++)
	{
		if(a==m[i])
			m1=1;
		if(b==m[i])
			m2=1;
	}
	if(m1&&m2)
		puts("AMBIGUOUS");
	else if(m1)
		puts("MMYY");
	else if(m2)
		puts("YYMM");
	else
		puts("NA");
	return 0;
}


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

using namespace std;
const double PI=3.14159265358979323846;

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))


int main() {

	long N;

	cin >> N;

	long sum = 0;

	for (long i = 1; i <= N; i++)
		if (i % 3 != 0 && i % 5 != 0) sum += i;	

	cout << sum << endl;
}

Measured memory_bytes: 3580
a = int(input().split()[0])
b = list(map(str, input().split()[0]))
k = 0
s = 1
#print(a)
#print(b)
while k<len(b) -1:
 t = b[k]
 u = b[k+1]
 #print("t",t,"u",u)
 if not t == u:
  s = s + 1
  #print(s)
 k = k + 1
print(s)

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

int main(){
	int n; cin >> n;
	int d[101]={0};
	int a;
	for(int i=0;i<n;++i){
		cin>>a; d[a]=1;
	}
	int ans;
	for(int i=1;i<=100;++i){
		if(d[i]==1) ++ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1) 

const ll INF = 10010001010;
const int inf = 2000000000;


typedef tuple<string, int, int> TUP;

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

int main()
{
    int N;
    cin >> N;
    vector<int> A(3 * N);
    ll ans = 0;
    vector<int> G(N);
    for (int i = 0; i < 3 * N; i++)
    {
        cin >> A[i];
    }
    sort(all(A));
    for (int i = N; i < 3 * N;i+= 2)
    {
        ans += A[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int M = 300010;
		var ST = new SegTreeMax(M);
		
		long[] dp = new long[N];
		for(int i=N-1;i>=0;i--){
			int now = A[i];
			int l = A[i] - K;
			int r = A[i] + K;
			var ma = ST.QueryMax(l, r + 1);
			if(ma == ST.Inf){
				dp[i] = 1;
			} else {
				dp[i] = 1 + ma;
			}
			ST.Update(A[i], dp[i]);
		}
		Console.WriteLine(dp.Max());
		
		
	}
	int N,K;
	int[] A;
	public Sol(){
		var d = ria();
		N = d[0]; K = d[1];
		A = new int[N];
		for(int i=0;i<N;i++) A[i] = ri();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


class SegTreeMax{
	//segment Tree 
	// 0-origin
	protected long[] Data;	
	public long Inf;	
	protected int N;		 
	protected int n;		
	
	public SegTreeMax(int n_){
		N = n_; Inf = -(long)1e18;
		n = 1;
		while(n < n_) n *= 2;
		Data = new long[2 * n - 1];
		for(int i=0; i < 2 * n - 1; i++) Data[i] = Inf;
	}
	
	//	   0
	//	 1   2
	//	3 4 5 6
	public void Update(int k,long a){
		k += n - 1;	
		Data[k] = a;
		while(k > 0){
			k = (k - 1) / 2;
			Data[k] = Math.Max(Data[k * 2 + 1], Data[k * 2 + 2]);
		}
	}
	
	
	public long QueryMax(int a, int b){
		return Query(a, b, 0, 0, n);
	}
	//RMQ; [a,b)
	public long Query(int a,int b,int k,int l,int r){
		if(r <= a || b <= l) return Inf;
		if(a <= l && r <= b) return Data[k];
		
		var vl = Query(a, b, k * 2 + 1, l, (l + r) / 2);
		var vr = Query(a ,b, k * 2 + 2, (l + r) / 2, r);
		return Math.Max(vl, vr);
	}
	
	
	public long Max{
		get{ return Data[0];}
	}
	
	
	public void Dump(){
		Console.WriteLine();
		int h = 0;
		int cnt = 0;
		for(int i=0;i<Data.Length;i++){
			Console.Write("{0} ", Data[i]);
			cnt++;
			if(cnt == 1 << h){
				cnt = 0;
				h++;
				Console.WriteLine();
			}
		}
	}
	
}



Measured memory_bytes: 51132
/// You just can't beat the person who never gives up
/// ICPC next year

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std ;
const int N = 1e6+5 ;

int n ,p ;
string str ;
int cnt[N] ,cur[N] ,len[N] ;
int main(){
    cin >> n >> p >> str ;
    if(p==2 || p==5){
        long long ans = 0 ;
        for(int i=0;i<n;++i) if((str[i]-'0')%p == 0) ans += i+1 ;
        printf("%lld",ans);
        return 0;
    }

    len[0] = 1 ;
    for(int i=1;i<=n;++i) len[i] = len[i-1]*10%p;
    /// arr[i][j] = (arr[i][n] - arr[j+1][n]) / (10^(n-j))
    cnt[0] = 1 ;
    long long ans = 0 ;
    for(int i=n-1;i>=0;--i){
        cur[i] = (len[n-i-1]*(str[i]-'0')%p + cur[i+1])%p ;
        ans += cnt[cur[i]]++ ;
    }
    printf("%lld\n",ans);
    return 0;
}


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

vector<int> viSort;
int iMaxSize;

void fnTrace()
{
  for (int i = 0; i < iMaxSize; i++)
  {
    if (i) cout << " ";
    cout << viSort[i];
  }
  cout << endl;
}

void insertionSort()
{
  for (int i = 1; i < iMaxSize; i++)
  {
    int iTarget = viSort[i];
    int j = i - 1;
    while (iTarget < viSort[j] &&
           j       >= 0            )
    {
      viSort[j + 1] = viSort[j];
      j--;
    }
    viSort[j + 1] = iTarget;
    fnTrace();
  }
}

int main()
{
  cin >> iMaxSize;
  viSort.resize( iMaxSize );
  for (int i = 0; i < iMaxSize; i++) cin >> viSort[i];

  fnTrace();
  insertionSort();

  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

int N, A[3];
int x[3];
int l[10];
int ans;
void dfs(int i, int cost) {
    if (i == N) {
        REP(j, 3) {
            if (x[j] == 0) return;
            cost += abs(A[j] - x[j]);
        }
        chmin(ans, cost);
        return;
    }
    REP(j, 3) {
        int c = cost;
        if (x[j] != 0) {
            c += 10;
        }
        x[j] += l[i];
        dfs(i + 1, c);
        x[j] -= l[i];
    }
    dfs(i + 1, cost);
}
signed main() {
    cin >> N >> A[0] >> A[1] >> A[2];
    REP(i, N) cin >> l[i];

    ans = INF;
    dfs(0, 0);
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
#include <stdio.h>
#define N 5000000

int H[N],n;

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

void maxHeapify(int i){
  int l,r,v,largest;
  l = left(i);
  r = right(i);
  if(l<=n&&H[l]>H[i]){
    largest = l;
  }
  else  largest = i;
  if(r<=n&&H[r]>H[largest]){
    largest = r;
  }
  if(largest!=i){
    v =H[i];
    H[i] = H[largest];
    H[largest]=v;
    maxHeapify(largest);
  } 
}

void buildMaxHeap(int i){
  for(i=n/2;i>=1;i--){
    maxHeapify(i);
  }
}

int main(){
  int i;

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&H[i]);
  }
  buildMaxHeap(i);
   for(i=1;i<=n;i++){
    printf(" %d",H[i]);
   }
    printf("\n");
  return 0;
}

Measured memory_bytes: 2556
#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion

#define M_PI 3.14159265358979

signed main() {
  double A, B, H, M;
  cin >> A >> B >> H >> M;

  double h12 = 12 * 60;
  double HM = H * 60 + M;

  double a = (2 * M_PI) * HM / h12;
  double b = (2 * M_PI) * M / 60;

  double c = abs(a - b);
  chmin(c, 2 * M_PI - c);
  double ans = sqrt(pow(B * sin(c), 2) + pow(B * cos(c) - A, 2));
  cout << ans << endl;
}

Measured memory_bytes: 4184
#include <stdio.h>
#include <string.h>
int main(){
    int N;
    int cnt = 0,m = 0, point = 0, num = 0;
    char S[31000] = {0};
    scanf("%d", &N);
    getchar();
    scanf("%s", S);
    int len = strlen(S);
    for (int i = 0; i <= 999; i++){
        int a[3] = {0};
        a[0] = i/100;//100
        a[1] = (i/10)%10;//10
        a[2] = i%10;//1
        m = 0, point = 0, num = 0;
        for (point = 0; point < len; point++) {
            if (a[m] == (S[point]-48)){//一致したら次
                num++;
                point++;
                break;
            }
        }
        m = 1;
        for (; point < len; point++){
            if (a[m] == (S[point] - 48)){//一致したら次}
                num++;
                point++;
                break;
            }
        }
        m = 2;
        for (; point < len; point++){
            if (a[m] == (S[point] - 48)){
                num++;
                break;
            }
        }
        if (num == 3){
            cnt++;
        }
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 256
'''
INPUT SHORTCUTS
N, K = map(int,input().split())
N ,A,B = map(int,input().split())
string = str(input())
arr = list(map(int,input().split()))
N = int(input())
'''
n , m = map(int,input().split())
if n>=10:
	print(m)
else:
	m = m + (100*(10-n))
	print(m)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define lli long long int
#define MAX(A,B) A>B?A:B
#define MIN(A,B) A<B?A:B
#define gcd(A,B) __gcd(A,B)
#define lcm(A,B) A/(__gcd(A,B))*B
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define ld long double
#define modulo 998244353
using namespace std;

typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<int,double> pid;

int main()
{
    int c=0;
    char str[100];
    scanf("%s",str);
    for (int i = 0; i<4; i++)
        c+=((str[i]-'0')==2);
    printf("%d",c);
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/diverta2019/tasks/diverta2019_d
# 問題文を数式に起こすと N=am+a (a<m, a \in N)を満たすmの合計を求めろという問題
# N=a(m+1) なのでN%(m+1)=0になるmの中で条件を満たすものを合計すれば良い。つまりNの約数を列挙する。
# 約数は√Nまで調べればいいので、オーダーはO(√N)となる


def make_divisors(n: int, sort=False):
    # 約数列挙
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    if sort:
        divisors.sort()
    return divisors


N = int(input())
candi = make_divisors(N)
ans = 0
for mp in candi:
    m = mp - 1
    if m > 0 and (N // m) == (N % m):
        ans += m
print(ans)


Measured memory_bytes: 3272
#pragma comment(linker, "/STACK:60777216")  

#include <cassert>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<complex>
#include<vector>
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<string>
#include<cstdlib>
#include<memory.h>
#include<ctime>
#include<bitset>
#include<fstream>
#include<queue>
#include<stack>
#include<unordered_map>
#include<unordered_set>

using namespace std;

typedef long double ld;

typedef long long ll;
typedef pair<int,int>	pii;
typedef pair<ld,ld>	pdd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef pair<ll,ll> pl;

#define FOR(i,a,b)		for(int i=(a);i<(b);i++)
#define REP(i,n)		FOR(i,0,n)
#define SORT(v)			sort((v).begin(),(v).end())
#define UN(v)			SORT(v),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define CL(a,b)			memset(a,b,sizeof a)
#define pb				push_back

int n;
ll a[111];
ll b[111];
ll best=0;
int num;
const int LIM = 28;
void go(vi v,int next){
	if(next==LIM+1){
		REP(i,n){
			b[i]=a[i];
			REP(j,v.size())if((i+1)%v[j]==0)b[i]=0;
		}
		for(int i=50;i>LIM;i--){
			ll sm=0;
			for(int j=1;j*i<=n;j++)sm+=b[i*j-1];
			if(sm<0){
				for(int j=1;j*i<=n;j++)b[i*j-1]=0;
			}
		}
		//30 45
		if(b[30-1]+b[45-1]+b[90-1]+b[60-1]<0){b[60-1]=b[30-1]=b[45-1]=b[90-1]=0;}
		//32 48
		if(b[32-1]+b[48-1]+b[96-1]+b[64-1]<0){b[64-1]=b[32-1]=b[48-1]=b[96-1]=0;}

		ll t =0;
		REP(i,n)t+=b[i];
		best=max(best,t);
		return;
	}
	go(v,next+1);
	bool h = 0;
	REP(i,v.size())if(next%v[i]==0){h=1;break;}
	if(!h){
		v.pb(next);
		go(v,next+1);
	}
}

int gcd(int a,int b){
	while(a&&b)
		if(a>b)a%=b;
		else b%=a;
		return a+b;
}

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

	
	cin>>n;
	//n=100;
	REP(i,n){
		cin>>a[i];
		//a[i]=0;
		if(i>=50 && a[i]<0)a[i]=0;
	}

	vi v;
	go(v,1);
	cout<<best<<endl;
	/*int t;
	FOR(i,21,51)FOR(j,i+1,51)if((t=i*j/gcd(i,j))<=100 && j%i!=0){
		num++;cout<<i<<' '<<j<<endl;

		FOR(k,j+1,51)if(t*k/gcd(t,k)<=100 && k%i!=0 && k%j!=0)cout<<i<<' '<<j<<' '<<k<<endl;
	}
	cout<<num<<endl;*/
	/*
	21 28
22 33
24 32
24 36
26 39
28 42
30 45
32 48
*/
#ifdef LocalHost
	printf("TIME: %.3lf\n",ld(clock())/CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

class Item implements Comparable<Item> {
	int price;
	int weight;
	char type;
	long day;
	String name;
	
	public Item(int price, int weight, char type, long day, String name) {
		this.price = price;
		this.weight = weight;
		this.type = type;
		this.day = day;
		this.name = name;
	}
	
	@Override
	public int compareTo(Item o) {
		int res = Integer.compare(price, o.price);
		if (res == 0) {
			res = Integer.compare(weight, o.weight);
			if (res == 0) {
				res = Character.compare(type, o.type);
				if (res == 0) {
					res = Long.compare(day, o.day);
					if (res == 0) {
						res = name.compareTo(o.name);
					}
				}
			}
		}
		return res;
	}
}

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Item> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			list.add(new Item(sc.nextInt(), sc.nextInt(), sc.next().charAt(0), sc.nextLong(), sc.next()));
		}
		Collections.sort(list);
		for (int i = 0; i < list.size(); i++) {
			System.out.println(list.get(i).price + " " + list.get(i).weight + " " + list.get(i).type + " " + list.get(i).day + " " + list.get(i).name);
		}
	}
}



Measured memory_bytes: 195356