akhauriyash/Code-Regression huggingface dataset:
#include <cctype>
#include <iostream>
using namespace std;

int main() {
  int N;
  cin >> N;
  if (isupper(N) != 0)
    cout << 1 << endl;
  else if (islower(N) != 0)
    cout << 2 << endl;
  else
    cout << 0 << endl;
}


Measured memory_bytes: 3100
from operator import itemgetter

n, x, d = map(int, input().split())

if d == 0:
    if x == 0:
        print(1)
    else:
        print(n+1)
    exit()
if d < 0:
    x *= -1
    d *= -1

p = dict()
q = dict()

for k in range(n+1):
    temp = k * x % d
    if temp in p.keys():
        #print((k - p[temp]) * x)
        a = (k - p[temp]) * x // d
        L = (k-1)*k//2 + a
        H = (2*n-k-1)*k//2 + a
        q[temp].append([L, H])
    else:
        p[temp] = k
        L = (k-1)*k//2
        H = (2*n-k-1)*k//2
        q[temp] = [[L, H]]

ans = 0

for z in q.values():
    c = - float('inf')
    for a, b in sorted(z):
        if a > c:
            ans += b - a + 1
        elif b > c:
            ans += b - c
        else:
            continue
        c = b

print(ans)

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

int main(){
  int n;
  cin >> n;
  for(int i=0; i<26; i++){
    for(int j=0; j<16; j++){
      if(4*i+7*j == n){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(void) {
	int N, M;
	cin >> N >> M;
	vector<int>A(M);
	for (int i = 0; i < M; i++) {
		cin >> A[i];
	}
	int all =0;
	for (int i = 0; i < M; i++) {
		all += A[i];
	}
	int Ans = N - all;
	if (Ans >= 0) {
		cout << Ans << endl;
	}
	else {
		cout << "-1" << endl;
	}
}

Measured memory_bytes: 3668
#include <stdio.h>
int main(){
  int i,j,n,cnt=0,min,hozon,flag=0;
  scanf("%d",&n);
  int hai[n];

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

  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(hai[j]<hai[min]){
	min=j;
	flag=1;
      }
    }
    if(flag==1){
      hozon=hai[i];
      hai[i]=hai[min];
      hai[min]=hozon;
      cnt++;
      flag=0;
    }
  }
  for(i=0;i<n;i++){
    printf("%d",hai[i]);
    if(i==n-1) printf("\n");
    else printf(" ");
  }
  printf("%d\n",cnt);

  return 0;
}

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

using namespace std;

int main() {
    int x, tmp = 0;
    cin >> x;

    if (x == 1) {
        tmp = 1;
    } else {
        for (int i = 2; i <= sqrt(x); i++) {
            for (int j = 2; ; j++) {
                if (pow(i, j) > x) {
                    if (pow(i, j-1) > tmp) tmp = pow(i, j-1);
                    break;
                }
            }
        }
    }

    cout << tmp << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
  char w[11], t[1001];
  int ans[26] = {0};
  int i = 0;
  int ch;

  while ((ch = getchar()) != EOF) {
    if (ch >= 'A' && ch <= 'Z') {
      ch = ch - 'A' + 'a';
    }
    ch -= 'a';
    ans[ch]++;
  }

  for (i = 0; i < 26; i++) {
    printf("%c : %d\n", i + 'a', ans[i]);
  }

  return 0;
}



Measured memory_bytes: 2080
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}












int d[55][55];
int dx[]={0,0,-1,1};
int dy[]={-1,1,0,0};
int vis[55][55];
int main()
{
    int h,w;
    cin>>h>>w;
    char s[h+1][w+1];
    int ct=0;
    string t;
    for(int i=1;i<=h;i++){
         cin>>t;
        for(int j=0;j<t.length();j++){
             s[i][j+1]=t[j];
             if(t[j]=='.')ct++;
        }
    }
    if(s[1][1]=='#'||s[h][w]=='#'){cout<<-1;return 0;}
    queue<pair<int,int>> q;
    q.push({1,1});
    memset(vis,0,sizeof(vis));memset(d,-1,sizeof(d));
    vis[1][1]=1;d[1][1]=0;
    while(!q.empty()){
         int x=q.front().fi;
         int y=q.front().se;
         q.pop();
         
         for(int l=0;l<4;l++){
              int nx=x+dx[l],ny=y+dy[l];
              //cout<<x<<" "<<y<<" "<<nx<<" "<<ny<<"\n";
              if(nx<1||nx>h||ny<1||ny>w||s[nx][ny]=='#')continue;
              if(vis[nx][ny]==0){
               d[nx][ny]=1+d[x][y];
               vis[nx][ny]=1;
               q.push(make_pair(nx,ny));
              }
          }
    }
    //cout<<d[h][w]<<"\n";
   if(d[h][w]==-1)cout<<-1;
   else cout<<(ct-d[h][w]-1);


}
 
 
 
 

 
 
 
 
 
 
 
 
 
 
 
 
 



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll m, d;
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> m >> d;
	cin >> m >> d;
	if(d == 1){
		print(1)
	}
	else{
		print(0)
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  ll n,m;
  cin>>n>>m;
  vector<ll> a(n);
  priority_queue<ll> que;
  rep(i,n){
    cin>>a[i];
    que.push(a[i]);
  }
  
  rep(i,m){
    auto q=que.top();
    que.pop();
    q/=2;
    que.push(q);
  }
  
  ll ans=0;
  while(!que.empty()){
    auto q=que.top();
    que.pop();
    ans+=q;
  }

  cout << ans << endl;

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}

Measured memory_bytes: 2168
// clang-format off
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort(all(x), greater<>())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl;
template<class T>bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if (b<a){a=b;return 1;}return 0;}
const int INF = 1e9;
const ll LINF = 1e18;
// clang-format on
const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<long long> H) {
  ll min = 0;
  rep(i, N) {
    if (min < H[i] - 1) {
      min = H[i] - 1;
    } else if (H[i] < min) {
      ANS(NO);
      return;
    }
  }
  ANS(YES);
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> H(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &H[i]);
  }
  solve(N, std::move(H));
  return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3

