akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

const int MAXN = 1e9;
int table[20][20];
ll ans = 0LL;
int n;
int dp[20][(1<<16)];

void func(){
  int lim = (1<<n);
  
  REP(i, n) REP(j, n+1) cin >> table[i][j];
  //nステージクリアなので、nまで更新するのに気をつける
  REP(j, n+1) REP(i, lim) dp[j][i] = MAXN;
  
  bool used[n];
  REP(i, n) dp[1][(1<<i)] = table[i][0];
    
  FOR(i, 2, n+1){
    REP(bit, lim){
      //i-1番目がMAXNじゃないとき じゃないとTLE
      if(dp[i-1][bit] != MAXN){
	REP(j, n){
	  if(bit & (1<<j)) used[j] = true;
	  else used[j] = false;
	}
	REP(j, n){
	  if(!used[j]){
	    //bit立てる
	    int tmp = bit | (1<<j);
	    REP(k, n){
	      //k番目のbitが立っているとき、j番目のbitを立てた場合 vs j番目のbitをたてずに既に立っているk番目のbitを使ったときの最小値　比較
	      if(used[k]) dp[i][tmp] = min(dp[i][tmp], dp[i-1][bit] + min(table[j][0], table[j][k+1]));
	      else dp[i][tmp] = min(dp[i][tmp], dp[i-1][bit]+table[j][0]);
	    }
	  }
	}
      }
    }
  }
  //bit: 1,1,...,1 のときのn全部クリア
  cout << dp[n][lim-1] << endl;
}

int
main(void){  
  ios_base::sync_with_stdio(false);

  while(true){
    cin >> n;
    if(n == 0)break;
    func();
  }
    
  return 0;
}



Measured memory_bytes: 7484
#include"bits/stdc++.h"
#include<atcoder/dsu.hpp>
using namespace std;
using namespace atcoder;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tp3 = tuple<int, int, int>;
using Mat = vector<vector<ll>>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
// ============ template finished ============

