akhauriyash/Code-Regression huggingface dataset:
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<math.h>
#include<list>
#include<complex>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vtype(type) vector<type>
#define vvtype(type) vector<vector<type>>
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,x) unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;


ll const MOD = 998244353;
ll mod_p(ll x, ll y) {
	x %= MOD;
	y %= MOD;
	return (x + y + MOD) % MOD;
}

ll mod_m(ll x, ll y) {
	x %= MOD;
	y %= MOD;
	return x * y%MOD;
}

ll mod_pow(ll x, ll t) {
	x %= MOD;
	if (t == 0) {
		return 1;
	}
	else {
		ll v = mod_pow(x, t / 2);
		if (t % 2 == 0) {
			return v * v % MOD;
		}
		else {
			return v * v%MOD * x %MOD;
		}
	}
}

ll mod_inv(ll x) {
	return mod_pow(x, MOD - 2);
}

struct edge
{
	long long to; ll name;
	bool operator<(const edge& rhs) const {
		return name > rhs.name;
	}
};

ll const MAX = 4e3 + 5;
ll dp[MAX][MAX] = {};


int main() {
	string s; cin >> s;
	ll n = s.size();
	ll bl = 0; ll rd = 0;
	dp[0][0] = 1;
	REP(i, 0, n * 2 - 1) {
		if (i < n) {
			bl += s[i] - '0';
			rd += -(s[i] - '2');
		}
		REP(j, 0, n * 2 - 1) {
			if (j < bl) {
				dp[i + 1][j + 1] = mod_p(dp[i + 1][j + 1], dp[i][j]);
			}
			if (i - j < rd) {
				dp[i + 1][j] = mod_p(dp[i + 1][j], dp[i][j]);
			}
		}
	}
	cout << dp[n * 2][bl] << endl;
}

Measured memory_bytes: 125440
import queue
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]

inf=100000000
ma=[]
for i in range(h):
    for j in range(w):
        if s[i][j]==".":
            x=[[inf for i_sub in range(w)] for j_sub in range(h)]
            q=queue.Queue()
            d=0
            q.put([i,j])
            x[i][j]=0
            while q.qsize()!=0:
                d+=1
                l=q.qsize()
                for t in range(l):
                    I,J=q.get()
                    if I-1>=0 and s[I-1][J]=="." and x[I-1][J]==inf:
                        q.put([I-1,J])
                        x[I-1][J]=d
                    if I+1<=h-1 and s[I+1][J]=="." and x[I+1][J]==inf:
                        q.put([I+1,J])
                        x[I+1][J]=d
                    if J-1>=0 and s[I][J-1]=="." and x[I][J-1]==inf:
                        q.put([I,J-1])
                        x[I][J-1]=d
                    if J+1<=w-1 and s[I][J+1]=="." and x[I][J+1]==inf:
                        q.put([I,J+1])
                        x[I][J+1]=d
            ma_sub=0
            for k in range(h):
                for l in range(w):
                    if x[k][l]!=inf:
                        ma_sub=max(ma_sub,x[k][l])
            ma.append(ma_sub)

print(max(ma))