def main():
    N = int(input())
    S = input()
    new_S = ''
    for i in range(len(S)):
        new_S += judgeChangeChara(S[i],N)
    print(new_S)
    

def judgeChangeChara(chr,N):
    alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    index = alphabet.find(chr)
    if index+N > 25:
        return alphabet[(index+N) - 26]
    else:
        return alphabet[index + N]


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n;
  R n;
  ll l=0,r=MAX;
  while(l+1<r) {
    ll m=(l+r)/2,x=n;
    rrep(i,m+1) {
      if(x>=i) x-=i;
    }
    if(!x) r=m;
    else l=m;
  }
  pr(r);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> ans(N);
  for (int i=0;i<M;i++){
    int a,b;
    cin >> a >> b;
    for (int j=0;j<N;j++){
	if(j+1 == a || j+1 == b)
      ans.at(j) +=1;
    }
  }
  for (int i=0;i<N;i++){
	cout << ans.at(i) <<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n;
	cin>>n;	
	long double a[n],sum=0,tmp;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=(1/a[i]);
	}
	tmp=1/sum;
	cout<<fixed<<setprecision(10)<<tmp;
}

Measured memory_bytes: 256
let S: String = readLine()!
var res: Int = 1000

var idxl: String.Index = S.startIndex
var idxr: String.Index = S.index(S.startIndex, offsetBy: 2)

while idxr < S.endIndex {
    res = min(res, abs(Int(S[idxl...idxr])! - 753))
    idxl = S.index(after: idxl)
    idxr = S.index(after: idxr)
}
print(res)