int main()
{
    int N, Q;
    cin >> N >> Q;
    dsu uf(N);
    rep(_, Q) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0) {
            uf.merge(u, v);
        }
        else {
            cout << (uf.same(u, v) ? 1 : 0) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3836
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cstdlib>

using namespace std;

int n, ch['z' + 1], tmp['z' + 1];
char s[60];

int main(){
	scanf("%d", &n);
	memset(ch, 0x3f, sizeof(ch));
	while(n --){
		scanf("%s", s);
		memset(tmp, 0, sizeof(tmp));
		for(int i = strlen(s) - 1 ; i >= 0 ; i --){
			tmp[s[i]] ++;
		}
		for(int i = 'a' ; i <= 'z' ; i ++){
			ch[i] = min(ch[i], tmp[i]);
		}
	}
	for(int i = 'a' ; i <= 'z' ; i ++){
		for(int j = 0 ; j < ch[i] ; j ++){
			putchar(i);
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios        	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int main()
{
	ios
	int n;
	cin>>n;
	int a[100005];
	for(int i=1;i<=n;i++)
	cin>>a[i];
	
	int b[100005]={0};
	
	for(int i=1;i<=n;i++)
	{
		b[a[i]]++;
		b[a[i]+1]++;
		b[a[i]-1]++;
	}
	int ans=0;
	for(int i=0;i<=100001;i++)
	{
		ans=max(ans,b[i]);
	}
	cout<<ans;
}


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

const int MAX = 110000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<ll> nums(N);
    for (int i = 0; i < N; i++)
    {
        ll A;
        cin >> A;
        nums.at(i) = A;
    }
    COMinit();
    sort(nums.begin(), nums.end());
    if(nums.at(0) < 0){
        ll firstNum = nums.at(0);
        for(int i = 0; i < N; i++){
            nums.at(i) += firstNum;
        }
    }
    ll answer = 0;
    for (int i = K - 1; i < N; i++)
    {
        answer = (answer + COM(i, K - 1) * nums.at(i)) % MOD;
    }
    for (int i = 0; i < N - K + 1; i++)
    {
        answer = answer - ((COM(N - i - 1, K - 1) * nums.at(i)) % MOD);
        if(answer < 0){
            answer = answer + MOD;
        }
        answer = answer % MOD;
    }
    cout << answer << endl;
    return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	int a, b;
	cin >> a >> b;

	int min_08 = ceil(12.5 * a);
	int max_08 = min_08 + 12;
	int min_10 = 10 * b;
	int max_10 = min_10 + 9;

	if (min_08 < max_10 && min_10 < max_08)
	{
		cout << max(min_08, min_10);
	}
	else
	{
		cout << -1;
	}

}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=201000;
int h,w,n,sr,sc;
char s[N],t[N];
int main() {
	scanf("%d%d%d",&h,&w,&n);
	scanf("%d%d",&sr,&sc);
	scanf("%s",s);
	scanf("%s",t);
	// 'L'
	auto FAIL=[&]() {
		puts("NO");
		exit(0);
	};
	int pos=sc;
	rep(i,0,n) {
		if (s[i]=='L') pos--;
		if (pos==0) FAIL();
		if (t[i]=='R') pos=min(pos+1,w);
	}
	pos=sc;
	rep(i,0,n) {
		if (s[i]=='R') pos++;
		if (pos==w+1) FAIL();
		if (t[i]=='L') pos=max(pos-1,1);
	}
	pos=sr;
	rep(i,0,n) {
		if (s[i]=='U') pos--;
		if (pos==0) FAIL();
		if (t[i]=='D') pos=min(pos+1,h);
	}
	pos=sr;
	rep(i,0,n) {
		if (s[i]=='D') pos++;
		if (pos==h+1) FAIL();
		if (t[i]=='U') pos=max(pos-1,1);
	}
	puts("YES");
}

Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
#mod = 10 ** 9 + 7 
mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
xy = [LIST() for _ in range(N)]

if N == 1:
	print(1)
	exit()

xy.sort(key = lambda x: (x[0], x[1]))
diff = []

for s, t in combinations(xy, 2):
	st = str(t[0]-s[0]) + " " +str(t[1]-s[1])
	diff.append(st)

print(max(N - Counter(diff).most_common()[0][1], 1))



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

int main() {
  int a;
  cin >> a;
  if(a == 3 || a == 5){
    cout << "YES";
  }
  else if(a == 7){
    cout << "YES";
  }
  else{
    cout << "NO";
  }
 
  return 0;
}

Measured memory_bytes: 256
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
import math
from operator import itemgetter
input = sys.stdin.readline

list_time = [int(input()) for i in range(5)]
list_CeilMati = [[0, 0] for i in range(5)]

temp = 0.0
for i in range(5):
    temp = list_time[i]/10
    list_CeilMati[i][0] = math.ceil(temp) * 10
    list_CeilMati[i][1] = list_CeilMati[i][0] - list_time[i]

# print(list_CeilMati)
list_CeilMati.sort(key=lambda x: x[1])
# print(list_CeilMati)

ans = 0
for i in range(5):
    ans += list_CeilMati[i][0]
ans -= list_CeilMati[5-1][1]

print(ans)


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

int main(){
    int N;
    cin >> N;
    char S;
    bool isfour = false;
    for(int i = 0; i < N; i++){
        cin >> S;
        if(S == 'Y'){
            isfour = true;
        }
    }
    if(isfour){
        cout << "Four" << endl;
    }
    else{
        cout << "Three" << endl;
    }
}

Measured memory_bytes: 256
N = gets.to_i
b = gets.split.map(&:to_i)
ans = []

N.times do |i|
  max = N
  t = N-1-i
  (N-i).times do |j|
    c = j+1 - b[j]
    if c < 0
      p -1
      exit
    elsif max >= c
      max = c
      t = j
    end
  end
  #p diff
  ans << b[t]
  b.delete_at(t)
end

ans.reverse.each do |v|
  p v
end


Measured memory_bytes: 1788
N,Q = map(int,input().split())
A = [list(map(int,input().split())) for i in range(N-1)]
B = [list(map(int,input().split())) for i in range(Q)]

G = {}
for i in range(1,N+1):
    G[i] = []

for i in range(N-1):
    G[A[i][0]].append(A[i][1])
    G[A[i][1]].append(A[i][0])

from collections import deque

H = {}
for i in range(1,N+1):
    H[i] = 0

for i in range(Q):
    H[B[i][0]] += B[i][1]

#bfs

r = 0
P = [0]*(N+1)  #ポイント

D = [0]+[-1]*(N)
D[1] = 1
P[1] = H[1]
q = deque([1])

while q:
    n = q.pop()
    for d in G[n]:
        if D[d] != -1:
            continue
        else:
            D[d] = 1
            q.appendleft(d)
            P[d] = P[n] + H[d]
del P[0]

print(*P)

Measured memory_bytes: 152468
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int INF=1e3+125;
const int dfx[]={0,0,1,-1},dfy[]={1,-1,0,0};
const int bfx[]={-2,-2,-2,-2,-2,-1,-1,-1,-1,0,0,1,1,1,1,2,2,2,2,2};
const int bfy[]={-2,-1,0,1,2,-2,-1,1,2,-2,2,-2,-1,1,2,-2,-1,0,1,2};
int h,w,cx,cy,dx,dy,qx[INF*INF*30+25],qy[INF*INF*30+25],l,r,dis_[INF][INF];
bool vis[INF][INF];
char Map[INF][INF];
void DFS(int x,int y) {
        for (int i=0; i<4; i++) {
                int gx=x+dfx[i],gy=y+dfy[i];
                if (gx<1 || gy<1 || gx>h || gy>w|| Map[gx][gy]!='.' || dis_[gx][gy]<=dis_[x][y]) continue;
                vis[gx][gy]=true;
                dis_[gx][gy]=dis_[x][y];
                qx[++r]=gx;
                qy[r]=gy;
                DFS(gx,gy);
        }
        return;
}
void BFS() {
        memset(dis_,63,sizeof dis_);
        vis[cx][cy]=true;
        dis_[cx][cy]=0;
        DFS(cx,cy);
        // bool flag=false;
        while (l<=r) {
                int x=qx[l],y=qy[l]; l++;
                // if (vis[dx][dy]) flag=true;
                // if (flag) break;
                for (int i=0; i<20; i++) {
                        int gx=x+bfx[i],gy=y+bfy[i];
                        if (gx<1 || gy<1 || gx>h || gy>w|| Map[gx][gy]!='.' || dis_[gx][gy]<dis_[x][y]+1 || vis[gx][gy]) continue;
                        dis_[gx][gy]=dis_[x][y]+1;
                        vis[gx][gy]=true;
                        DFS(gx,gy);
                        // if (vis[dx][dy]) flag=true;
                        // if (flag) break;
                        qx[++r]=gx;
                        qy[r]=gy;
                }
                // if (flag) break;

               
        }
        return;
}
signed main()
{
   
        scanf("%d %d",&h,&w); scanf("%d %d %d %d ",&cx,&cy,&dx,&dy);
        for (int i=1; i<=h; i++) {
                for (int j=1; j<=w; j++)
                        cin>>Map[i][j];
        }
        // cout<<"ok\n";
        l=1;
        qx[++r]=cx;
        qy[r]=cy;
        BFS();
        if (vis[dx][dy]) cout<<dis_[dx][dy]<<"\n";
        else cout<<"-1\n";
        return 0;
}


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


int main(){
    ll sum = 0;
    int n, m;
    cin >> n >> m;
    ll tenbou[n+5];

    for(int i=1;i<=n;i++){
        cin >> tenbou[i];
    }
    bool yoi[n + 1] = {};
    int a,b;

    rep(i,m){
        cin >> a >> b;
        if(tenbou[a]<tenbou[b]){
            yoi[a] = true;
        }
        else if (tenbou[a] == tenbou[b]){
            yoi[a] = true;
            yoi[b] = true;
        }
        else{
            yoi[b] = true;
        }
    }

    for(int i=1;i<=n;i++){
        if(!yoi[i]){
            sum++;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4512
n = int(input())
a = [int(x) for x in input().split()]
c = 0
for x in range(n):
    m = x
    for i in range(x, n):
        if a[i] < a[m]:
            m = i
    if x != m:
        a[x], a[m] = a[m], a[x]
        c += 1
print(*a)
print(c)

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

using namespace std;


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

    cin>>s;

    if(islower(s)) {
        cout<<"a"<<endl;
    }
    else {
        cout<<"A"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
    mint p(int n, int k) {
        return fact[n]*ifact[n-k];
    }
};


int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    rep(i, n) cin >> a[i];
    sort(whole(a));
    rep(i, n) {
        b[i] = abs(i - (n-1-i));
    }
    sort(whole(b));
    rep(i, n) {
        if (a[i]!=b[i]) {
            cout << 0 << endl;
            return 0;
        }
    }
    mint ans = 1;
    map<int, int> mp;
    rep(i, n) mp[a[i]]++;
    for (auto m: mp) {
        ans *= m.second;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6324
#include <algorithm>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
class edge {
   public:
    int t;
    int id;
    edge(int to, int i) : t(to), id(i) {}
    edge() {}
};
int n = 0, m = 0;
vector<vector<edge>> g;
vector<int> pre;
vector<int> ll;
vector<bool> res;
int tt = 0;
void input() {
    cin >> n >> m;

    int id = 1, M = m;
    g = vector<vector<edge>>(n, vector<edge>());
    pre = vector<int>(n, -1);
    ll = vector<int>(n, -1);
    res = vector<bool>(n, false);
    while (M--) {
        int a = 0, b = 0;
        cin >> a >> b;
        g[a].push_back({b, ++id});
        g[b].push_back({a, id});
    }
}
int dfs(int i, int p, int id) {
    if (pre[i] != -1) {
        ll[p] = min(ll[p], pre[i]);
        return ll[p];
    }
    bool hasf = false;
    pre[i] = ++tt;
    ll[i] = pre[i];
    for (auto v : g[i]) {
        if (v.id == id) {
            continue;
        }
        if (dfs(v.t, i, v.id) < 0) {
            ll[i] = min(ll[i], ll[v.t]);
            if (i != p ? ll[v.t] >= pre[i] : hasf) res[i] = true;
            hasf = true;
        }
    }
    return -1;
}
void compute() {
    for (int i = 0; i < n; i++) {
        if (pre[i] == -1) {
            dfs(i, i, m + 2);
        }
    }

        for (int i = 0; i < res.size(); i++) {
        if (res[i]) cout << i << endl;
    }
}

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


Measured memory_bytes: 5416
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  cin>>s;
  if((s[0]==s[1]&&s[1]==s[2])||(s[1]==s[2]&&s[2]==s[3])) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int ways(int n, int x)
{
    int s = 0;
    for(int i = 1; i <= n; i++)
        for(int j = i+1; j <=n; j++)
            for(int k = j+1; k <=n; k++)
                if((i + j + k) == x)
                    s++;
    return s;
}

int main()
{
    int n, x;

    while(true)
    {
        cin >> n >> x;
        if(n == 0 && x == 0)
            break;
        cout << ways(n, x) << endl;
    }
    return 0;
}

Measured memory_bytes: 3120
#include<stdio.h>
#include<iostream>
#include<string>
#include<cstring>

using namespace std;

int main()
{
	char n[100000];
	char b;
	char c;

	int i=0;
	cin>>n;


	c=n[0];
	int d=0;
	for(i=1;;i++)
	{
		if(n[i]==0)
			break;
		b=n[i];

		if(c==b)
		{
			if(b=='1')
			{
				c='0';
			}
			else
			{
				c='1';
			}
			d++;
		}
		else
		{
			c=b;
		}
	}
	cout<<d;
return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    for (ll i = 0; i < n; ++i) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b.begin(), b.end());
    ll count = 0;
    for (ll i = 0; i < n; ++i) {
        if (a[i] != b[i]) ++count;
    }
    if (count <= 2) {
        cout << "YES" <<endl;
    } else {
        cout << "NO" <<endl;
    }
}


Measured memory_bytes: 256
"use strict";
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.split(/ |\n/),
    cid = 0;

function next() {
    return +cin[cid++];
} // number一個取得
function nextstr() {
    return cin[cid++];
} // 文字列一個取得
function nextbig() {
    return BigInt(cin[cid++]);
} // BigInteger一個取得
// 長さnの配列として取得。aは文字列フラグ
function nexts(n, a) {
    return a ? cin.slice(cid, cid += n) : cin.slice(cid, cid += n).map(a => +a);
}
// 長さnのBigInt配列として取得。
function nextsbig(n) {
    return cin.slice(cid, cid += n).map(a => BigInt(a));
}
// w個ずつを組にして長さhの配列。aは文字列フラグ。
function nextm(h, w, a) {
    var r = [],
        i = 0;
    if (a)
        for (; i < h; i++) r.push(cin.slice(cid, cid += w));
    else
        for (; i < h; i++) r.push(cin.slice(cid, cid += w).map(a => +a));
    return r;
}
// 多次元配列。v,a1,a2,a3 なら、3次元。[[値vで長さa3の配列]をa2個並べた配列]をa1個並べた配列。
function xArray(v) {
    var a = arguments,
        l = a.length,
        r = "Array(a[" + --l + "]).fill().map(x=>{return " + v + ";})";
    while (--l) r = "Array(a[" + l + "]).fill().map(x=>" + r + ")";
    return eval(r);
}


console.log(main().toString());

function main() {
    let a = next();
    let b = next();
    return Math.ceil((a+b)/2)
}

Measured memory_bytes: 7496
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(void) {
	int n, sum = 0,min=10000;
	int tsum = 0;
	int a[110];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	for (int i = 0; i < n; i++) {
		tsum += a[i];
		if (abs(sum-tsum - tsum) < min)min = abs(sum-tsum - tsum);
	}
	cout << min << endl;
	return 0;
}

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

int main(){
    long long N, D;
    cin >> N >> D;
    int count = 0;

    for(int i = 0; i < N ; i++){
        long long X, Y;
        cin >> X >> Y;
        
        if(0 <= X*X + Y*Y && X*X + Y*Y <= D*D){
            count++;
        }else {

        }
    }

    cout << count << endl;

}

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

int main() {
	int N,r=0,a;
	cin >> N;

	rep(i,N) {
		cin >> a;
		r += a-1;
	}

	cout << r << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sync ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD  1000000007 
int powm(int base,int exp,int mod=MOD) {int ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
int32_t main()
{
	int n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	//int n=s.length();
	string ans="";
	for(int i=0;i<n;i++)
	{
		ans+=s[i];
		ans+=t[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    int n,sum=0;
    cin>>n;
    vec a(n);
    rep(i,n) cin>>a[i];
    sort(all(a));
    rep(i,n-1) sum+=a[i];
    sum+=a[n-1]/2;
    cout<<sum;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
list1 = []
list2 = []
for i in range(m):
  l, r = map(int, input().split())
  list1.append(l)
  list2.append(r)
if min(list2)<max(list1):
  print(0)
else:
  print(min(list2)-max(list1)+1)

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

int main()
{
  int n; cin >> n;
  string s; cin >> s;
  int c1=0, c2=0;
  int r=count(s.begin(),s.end(),'R');
  for(int i=0; i<r; ++i){
    if(s[i]=='W') ++c1;
  }
  cout << c1 << endl;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
 
using namespace std;
 
const ll MOD = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

ll dp[55][55][2505]; 
//dp[i][j][k] := 左からi枚まで見た時に
// j枚選んで
// 合計がkとなる総数

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N,A;
    cin >> N >> A;
    vector<int> x(N);
    rep(i,N)cin >> x[i];
    dp[0][0][0] = 1;
    for(int i=0;i<N;i++){
        for(int j=0;j<50;j++){
            for(int k=0;k<2505;k++){
                // i番目を選んだ場合
                if(x[i]+k<2505){
                    dp[i+1][j+1][k+x[i]] += dp[i][j][k];
                }
                // i番目を選ばない場合
                    dp[i+1][j][k] += dp[i][j][k];
            }
        }
    }
    ll ans = 0;
    for(int j=1;j<=N;j++){
        ans += dp[N][j][j*A];
    }
    cout << ans << endl;
}

Measured memory_bytes: 54528
#pragma region Macros

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int N, Q;
    cin >> N;
    vi A(N);
    REP(i, N) {
        cin >> A[i];
    }
    cin >> Q;
    vvi inQ(Q, vi(2));

    REP(i, Q) {
        cin >> inQ[i][0] >> inQ[i][1];
    }
    vi arrayInt(100001, 0);
    //iota(ALL(arrayInt), 0);
    int sum = 0;
    REP(i, N) {
        sum += A[i];
        arrayInt[A[i]]++;
    }

    REP(i, Q) {
        int count = arrayInt[inQ[i][0]];
        arrayInt[inQ[i][1]] += arrayInt[inQ[i][0]];
        arrayInt[inQ[i][0]] = 0;

        sum += count * (inQ[i][1] - inQ[i][0]);
        cout << sum << "\n";
    }
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 10220
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int h, w;
string s[110];
int dp[110][110];

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

int main() {
    cin >> h >> w;
    rep(i, h) cin >> s[i];

    rep(y, h) rep(x, w) dp[y][x] = INF;
    if (s[0][0] == '#') dp[0][0] = 1;
    else dp[0][0] = 0;
    rep(y, h) rep(x, w) {
        rep(k, 2) {
            int ny = y + dy[k];
            int nx = x + dx[k];
            if (nx >= w || ny >= h) continue;
            if (s[y][x] == '.' && s[ny][nx] == '#') {
                dp[ny][nx] = min(dp[ny][nx], dp[y][x] + 1);
            } else {
                dp[ny][nx] = min(dp[ny][nx], dp[y][x]);
            }
        }
    }
    cout << dp[h-1][w-1] << endl;
}


Measured memory_bytes: 256
import java.util.*;
class Main
{
  public static void main(String args[])
  {
    int n,x,t,k;
    Scanner sc= new Scanner(System.in);
    n=sc.nextInt();
    x=sc.nextInt();
    t=sc.nextInt();
    k=n/x;
    if(n%x>0)
      k+=1;
    System.out.println(k*t);
  }
}

Measured memory_bytes: 35768
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int d, t, s;
  cin >> d >> t >> s;
  cout << (d <= t * s ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        double max=0;
        double diff=0;
        while(sc.hasNext()) {
            double mt=sc.nextDouble();
            max=Math.max(max, mt);
            diff=Math.max(diff,max-mt);
        }
        System.out.printf("%.1f",diff);
    }
}


Measured memory_bytes: 27708
N = int(input())
c0,c1,c2,c3 = 0,0,0,0
for _ in range(N):
    s = input()
    if s == "AC":
        c0 += 1
    elif s == "WA":
        c1 += 1
    elif s == "TLE":
        c2 += 1
    else:
        c3 += 1
print("AC x " + str(c0))
print("WA x " + str(c1))
print("TLE x " + str(c2))
print("RE x " + str(c3))


Measured memory_bytes: 9200
M, D = map(int, input().split())
ans = 0
for i in range(4, M + 1):
    for j in range(22, D + 1):
        d1, d2 = j % 10, j // 10
        if d1 >= 2 and d2 >= 2 and d1 * d2 == i:
            ans += 1

print(ans)

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    ll a, b, k;
    cin >> a >> b >> k;
    ll c = min(a, k);
    k -= c;
    cout << a - c << ' ' << max(b - k, 0LL) << endl;;
}

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

using namespace std;

int main(){
    string S;
    cin >> S;
    if(S[5] == '1') cout << "TBD" << endl;
    else if(S[6] <= '4') cout << "Heisei" << endl;
    else cout << "TBD" << endl;
}

Measured memory_bytes: 888
a, b = map(int, input().split())
num_list = [2,3,4,5,6,7,8,9,10,11,12,13,1]
a_st = num_list.index(a) 
b_st = num_list.index(b)
if a_st > b_st:
    print("Alice")
elif a_st < b_st:
    print("Bob")
else:
    print("Draw")

Measured memory_bytes: 3060
import java.util.*;
import java.util.stream.*;
class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n;
        n = input.nextInt();
        for (int i = 1; i < (n+1); i++){
            String tmp = String.valueOf(i);
            if ((i%3 == 0) || (tmp.contains("3"))){
                System.out.printf(" %d",i);
            }
        }
        System.out.printf("\n");
    }
}


Measured memory_bytes: 37156
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#include<math.h>

#define MNM 100009
#define R 1000000007

int N, M;

long F[MNM];

long fact(long n){
  if( n <= 1 ){ return 1; }
  return (F[n] = (fact(n-1) * n) % R);
}

int main(){
  std::cin >> N >> M;
  if( abs(N-M) > 1 ){
	std::cout << 0 << std::endl;
	return 0;
  }
  F[0] = 1;
  F[1] = 1;
  fact(N>=M ? N : M);
  int ret = (F[N] * F[M]) % R;
  if( (N+M) % 2 == 0 ){ ret = (ret * 2) % R; }
  std::cout << ret << std::endl;
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define pii pair<int,int>
#define prec(n) fixed<<setprecision(n)
#define MOD 1000000007
#define eps 1e-8
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

bool f(int n){
    for(int i=1;i*i<=n;i++){
        if(i*i==n){
            return 1;
        }
    }
    return 0;
}

signed main(){
    FASTER;
    int n,m;cin>>n>>m;
    vector<vi> v(n,vi(m));cin>>v;
    int cnt=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int ans=0;
            for(int k=0;k<m;k++){
                ans+=(v[i][k]-v[j][k])*(v[i][k]-v[j][k]);
            }
            cnt+=f(ans);
        }
    }
    cout<<cnt;

}


Measured memory_bytes: 256
l,r=map(int,input().split())
mn=2018
if r-l<2019:
  for i in range(l%2019,r%2019+1):
    for j in range(l%2019,r%2019+1):
      if i<j:
        mn=min(mn,(i*j)%2019)
  print(mn)
else:
  print(0)

Measured memory_bytes: 3060
import math
from collections import deque
from collections import defaultdict


#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))


n = readInt()
a = readInts()

ans = 1

d = defaultdict(int)

if 0 in a:
	print(0)
	exit()

for i in a:
	d[i]+=1

for k in d:
	ans*=k**d[k]
	if ans>10**18:
		print(-1)
		exit()

else:
	print(ans)

Measured memory_bytes: 22528
from collections import deque

dq=deque()
n=int(input())

for i in range(n):
	com=input().split()
	if com[0]=='insert':
		dq.appendleft(com[1])
	elif com[0]=='deleteFirst':
		dq.popleft()
	elif com[0]=='deleteLast':
		dq.pop()
	else:
		if com[1] in dq:
			dq.remove(com[1])
print(' '.join(dq))

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

namespace ABC043A
{
    class Program
    {
        static void Main(string[] args)
        {
            int N;
            int a = 0;
            N = int.Parse(Console.ReadLine());
            for (int i = 1; i <= N; i++) 
            {
                 a += i;
            }
            Console.WriteLine(a);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
use std::io::Read;

fn main() {
    let mut buf = String::new();
    let mut stdin = std::io::stdin();
    stdin.read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let n: usize = iter.next().unwrap().parse().unwrap();

    if n%2 == 0 {
        let a = n/2;
        let mut ans: usize = 0;
        let mut d: usize = 5;
        loop {
            ans += a/d;
            if d > n { break; }
            d *= 5;
        }
        println!("{}", ans);
    } else {
        println!("0");
    }
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(S, s) S.find(s) != string::npos

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> graph(N + 1);
    Rep(i, M) {
        int a, b;
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    vector<bool> seen(N + 1);
    queue<int> Q;
    vector<int> ans(N - 1);
    seen[1] = true;
    Q.push(1);
    while (!Q.empty()) {
        int v = Q.front();
        Q.pop();
        Rep(i, graph[v].size()) {
            int p = graph[v][i];
            if (!seen[p]) {
                seen[p] = true;
                ans[p - 2] = v;
                Q.push(p);
            }
        }
    }
    Rep(i, ans.size()) {
        if (ans[i] == 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    Rep(i, ans.size()) {
        cout << ans[i] << endl;
    }
    return 0;
}

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

int main() {
  int N ;
  int A ; 
  
  cin >> N ; 
  
  for (int i = 0 ; i < N ; i++){
    cin >> A ; 
    if(A % 2 == 0 ){
      
      if(A % 3 != 0 && A % 5 != 0){
        cout << "DENIED" << endl ;  
        return 0 ; 
      }
      
    }
  }
  
  cout << "APPROVED" << endl ; 
  
  
  
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
#define pi 3.14159265358979323846264338
#define pb push_back
#define mp make_pair
#define INF 1e9
using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;

ll divisor=1000000007;

int main(){
	int d;
	cin>>d;
	int c[26];
	rep(i,26)cin>>c[i];
	int s[d][26];
	rep(i,d)rep(j,26)cin>>s[i][j];
	int t[d];
	rep(i,d){
      cin>>t[i];
      t[i]--;
    }
	int last[26]={};
	ll ans=0;
	for(int i=1;i<=d;i++){
		ans+=s[i-1][t[i-1]];
		last[t[i-1]]=i;
		rep(j,26)ans-=c[j]*(i-last[j]);
      	puts(ans);
	}
	
}


Measured memory_bytes: 3672
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
def S_():
    return input()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
YN=['Yes','No']
inf=float('inf')
input=lambda: sys.stdin.readline().rstrip()

ans=1

a=[]
n,l=LI()
for i in ' '*n:
    a.append(input())

print(''.join(sorted(a)))


Measured memory_bytes: 38512
/*
 * Author : Sadi
 * Mon 20/07/2020
 * 20:48:42.37
 */
#include <bits/stdc++.h>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    double l;
    cin >> l;
    double a, b, c;
    a = l / 3;
    b = (l - a) / 2;
    c = l - a - b;
    cout << fixed << setprecision(12) << a * b * c << "\n";
    return 0;
}


Measured memory_bytes: 3752
#!/usr/bin/env python3
import sys


def solve(X: int, t: int):
    if X - t <= 0:
        print(0)
        return

    print(X - t)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    t = int(next(tokens))  # type: int
    solve(X, t)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;


const int maxn = 205;
vector<int>g[maxn],vis(maxn),clr(maxn),dis(maxn),inq(maxn);
int n,bipartite=1;
void dfs(int u,int c){
	vis[u]=1;
	clr[u]=c;
	for(auto v:g[u]){
		if( !vis[v]){
			dfs(v,c^1);
		}
		else if( clr[v] == c ){
			bipartite = 0;
		}
	}
}
void spfa(int s){
	fill(dis.begin(),dis.end(),1e15);
	fill(inq.begin(),inq.end(),0);
	queue<int>q;
	dis[s]=0;
	q.push(s);
	inq[s]=1;
	while( q.size() ){
		int u = q.front();q.pop();inq[u]=0;
		for(auto v:g[u]){
			if( dis[v] > dis[u] + 1){
				dis[v] = dis[u] + 1;
				if( !inq[v] ){
					q.push(v);
					inq[v]=1;
				}
			}
		}
	}
}
	
int32_t main(){
	IOS
	cin>>n;
	for(int i=1;i<=n;i++){
		string s;cin>>s;
		for(int j=1;j<=n;j++){
			if( s[j-1] =='1'){
				g[i].push_back(j);
			}
		}
	}
	for(int i=1;i<=n;i++){
		if( !vis[i] ){
			dfs(i,0);
		}
	}
	if( !bipartite ){
		cout << -1 ; return 0;
	}
	int mx = 0;
	for(int i=1;i<=n;i++){
		spfa(i);
		for(int j=1;j<=n;j++){
			mx = max( mx , dis[j] );
		}
	}
	cout << mx + 1;
	
	
}
/*
 * long long or int?
 * index out of bound? 
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


Measured memory_bytes: 4092
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;

#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pi acos(-1.0)

#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pf(a) printf("%lld\n",a)

#define stll(a) stoll(a,nullptr,10)
#define all(a) a.begin(),a.end()
#define PII pair<ll,ll>
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define EL printf("\n")
#define ff first
#define ss second
#define rev(a) reverse(all(a))


#define mem(ar,val) memset(ar,val,sizeof(ar))
#define ssort(ar) sort(ar.begin(),ar.end())
#define csort(ar,comp) sort(ar.begin(),ar.end(),comp)

#define bug1(a) cout<<"test "<<a<<endl;
#define bug2(a,b) cout<<"test "<<a<<" "<<b<<endl;
#define bug3(a,b,c) cout<<"test "<<a<<" "<<b<<" "<<c<<endl;
#define bug4(a,b,c,d) cout<<"test "<<a<<" "<<b<<" "<<c<<" "<<d<<endl;

#define fout freopen("output.txt","w",stdout)
#define fin  freopen("input.txt","r",stdin)

/// unordered_map<int,int>mp;
/// mp.reserve(1024);
/// mp.max_load_factor(0.25);

/// pbds
/// *find_by_order(k) - return k th largest element.. 0 based
/// order_of_key(k) - number of items strictly smaller than k

/*
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
*/

typedef long long ll;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

ll stat[10000000];
void sieve()
{
    ll n=10000000;

    for(int i=1; i<=n; i++)
        for(int j=i; j<=n; j+=i)
            stat[j]++;
}

int main()
{
    sieve();
    ll n ;
    cin>>n;
    ll ans =0;
    for(int i=1; i<=n; i++)
    {
        //cout<<i<<" ";
        //bug1(stat[i]);
        ans+=1LL*i*stat[i];
    }
    cout<<ans<<endl;


}














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

void ans(bool i)
{
    if (i)
    {
        cout << "Heisei" << endl;
    }
    else
    {
        cout << "TBD" << endl;
    }
}
int main()
{
    string s;
    cin >> s;

    int y = stoi(s.substr(0, 4));
    int m = stoi(s.substr(5, 2));
    int d = stod(s.substr(8, 2));

    if (y <= 2019 && m <= 4 && d <= 30)
    {
        ans(true);
    }
    else
    {
        ans(false);
    }
}


Measured memory_bytes: 256