akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N, M;
	cin >> N >> M;
	vector<int>A(M);
	vector<int>B(M);
	rep(i, M) {
		cin >> A[i] >> B[i];
	}
	vector<int>AA(M);
	vector<int>BB(M);
	int cnta = 0;
	int cntb = 0;
	rep(i, M) {
		if (A[i] == 1) {
			AA[cnta] = B[i];
			cnta++;
		}
	}
	rep(i, M) {
		if (B[i] == N) {
			BB[cntb] = A[i];
			cntb++;
		}
	}
	int ans = 0;
	sort(BB);
	rep(i, M) {
		if (AA[i] != 0) {
			ans += upper(BB, AA[i]) - lower(BB, AA[i]);
		}
	}
	if (ans == 0) {
		cout << "IMPOSSIBLE" << endl;
	}
	else {
		cout << "POSSIBLE" << endl;
	}
}




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

int a[111111];
int main() {
    int n, d, p = 998244353;
    cin >> n >> d;
    if(d) {
        cout << 0 << endl;
        return 0;
    }
    for(int i = 1; i < n; i++)
        scanf("%d", &d), a[d]++;
    if(*a) {
        cout << 0 << endl;
        return 0;
    }
    *a = 1;
    long r = 1;
    int c = 0;
    for(int i = 0; c < n; i++) {
        for(int j = 0; j < a[i + 1]; j++)
            (r *= a[i]) %= p;
        c += a[i];
    }
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 640
def main():
  import numpy as np
  N,W = map(int, input().split())
  
  dp = np.zeros(W+1, dtype=np.int64)
  
  for _ in range(N):
    w,v = map(int,input().split())
    np.maximum(dp[:-w]+v,dp[w:], out=dp[w:])
  
  print(dp[-1])

if __name__ == '__main__':
  main()

Measured memory_bytes: 14584
while 1:
    n,x = map(int,input().split())
    if n == 0:break
    d = 0
    for a in range(1,x//3):
        for c in range(n,(x-a)//2,-1):
            b = x - a - c
            if a < b < c :d += 1
    print(d)


Measured memory_bytes: 5596
T = [[0,0],[0,0],[0,0],[0,0],[0,0]]
for i in range(5):
	t = int(input())
	if t%10 == 0:
		T[i][0] = 10
	else:
		T[i][0] = t%10
	T[i][1] = t

T.sort(reverse=True)
# print(T)
ans = 0
for i in range(4):
	if T[i][0] == 10:
		ans += T[i][1]
	else:
		ans += (T[i][1]//10+1)*10
	# print(ans)
ans += T[4][1]
print(ans)


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

int read()
{
	int s=0;
	char c=getchar(),lc='+';
	while (c<'0'||'9'<c) lc=c,c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return lc=='-'?-s:s;
}
void write(int x)
{
	if (x<0)
	{
		putchar('-');
		x=-x;
	}
	if (x<10) putchar(x+'0');
	else
	{
		write(x/10);
		putchar(x%10+'0');
	}
}
void print(int x,char c='\n')
{
	write(x);
	putchar(c);
}

signed main()
{
	int n=read();
	for (int i=1;i<=n;i++) cout<<"ACL";

	return 0;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

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


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#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 fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


signed main(){
    int h,w;
    cin >> h >> w;
    int cnt[26] = {};
    REP(i,h){
        string tmp;
        cin >> tmp;
        REP(i,w) cnt[int(tmp[i] - 'a')] ++;
    }
    int ni = 0;
    if(h%2 ==1){
        ni += w / 2;
    }

    if(w%2 == 1){
        ni += h / 2;
    }
    int iti = 0;
    if( h %2 == 1 and w %2 == 1) iti = 1;


    REP(i,26){
        if(cnt[i] %4 ==2){
            ni --;
        }
        else if(cnt[i] %2 == 1){
            iti --;
        }
        if(ni <0 or iti < 0){
            cout << "No" <<endl;
            return 0;
        }
    }


    cout << "Yes" << endl;


}


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

int main() {
	int N, S;
	vector<int> v(10);
	for (int i = 0; i < 10; i++) {
		v.at(i) = i;
	}

	while (cin >> N >> S) {
		if (N == 0 && S == 0) {
			break;
		}

		int cnt = 0;
		for (int tmp = 0; tmp < (1 << 10); tmp++) {
			bitset<10> bs(tmp);

			if (bs.count() == N) {
				int sum = 0;
				for (int i = 0; i < 10; i++) {
					if (bs.test(i)) sum += i;
				}

				if (sum == S) cnt++;
			}
		}

		cout << cnt << endl;
	}
}


Measured memory_bytes: 3064
import java.util.Scanner;

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

		int count = 0;
		for (int id = 0; id < l1.length; id++) {
			if (l1[id] != l2[id]) {
				count++;
			}
		}

		System.out.println(count);
	}
}


Measured memory_bytes: 42916
#include <bits/stdc++.h>
using namespace std;
int dp[100005];
int path(int i,vector <int> *g){
	if(dp[i]!=-1)
		return dp[i];
	if(g[i].size()==0){
		dp[i]=0;
		return 0;
	}
	int mx=0;
	for(int j=0;j<g[i].size();j++){
		mx=max(mx,path(g[i][j],g));
	}
	dp[i]=mx+1;
	return dp[i];
}
int main(){
	int n,m;
	cin >> n >> m;
	memset(dp,-1,sizeof(int)*100005);
	vector <int> g[n+1];
	for(int i=0;i<m;i++){
		int x,y;
		cin >> x >> y;
		g[x].push_back(y);
	}
	int mx=0;
	for(int i=1;i<=n;i++){
		mx=max(mx,path(i,g));
	}
	cout << mx << endl;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> //required
//#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define lb long double
#define pb push_back
#define loop(i,start,n) for(ll i=start;i<n;i++)
#define rloop(i,n,start)for(ll i=n;i>=start;i--)
#define mod 1000000007
#define endl "\n"
#define INF     1e15
#define NEG_INF -1e15
#define pll pair<ll,ll>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
//template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
//using namespace __gnu_pbds;

int main(){
	IOS;
	char a;
	cin >> a;
	if( a >= 'A' && a <= 'Z')
		cout << 'A';
	else
		cout << 'a';
}

Measured memory_bytes: 3652
N, M = map(int, input().split())
ab_list = [list(map(lambda x: int(x) - 1, input().split())) for i in range(M)]

lis = [[] for i in range(N)]

for i in range(M):
    lis[ab_list[i][0]].append(ab_list[i][1])

que = [[0, 0, lis[0], []]]
ends = []
res = False

while que:
    count, now, next_nodes, visited = que.pop()
    visited.append(now)
    if now == N - 1:
        ends = visited[:]
    for node in next_nodes:
        if node in visited or count == 2:
            continue
        que.append([count + 1, node, lis[node], visited[:]])

if N - 1 in ends:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 79792
N, T = map(int, input().split())
A = [int(x) for x in input().split()]
cost, buy, mprofit = 1, 10e9, 0
for a in A:
    if a < buy:
        buy = a
    else:
        profit = a - buy
        if profit == mprofit:
            cost += 1
        if profit > mprofit:
            mprofit = profit
            cost = 1
print(cost)

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  for(int h = 1; h <= 3500; h++) {
    for(int w = 1; w <= 3500; w++) {
      if(4*h*w-N*w-N*h <= 0) continue;
      if((N*h*w)%(4*h*w-N*w-N*h) == 0) {
	cout << h << " " << w << " " << (N*h*w)/(4*h*w-N*w-N*h) << endl;
	return 0;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n,T;

ll dp[101][1001];
ll c[100];
ll t[100];

int main(){
	cin >> n >> T;
	ll ans = INF;
	rep(i,n){
		cin >> c[i] >> t[i];
		if(t[i] <= T)ans = min(ans,c[i]);
	}
	if(ans == INF)cout << "TLE" << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define lowbit(x) (x)&(-x)
#define fir first
#define sec second
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define maxd 1000000007
typedef long long ll;
const int N=100000;
const double pi=acos(-1.0);
struct node{
	int to,nxt;
}sq[200200];
int n,fa[200200],mex[200200],all=0,head[200200];
bool vis[200200],cir[200200];

int read()
{
	int x=0,f=1;char ch=getchar();
	while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
	while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
	return x*f;
}

void add(int u,int v)
{
	all++;sq[all].to=v;sq[all].nxt=head[u];head[u]=all;
}

void dfs(int u)
{
	int i;
	for (i=head[u];i;i=sq[i].nxt)
	{
		int v=sq[i].to;
		if (!cir[v]) dfs(v);
	}
	for (i=head[u];i;i=sq[i].nxt)
	{
		int v=sq[i].to;
		if (!cir[v]) vis[mex[v]]=1;
	}
	while (vis[mex[u]]) mex[u]++;
	for (i=head[u];i;i=sq[i].nxt) 
	{
		int v=sq[i].to;
		vis[mex[v]]=0;
	}
}

int main()
{
	n=read();
	rep(i,1,n)
	{
		fa[i]=read();
		add(fa[i],i);
	}
	int u=1,cnt=0;
	while (!vis[u]) {vis[u]=1;u=fa[u];}
	while (!cir[u]) {cir[u]=1;u=fa[u];}
	memset(vis,0,sizeof(vis));
	int maxsg=-1,minsg=n+1;
	rep(i,1,n)
	{
		if (cir[i])
		{
			dfs(i);cnt++;
			maxsg=max(maxsg,mex[i]);minsg=min(minsg,mex[i]); 
		}
	}
	if ((maxsg==minsg) && (cnt&1)) puts("IMPOSSIBLE");
	else puts("POSSIBLE");
	return 0;
}


Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;
const int maxn=1e3+7;
struct Point{
	int x,y,r;
}pt[maxn];
double dis[maxn];
bool vis[maxn];
struct D{
	int u;
	double d;
	bool operator<(const D&a)const{
		return d>a.d;
	}
};
inline double getdis(int i,int j)
{
	return sqrt(1LL*(pt[i].x-pt[j].x)*(pt[i].x-pt[j].x)+1LL*(pt[i].y-pt[j].y)*(pt[i].y-pt[j].y));
}
int n;
void dij()
{
	priority_queue<D> q;
	q.push({0,0});
	for(int i=0;i<maxn;i++) dis[i]=1e15;
	dis[0]=0;
	while(!q.empty())
	{
		auto u=q.top();q.pop();
		if(vis[u.u]) continue;
		vis[u.u]=1;
		for(int i=0;i<=n;i++)
		{
			if(i==u.u) continue;
			double d=getdis(i,u.u);
			d-=pt[i].r+pt[u.u].r;
			if(d<0) d=0;
			if(dis[i]>u.d+d)
			{
				dis[i]=u.d+d;
				q.push({i,dis[i]});
			}
		}
	}
}
int main()
{
	int xs,ys,xt,yt;
	scanf("%d%d%d%d",&xs,&ys,&xt,&yt);
	scanf("%d",&n);
	pt[0]={xs,ys,0};
	pt[n+1]={xt,yt,0};
	for(int i=1;i<=n;i++)
		scanf("%d%d%d",&pt[i].x,&pt[i].y,&pt[i].r);
	n++;
	dij();
	printf("%.10f\n",dis[n]);
}


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

int main(){
  int W,H,N;
  cin>>W>>H>>N;
  int x,y,a;
  int x_max,x_min,y_max,y_min;
  x_max=W;y_max=H;x_min=0;y_min=0;
  for (int i=0;i<N;i++){
    cin>>x>>y>>a;
    if (a==1){
      x_min=max(x_min,x);
    }
    if (a==2){
      x_max=min(x_max,x);
    }
    if (a==4){
     y_max=min(y_max,y);
    }
    if (a==3){
     y_min=max(y_min,y); 
    }
  }
  if ((x_max<=x_min)||(y_max<=y_min)){
    cout<<0<<endl;
  }
  else{
    cout<<(x_max-x_min)*(y_max-y_min)<<endl;
  }
}

Measured memory_bytes: 256
S = input()

mi = len(S) // 2 + len(S) % 2 

if len(S) % 2 == 0:
  l = mi - 1
  r = mi
  if S[l] != S[r]:
    print(r)
    exit()
else:
  l = mi - 1
  r = mi - 1

re = S[l]
for i in range(l):
  if S[l - 1 - i] != re or S[r + 1 + i] != re:
    ans = r + i + 1
    break
else:
  ans = len(S)


print(ans)

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

using namespace std;

int main() {
  string ring, target;
  cin >> ring;
  cin >> target;

  bool is_find = false;
  for(int i=0; i<ring.length(); i++) {
    int pos = i;
    int len = ring.length();
    bool flag = true;
    for(int j=0; j<target.length(); j++) {
      if(ring[pos] != target[j]) {
        flag = false;
        break;
      }
      pos = (pos+1) % len;
    }
    if(flag) {
      is_find = true;
      cout << "Yes" << endl;
      break;
    }
  }
  
  if(!is_find) {
    cout << "No" << endl;
  }
  return 0;
}

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

// https://qiita.com/rsk0315_h4x/items/ff3b542a4468679fb409
class smart_sieve {
    intmax_t L, R, M;
    std::vector<int> small;                    // 小さい篩
    std::vector<std::vector<intmax_t>> large;  // 大きい篩
    std::vector<intmax_t> aux;                 // aux[i] := large[i] の素因数の積

   public:
    smart_sieve(intmax_t L, intmax_t R) : L(L), R(R), M(sqrt(R) + 1) {
        small.resize(M);
        std::iota(small.begin(), small.end(), 0);
        large.resize(R - L);
        aux.assign(R - L, 1);

        for (intmax_t i = 2; i * i < R; ++i) {
            if (small[i] < i) continue;
            small[i] = i;
            for (intmax_t j = i * i; j < M; j += i)
                if (small[j] == j) small[j] = i;

            for (intmax_t j = (L + i - 1) / i * i; j < R; j += i) {
                intmax_t k = j;
                do {
                    // aux[j-L] > M で判定した方がいいかも？
                    // j / aux[j-L] < M の方がいい？（割り算したくない）
                    if (aux[j - L] * aux[j - L] > R) break;

                    large[j - L].push_back(i);
                    aux[j - L] *= i;
                    k /= i;
                } while (k % i == 0);
            }
        }
    }

    std::vector<intmax_t> factor(intmax_t n) {
        assert(L <= n && n < R);
        std::vector<intmax_t> res = large[n - L];
        n /= aux[n - L];
        if (n >= M) {
            // この場合，n は素数となることが示せる（はず）
            // n*n >= R だとオーバーフローしそう？
            res.push_back(n);
            return res;
        }
        while (n > 1) {
            res.push_back(small[n]);
            n /= small[n];
        }
        return res;
    }
};

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    map<int, int> mp;
    const int R = 1000001;
    smart_sieve ss(1, R);
    vector<vector<intmax_t>> alldiv(R + 1);
    for (intmax_t i = 1; i < R; ++i) {
        alldiv[i] = ss.factor(i);
    }
    rep(i, n) {
        set<int> st;
        for (int t : alldiv[a[i]]) {
            if (st.count(t)) continue;
            mp[t]++;
            st.insert(t);
        }
    }
    bool is_pc = true;
    bool is_sc = true;
    for (auto t : mp) {
        int now = t.second;
        if (now > 1) is_pc = false;
        if (now >= n) is_sc = false;
    }
    
    if (is_pc) cout << "pairwise coprime" << endl;
    else if (is_sc) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
    return 0;
}
/*
g++ -std=c++17 -Wall -Wextra -g -O0 -fsanitize=undefined,address main.cpp && oj t
*/

Measured memory_bytes: 162268
n = int(raw_input())
for i in range(n):
    ball = map(int, raw_input().split())
    a = [ball[0]]
    b = []
    flag = 0
    for j in range(1,10):
        if ball[j] > a[len(a)-1]:
            a.append(ball[j])
        else:
            b.append(ball[j])
            if len(b) > 1 and b[len(b)-2] > b[len(b)-1]:
                print "NO"
                flag = 1
                break
    if flag == 0:
        print "YES"

Measured memory_bytes: 4228
x, y = map(int, input().split())

def hantei(x, y):
    for i in range(0, x+1):
        if 2 * i + 4 * (x - i) == y:
            return True
    return False

if hantei(x, y) == True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9116
N = int(input())
a = list(map(int,input().split()))
k = 0
i = 1
flag = False
while k < N:
  if a[k] == i:
    i += 1
    k += 1
    flag = True
  else:
    k += 1
if flag == True:
  print(N-i+1)
else:
  print(-1)

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

// #undef LOCAL
#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int N;
double dp[3000][3000];
vector<double> p, q, r;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);

  cin >> N;
  for (int i = 0; i < N; i++) {
    double d;
    cin >> d;
    p.push_back(d);
    q.push_back(1 - d);
  }
  dumpv(p);
  dumpv(q);
  dp[0][0] = p[0];
  dp[1][0] = q[0];
  dumpv(dp, N, N);
  for (int i = 1; i < N; i++) {
    dp[0][i] = dp[0][i - 1] * p[i];
    for (int j = 1; j <= i; j++) {
      dp[j][i] += dp[j - 1][i - 1] * q[i];
      dp[j][i] += dp[j][i - 1] * p[i];
    }
    dp[i + 1][i] += dp[i][i - 1] * q[i];
    dumpv(i, dp, N, N);
  }
  double ans = 0.0;
  for (int i = 0; i < (N + 1) / 2; i++) {
    ans += dp[i][N - 1];
    dump(ans);
  }
  printf("%.10f\n", ans);
  ans = 0.0;
  for (int i = 0; i <= N; i++) {
    ans += dp[i][N - 1];
  }
  dump(ans);
  return 0;
}


Measured memory_bytes: 70144
def main():
    n = int(input())
    s = input()
    before = [[0] * 10 for _ in range(n)]
    after = [[0] * 10 for _ in range(n)]
    for i in range(1, n):
        before[i] = before[i - 1][:]
        before[i][ord(s[i - 1]) - ord('0')] = 1
    for i in range(n - 2, 0, -1):
        after[i] = after[i + 1][:]
        after[i][ord(s[i + 1]) - ord('0')] = 1
    res = [0] * 1000
    for j in range(n):
        mid = ord(s[j]) - ord('0')
        for i in range(10):
            if before[j][i]:
                for k in range(10):
                    if after[j][k]:
                        res[i * 100 + mid * 10 + k] = 1
    sum = 0
    for v in res:
        sum += v
    print(sum)

main()

Measured memory_bytes: 14708
from collections import deque

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

vertex = [[] for i in range(N)]
for side in sides:
    vertex[side[0]-1].append(side[1])
    vertex[side[1]-1].append(side[0])

# print(vertex)

ans = 0

for side in sides:
    vertex[side[0]-1].remove(side[1])
    vertex[side[1]-1].remove(side[0])
    # print(vertex)
    for i in range(1,N+1):
        a = 1
        check = deque([i])
        fromcheck = {j:0 for j in range(1,N+1)}
        visit = {i}
        while len(check) != 0:
            v = check.popleft()
            for ver in vertex[v-1]:
                if fromcheck[ver] == 0:
                    fromcheck[ver] = 1
                    check.append(ver)
                    visit.add(ver)
            fromcheck[v] = 1
        if visit != {i for i in range(1,N+1)}:
            a = 0
            break
    if a == 1:
        ans += 1
    vertex[side[0]-1].append(side[1])
    vertex[side[1]-1].append(side[0])

print(M-ans)


Measured memory_bytes: 3316
N = int(input())
from collections import defaultdict
d = defaultdict(list)
for i in range(N):
    s,p = input().split()
    p = int(p)
    d[s].append((p, i+1))
k = list(d.keys())
k.sort()
for c in k:
    l = d[c]
    l.sort(key=lambda x:x[0], reverse= True)

    for p,i in l:
        print(i)

Measured memory_bytes: 3316
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    int solve(vector<int>&A ) {
        int n = A.size();
        int res = 0;
        vector<vector<pair<int,int>>> C(2);
        for (int beg = 0; beg < 2; ++beg) {
            vector<int> B;
            for (int i = beg; i < n; i += 2) {
                B.push_back(A[i]);
            }
            sort(B.begin(), B.end());
            int mx = 0;
            int m = B.size();
            for (int i = 0; i < m; ++i) {
                int cnt = 1;
                while (i + 1 < m && B[i + 1] == B[i]) {
                    ++i;
                    ++cnt;
                }
                mx = max(mx, cnt);
                C[beg].emplace_back(cnt, B[i]);
            }
            sort(C[beg].begin(), C[beg].end());
            reverse(C[beg].begin(), C[beg].end());
        }
        
        for (int i = 0; i < C[0].size() && i < 3; ++i) {
            for (int j = 0; j < C[1].size() && j < 3; ++j) {
                // cout << C[0][i].first << " " << C[1][i].second << endl;
                if (C[0][i].second == C[1][j].second) {
                    res = max(res, C[0][i].first);
                    res = max(res, C[1][j].first);
                    continue;
                }
                res = max(res, C[0][i].first + C[1][j].first);
            }
        }
        res = n - res;

        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

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

    Solution sol;
    cout << sol.solve(A) << "\n";

    return 0;
}

Measured memory_bytes: 2100
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/


#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printfin(a) printf(a ? "possible\n" : "inposible\n")
#define all(x) (x).begin(), (x).end()
using ll = long long;

const int INF = 2147483647;
//const ll LINF = ll();今度書く

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>

using namespace std;

int main() {

	int a, b, count = 0;
	scanf("%d%d", &a, &b);
	for (int i = a; i <= b; ++i) {
		if (i / 10000 == i - int(i / 10) * 10 && i / 1000 - int(i / 10000) * 10 == i / 10 - int(i / 100) * 10)++count;
	}
	printf("%d\n", count);

	return 0;
}


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

#define pb push_back
#define mp make_pair

using namespace std;

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

int DP[100005];
bool ok[100005];
int h[100004];
int N;

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    cin >> N;
    
    for (int i = 1; i <= N; ++i) {
        cin >> h[i];
    }
    
    DP[1] = 0;
    DP[2] = abs(h[2]-h[1]);
    
    for (int i = 3; i <= N; ++i) {
        DP[i] = min(abs(h[i]-h[i-1]) + DP[i-1], abs(h[i]-h[i-2]) + DP[i-2]);
    }
    
    cout << DP[N] << endl;
    
	return 0;
}

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

namespace AizuOnlineJudge {
    class Program {
        static void Main() {
            var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var k = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var p = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var result = (h[0] * p[0] + h[1] * p[1] + (h[0] / 10) * p[2] + (h[1] / 20) * p[3]) -
                (k[0] * p[0] + k[1] * p[1] + (k[0] / 10) * p[2] + (k[1] / 20) * p[3]);

            Console.WriteLine(result == 0 ? "even" : result > 0 ? "hiroshi" : "kenjiro");
        }
    }
}



Measured memory_bytes: 18336
#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 order(int &N, vector<int> &data) {
    vector<int> num(N);
    rep(i,N) num.at(i) = i + 1;
    int premini = 1;
    int premax = 1;
    int maximum, minimum;
    rep(i,N) premax *= (i + 1);
    rep(i,N-1) {
        rep(j,N-i) {
            if (data.at(i) == num.at(j)) {
                minimum = premini + (premax - premini + 1) * j / (N - i);
                maximum = premini + (premax - premini + 1) * (j + 1) / (N - i) - 1;
                premini = minimum;
                premax = maximum;
                num.erase(num.begin() + j);
                break;
            }
        }
    }
    return minimum;
}


int main() {
    int N;
    cin >> N;
    vector<int> P(N), Q(N);
    rep(i,N) cin >> P.at(i);
    rep(i,N) cin >> Q.at(i);

    cout << abs(order(N, P) - order(N, Q)) << endl;
}


Measured memory_bytes: 3600
n, m = map(int, input().split(' '))

d = {0: 1}
asum = 0
for a in map(int, input().split(' ')):
    asum = (asum + a) % m
    if asum in d:
        d[asum] += 1
    else:
        d[asum] = 1


ans = 0
for v in d.values():
    ans += int(v * (v - 1) / 2)

print(ans)

Measured memory_bytes: 16100
n, m = map(int, input().split())
students = [list(map(int, input().split())) for i in range(n)]

targets = [list(map(int, input().split())) for i in range(m)]
x = 0
snumber = [(0, x)] * n
  
def md(s, t):
  d = abs(s[0] - t[0]) + abs(s[1] - t[1])
  return d

for i in range(n):
  x = 4 * 10 ** 8
  for j in range(m):    
    if x > md(students[i], targets[j]):
      x = md(students[i], targets[j])
      snumber[i] = (j+1, md(students[i], targets[j]))
      
for i in range(n):      
  print(snumber[i][0])

Measured memory_bytes: 9244
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template


signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cini(N);
    vector<int> dp(N+1,INF);
    dp[0] = 0;
    set<int> s;
    for(int i=0;;i++) {s.insert(pow(6,i)); if(pow(6,i)>10000) break;}
    for(int i=0;;i++) {s.insert(pow(9,i)); if(pow(9,i)>10000) break;}
    for(int i=1;i<=N;i++){
        for(auto j:s){
            if(i-j<0) continue; 
            dp[i] = min(dp[i],dp[i-j] + 1);
        }
    }
    cout << dp[N] << nn;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cmath>
#include <time.h>
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) ((c).rbegin(),(c).rend())
#define ll long long
#define fi first
#define se second
#define inf (999999999)
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int n, p;
int a[50];
ll dp[60][5100];
int main() {
	cin >> n >> p;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++)for (int j = 0; j < 5100; j++)dp[i][j] = 0;
	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= 5000; j++) {
			if (dp[i][j]) {
				dp[i + 1][j + a[i]] += dp[i][j];
				dp[i + 1][j] += dp[i][j];
			}
		}
	}
	ll ans = 0;
	for (int i = 0; i <= 5000; i++) {
		if (dp[n][i] && i % 2 == p)ans += dp[n][i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 2304
using System;

namespace Although_I_Always_Use_C_plus_plus
{
	class MainClass
	{
		public static void Main(string[] args)
		{
            int x = readInt(), i;
            for (i = 1; i * (i + 1) / 2 < x; i++) {}
            Console.Write(i);
		}

		private static int readInt()
		{
			char c;
			while ((c = (char)Console.Read()) > 0)
				if (c >= '0' && c <= '9' || c == '-') break;
			int res = 0, multi = (c == '-' ? -1 : 1);
			do
			{
				if (c == '-')
					continue;
				else if (c >= '0' && c <= '9')
					res = res * 10 + c - '0';
				else
					break;
			} while ((c = (char)Console.Read()) > 0);
			return res;
		}
	}
}


Measured memory_bytes: 13140
#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;

template <typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define mod1 998244353
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(12)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

int _x[] = {0, 0, -1, 1, -1, 1, -1, 1};
int _y[] = { -1, 1, 0, 0, 1, -1, -1, 1};

void solve() {
	int n, k;
	cin >> n >> k;
	vi v(n);
	int idx;
	rep(i, 0, n - 1) {
		cin >> v[i];
		if (v[i] == 1) {
			idx = i;
		}
	}
	if ((n - 1) % (k - 1) == 0) cout << (n - 1) / (k - 1);
	else cout << (n - 1) / (k - 1) + 1;
}

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


#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// test
	solve();

	return 0;
}


Measured memory_bytes: 3948
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
struct revran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { --i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr revran(const i64 e) noexcept: b(0), e(e) {}
  constexpr revran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(e - 1); }
  constexpr iter end() const noexcept { return iter(b - 1); }
};