Measured memory_bytes: 8100
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
using namespace std;
typedef long long ll;
const ll INF = 1e15;
int main() {
  string s;
  cin >> s;
  vector<string> v = {"", "A"};
  for (auto a : v)
    for (auto b : v)
      for (auto c : v)
        for (auto d : v) {
          string cmp = a + "KIH" + b + "B" + c + "R" + d;
          if (s == cmp) {
            cout << "YES" << endl;
            return 0;
          }
        }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
LL n,s;
int main() {
	
	scanf("%lld%lld",&n,&s);
	
	if (s > n) {
		printf("-1");
		return 0;
	}
	if (s == n) {
		printf("%lld",n + 1);
		return 0;
	}
	if (n == 1) {
		if (s == 1) {
			printf("2");
			return 0;
		}
		else {
			printf("-1");
			return 0;
		}
	}
	if (n == 2) {
		if (s == 1) {
			printf("2");
			return 0;
		}
		else printf("-1");
		return 0;
	}
	
	for(int i=2;i<=sqrt(n);++i) {
		LL cnt = 0,_n = n,b = (LL)i;
		while (_n >= b) {
			cnt += _n % b;
			_n /= b;
		}
		cnt += _n;
		if (cnt == s) {
			printf("%lld",b);
			return 0;
		}
	}
	
	LL _n = n;
	n -= s;
	for(int i=(int)sqrt(n);i;--i) {
		if (sqrt(_n) <= n / (LL)i + 1)
		if (n % (LL)i == 0) {
			LL cnt = 0,__n = _n,b = n / (LL)i + 1;
		  while (__n >= b) {
		  	cnt += __n % b;
		  	__n /= b;
	  	}
	  	cnt += __n;
	  	if (cnt == s) {
	  		printf("%lld",b);
	  		return 0;
	  	}
		}
	}
  
  printf("-1");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <utility>
#include <set>
#include <unordered_set>
#include <stack>
#include <iterator>
#include <random>
#include <fstream>
#include <chrono>
using namespace std;
#define int long long
void fast(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int S(int x)
{
    return (x*(x+1))/2;
}
int32_t main()
{
    fast();
    int n, k;
    int ans = 0;
    int m = 1e9+7;
    cin >> n >> k;
    for(int i = k; i <= (n+1); i++){
        int t=S(i-1);
        int t1 = S(n)-S(n-i);
        ans += t1-t + 1;
        //cout << (t1 -t + 1) << "\n";
        ans %=m;
    }
    //ans += 1;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3176
#include <stdio.h>

int main(void)
{
    int d;
    scanf("%d", &d);

    if (d == 25)
        printf("Christmas");
    else if (d == 24)
        printf("Christmas Eve");
    else if (d == 23)
        printf("Christmas Eve Eve");
    else if (d == 22)
        printf("Christmas Eve Eve Eve");
    return 0;
}


Measured memory_bytes: 128
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

void solve()
{
    IN(R, G, B, n);
    ll s = 0;
    rep(r, (n+R-1)/R+1) {
        rep(g, (n+G-1)/G+1) {
            ll b = n-r*R-g*G;
            if (b % B == 0 && 0 <= b / B)
            {
                ++s;
            }
        }
    }
    cout << s << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string N;
    cin >> N;
    char c;
    c = N.at(N.size()-1);
    if (c == '3') cout << "bon" << endl;
    else if (c == '0' || c == '1' || c == '6' || c == '8') cout << "pon" << endl;
    else cout << "hon" << endl;
    return 0;
}

Measured memory_bytes: 3584
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline

########################################
def valid(a,b):
	#print(a,b)
	if 0<=a<=h-1 and 0<=b<=w-1 and arr[a][b] == ".":
		return True
	else:
		return False


h , w = map(int , input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
ch-=1
cw-=1
dh-=1
dw-=1
arr = [input() for i in range(h)]
#print(arr)
can_vis = []
dist = [[10**10]*w for i in range(h)]
q = deque()
ans = float("inf")
q.append((ch,cw))
dist[ch][cw] = 0
#print(dh,dw,ch,cw)
while q:
	#print(q.popleft())
	#print(q)
	curx , cury = q.popleft()
	#can_vis.append((curx,cury))
	for dx,dy in [[1,0],[0,1],[-1,0],[0,-1]]:
		if valid(curx+dx, cury+dy) and dist[curx+dx][cury+dy] > dist[curx][cury]:
			dist[curx+dx][cury+dy] = dist[curx][cury]
			q.appendleft((curx+dx, cury+dy))
	for dx in range(-2,3):
		for dy in range(-2,3):
			if valid(curx+dx, cury+dy) and dist[curx+dx][cury+dy] > dist[curx][cury] + 1:
				dist[curx+dx][cury+dy] = dist[curx][cury] + 1 
				q.append((curx+dx, cury+dy))


if dist[dh][dw] == 10**10:
	print(-1)
else:
	print(dist[dh][dw])



Measured memory_bytes: 100248
//Giorgi Kldiashvili

#include <bits/stdc++.h>

#define M 1000000007ll
#define ll long long
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) < (y) ? (y) : (x))

using namespace std;

const int N = 3020;

int n, a[N], tot[N];
vector < int > res, G[N], g[N];
bool answer[N];
set < pair < int, int > > S;

inline void go(int v)
{
  for(int i = 0; i < G[v].size(); ++ i)
  {
    int to = G[v][i];
    if(answer[to] == false)
    {
      answer[v] = true;
      res.push_back(v);
      break;
    }
  }
  for(int i = 0; i < g[v].size(); ++ i)
  {
    int to = g[v][i];
    S.erase(make_pair(tot[to], to));
    tot[to] --;
    S.insert(make_pair(tot[to], to));
  }
}

int main()
{
  scanf("%d", &n);

  for(int i = 1; i <= n; ++ i)
    scanf("%d", &a[i]), S.insert(make_pair(0, i));
  for(int i = 1; i < n; ++ i)
  {
    int x, y;
    scanf("%d %d", &x, &y);
    if(a[x] == a[y])
      continue;
    if(a[x] > a[y])
      swap(x, y);
    G[y].push_back(x);
    g[x].push_back(y);
    S.erase(make_pair(tot[y], y));
    tot[y] ++;
    S.insert(make_pair(tot[y], y));
  }

  while(!S.empty())
  {
    int x = (*S.begin()).second;
    S.erase(S.begin());
    go(x);
  }
  sort(res.begin(), res.end());
  for(int i = 0; i < res.size(); ++ i)
    printf("%d ", res[i]);
}

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

int main(){
  int n;
  cin >> n;
  map<string,int> mp;
  rep(i,n){
    string s;
    cin >> s;
    mp[s]++;
  }
  int mx = 0;
  for(auto a:mp) mx = max(mx,a.second);
  
  for(auto a:mp){
    if(mx!=a.second) continue;
    cout << a.first << endl;
  }
}

Measured memory_bytes: 25216
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}


int i_gcd(int a, int b);
int i_gcd(int a, int b) {
	if (!b)return a;
	return i_gcd(b, a % b);
}
int i_lcm(int a, int b);
int i_lcm(int a, int b) {
	return (a * b) / i_gcd(a, b);
}
int ll_gcd(ll a, ll b);
int ll_gcd(ll a, ll b) {
	if (!b)return a;
	return ll_gcd(b, a % b);
}
int ll_lcm(ll a, ll b);
int ll_lcm(ll a, ll b) {
	return (a * b) / ll_gcd(a, b);
}

// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
//ll _pfact(ll a);
//static ll pf[100000000];
//static ll pc;
//
//ll _pfact(ll a) {
//	long i, r;
//	if (a % 2 == 0) {
//		pf[pc] = 2; pc++;
//		return(_pfact(a / 2));
//	}
//	r = sqrt(a);
//	for (i = 3; i <= r; i += 2) {
//		if (a % i == 0) {
//			pf[pc] = i; pc++;
//			return(_pfact(a / i));
//		}
//	}
//	if (a != 1) {
//		pf[pc] = a; pc++;
//	}
//	return 0;
//
//}

//同じものの最初の文字をNULLにして降順
int _sort(const void* a, const void* b);
int _sort(const void* a, const void* b) {
	char rc;

	rc = strcmp((char*)b, (char*)a);
	if (rc == 0) {
		*(char*)a = 0x00;
		return(1);
	}
	return(rc);
}
// 立っている ビットの数
int bitcount(unsigned int uc);
int bitcount(unsigned int uc)
{
	int bit;

	for (bit = 0; 0 != uc; uc = (unsigned int)(uc >> 1))
		if (0 != (uc & 1))++bit;

	return bit;
}//bitco

#pragma endregion

// ABC088 A-Infinite Coins

int main(void) {
	int n,a;
	
	scanf("%d %d", &n,&a);
	(n%500<=a)?printf("Yes\n"):printf("No\n");
	return 0;
}

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

int main() {
	int  n,x;
	cin >> n;
	for (int i = 3; i <= n; i++) {
		if (i % 3 == 0)cout << ' ' << i;
		else {
			x = i;
			while (x) {
				if (x % 10 == 3) {
					cout << ' ' << i;
					break;
				}
				x /= 10;
			}
		}
	}
	cout << endl;
}


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

using namespace std;

const int INF = 1 << 30;

int L, X[200000];
int dp[200002][5];

int rec(int idx, int state) {
  if(idx == L) return 0;
  if(~dp[idx][state]) return dp[idx][state];
  int ret = INF;
  if(state == 0 || state == 4) {
    ret = min(ret, rec(idx + 1, state) + X[idx]);
    if(state == 0) ret = min(ret, rec(idx, state + 1));
  } else if(state == 1 || state == 3) {
    ret = min(ret, rec(idx + 1, state) + (X[idx] == 0 ? 2 : X[idx] % 2));
    ret = min(ret, rec(idx, state + 1));
  } else {
    ret = min(ret, rec(idx + 1, state) + 1 - X[idx] % 2);
    ret = min(ret, rec(idx, state + 1));
  }
  return dp[idx][state] = ret;
}

int main() {
  cin >> L;
  for(int i = 0; i < L; i++) cin >> X[i];
  memset(dp, -1, sizeof(dp));
  cout << rec(0, 0) << endl;
}


Measured memory_bytes: 14336
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a = [LI() for _ in range(3)]
    for i in range(3):
        a[i][2] -= a[i][1]
        a[i][1] -= a[i][0]
    if a[0][1] != a[1][1] or a[0][1] != a[2][1] or a[0][2] != a[1][2] or a[0][2] != a[2][2]:
        return 'No'

    return 'Yes'


print(main())




Measured memory_bytes: 5584
n = int(input())
a = list(map(int,input().split()))
a.sort()
ls = [1]*(10**6+1)
ans = 0
for idx,i in enumerate(a):
  if ls[i] == 0:
    continue
  if idx == n-1 or a[idx+1] != i:
    ans += 1
  for j in range(i,10**6+1,i):
    ls[j] = 0
print(ans)

Measured memory_bytes: 105840
import Data.Char
import Data.List

main :: IO ()
main = do
  s <- getLine
  let c1 = (=='A') . head
  let c2 = (==1) . length . filter (=='C') . tail . tail . init
  let c3 = all isLower . drop 2 . sort
  putStrLn $ if c1 s && c2 s && c3 s then "AC" else "WA"

Measured memory_bytes: 380
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;


int main(void)
{
	lli N; cin >> N;
	lli n = 1;
	while ((n + 1)*(n + 1) <= N)n++;
	cout << n*n << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define FOR(i,a) for(int i=0;i<a;i++)
int main()
{
	int n; string k; cin >> n >> k;
	if (n & 1){
		cout << "No\n";
		return 0;
	}
	FOR(i, n / 2) {
		if (k[i] != k[i + n / 2]) {
			cout << "No\n"; return 0;
		}

	}
	cout << "Yes\n"; return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 1000000
int main() {
	int s;
	cin >> s;
	vector<int> c(N, 0);
	c[s] = 1;
	int cnt = 1;
	for (int i = 0; i < N; i++) {
		cnt++;
		if (s%2 == 0) {
			s/=2;
		}
		else {
			s = 3*s+1;
		}
		if (c[s]) {
			break;
		}
		c[s] = 1;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include<cstdio>
using namespace std;
int main()
{
string a;
cin>>a;
if(a=="A")
    cout<<"T"<<endl;
else if(a=="T")
    cout<<"A"<<endl;
else if(a=="C")
    cout<<"G"<<endl;
else
    cout<<"C"<<endl;
return 0;
}


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

int main(){
    int c=0,f=0,i;
    char s[100000];
    scanf("%s",s);
    for(i=1;i<strlen(s);i++){
        if(s[i]!=s[i-1] && f==1){
            c++;
        }else if(s[i]==s[i-1] && f==0){
            c++;
            f=1;
        }else f=0;
    }
    printf("%d\n",c);
    return 0;
}

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

pa, pb, pc = 0, 0, 0
for _ in range(N) :
    a, b, c = map(int, input().split())
    na = max(pb + a, pc + a)
    nb = max(pa + b, pc + b)
    nc = max(pa + c, pb + c)
    pa, pb, pc = na, nb, nc
print(max([na, nb, nc]))

Measured memory_bytes: 47576
#include <stdio.h>
int main(void)
{
	int t[4],n[4],i;
	
	for(i=0;i<4;i++){

	scanf("%d%d",&t[i],&n[i]);
	if(t[i]==1){
		printf("%d\n",n[i]*6000);
	}else if(t[i]==2){
		printf("%d\n",n[i]*4000);
	}else if(t[i]==3){
		printf("%d\n",n[i]*3000);
	}else if(t[i]==4){
		printf("%d\n",n[i]*2000);
	}
	}
	return 0;
}

Measured memory_bytes: 600
h, w, m = map(int, input().split())
r = [0]*h
c = [0]*w
s = set()
for i in range(m):
    hi, wi = map(int, input().split())
    hi -= 1
    wi -= 1
    r[hi] += 1
    c[wi] += 1
    s.add((hi, wi))

a = max(r)
b = max(c)

p = []
q = []
for i in range(h):
    if r[i] == a:
        p.append(i)
for j in range(w):
    if c[j] == b:
        q.append(j)

k = 1
for i in p:
    for j in q:
        if (i, j) not in s:
            k = 0
            break
    if k == 0:
        break

print(a + b - k)



Measured memory_bytes: 83536
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
#define pw(x) (1LL<<(x))
static const int fast_io = [](){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);return 0;}();
static const int precise_doubles = [](){cout<<fixed<<setprecision(20);return 0;}();
typedef pair<int, int> PII;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(k) - iterator to kth largest, order_of_key(k) - #things < k
typedef long double LD;
typedef long long LL;
#define EVAL(x) x
#define SPA(x) EVAL({cout << #x" = " << x << ' ';})
#define NEWL EVAL({cout << '\n';})
#define SPAR(a, b) EVAL({cout<<#a" = ";for(auto it=a;it!=b;)cout<<*(it++)<<" ";cout<<'\n';})
#define SPAV(v) EVAL({cout<<#v" = ";for(auto it=v.begin();it!=v.end();)cout<<*(it++)<<" ";cout<<'\n';})
const int INF = 0x3f3f3f3f; // 1.0e9
const LL LINF = 0x3f3f3f3f3f3f3f3fll; // 4.5e18
const LD eps = 1e-20;
int mod = 0;
inline int msum(int x, int y) {return (x+y<mod ? x+y : x+y-mod);}
inline int mdif(int x, int y) {return (x>=y ? x-y : x-y+mod);}
inline int mprod(int x, int y) { return (1ll*x*y) % mod; }
inline int mpow(int x, LL y) {LL r=1;while(y){if(y&1)r=mprod(r,x);x=mprod(x,x);y>>=1;}return r;}
inline int minv(int x) { return mpow(x, mod-2); }
#define DIE EVAL({cout << -1 << '\n'; exit(0);})
//------------------------------------------------------------------------------------------------------

#define mp make_pair

int main() {
    cin >> mod;
    vector<int> dis(mod, INF);
    dis[1] = 0;
    deque<int> queue;
    queue.push_front(1);
    while(!queue.empty()) {
        int u = queue.front();
        queue.pop_front();
        for(PII pp : {mp(msum(u, 1), 1), mp(mprod(u, 10), 0)}) {
            int v = pp.first;
            int d = pp.second;
            if (dis[u] + d < dis[v]) {
                dis[v] = dis[u] + d;
                if (d == 0) {
                    queue.push_front(v);
                } else {
                    queue.push_back(v);
                }
            }
        }
    }
    cout << dis[0] + 1 << '\n';
}






























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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	int a,b,c;
	cin >> a >> b >> c;

	int ab = a + b;
	int bc = b + c;
	int ac = a + c;

	int ans = min(ab, bc);
	ans = min(ans, ac);
	cout << ans << endl;
	return 0;
}

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

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

	int setX, setY;
	if (N%A > 0) {
		setX = B * (N / A + 1);
	}
	else {
		setX = B * N / A;
	}
	if (N%C > 0) {
		setY = D * (N / C + 1);
	}
	else {
		setY = D * N / C;
	}

	if (setX > setY) {
		cout << setY << endl;
	}
	else if (setX < setY) {
		cout << setX << endl;
	}
	else {
		cout << setX << endl;
	}

	return 0;
}


Measured memory_bytes: 3092
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
int t=10000000000000000;
void calc(vector<int>& res, int i, int n){
    res[i]+=n;
    rep(j,n){
        if(j!=i)res[j]--;
    }
}
signed main(){
    int k;cin>>k;
    int a=k/2+1;int b=k/2+1;
    if(k%2==1){
        a+=2;b-=1;
    }

    if(k>=t)goto NEXT;
    cout<<2<<endl;
    cout<<a<<" "<<b<<endl;
    NEXT:
    if(k>=t){
        int n=(k-1)/t+1;
        vector<int> res(n,n-1);
        //rep(i,n)res[i]=i;
        int i=k/n;
        rep(j,n)res[j]+=i;
        int rest=k%n;
        rep(kk,rest)calc(res,kk,n);
        cout<<n<<endl;
        rep(j,n){
            cout<<res[j]<<" ";
        }
        cout<<endl;
    }
    return 0;
}

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

using namespace std;

vector<long long> sum;

long long calc_cost(bool ps) {
	long long res,dis;
	res = dis = 0;
	vector<long long> temp = sum;
	for (int i = 0; i < temp.size(); ++i) {
		temp[i] += dis;
		if (i%2 == 0) {
			if (temp[i] == 0) {
				++res;
				if (ps) {
					++dis;
				}
				else {
					--dis;
				}
			}
			else if (ps && temp[i] < 0) {
				res += -temp[i]+1;
				dis += -temp[i]+1;
			}
			else if (!ps && temp[i] > 0) {
				res += temp[i]+1;
				dis -= temp[i]+1;
			}
		}
		else {
			if (temp[i] == 0) {
				++res;
				if (ps) {
					--dis;
				}
				else {
					++dis;
				}
			}
			else if (ps && temp[i] > 0) {
				res += temp[i]+1;
				dis -= temp[i]+1;
			}
			else if (!ps && temp[i] < 0)  {
				res += -temp[i]+1;
				dis += -temp[i]+1;
			}
		}
	}
	return res;
}

int main(void) {
	int n;
	cin >> n;
	sum = vector<long long>(n,0);
	for (int i = 0; i < n; ++i) {
		long long a;
		cin >> a;
		if (i == 0) {
			sum[i] = a;
		}
		else {
			sum[i] += sum[i-1] + a;
		}
	}

	cout << min(calc_cost(true),calc_cost(false)) << endl;
	return 0;
}


Measured memory_bytes: 1804
a,b=map(int,input().split())

def factorization(n):
    arr = []
    tmp = n

    for i in range(2, int(n**0.5//1)+1):
        if tmp%i==0:
            cnt = 0
            while tmp%i==0:
                cnt+=1
                tmp//=i
            arr.append([i,cnt])
    if tmp!=1:
        arr.append([tmp,1])
    if arr==[]:
        arr.append([n,1])
    return arr

a_arr = factorization(a)
b_arr = factorization(b)
a_map = {str(arr[0]):arr[1] for arr in a_arr}
b_map = {str(arr[0]):arr[1] for arr in b_arr}

factor = set(list(a_map.keys())+list(b_map.keys()))
ans = 1
for i in factor:
  if str(i) in a_map.keys():
    a_num = a_map[str(i)]
  else:
    a_num = 0
    
  if str(i) in b_map.keys():
    b_num = b_map[str(i)]
  else:
    b_num = 0
  
  ans *= int(i)**(max(a_num,b_num))
print(ans)

Measured memory_bytes: 9372
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

//using namespace atcoder;
using namespace std;

int main(void){
  ll n;
  cin >> n;
  
  vector<ll> a(n);
  map<ll, ll> m;
  ll t = 0;
  for (int i = 0; i < n; i++){
    cin >> a[i];
    if (m[a[i]] != 0)
      t++;
    m[a[i]]++;
  }


  cout << n - 2*((t + 1)/ 2) << endl;
  

  return 0;
}


Measured memory_bytes: 10324
/*input
3
6 3 3

*/
#include <bits/stdc++.h>
using namespace std;
#define int long long int
const int maxn = 5e3 +5;
int n;
void solve(){
	int n;
	cin >> n;
	vector<int> v(n);
	for ( int i =0 ; i < n ; i++)
			cin >> v[i];
	sort( v.begin() , v.end());
	int c =0;
	for ( int i = n-1 ;  i  >= 0 ; i--){
		for ( int j = i-1 ; j >=0 ; j--){
			int pos = lower_bound( v.begin() , v.end() , v[i] - v[j]+1) - v.begin();
			if ( j - pos < 0 )continue;
			c += j - pos;
		}
	}
	cout << c;

}

signed main(){
	solve();
}

Measured memory_bytes: 384
from sys import stdin
from itertools import accumulate
input = stdin.readline

INF = float('inf')

N = int(input())
*a, = map(int,input().split())

cost = [[0]*N for _ in range(N)]
for i in range(N):
    cost[i][i] = 0
prefix = [0]+ list(accumulate(a))

for i in range(1,N):
    for j in range(0,N-i):
        temp = INF
        for k in range(i):
            temp = min(temp,cost[j][j+k] + cost[j+k+1][j+i])
        cost[j][j+i] = temp + prefix[j+i+1] - prefix[j]


print(cost[0][N-1])


Measured memory_bytes: 43116
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  
  int count = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == '1'){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3584
lst = list(map(int, input().split()))

lst.sort()

A, B, C = lst[0], lst[1], lst[2]

sa = (C-A) + (C-B)
if sa%2 == 1:
    ans = 1
    sa += 1
else:
    ans = 0

ans =ans + sa//2

print (ans)  



Measured memory_bytes: 3060
n, x, y = map(int, input().split())
x -= 1
y -= 1
out = [0]*n
for i in range(n-1):
  for j in range(i + 1, n):
    out[min(j -i, abs(i - x) + 1 + abs(j - y))] += 1
for i in range(1, n):
  print(out[i])

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a+b+c<=21){
    cout << "win" << endl;
  }
  else{
    cout << "bust" << endl;
  }

  return 0;
}

Measured memory_bytes: 3608
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    N = int(input())
    A = list(map(int, input().split()))
    count = 0
    for i, ai in enumerate(A):
        if (i + 1) % 2 == 1 and ai % 2 == 1:
            count += 1
    print(count)

if __name__ == '__main__':
    main()

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
const ll MAX_NUM = 1000000000000001;

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    int x_sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
        x_sum ^= a.at(i);
    }
    for (int i = 0; i < N; i++) {
        int ans = x_sum ^ a.at(i);
        cout << ans << endl;;
    }
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] % 2 == 0) {
			if (a[i] % 3 == 0 || a[i] % 5 == 0) {
				continue;
			}
			else {
			    cout << "DENIED" << "\n";
			    return 0;
			}
			
		}
	}
	cout << "APPROVED" << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int a, b, max;

  scanf("%d %d", &a, &b);

  max = a+b;
  if (max < a-b) {
    max = a-b;
  }
  if (max < a*b) {
    max = a*b;
  }

  printf("%d", max);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main (void) {
	long long int n, m;
	cin >> n >> m;
	if ((m / 2) <= n) {
		cout << m / 2 << endl;
		return 0;
	}

	m -= n * 2;
	// cout << "d :" << m  << " " << m / 4 << endl;
	n += m / 4;
	cout << n << endl;

	return 0;
}