Measured memory_bytes: 116712
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;
int main(){
	string a;
	long long b;
	cin>>a;
	cin>>b;
	int i,sum=0;
	for(i=0;i<a.length();i++){
		if(a[i]=='1'){
			sum++;
		}else{
			break;
		}
	}
	if(b<=sum){
		cout<<a[0]<<endl;
	}else{
		cout<<a[sum]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int a,b,c;cin>>a>>b>>c;
  string ans="NO";
  reps(i,b-1){
    int now=a*i;
    if(now%b==c)ans="YES";
  }
  cout(ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int a, b, t, i;
int main() {
	cin>>a>>b;
	t = b;
	while(t) {
		a *= 10;
		t /= 10;
	}
	a += b;
	for(i=1; i*i<=a; i++) if(i*i==a) {cout<<"Yes"; return 0;}
	cout<<"No";
	return 0;
}

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

int main(){
    long long n,k;
    cin >> n >> k;
    long long a[n];
    for(int i=0; i<n; i++) {
        cin >> a[i];
        a[i]--;
    }
    int s = 0;
    int check[n];fill(check,check+n,-1);
    vector<int> his;
    for(int i=0; i<=n; i++){
        if(check[s]!=-1){
            break;
        }
        else{
            check[s]=i;
            his.push_back(s);
            s = a[s];
        }
    }
    long long c = check[s] , b = his.size()-c;
    if(k < c) cout << his[k]+1 << endl;
    else cout << his[c+((k-c)%b)]+1 << endl;
    return 0;
}


Measured memory_bytes: 6664
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


namespace FFT{
  using dbl = double;

  struct num{
    dbl x,y;
    num(){x=y=0;}
    num(dbl x,dbl y):x(x),y(y){}
  };

  inline num operator+(num a,num b){
    return num(a.x+b.x,a.y+b.y);
  }
  inline num operator-(num a,num b){
    return num(a.x-b.x,a.y-b.y);
  }
  inline num operator*(num a,num b){
    return num(a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x);
  }
  inline num conj(num a){
    return num(a.x,-a.y);
  }

  int base=1;
  vector<num> rts={{0,0},{1,0}};
  vector<int> rev={0,1};

  const dbl PI=asinl(1)*2;

  void ensure_base(int nbase){
    if(nbase<=base) return;

    rev.resize(1<<nbase);
    for(int i=0;i<(1<<nbase);i++)
      rev[i]=(rev[i>>1]>>1)+((i&1)<<(nbase-1));

    rts.resize(1<<nbase);
    while(base<nbase){
      dbl angle=2*PI/(1<<(base+1));
      for(int i=1<<(base-1);i<(1<<base);i++){
        rts[i<<1]=rts[i];
        dbl angle_i=angle*(2*i+1-(1<<base));
        rts[(i<<1)+1]=num(cos(angle_i),sin(angle_i));
      }
      base++;
    }
  }

  void fft(vector<num> &as){
    int n=as.size();
    assert((n&(n-1))==0);

    int zeros=__builtin_ctz(n);
    ensure_base(zeros);
    int shift=base-zeros;
    for(int i=0;i<n;i++)
      if(i<(rev[i]>>shift))
        swap(as[i],as[rev[i]>>shift]);

    for(int k=1;k<n;k<<=1){
      for(int i=0;i<n;i+=2*k){
        for(int j=0;j<k;j++){
          num z=as[i+j+k]*rts[j+k];
          as[i+j+k]=as[i+j]-z;
          as[i+j]=as[i+j]+z;
        }
      }
    }
  }

  template<typename T>
  vector<long long> multiply(vector<T> &as,vector<T> &bs){
    int need=as.size()+bs.size()-1;
    int nbase=0;
    while((1<<nbase)<need) nbase++;
    ensure_base(nbase);

    int sz=1<<nbase;
    vector<num> fa(sz);
    for(int i=0;i<sz;i++){
      T x=(i<(int)as.size()?as[i]:0);
      T y=(i<(int)bs.size()?bs[i]:0);
      fa[i]=num(x,y);
    }
    fft(fa);

    num r(0,-0.25/sz);
    for(int i=0;i<=(sz>>1);i++){
      int j=(sz-i)&(sz-1);
      num z=(fa[j]*fa[j]-conj(fa[i]*fa[i]))*r;
      if(i!=j)
        fa[j]=(fa[i]*fa[i]-conj(fa[j]*fa[j]))*r;
      fa[i]=z;
    }
    fft(fa);

    vector<long long> res(need);
    for(int i=0;i<need;i++)
      res[i]=round(fa[i].x);

    return res;
  }

};

struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  using ll = long long;
  ll n,m;
  cin>>n>>m;
  vector<ll> as(n);
  for(int i=0;i<n;i++) cin>>as[i];

  const int MAX = 1e5+10;
  vector<ll> cs(MAX,0);
  for(int a:as) cs[a]++;

  auto rs=FFT::multiply(cs,cs);
  ll ans=0,res=m;
  for(int i=rs.size()-1;i>=0;i--){
    ll tmp=min(res,rs[i]);
    ans+=tmp*i;
    res-=tmp;
  }

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


Measured memory_bytes: 12672
#include <cstdio>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    bool ok = true;
    rep(i, n) {
        if (a[i] % 2 == 1) continue;
        if (a[i] % 3 != 0 && a[i] % 5 != 0) ok = false;
    }
    if (ok) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

void solve(int test_case) {
	string s;
	cin>>s;
	int a = 0;
	for(char c:s) {
		a^=((int)(c-'a')+1);
	}
	cout<<(a?"No":"Yes");
}

int main() {
	
	////// FILE BASED IO////
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
}	


Measured memory_bytes: 3556
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, m; cin >> n >> m;
	priority_queue<int> q;
	rep(i, n){
		int a; cin >> a;
		q.push(a);
	}
	while(m--){
		int x = q.top(); q.pop();
		q.push(x / 2);
	}
	ll ans = 0;
	while(q.size()){
		ans += q.top(); q.pop();
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (const string& e_) { return "\"" + e_ + "\""; }
string to_string (char e_) { return "\'" + string(1, e_) + "\'"; }
string to_string (bool e_) { return e_ ? "true" : "false"; }
template <typename T> string to_string (T e_) {
	string s_ = "[ ";
	for (const auto& x_ : e_) s_ += to_string(x_) + " ";
	return s_ + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e_) {
	return "(" + to_string(e_.first) + ", " + to_string(e_.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	int n, k, x;
	cin >> n >> k;
	vector<int> a;
	for(int i = 0; i < n; i++){
		cin >> x;
		a.push_back(x);
	}
	sort(a.begin(),a.end());
	ll ans = 10000000000;
	for(int i = 0; i+k-1 < n; i++){
		if(a[i+k-1]-a[i] < ans) ans = a[i+k-1]-a[i];
	}
	cout << ans ;

}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int n, k; cin >> n >> k;
    map<int, int> mp;
    rep(i, k) {
        int d; cin >> d;
        rep(j, d) {
            int a; cin >> a;
            mp[a] = 1;
        }
    }
    cout << n - mp.size();
}


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

int main() {

int A, B, C, D;
cin >> A >> B >> C >> D;

int X = A + B;
int Y = C + D;

if (X > Y) {
cout << "Left" << endl;
} else if (Y > X) {
cout << "Right" << endl;
} else {
cout << "Balanced" << endl;
}
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

int main() {
  int i;
  string s, t;
  cin >> s >> t;
  if (s.length() + 1 == t.length()) {
    for (i = 0; i < s.length(); i++)
      if (s[i] != t[i]) break;
    if (i == s.length())
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3532
#include<bits/stdc++.h>
long long x[10000010];
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,n) for(int i=1; i<(n); i++)
#define pii pair<long,long>
#define all(x) (x).begin(), (x).end()
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
using namespace std;
signed main(){
 
  cin.tie(0);
  ios::sync_with_stdio(false);

  string s,g;
  int a,b;
  cin>>s>>g;

  a=s.size();
  b=g.size();

  if(s==g) cout<<"EQUAL"<<'\n';
  else if(a>b) cout<<"GREATER"<<'\n';
  else if(a<b) cout<<"LESS"<<'\n';
  else if(s>g) cout<<"GREATER"<<'\n';
  else if(s<g) cout<<"LESS"<<'\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int     long long
#define F       first
#define S       second
#define _READ   freopen("input.txt","r", stdin);
#define _FAST   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
void solve()
{
    char ch;
    cin>>ch;
    if(ch>='a' && ch<='z')
        cout<<'a';
    else
    {
        cout<<"A";
    }
    
}
int32_t main()
{
    #ifndef ONLINE_JUDGE
    _READ
    #endif
    
    int t;
    t=1;
    while(t--)
        solve();
    
    
    return 0;
}


Measured memory_bytes: 3584
import sys
import math

#https://atcoder.jp/contests/agc008/submissions/15248942
sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

n = ini()
cont = 0
ans = 'No'
for i in range(n):
    d = inl()
    if d[0] == d[1]:
        cont += 1
    else:
        cont = 0
    if cont >= 3:
        ans = 'Yes'

print(ans)

Measured memory_bytes: 9204
#include<stdio.h>

int main(void) {
	int x, y, i, j;
	while(1) {
		scanf("%d %d", &y, &x);
		if (x + y == 0) break;
		for (i = 0; i < y; i++) {
			for (j = 0; j < x; j++)
				if (i*j == 0 || i + 1 == y || j + 1 == x)
					printf("#");
				else
					printf(".");
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int n;
vector<int> a;

bool solve(int i, int m){
    if(m == 0) return true;
    if(i >= n) return false;
    bool res = solve(i + 1, m) || solve(i + 1, m - a[i]);
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    a.resize(n);
    rep(i, 0, n) cin >> a[i];
    int q;
    cin >> q;
    rep(i, 0, q){
        int m;
        cin >> m;
        if(solve(0, m)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}

Measured memory_bytes: 3172
const fi='STONE.INP';
      fo='STONE.OUT';
      maxn=100;
      maxk=trunc(1e5);

var n,k:longint;
    a:array[1..maxn] of longint;
    f:array[0..maxk] of 0..1; {f=0-> thua, f=1->thang}
//============================
procedure doc;
var i:longint;
begin
  readln(n,k);

  for i:=1 to n do read(a[i]);
end;
//============================
procedure xuli;
var i,j:longint;
    ok:boolean;
begin
  fillchar(f,sizeof(f),0);

  for i:=1 to k do
    begin
      if (i<a[1]) then begin f[i]:=0; continue; end;

      ok:=false;

      for j:=1 to n do
        begin
          if (i>=a[j]) then
            begin
            if (f[i-a[j]]=1) then continue;
            ok:=true; break;
            end;
        end;

      if ok then f[i]:=1 else f[i]:=0;
    end;

  if f[k]=1 then write('First')
  else write('Second');
end;
//============================
BEGIN
  //assign(input,fi); reset(input);
  //assign(output,fo); rewrite(output);
  doc;
  xuli;
  //close(input); close(output);
END.


Measured memory_bytes: 256
S=input()
T=input()
def check(i):
    flag=True
    for j in range(len(T)):
        if S[i+j]!='?' and S[i+j]!=T[j]:
            flag=False
            break
    return flag
def search(S,T):
    for i in range(len(S)-len(T),-1,-1):
        if check(i):return i
    return -1
def main(S,T):
    ans=''
    if T not in S:
        idx=search(S,T)
        if idx==-1:
            return 'UNRESTORABLE'
        S=S[:idx]+T+S[idx+len(T):]
    for s in S:
        if s=='?':ans+='a'
        else:ans+=s
    return ans
print(main(S,T))

Measured memory_bytes: 3064
#include<cstdio>
#include<cmath>
using namespace std;
#define MAXN 10
bool U[MAXN+5];
bool C(int n){
	while(n){
		if(U[n%10]) return 0;
		n/=10;
	}
	return 1;
}
int main(){
	int n,k;
	scanf("%d %d",&n,&k);
	for(int i=1;i<=k;i++){
		int x;
		scanf("%d",&x);
		U[x]=1;
	}
	while(1){
		if(C(n)){
			printf("%d",n);
			break;
		}
		n++;
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
typedef struct{
    int head;
    int tail;
    int right;
    int left;
    int up;
    int down;
} dice;
dice s(dice a) {
    int buf;
    buf = a.tail;
    a.tail = a.down;
    a.down = a.head;
    a.head = a.up;
    a.up = buf;
	return a;
}
dice n(dice a) {
	return s(s(s(a)));
}
dice e(dice a) {
    int buf;
    buf = a.tail;
    a.tail = a.right;
    a.right = a.head;
    a.head = a.left;
    a.left = buf;
	return a;
}
dice w(dice a) {
	return e(e(e(a)));
}
dice rev(dice a) {
	return e(e(a));
}
dice round(dice a) {
	int buf;
	buf = a.right;
	a.right = a.up;
	a.up = a.left;
	a.left = a.down;
	a.down = buf;
	return a;
}
bool same(dice a, dice b) {
	dice c = a;
	rep(i,4) {
		if(c.head == b.head && c.tail == b.tail && c.up == b.up && c.down == b.down && c.right == b.right && c.left == b.left) return true;
		c = round(c);
	}
	return false;
}

int main() {
    int a[6], b[6];
    dice da, db;
    rep(i,6) {
        cin >> a[i];
	}
	rep(i,6) {
        cin >> b[i];
    }
    da.head = a[0];
    da.down = a[1];
    da.right = a[2];
    da.left = a[3];
    da.up = a[4];
    da.tail = a[5];
	db.head = b[0];
    db.down = b[1];
    db.right = b[2];
    db.left = b[3];
    db.up = b[4];
    db.tail = b[5];
	if(same(da,db) || same(s(da), db) || same(n(da), db) || same(e(da), db) || same(w(da), db) || same(rev(da), db)) cout << "Yes" <<endl;
	else cout << "No" << endl;	
	return 0;
}

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

#define N (100)

int push(int stack[], int data, int *top, char n);
int pop(int stack[], int *top);

int
main(void)
{
        int num;
        char formula[256];
        int top = 0;
        int stack [N];
        int a, b;

        while (scanf("%s", formula) != EOF) {
                if (formula[0] == '+') {
                        a = pop(stack, &top);
                        b = pop(stack, &top);
                        push(stack, (a + b), &top, N);
                } else if (formula[0] == '-') {
                        a = pop(stack, &top);
                        b = pop(stack, &top);
                        push(stack, (b - a), &top, N);
                } else if (formula[0] == '*') {
                        a = pop(stack, &top);
                        b = pop(stack, &top);
                        push(stack, (a * b), &top, N);
                } else {
                        num = atoi(formula);
                        push(stack, num, &top, N);
                }
        }
                printf("%d\n", stack[0]);
                return 0;
}

int
push(int stack[], int data, int *top, char n)
{
        if (*top < n) {
                stack[(*top)++] = data;
                return *top;
        } else {
                return 0;
        }
}

int
pop(int stack[], int *top)
{
        if (*top > 0) {
                return stack[--(*top)];
        } else {
                return 0;
        }
}



Measured memory_bytes: 2040
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int i;
	int count=1;
	long long max1=0,max2=0;
	long long a[100000];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	for(i=0;i<n;i++)
	{
		if(a[i]==a[i+1])
		{
			count=2;
		}else
		{
			count=1;
		}
		if(count>=2)
		{
			max1=max2;
			max2=a[i];
			i++;
			count=1;
		}
	}
	cout<<max1*max2<<endl;
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline

n, c = map(int, input().split())
xv = [list(map(int, input().split())) for _ in range(n)]

m1 = []
v1 = []
v_cum = 0
tmp = 0

for x, v in xv:
    v_cum += v
    tmp = max(tmp, v_cum - x)
    v1.append(v_cum - x)
    m1.append(tmp)

m2 = []
v2 = []
v_cum = 0
tmp = 0

for x, v in xv[::-1]:
    v_cum += v
    tmp = max(tmp, v_cum + x - c)
    v2.append(v_cum + x - c)
    m2.append(tmp)

ans = max((0, m1[-1], m2[-1]))

for i in range(n-1):
    ans = max((
        ans,
        v1[i] + m2[-i-2] - xv[i][0],
        v2[i] + m1[-i-2] + xv[-i-1][0] - c
    ))

print(ans)


Measured memory_bytes: 44136
import math
a, b, x = map(int, input().split())
s = x / a
if s > a * b / 2:
  if x == a * a * b:
    print(0)
  else:
    rad = math.atan(a ** 3 / (2 * a * a * b - 2 * x))
    print(90 - (rad * 180 / math.pi))
else:
  rad = math.atan(a * b * b / (2 * x))
  print(rad * 180 / math.pi)

Measured memory_bytes: 3064
n = int(input())
a = [int(x) for x in input().split()]

ans = 0

for i in range(len(a)):
    count = 0
    if a[i]%2 == 0:
        while(a[i]%2 == 0):
            a[i] //= 2
            count += 1
        ans += count

print(ans)


Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int gcd(int a, int b){
    if(b == 0) return 1;

    while(b != 0){
        int t = a;
        a = b;
        b = t%b;
    }

    return a;
}

int main(){
    int a,b; cin >> a >> b;
    cout << gcd(a, b) << endl;
}


Measured memory_bytes: 3084
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#pragma warning (disable: 4996)
using namespace std;

long long modpow(long long a, long long b, long long m) {
	long long p = 1, q = a;
	for (int i = 0; i < 32; i++) {
		if ((b / (1LL << i)) % 2LL == 1) { p *= q; p %= m; }
		q *= q; q %= m;
	}
	return p;
}

long long N;
long long mod = 1000000007;

int main() {
	cin >> N;
	long long V1 = modpow(10, N, mod);
	long long V2 = modpow(9, N, mod);
	long long V3 = modpow(8, N, mod);
	long long R = (V1 - 2LL * V2 + V3 + mod * mod) % mod;
	cout << R << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

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

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

  if(a <= c && c <= b){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <algorithm>
 
int main() {
 
  int long long t=0,i=0,j=0,N,K;
  double sum=0;
  int long long ans;

  cin >> N >> K;
  ans=N;
  if (N>K)
  {
    ans=N-(N/K)*(K);
  }
  if(ans>abs(ans-K))
  {
    ans=abs(ans-K);
  }
  
  
  cout << ans << endl;
  
  
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    string s;
    cin >> s;
    int n = s.size();
    int ans = inf;
    int mn = 0;
    int now = 0;
    rep(i,n) {
        if(s[i] == '0') now--;
        else now++;
        chmin(mn,now);
    }
    vi posmn(n);
    int nmn = 0;
    now = 0;
    rrep(i,n) {
        posmn[i] = now-nmn;
        if(s[i] == '0') now++;
        else now--;
        chmin(nmn,now);
    }
    rep(_,2) {
        int mx = 0;
        now = 0;
        rep(i,n) {
            if(s[i] == '0') now--;
            else if(s[i] == '1') now++;
            else {
                if(now-1-posmn[i] >= mn) now--;
                else now++;
            }
            chmax(mx,now);
        }
        chmin(ans,mx-mn);
        mn--;
    }
    cout << ans << endl;
}


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

using namespace std;

int main()
{
  int n; cin >> n;
  while(n)
  {
    if(n%10 == 7)
    {
      cout << "Yes" << endl;
      return 0;
    }
    n/=10;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3600
x, y = map(int, input().split())
if y/2 != int(y/2):
    print("No")
else:
    p = 2*x - y/2
    q = y/2 - x
    if p >= 0:
        if q >= 0:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

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

typedef long long LL;

const int MaxN=1e5+5;

int N;
int A[MaxN],Deg[MaxN];

vector<int> To[MaxN];

void DFS(int u,int fa){
	int i,mx=0,cnt=0;
	LL x,sum=0;
	for(auto v:To[u])
		if(v^fa){
			DFS(v,u);
			cnt++;
			sum+=A[v];
			mx=max(mx,A[v]);
		}
	if(cnt){
		x=min(sum/2,sum-mx);
		if(A[u]>sum||sum-A[u]>x){
			puts("NO");
			exit(0);
		}
		A[u]-=sum-A[u];
	}
}

int main(){
	int i,u,v;
	scanf("%d",&N);
	for(i=1;i<=N;i++)
		scanf("%d",&A[i]);
	if(N<3){
		puts(A[1]^A[2]?"NO":"YES");
		return 0;
	}
	for(i=1;i<N;i++){
		scanf("%d%d",&u,&v);
		To[u].push_back(v);
		To[v].push_back(u);
		Deg[u]++,Deg[v]++;
	}
	for(i=1;i<=N;i++)
		if(Deg[i]>1){
			DFS(i,0);
			puts(A[i]?"NO":"YES");
			return 0;
		}
}

Measured memory_bytes: 13184
#include <iostream>
#include <string>
#include <cassert>
#include <algorithm>
#include <cmath>

int main (void){
  std::string S; std::cin >> S;

  bool SisOdd = false;
  if ( S.size() % 2 == 1 ) {
    SisOdd = true;
    if ( S.back() == '1' ) S += '0';
    else S += "1";
  }

  int pair10 = 0, pair11 = 0, pair01 = 0, pair00 = 0;
  char last2word[2];
  for(int i=0; i<S.size(); i++){
    if ( S.substr(i,2) == "00" ) pair00++;
    if ( S.substr(i,2) == "10" ) pair10++;
    if ( S.substr(i,2) == "01" ) pair01++;
    if ( S.substr(i,2) == "11" ) pair11++;
    last2word[0] = S[i];
    last2word[1] = S[i+1];
    i++;
  }

  if ( SisOdd ){
    if ( (pair10 <= pair01 && last2word[0] == '1' && last2word[1] == '0') ||
         (pair01 <= pair10 && last2word[0] == '0' && last2word[1] == '1' ) ) {
      std::cout << std::min(pair10,pair01)*2 - 1 + pair00 + pair11 << std::endl;
      return 0;
    }
  }
  std::cout << std::min(pair10,pair01)*2 + pair00 + pair11 << std::endl;
  return 0;
}

Measured memory_bytes: 512
/*
 * b.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int dxs[] = {1, 0, -1}, dys[] = {0, -1, 0};

/* typedef */

/* global variables */

int xs[2], ys[2], dis[2], xmaxs[2], ymins[2];

/* subroutines */

/* main */

int main() {
  int w, h, n;
  cin >> w >> h >> n;

  xs[0] = 0, ys[0] = h - 1, dis[0] = 0;
  xs[1] = 0, ys[1] = h - 2, dis[1] = 0;

  xmaxs[0] = w - 1, xmaxs[1] = w - 2;
  ymins[0] = 0, ymins[1] = 1;

  int cnt = 0;
  
  for (int i = 0; i < n; i++) {
    int pi;
    cin >> pi;

    int x = xs[pi] + dxs[dis[pi]], y = ys[pi] + dys[dis[pi]];
    if (x > xmaxs[pi] || y < ymins[pi]) dis[pi]++;
    xs[pi] += dxs[dis[pi]], ys[pi] += dys[dis[pi]];

    if ((xs[0] == xs[1] && abs(ys[0] - ys[1]) == 1) ||
	(ys[0] == ys[1] && abs(xs[0] - xs[1]) == 1)) cnt++;
  }

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

Measured memory_bytes: 1144
import math

n = int(input())
a = 0
li = [] #累積和のリスト
ans = []

def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

for i in range(10**5//2):
    x = 2*i+1
    y = i+1
    if is_prime(y):
        if is_prime(x):
            a += 1
    li.append(a)

for i in range(n):
    l, r = map(int,input().split())
    ans.append(li[r//2]-li[max(0,l//2-1)])

for i in ans:
    print(i)

Measured memory_bytes: 8200
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

Int dp[105][10];
Int amida[10][10];

int main(){
    cin.tie(0);

    Int H, W, K; cin >> H >> W >> K;

    dp[0][0] = 1;

    for (int i = 0; i < (1 << (W-1)); i++){
        int flag = 1;
        for (int j = 0; j < (W-2); j++){
            if ((1 << j) & i && (1 << (j+1)) & i){
                flag = 0;
            }
        }
        if (!flag) continue;

        int pos[10];
        for (int j = 0; j < W; j++){
            pos[j] = j;
        }

        for (int j = 0; j < (W-1); j++){
            if ((1 << j) & i) swap(pos[j], pos[j+1]);
        }

        for (int j = 0; j < W; j++){
            amida[pos[j]][j]++;
        }
    }

    for (int h = 1; h <= H; h++){
        for (int w = 0; w < W; w++){
            if (w-1 >= 0) dp[h][w] += dp[h-1][w-1] * amida[w-1][w] % MOD;
            dp[h][w] %= MOD;
            dp[h][w] += dp[h-1][w] * amida[w][w] % MOD;
            dp[h][w] %= MOD;
            if (w+1 < W) dp[h][w] += dp[h-1][w+1] * amida[w+1][w] % MOD;
            dp[h][w] %= MOD;
        }
    }
    cout << dp[H][K-1] << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vpi = vector<pi>;
using vvpi = vector<vpi>;
const ull MOD = 998244353;
#ifdef LOCAL
#include "../../pp.hpp"
#define debug pp::debug
#else
#define debug(args...)
#endif

int n;
vector<long long> a;
vector<vector<pair<long long, int>>> dp;

pair<long long, int> solve(int i, int j) {
    if (i > j) return make_pair(0, -1);
    if (i == j) return make_pair(a[i], i);
    if (dp[i][j].first != -1) return dp[i][j];

    long long ans_l, ans_r;
    long long ans_l_my, ans_r_my;
    int idx_l, idx_r;
    int idx_l_my, idx_r_my;
    tie(ans_r, idx_r) = solve(i+1, j);
    tie(ans_l, idx_l) = solve(i, j-1);

    if (idx_r == i+1) {
        tie(ans_r_my, idx_r_my) = solve(i+2, j);
    } else {
        assert(idx_r == j);
        tie(ans_r_my, idx_r_my) = solve(i+1, j-1);
    }

    if (idx_l == i) {
        tie(ans_l_my, idx_l_my) = solve(i+1, j-1);
    } else {
        assert(idx_l == j-1);
        tie(ans_l_my, idx_l_my) = solve(i, j-2);
    }

    long r_val = a[i] + ans_r_my - a[idx_r];
    long l_val = a[j] + ans_l_my - a[idx_l];
    if (r_val > l_val) {
        dp[i][j] = make_pair(r_val, i);
    } else {
        dp[i][j] = make_pair(l_val, j);
    }
    return dp[i][j];
}

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

    cin >> n;
    dp = vector<vector<pair<long long, int>>>(n, vector<pair<long long, int>>(n, make_pair(-1, -1)));
    a = vector<long long>(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    long long ans; int idx;
    tie(ans, idx) = solve(0, n - 1);

    cout << ans << '\n';
}


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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
  int N, A, B;
  cin >> N >> A >> B;
  int ans = 0;
  REP1(i, N) {
    int sum = 0;
    int j = i;
    while(j > 0) {
      sum += j % 10;
      j /= 10;
    }
    if(sum >= A && sum <= B) {
      ans += i;
    }
  }
  cout << ans << endl;    
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int x, y;
  char input[150];
  fgets(input, 149, stdin);
  sscanf(input, "%d %d", &x, &y);

  for (size_t i = 0; i < x+1; i++) {
    int a;
    a = x - i;
    if (a * 2 + i * 4 == y) {
      printf("Yes");
      return 0;
    }
  }
  printf("No");

  return 0;
}


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

int main(){
	int m;scanf("%d",&m);
	rep(i,m){
		int p,y,n;scanf("%d%d%d",&p,&y,&n);
		double Max=0;
		rep(j,n){
			int o,d;double k;
			scanf("%d%lf%d",&o,&k,&d);
			if(o){
				double x=p;
				rep(t,y){x*=(1+k);x=(int)x;x-=d;}
				Max=max(Max,x);
			}
			else{
				double r=p,cnt=0;
				rep(t,y){cnt+=r*k;cnt=(int)cnt;r=(int)r;r-=d;}
				Max=max(Max,r+cnt);
			}
		}
		printf("%d\n",(int)Max);
	}
}

Measured memory_bytes: 3176
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdin = new Scanner( System.in);
		String S= stdin.next();
		String ans="0";
            
		for(int i=0;i<7;i++) {
			ans=S.substring(0,i)+S.substring(S.length()-7+i);
			if(ans.equals("keyence")) break; 
		}

		if(ans.equals("keyence")) {
			System.out.print("YES");
		}else	System.out.print("NO");


         
           
       
	}
}


Measured memory_bytes: 22612
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;

void main()
{
    auto S = readln.chomp.to!(wchar[]);
    if (S[0] != 'A') {
        writeln("WA");
        return;
    }
    auto len = S.length;
    int C;
    foreach (i, c; S) {
        if (!i) continue;
        if (i >= 2 && i <= len - 2 && c == 'C') {
            ++C;
        } else if (c >= 'A' && c <= 'Z') {
            writeln("WA");
            return;
        }
    }
    if (C != 1) {
        writeln("WA");
        return;
    }
    writeln("AC");
}

Measured memory_bytes: 380
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#

"""
agc012 C
"""

from collections import defaultdict

n, m = map(int, input().split())

graph = defaultdict(list)
for i in range(m):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

q = int(input())
qlist = [tuple(map(int, input().split())) for i in range(q)]
qlist.reverse()

dp = [[-1]*11 for i in range(n+1)]
col = [0]


def updatedp(v, t, d):
    if dp[v][d] == -1:
        dp[v][d] = t
        if d > 0:
            updatedp(v, t, d-1)
            for u in graph[v]:
                updatedp(u, t, d-1)


t = 0
for v, d, c in qlist:
    col.append(c)
    updatedp(v, t, d)
    t += 1

for i in range(1, n+1):
    print(col[dp[i][0]+1])


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

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {


		int N,tmp,maximum = -BIG_NUM,minimum = BIG_NUM;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			N = Integer.parseInt(br.readLine());

			for(int loop = 0; loop < N; loop++){
				tmp = Integer.parseInt(br.readLine());
				maximum = Math.max(maximum, tmp-minimum);
				minimum = Math.min(minimum, tmp);
			}
		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}

		System.out.println(maximum);
	}
}



Measured memory_bytes: 42204
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            int val = sc.nextInt();
            if (val % 2 == 0 && val % 3 != 0 && val % 5 != 0) {
                System.out.println("DENIED");
                return;
            }
        }
        System.out.println("APPROVED");
    }
}


Measured memory_bytes: 21844
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e16;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };


const int N=300005;



void solve()
{
    int s,w;
    cin>>s>>w;
    if(w>=s)
    {
        cout<<"unsafe";
    }
    else
        cout<<"safe";
    cout<<endl;

}

int32_t main()
{
    IOS;
    //FILE *fin = freopen("in","r",stdin);
    //FILE *fout = freopen("out","w",stdout);
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
using namespace std;
int main(){
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	
	int d = 2*c - a - b;
	int res = 1000000000;
	if (d >= 0) {
		
		cout << a*x + b*y <<endl;
		
	}
  	else  {
		
		for (int i=1; i<=max(x,y); i++) {
			
			res = min(res,max(x-i,0)*a+max(y-i,0)*b+2*i*c);
			
		}
	  
		
		cout << res << endl;
	}
    return 0;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std;
int main()
{
    int a[100000];
    int n,m,total=0;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=n;i>=n-m+1;i--)
    total+=a[i];
    cout<<total;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  vector<int> v;
  for (int i=0; i*i<=(1<<15); ++i) {
    v.push_back(i*i);
  }
  int n;
  while(cin>>n,n) {
    int res = 0;
    REP(i, v.size()) {
      if (v[i] > n) break;
      REP(j, i+1) {
        if (v[i]+v[j] > n) break;
        REP(k, j+1) {
          if (v[i]+v[j]+v[k] > n) break;
          REP(l, k+1) {
            if (v[i]+v[j]+v[k]+v[l] > n) break;
            if (v[i]+v[j]+v[k]+v[l] == n)
              res++;
          }
        }
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 908
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main()
{
    int n, d;
    cin >> n >> d;
    int x[n * d];
    for (int i = 0; i < n * d; i++) {
        cin >> x[i];
    }
    int sq_tbl[128];
    int ans = 0;
    for (int i = 0; i < 128; i++) {
        sq_tbl[i] = (i+1) * (i+1);
    }

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int sq_dist = 0;
            for (int k = 0; k < d; k++) {
                sq_dist += (x[i * d + k] - x[j * d + k]) * (x[i * d + k] - x[j * d + k]);
            }
            for (int l = 0; l < 128; l++) {
                if (sq_dist == sq_tbl[l]) {
                    ans++;
                    break;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
//for(int i=0; i<n; ++i)
using namespace std;
#define all(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " is " << (x) << endl
#define ll long long

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

    int n;
    ll sign;
    cin >> n;
    vector<int> a(n);

    for (int i = 0; i < n; ++i)
        cin >> a[i];
    if (n % 2 == 1)
        sign = 1ll;
    else
        sign = -1ll;

    vector<vector<ll>> dp(n, vector<ll>(n, 0ll));
    for (int i = n - 1; i >= 0; --i)
    {
        dp[i][i] = sign * a[i];
        ll det = sign;
        for (int j = i + 1; j < n; ++j)
        {
            det = -1 * det;
            if (det < 0)
                dp[i][j] = min(dp[i + 1][j] + (det * a[i]), dp[i][j - 1] + (det * a[j]));
            else
                dp[i][j] = max(dp[i + 1][j] + (det * a[i]), dp[i][j - 1] + (det * a[j]));
        }
    }
    /*
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            cout << dp[i][j] << " \n"[j == n - 1];
    */

    cout << dp[0][n - 1] << endl;
    return 0;
}

Measured memory_bytes: 73536
// Tree Walk
#include <stdio.h>

#define MAX 25 // 接点の個数の上限
#define NIL -1 // 番兵(接点番号として使われない値を設定)

struct node{
  int parent; // 接点の親を参照
  int left;   // 左の子を参照
  int right;  // 右の子を参照
};
struct node T[MAX];

// 再帰を使って先行順巡回(Preorder)で表示
void printPreorder(int u){
  if(u == NIL)return;
  printf(" %d", u);
  printPreorder(T[u].left);
  printPreorder(T[u].right);
}

// 再帰を使って中間順巡回(Inorder)で表示
void printInorder(int u){
  if(u == NIL)return;
  printInorder(T[u].left);
  printf(" %d", u);
  printInorder(T[u].right);
}

// 再帰を使って後行順巡回(Postorder)で表示
void printPostorder(int u){
  if(u == NIL)return;
  printPostorder(T[u].left);
  printPostorder(T[u].right);
  printf(" %d", u);
}

int main(){
  int i, n, id, l, r;

  scanf("%d", &n);

  for(i=0; i < n; i++){ // NILを代入して初期化
    T[i].parent = T[i].left = T[i].right = NIL;
  }

  for(i=0; i < n; i++){
    scanf("%d", &id);
    scanf("%d%d", &T[id].left, &T[id].right);
    T[T[id].left].parent = T[T[id].right].parent = id;
  }
  
  i = 0;
  while(1){
    if(T[i].parent == NIL) break;
    i++;
  }
  
  printf("Preorder\n");
  printPreorder(i);
  printf("\nInorder\n");
  printInorder(i);
  printf("\nPostorder\n");
  printPostorder(i);
  printf("\n");
  
  return 0;
}


Measured memory_bytes: 2104
N,x=map(int,input().split())
A=list(map(int,input().split()))
if A[0]>x:
  cnt=A[0]-x
  A[0]=A[0]-cnt
else:
  cnt=0
for i in range(1,N):
  gap=A[i]+A[i-1]-x
  if gap>0:    
    cnt+=gap
    A[i]-=gap
print(cnt)

Measured memory_bytes: 14132
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
	char s[100100];scanf("%s",s+1);
	int n=strlen(s+1),ans=0;
	for(int i=1,x=0,y=0;i<=n;i++)
		if(x==y) ans+=(s[i]=='g')-1,x++;
		else ans+=(s[i]=='g'),y++;
	cout<<ans;
}

Measured memory_bytes: 384
n=int(input())
a=[list(map(int,input().split())),list(map(int,input().split()))]

ue=[0]*(n+1)
sita=[0]*(n+1)

for i in range(n):
    ue[i+1]+=ue[i]+a[0][i]
    sita[n-i-1]+=sita[n-i]+a[1][n-i-1]

ans=0
for i in range(n):
    ans=max(ans, ue[i+1]+sita[i])
print(ans)

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

int main()
{
	int n, m;

	int a[100][100], b[100],c[100];

	cin >> n >> m;

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

	for (int x = 0; x < n; x++)
	{
		c[x] = 0;
	}

	for (int x = 0; x < n; x++)
	{
		for (int y = 0; y < m; y++)
		{
			c[x] += a[x][y] * b[y];
		}
	}

	for (int x = 0; x < n; x++)
	{
		cout << c[x] << endl;
	}
}


Measured memory_bytes: 3136