struct ran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { ++i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr ran(const i64 e) noexcept: b(0), e(e) {}
  constexpr ran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(b); }
  constexpr iter end() const noexcept { return iter(e); }
  constexpr revran rev() const noexcept { return revran(b, e); }
};

constexpr ran rin(const i64 e) noexcept { return ran(1, e + 1); }
constexpr ran rin(const i64 b, const i64 e) noexcept { return ran(b, e + 1); }

int main() {
  i64 n, x;
  cin >> n >> x;
  i64 now = 0;
  i64 ans = 1;
  for(int i = 0;i < n;i++) {
    i64 l;
    cin >> l;
    now += l;
    if(now <= x) ans++;
  }
  cout << ans << endl;
}


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

#define endl '\n'

using namespace std;

struct custom_hash 
{
    static unsigned long long splitmix64(unsigned long long x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(unsigned long long x) const 
    {
        static const unsigned long long FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int maxn = 2e5 + 3; 
const long long inf = 1e18; 

int n;
int a[maxn];
void read()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
}

long long dp[maxn][2][2];
void solve()
{
	for (int i = 0; i < maxn; i++)
		for (int j = 0; j < 2; j++)
			for (int k = 0; k < 2; k++)
				dp[i][j][k] = -inf;

	dp[1][0][0] = a[1], dp[1][1][0] = a[2], dp[1][0][1] = 0; 
    for (int i = 2; i <= n / 2; i++)
    {
    	dp[i][0][0] = dp[i-1][0][0] + a[i*2-1];
    	dp[i][1][0] = max(dp[i-1][0][0], dp[i-1][1][0]) + a[i*2];
    	dp[i][1][1] = max(dp[i-1][0][1], dp[i-1][1][1]) + a[i*2];
    	dp[i][0][1] = max(dp[i-1][0][1] + a[i*2-1], max(dp[i-1][0][0], dp[i-1][1][0])); 
    }

    if (n % 2 == 0)
    	cout << max(dp[n/2][0][0], dp[n/2][1][0]) << endl; 

    else 
    	cout << max(dp[n/2][0][0], max(dp[n/2][1][0], a[n] + dp[n/2][0][1])) << endl; 
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	
	read();
	solve();
}

Measured memory_bytes: 10684
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <functional>
#include <cstdint>
#define REP(i, n) for(ll i = 0; i < n; i++)
using ll = long long;
using namespace std;

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string ans="APPROVED";
  int n;
  cin >> n;
  int a[n];
  REP(i,n) cin >> a[i];

  REP(i,n){
    if (a[i] % 2 == 0){
      if(a[i]%3!=0 && a[i]%5!=0)
        ans = "DENIED"; 
    }
  }
    
  cout << ans << endl;

}
  


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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while (A > 0 || C > 0) {
        C -= B;
        if (C <= 0) {
            cout << "Yes" << endl;
            return 0;
        }

        A -= D;
        if (A <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,k,s;
    cin>>n>>k>>s;
    for(int i=0;i<k;i++){
        cout << s<<" ";
    }
    ll num=1000000000;
    if(s==1000000000)num--;
    for(int i=0;i<n-k;i++){
        cout << num<<" ";
    }
    cout <<endl;
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
long double pi = 2 * acos(0.0);
const ll mod = 1e9 + 7;

void solve() {
    ll n;
    cin >> n;
    ll x = 1000;
    while(x < n) x += 1000;
    cout << x - n;
}       

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(nullptr);   
    ll t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    int n;cin>>n;
    vector<int> a(n),b(n);
    ll a_sum=0,b_sum=0;
    rep(i,n){
        cin>>a[i];
        a_sum+=a[i];
    }
    rep(i,n){
        cin>>b[i];
        b_sum+=b[i];
    }
    if(a_sum < b_sum){
        cout << -1 << endl;
        return 0;
    }
    vector<int> dif(n);
    int cnt = 0,negative_cnt=0;
    ll negative_amount = 0;
    rep(i,n){
        dif[i] = a[i]-b[i];
        if(dif[i]<0){
            negative_amount+=dif[i];
            negative_cnt++;
        }
    }
    sort(rall(dif));
    rep(i,n){
        if(negative_amount >= 0)break;
        negative_amount += dif[i];
        cnt++;
    }
    cout << negative_cnt+cnt << endl;
}



Measured memory_bytes: 1408
#!/usr/bin/env python3
n = int(input())
list_5 = []
a = 0
b = 0
for _ in range(-121,121):
    list_5.append(_**5)
for i in range(-121,121):
    if (n + list_5[i]) in list_5:
        b = i  
        a = list_5.index(n + list_5[i])       
print(a-121, b-121)




Measured memory_bytes: 9004
#include<bits/stdc++.h>
#define ll long long
#define reg register
#define mp make_pair
#define ri register int
using namespace std;
const int mxn=2e5+5;
int a[mxn],n;
int dp[2222][2222];
int base=1e8,mx=1e8,rmx[2222];
inline void cmax(int&a,int b){if(a<b)a=b;}
vector<tuple<int,int,int> >upd;
inline void Upd(int i,int j,int k){
	upd.emplace_back(i,j,k);
	swap(i,j);
	upd.emplace_back(i,j,k);
}
inline void solve(){
	cin>>n;
	for(int i=0;i<3*n;++i)cin>>a[i];
	dp[a[0]][a[1]]=rmx[a[0]]=rmx[a[1]]=base;
	for(int i=2;i<3*n;i+=3){
		if(a[i]==a[i+1] and a[i]==a[i+2]){
			--base;
			continue;
		}
		for(int _=0;_<3;++_){
			swap(a[i],a[i+1]),swap(a[i+1],a[i+2]);
			Upd(a[i],a[i+1],max(mx,dp[a[i+2]][a[i+2]]+1));
			for(int j=1;j<=n;++j){
				if(a[i+1]==a[i+2])Upd(j,a[i],dp[j][a[i+1]]+1);
				Upd(j,a[i],rmx[j]);
			}
		}
		for(int i=0;i<upd.size();++i){
			int e,f,g;
			tie(e,f,g)=upd[i];
			cmax(dp[e][f],g),cmax(rmx[e],g),cmax(mx,g);
		}
		upd.clear();
	}
	cout<<mx-base<<'\n';
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int T=1;//cin>>T;
	for(;T--;)solve();
}


Measured memory_bytes: 21152
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
        String s=sc.next();
        
        if(s.equals("AAA")){
            System.out.println("No");
        }
        else if(s.equals("BBB")){
            System.out.println("No");
        }
        else{
            System.out.println("Yes");
        }
        sc.close();
    }
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;
  if (s == u)
    a--;
  else
    b--;
  cout << a << ' ' << b << '\n';
  return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
int a, b, c;
cin >> a >> b >> c;
if(a == b) {
  cout << c;
}
  else if(a == c){
    cout << b;
  }
  else if(b == c){
    cout << a;
  }
}

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