Measured memory_bytes: 256
a1 = [input().split()]
m = int(a1[0][0])
n = int(a1[0][1])
a2 = [input().split() for i in range(m)]
a3 = [input().split() for i in range(n)]
i = 0
while i < m:
    sum = 0
    j = 0
    while j < n:
        s = int(a2[i][j]) * int(a3[j][0])
        sum += s
        j += 1
    print(sum)
    i += 1

Measured memory_bytes: 8264
#include <stdio.h>
#include <stdint.h>

int main(void)
{
    uint8_t is_init = 1;
    char prv_c, cur_c;
    uint32_t cnt = 0;

    prv_c = getchar();
    while ((cur_c = getchar()) != '\n') {
        if (prv_c != cur_c) cnt++;
        prv_c = cur_c;
    }

    printf("%u\n", cnt);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() 
{
	ll n,k,j;
	cin>>n>>k;
	ll arr[n],i,arr2[n];
	for(i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	arr2[0]=0;
	arr2[1]=abs(arr[1]-arr[0]);
	ll mini=INT_MAX;
	for(i=2;i<n;i++)
	{
		for(j=1;j<=min(k,i);j++)
		{
			mini=min(abs(arr[i]-arr[i-j])+arr2[i-j],mini);
		}
		arr2[i]=mini;
		mini=INT_MAX;
	}
	cout<<arr2[n-1];
	return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;

int first_num(int p) {
	while (p>=10) {
		p = p / 10;
	}
	return p;
}

int last_num(int p) {
	return p % 10;
}

int main() {
	int N;
	int numbers[10][10];

	cin >> N;

	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			numbers[i][j] = 0;
		}
	}
	for (int i = 1; i <= N; i++) {
		numbers[first_num(i)][last_num(i)]++;
	}

	long long ans = 0;
	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			ans += numbers[i][j] * numbers[j][i];
		}
	}

	cout << ans;

}