using namespace std;

int main(){
	string s;
	cin >> s;
	int ans = 0;
	for(int i = 1; i < s.size(); i++){
		if(s[i] != s[i - 1]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <stdio.h>
using namespace std;

int s, s1;

int main() {

	cin >> s;

	if (s / 1300 == 0 && s / 100 != 0) {
		s1 = s % 100;
		if (s1 / 13 == 0 && s1 != 0) {
			cout << "AMBIGUOUS" << endl;
		}
		else {
			cout << "MMYY" << endl;
		}
	}
	else {
		s1 = s % 100;
		if (s1 / 13 == 0 && s1 != 0) {
			cout << "YYMM" << endl;
		}
		else {
			cout << "NA" << endl;
		}
	}

	return 0;
}

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

namespace test
{
    class BiteEating
    {
        public static void Main()
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int L = int.Parse(input[1]);
            int S = 0;
            int min = 1000000;
            int memo = 0;
            int bitApple = 0;

            //総和を求めつつ最小を見つける
            for(int i = 1; i<=N; i++)
            {
                int temp = L + i - 1;
                S += temp;

                if(min > Math.Abs(temp))
                {
                    min = Math.Abs(temp);
                    memo = i;
                }
            }

            bitApple = L + memo - 1;
            Console.WriteLine(S - bitApple);
        }
    }
}


Measured memory_bytes: 13140