Measured memory_bytes: 256
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()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

const mod = 1000000007

func mpow(a, b int) int {
	if b == 0 {
		return 1
	} else if b%2 == 0 {
		tmp := mpow(a, b/2)
		return tmp * tmp % mod
	}
	return mpow(a, b-1) * a % mod
}

var fracMemo = []int{1, 1}

func mfrac(n int) int {
	if len(fracMemo) > n {
		return fracMemo[n]
	}
	if len(fracMemo) == 0 {
		fracMemo = append(fracMemo, 1)
	}
	for len(fracMemo) <= n {
		size := len(fracMemo)
		fracMemo = append(fracMemo, fracMemo[size-1]*size%mod)
	}
	return fracMemo[n]
}

var ifracMemo = []int{1, 1}

func mifrac(n int) int {
	if len(ifracMemo) > n {
		return ifracMemo[n]
	}
	if len(ifracMemo) == 0 {
		fracMemo = append(ifracMemo, 1)
	}
	for len(ifracMemo) <= n {
		size := len(ifracMemo)
		ifracMemo = append(ifracMemo, ifracMemo[size-1]*mpow(size, mod-2)%mod)
	}
	return ifracMemo[n]
}

func nCr(n, r int) int {
	if n == r {
		return 1
	}
	if n < r || r < 0 {
		return 0
	}
	ret := 1
	ret *= mfrac(n)
	ret %= mod
	ret *= mifrac(r)
	ret %= mod
	ret *= mifrac(n - r)
	ret %= mod
	return (ret)
}

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

	N, K := getInt(), getInt()

	a := make([]int, K+1)
	for k := 1; k <= K; k++ {
		n := K / k
		n = mpow(n, N)
		a[k] = n
	}
	// out(a)
	for i := K; i > 0; i-- {
		sum := 0
		for j := 2 * i; j <= K; j += i {
			sum += a[j]
			// fmt.Print(j, " ")
		}
		a[i] -= sum
		// out()
	}
	ans := 0
	for i := 1; i <= K; i++ {
		ans += (i * a[i]) % mod
		ans %= mod
	}
	// out(a)
	out(ans)
}


Measured memory_bytes: 2584
#include <stdio.h>

#define MAX 2000

void sort(int*, int);

int main()
{
	int n, k;
	int p[MAX];
	int sum = 0;

	scanf("%d %d", &n, &k);

	for (int i = 0; i < n; i++) {
		scanf("%d", &p[i]);
	}
	sort(p, n);

	for (int i = 0; i < k; i++)
		sum += p[i];

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

	return 0;
}

void sort(int* p, int n)
{
	int i, j;
	int temp;

	for (i = 0; i < n - 1; i++) {
		for (j = i + 1; j < n; j++) {
			if (p[i] > p[j]) {
				temp = p[i];
				p[i] = p[j];
				p[j] = temp;
			}
		}
	}
}

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

using namespace std;

typedef long long          ll;
typedef unsigned long long ull;
typedef vector<int>	       vi;
typedef vector<bool>       vb;
typedef map<int, int>      mii;
typedef pair<int, int>     ii;

#define INF                0x3f3f3f3f
#define INFLL              0x3f3f3f3f3f3f3f3f
#define MOD                1000000007
#define each(x, s)         for(auto& x : s)
#define loop(x)	           for(int i = 0;i < x;i++)
#define vloop(v, x)        for(int v = 0;v < x;v++)
#define avg(l, r)          l + (r - l) / 2
#define iter(a)            a.begin(), a.end()
#define riter(a)           a.rbegin(), a.rend()
#define endl               "\n"

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

	int n, m, a, b, ans = 0;
	cin >> n >> m;
	vector<ii> sl;
	loop(n) {
		cin >> a >> b;
		sl.emplace_back(b, a);
	}
	sort(iter(sl), [](ii a, ii b) {
		return a.second == b.second ? a.first < b.first : a.second < b.second;
	});
	int at = 0;
	priority_queue<ii> q;
	loop(m + 1) {
		while (at < n and sl[at].second == i) q.push(sl[at++]);
		if (!q.empty()) {
			ans += q.top().first;
			q.pop();
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 2548
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod1 = 1e9 + 7;
const int mod2 = 1e9 + 9;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
const int b1 = 1215135141;
const int b2 = 1256165151;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	ll x;
	cin >> x;
	ll start = 100;
	int days = 0;
	while (start < x) {
		start += start / 100;
		++days;
	}
	cout << days << '\n';
 	return 0;
}


Measured memory_bytes: 3652
//author : Brijesh1in
#include <bits/stdc++.h>

using namespace std;
	
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define endl '\n'
#define boost ios::sync_with_stdio(false); cin.tie(NULL);
typedef long long li;
const int N = 1e5 + 10;


void solve(){

	int n;
	cin>>n;
	int a[n];
	for(int i = 0 ; i < n ; ++i)
		cin>>a[i];
	int ans = 0;
	int prev = a[0];
	for(int i = 0 ; i < n ; ++i)
		if(a[i]>=prev)
			ans++ , prev = a[i];
	cout<<ans<<endl;
}
signed main(){

	int t;
	t = 1;
	//cin>>t;

	while(t--)
		solve();

}

Measured memory_bytes: 256