akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
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 int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

// 042d
const int MAX = 200500;

// fac: 階乗, finv: 階乗の逆元, inv: 逆元
ll 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;
    }
}

ll com(int n, int k){
    if (n<k) return 0;
    if (n<0 or k<0) return 0;
    return fac[n] * (finv[k]*finv[n-k]%mod)%mod;
}

int main(){
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    cominit();

    int ans = 0;
    rep(i, h-a){
        int tmp;
        tmp = com(b+i-1, i)*com(w-b+h-i-2, h-i-1)%mod;
        ans += tmp;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;
ll max_e = 1;

vector<pair<ll, ll>> prime_factorize(ll N) {
  vector<pair<ll, ll>> res;
  for (ll a = 2; a * a <= N; ++a) {
    if (N % a != 0) continue;
    long long ex = 0;  // 指数
    // 割れる限り割り続ける
    while (N % a == 0) {
      ++ex;
      N /= a;
    }
    res.push_back({a, ex});
    max_e = max(ex, max_e);
  }
  // 最後に残った数について
  if (N != 1) res.push_back({N, 1});
  return res;
}

int main() {
  ll N;
  cin >> N;
  vector<pair<ll, ll>> n_factor = prime_factorize(N);
  ll ans = 0;
  ll e = 1;
  while (e <= max_e) {
    for (auto x : n_factor) {
      if (e > x.second) continue;
      ll z = pow(x.first, e);
      if (N % z == 0) {
        N /= z;
        ans++;
        x.second -= e;
      }
    }
    e++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3992
n=int(input())
mozi=[]
for i in range(n):
    mozi.append(sorted(input()))
mozi.sort()

def hantei(x,y):
    for i in range(10):
        if x[i]!=y[i]:
            return False
    return True

def conbi(n,r):
    ue=1
    for i in range(n-r+1,n+1):
        ue*=i
 
    sita=1
 
    for i in range(1,r+1):
        sita*=i
 
 
    return (ue//sita)
i=0
ans=0
while i<n-1:
    c=1
    while i<n-1 and hantei(mozi[i],mozi[i+1]):
        c+=1
        i+=1
    ans+=conbi(c,2)
    i+=1

print(ans)

Measured memory_bytes: 30744
#include <cstdio>

int main() {
	int H,W;
	
	while(true){
		scanf("%d %d", &H, &W);
		if (H==0){break;}
		for(int i=0;i<W;i++){
			printf("#");
		}
		printf("\n");
		for(int i=0;i<H-2;i++){
			printf("#");
			for(int j=0;j<W-2;j++){
				printf(".");
			}
			printf("#");
			printf("\n");
		}
		for(int i=0;i<W;i++){
			printf("#");
		}
		printf("\n");
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 2500
import java.io.*;
import java.util.ArrayList;

public class Main {
	static ArrayList<Integer>[] arr = null;
	static int longestPath[] = null;
	static boolean vis[]  = null;
	
	private static int dfs(int node) {
		if(vis[node]) return longestPath[node];
		int maxLen = 0;
		for(int i=0; i<arr[node].size(); i++) {
			maxLen = Math.max(maxLen, dfs(arr[node].get(i))+1);
		}
		vis[node] = true;
		return longestPath[node] = maxLen;
	}
	
	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str;
		str = br.readLine().split(" ");
		int n = Integer.parseInt(str[0]);
		int m = Integer.parseInt(str[1]);
		int len = (int)1e5+1;
		arr = new ArrayList[len];
		for(int i=0; i<len; i++) arr[i] = new ArrayList<>();
		for(int i=0; i<m; i++) {
			str = br.readLine().split(" ");
			int x = Integer.parseInt(str[0]);
			int y = Integer.parseInt(str[1]);
			arr[x].add(y);
		}
		longestPath = new int[len];
		vis = new boolean[len];
		for(int i=0; i<len; i++) dfs(i);
		int ans = -1;
		for(int i=0; i<len; i++) ans = Math.max(ans, longestPath[i]);
		System.out.println(ans);
	}
}


Measured memory_bytes: 56996
from sys import stdin
from fractions import gcd
columns = int(stdin.readline().rstrip())
datas = [stdin.readline().rstrip().split() for _ in range(columns)]
for data in datas:
    A = int(data[0])
    B = int(data[1])
    C = int(data[2])
    D = int(data[3])
    if A < B:
        print("No")
        continue
    if D < B:
        print("No")
        continue
    if C > B:
        print("Yes")
        continue
    g = gcd(B,D)
    if (B - g + A % g) >C :
        print("No")
    else:
        print("Yes")     
    

Measured memory_bytes: 5332
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
template<class T> istream& operator>>(istream &is,vector<T> &st){
  for(size_t i=0;i<st.size();++i) is >> st[i];
  return is;
}
template<class T> istream& operator>>(istream &is,vector<vector<T>> &st){
  for(size_t i=0;i<st.size();++i) is >> st[i];
  return is;
}
template<class T> ostream& operator<<(ostream &os, const vector<T> &st){
  for(size_t i=0;i<st.size();++i){
    if(i==st.size()-1) os << st[i];
    else os << st[i] << " ";
  }
  return os;
}
template<class T> ostream& operator<<(ostream &os, const vector<vector<T>> &st){
  for(size_t i=0;i<st.size();++i){
    os << st[i];
    if(i!=st.size()-1) os << endl;
  }
  return os;
}
ll gcd(int a,int b){//ユークリッドの互除法
  while(b){
    a %= b;
    swap(a,b);
  }
  return a;
}
ll lcm(ll a,ll b){
  ll r = gcd(a,b);
  a /= r;
  b /= r;
  return a * b * r;
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  ll rg = b-a+1;
  ll ans = rg;
  ans -= rg/c + rg/d;
  if(rg%c&&(a%c>(a+rg%c-1)%c||a%c==0)) ans--;
  if(rg%d&&(a%d>(a+rg%d-1)%d||a%d==0)) ans--;

  // FOR(i,a,a+rg%c){
  //   if(i%c==0) ans--;
  // }
  // FOR(i,a,a+rg%d){
  //   if(i%d==0) ans--;
  // }
  ll p = lcm(c,d);
  ans += rg/p;
  // FOR(i,a,a+rg%p){
  //   if(i%p==0) ans++;
  // }
  if(rg%p&&(a%p>(a+rg%p-1)%p||a%p==0)) ans++;

  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
s = input()
t = list(set(s))
alpha = {}
for i in range(len(t)):
    alpha[t[i]] = s.count(t[i])

count = 1
for k, v in alpha.items():
    count *= (v + 1)
count -= 1
print(count%(10**9+7))

Measured memory_bytes: 3188
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ a, b, t ] <- readInts
	print $ ( t `div` a ) * b

Measured memory_bytes: 380
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>

using namespace std;

int main()
{
  int N;
  cin >> N;

  for (int i = 0; i < N; ++i)
  {
    int A;
    cin >> A;

    if (A % 2 != 0) continue;
    if (A % 3 != 0 && A % 5 != 0)
    {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int main(){
	
char str[20];
    
    scanf("%[^\n]", str);
    
  	for(int i = 0; i < 19; i++)
	{
    	
      if(str[i] == ','){
      	printf(" ");
        }else{
        printf("%c", str[i]);
        
      }
    }

}

Measured memory_bytes: 1600
#include<stdio.h>
#include<ctype.h>

int main() {
	//int i=0;
	char a[101],b[101],c[101];

	scanf("%s %s %s",a,b,c);
	char out[4];

	snprintf(out,4,"%c%c%c",a[0],b[0],c[0]);

	/*for (i = 0; i < 101;i++) {
		if(isupper(str[i]) !=0)*/
		printf("%s",out);
	//}

	return 0;

}

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

int N, W, vi, wi;

int main() {
    cin >> N >> W;
    int a[W+1];
    for (int i=0; i<W+1; i++) a[i]=0;
    for (int i=0; i<N; i++) {
        cin >> vi >> wi;
        for (int j=wi; j<W+1; j++) {
            if (a[j]<a[j-wi]+vi) a[j] = a[j-wi]+vi;
        }
    }
    cout << a[W] << endl;
}


Measured memory_bytes: 3136
from collections import*
I=9**9
(h,w),(s,t),(f,g)=eval('map(int,input().split()),'*3)
m,d=zip(*eval('(input(),[I]*w),'*h))
q=deque([(s-1,t-1,1)])
while q:
 y,x,c=q.popleft()
 if d[y][x]>c:
  for i in range(y-2,y+3):
   for j in range(x-2,x+3):d[y][x]=c;h>i>-1<j<w!=m[i][j]>'#'!=(abs(y-i)+abs(x-j)<2!=q.appendleft((i,j,c))or q.append((i,j,c+1)))
print(d[f-1][g-1]%I-1)

Measured memory_bytes: 249608
t,*S=*$<;i=1;p~(S.map{d=p=0;q=i;(d-=1;p|=r=s=p&q^q;q=0;(q|=S[-t.bit_length].to_i 2;s^=t)while(t=s&-s)>0;0<q&r&&x)while 0<q;i*=2;d}.min rescue 0)

Measured memory_bytes: 3964
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n,k = nm()
cnt = 0
while n:
    cnt += 1
    n //= k
print(cnt)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <sstream>
#include <numeric>
#include <queue>
#include <sstream>
#include <set>
using namespace std;

int64_t min(int64_t a,int64_t b) {
    if (a > b)
    {
        return b ;
    }else
    {
        return a ;
    }
}


int main(){
    int n ;
    cin >> n ;
    vector<int64_t> a(n) ;
    vector<int64_t> b(n) ;
    for (size_t i = 0; i < n; i++)
    {
        cin >> a.at(i) ;
    }
    for (size_t i = 0; i < n; i++)
    {
        cin >> b.at(i) ;
    }
    vector<int64_t> c(n) ;
    for (size_t i = 0; i < n; i++)
    {
        c.at(i) = a.at(i) - b.at(i) ;
    }
    sort(c.begin(),c.end()) ;
    bool ans = false ;
    if (c.at(n-1) < 1)
    {
        ans = true ;
    }else
    {
        int i = 0 ;
        int j = n-1 ;
        while(1){
            if (c.at(j) < 1)
            {
                ans = true ;
                break ;
            }else if (c.at(i) > -2)
            {
                ans = false ;
                break ;
            }
            int64_t judge = c.at(i) + c.at(j)*2 ;
            if ( judge <= 0 )
            {
                c.at(i) = judge ;
                if (c.at(i) > -2)
                {
                    i ++ ;
                }
                j -- ;
            }else
            {
                int p = c.at(i)/-2 ;
                c.at(j) -= p ;
                c.at(i) += 2*p ;
                i ++ ;
            }
            
            
            
        }
    }
    
    if (ans == true)
    {
        cout << "Yes" << endl ;
    }else
    {
        cout << "No" << endl ;
    }
    
    
}


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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const int MOD = (int) 1e9 + 7;
//const int MOD = (int) 998244353;
const int maxn = (int) 1e4 + 20;
const int maxm = (int) 1e6 + 20;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL m = MOD) {LL res = 1; for(; n; n >>= 1, a = a * a % m) if(n & 1) res = res * a % m; return res;}

int n, m;
int a[maxn], b[maxn];
int dp[maxn];

void work()
{
    cin >>n >>m;
    for(int i = 0; i < m; i++)
        cin >>a[i] >>b[i];

    memset(dp, 0x3f, sizeof(dp));

    dp[n] = 0;
    for(int i = 0; i < m; i++)
    {
        for(int j = n; j > 0; j--)
        {
            auto getmin = [](int &x, int y) {if(x > y) x = y;};
            getmin(dp[max(0, j - a[i])], dp[j] + b[i]);
        }
    }

    cout <<dp[0] <<endl;
}


int main()
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 256
o=list(input())
e=list(input())
pw=[]
if len(o)-len(e)==0:
  for i in range(len(o)):
    pw.append(o[i]+e[i])
else:
  for i in range(len(o)-1):
    pw.append(o[i]+e[i])
  pw.append(o[len(o)-1])
print(*pw,sep='')

Measured memory_bytes: 3064
/** Bismillahir Rahmanir Rahim **/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define endl '\n'
#define fi first
#define se second
#define Fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define debug(x) cerr << #x << " "<< x << endl

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	cout << c << " " << a << " " << b << endl;

	 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <iostream>
#include <string.h>
#include <map>

//ios::sync_with_stdio(false);

using namespace std;

map<string, int> spath;

string swap(string s, int i, int j){
    char c = s[i];
    s[i] = s[j];
    s[j] = c;
    return s;
}

void bfs(){
    vector<vector<int>> d = {
        {1, 4},
        {0, 2, 5},
        {1, 3, 6},
        {2, 7},
        {0, 5},
        {1, 4, 6},
        {2, 5, 7},
        {3, 6}
    };
    
    string start = "01234567";
    queue<string> q;
    
    spath[start] = 0;
    q.push(start);
    
    while(!q.empty()){
        string s = q.front(); q.pop();
        
        int pos = s.find("0");
        for(int i=0; i<d[pos].size(); i++){
            string t = swap(s, pos, d[pos][i]);
            if(spath.find(t) == spath.end()){
                spath[t] = spath[s] + 1;
                q.push(t);
            }
        }
    }
}

int main(){
    bfs();
    
    string s = "01234567";
    
    while(cin >> s[0]){
        for(int i=1; i<8; i++)
            cin >> s[i];
        cout << spath[s] << endl;
    }
    
	return 0;
}

Measured memory_bytes: 3440
#include <iostream>

#define rep(i,n) for(int i=0;i< (n);++i)
#define REP(i,n) for(int i=1;i<=(n);++i)
#define ALL(a) (a).begin(),(a).end()

int main() {
    std::ios::sync_with_stdio(false);
    int a,b,c,d;
    std::cin >> a >> b >> c >> d;
    int left = std::max(a,c);
    int right = std::min(b,d);
    std::cout << std::max(0,right-left) << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ちゃんとユニークな配列にする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

int main() {
  int X;
  cin >> X;
  int A, B;
  cin >> A >> B;
  int result = (X - A) % B;
  cout << result << endl;
}


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

#define MAX_VALUE 1000000007

using namespace std;
 
 
int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> s(n);
    vector<int> t(m);
    vector<vector<long long>> dp(2001, vector<long long>(2001));
    vector<vector<long long>> sum(2001, vector<long long>(2001));
    int i, j;
    for(i = 0; i < n; i++)
    {
        cin >> s.at(i);
    }
    for(i = 0; i < m; i++)
    {
        cin >> t.at(i);
    }
    for(i = 0; i <= 2000; i++)
    {
        for(j = 0; j <= 2000; j++)
        {
        dp.at(i).at(j) = 0;
        sum.at(i).at(j) = 0;
        }
    }
    for(i = 0; i < n; i++)
    {
        for(j = 0; j < m; j++)
        {
        if(s.at(i) == t.at(j))
        {
            dp.at(i+1).at(j+1) = (sum.at(i).at(j)+1)%MAX_VALUE;
        }
        else
        {
            dp.at(i+1).at(j+1) = 0;
        }
        sum.at(i+1).at(j+1) = sum.at(i).at(j+1)+sum.at(i+1).at(j)-sum.at(i).at(j)+dp.at(i+1).at(j+1);
        }
    }
    cout << (sum.at(n).at(m)+1)%MAX_VALUE << endl;;
}

Measured memory_bytes: 65024
def gcd(a,b):
    ma = max(a,b)
    mi = min(a,b)
    while(True):
        los = ma % mi
        ma = mi
        mi = los
        if los == 0:
            result = ma
            break
    return result

a,b = map(int,input().split())
print(a*b//gcd(a,b))

Measured memory_bytes: 3060
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def modinv2(x,r):
  return pow(x,r-2,r)

def perm(n,i):
    return (fact[n]*modinv2(fact[n-i],R))%R

n,m = inm()
a = inl()
b = inl()
fact = [0]*(n*m+1)
fact[0] = 1
for i in range(1,n*m+1):
    fact[i] = (fact[i-1]*i)%R
a.sort(reverse=True)
b.sort(reverse=True)
if a[0]!=n*m or b[0]!=n*m:
    print(0)
    exit()
prev = n*m
i = j = 1
x = 1
free = 0
while i<n or j<m:
    if i<n and (j==m or a[i]>b[j]):
        cur = a[i]
        use = prev-cur-1
        if use>free or use<0:
            print(0)
            exit()
        x = (x*perm(free,use)*j)%R
        free += j-1-use
        prev = cur
        i += 1
    elif j<m and (i==n or a[i]<b[j]):
        cur = b[j]
        use = prev-cur-1
        if use>free or use<0:
            print(0)
            exit()
        x = (x*perm(free,use)*i)%R
        free += i-1-use
        prev = cur
        j += 1
    elif i<n and j<m and a[i]==b[j]:
        cur = a[i]
        use = prev-cur-1
        if use>free or use<0:
            print(0)
            exit()
        x = (x*perm(free,use))%R
        free += i+j-use
        prev = cur
        i += 1
        j += 1
    #ddprint(f"{i=} {j=} {x=} {free=} {use=} {cur=}")
print((x*fact[prev-1])%R)


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


int main() {
    while(true){
        int n;
        cin >> n;
        if(n == 0) return 0;
        int ma=0;
        vector<string> a;
        string b="aiueo";
        for(int i=0;i<n;i++){
            string t;
            cin >> t;
            string tt;
            tt.push_back(t[0]);
            for(int j=1;j<t.size();j++){
                for(int k=0;k<5;k++){
                    if(t[j-1]==b[k]){
                        tt.push_back(t[j]);
                    }
                }
            }
            a.push_back(tt);
            ma=max(ma,(int)a[i].size());
        }
        for(int k=1;k<=ma;k++){
            set<string> s;
            for(int i=0;i<n;i++){
                string te=a[i].substr(0,k);
                s.insert(te);
            }
            if(s.size()==a.size()){
                cout << k << endl;
                break;
            }else if(k==ma){
                cout << -1 << endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 3164
#Educational-DP C
n = int(input())
vac = []
for i in range(n):
    vac.append(tuple(map(int,input().split())))

dp1 = [vac[0][0]] + [0] * (n-1)
dp2 = [vac[0][1]] + [0] * (n-1)
dp3 = [vac[0][2]] + [0] * (n-1)

for i in range(1,n):
    dp1[i] = max((vac[i][0]+dp2[i-1]),(vac[i][0]+dp3[i-1]))
    dp2[i] = max((vac[i][1]+dp1[i-1]),(vac[i][1]+dp3[i-1]))
    dp3[i] = max((vac[i][2]+dp2[i-1]),(vac[i][2]+dp1[i-1]))
    
    
print(max(dp1[-1],dp2[-1],dp3[-1]))

Measured memory_bytes: 95108
n, m = gets.split.map(&:to_i)
as = []
n.times do
  as << gets.split.map(&:to_i)
end
bs = []
m.times do
  bs << gets.to_i
end
as.each do |a|
  puts a.zip(bs).map { |aa, bb| aa * bb }.inject(:+)
end


Measured memory_bytes: 7068
def main():
	N = int(input())
	tasks = []
	for i in range(N):
		A, B = [int(x) for x in input().split(" ")]
		tasks.append({
			"time" : A,
			"deadline" : B
		})
	tasks.sort(key=lambda task: task["deadline"])
	tot = 0
	in_time = "Yes"
	for i in range(len(tasks)):
		t = tasks[i]["time"]
		d = tasks[i]["deadline"]
		tot += t
		if tot > d:
			in_time = "No"
			break
	print(in_time)

main()

Measured memory_bytes: 72376
#include <iostream>
#include <algorithm>
using namespace std;
int n;
double a[55];

int main()

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

	sort(a+1,a+1+n);
	double now=a[1];
	for (int i=2;i<=n;i++){
		now=(now+a[i])/2.0;
	}

	printf("%.10f\n",now);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 1005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

ll n, m;
ll mask1[N];
ll cost[N];
ll dp[N][1 << 12];

ll recur(ll pos, ll mask) {
  if (mask == ((1 << n) - 1))
    return 0;
  if (pos == m + 1) {
    return inf;
  }

  ll &ans = dp[pos][mask];
	if(ans!=-1)
      return ans;
  ans =
      min(recur(pos + 1, mask), cost[pos] + recur(pos + 1, mask | mask1[pos]));
  return ans;
}

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

  cin >> n >> m;

  for (ll i = 1; i <= m; i++) {
    cin >> cost[i];
    mask1[i] = 0;
    ll b;
    cin >> b;
    while (b--) {
      ll x;
      cin >> x;
      x--;
      mask1[i] |= (1 << x);
    }
  }
  memset(dp, -1, sizeof(dp));

  ll res = recur(1, 0);
  if (res > 1e12)
    cout << -1 << en;
  else
    cout << recur(1, 0) << en;

  return 0;
}


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

using namespace std;

int main() {
    unsigned int n, q;
    cin >> n >> q;

    vector<queue<int> > que(n);
    while (q--) {
        int op, t;
        cin >> op >> t;
        if (op == 0) {
            int x;
            cin >> x;
            que[t].push(x);
        } else if (op == 1) {
            if (que[t].empty()) continue;
            cout << que[t].front() << endl;
        } else if (op == 2) {
            if (que[t].empty()) continue;
            que[t].pop();
        }
    }
    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

int main() {
    int N;
    cin >> N;
    vi P(N);
    vi minElement(N,0);
    REP(i,N) cin >> P[i];

    minElement[0]=P[0];
    int ans=1;

    FOR(i,1,N){
        if(minElement[i-1]>=P[i])ans++;
        minElement[i] = min(minElement[i-1],P[i]);
    }

    cout << ans << endl;

}



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

int main() {
  int n;
  while (cin >> n) {
    bool f = false;
    for (int i = 0; i < 10; i++) {
      if (n & (1 << i)) {
        if (f) cout << " ";
        cout << pow(2, i);
        f = true;
      }
    }
    cout << endl;
  }
}


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

typedef vector<int> vi;

int N, M, Q;
vector<string> S;
vector<vi> nd, eg_x, eg_y;

void make_data(void) {
	vi v = vi(M + 1, 0);
	nd = vector<vi>(N + 1, v);
	eg_x = vector<vi>(N + 1, v);
	eg_y = vector<vi>(N + 1, v);

	for (int j = 1; j <= N; ++j) {
		for (int i = 1; i <= M; ++i) {
			nd[j][i] = nd[j - 1][i] + nd[j][i - 1] - nd[j - 1][i - 1];
			if (S[j][i] == '1')
				++nd[j][i];
			eg_x[j][i] = eg_x[j - 1][i] + eg_x[j][i - 1] - eg_x[j - 1][i - 1];
			if (S[j][i] == '1' && S[j][i - 1] == '1')
				++eg_x[j][i];
			eg_y[j][i] = eg_y[j - 1][i] + eg_y[j][i - 1] - eg_y[j - 1][i - 1];
			if (S[j][i] == '1' && S[j - 1][i] == '1')
				++eg_y[j][i];
		}
	}
}

int count_node(int y0, int x0, int y1, int x1) {
	int cnt = nd[y1][x1] - nd[y0 - 1][x1] - nd[y1][x0 - 1] + nd[y0 - 1][x0 - 1];
	return cnt;
}

int count_edge(int y0, int x0, int y1, int x1) {
	int cnt_x = eg_x[y1][x1] - eg_x[y0 - 1][x1] - eg_x[y1][x0] + eg_x[y0 - 1][x0];
	int cnt_y = eg_y[y1][x1] - eg_y[y0][x1] - eg_y[y1][x0 - 1] + eg_y[y0][x0 - 1];
	int cnt = cnt_x + cnt_y;
	return cnt;
}

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

	cin >> N >> M >> Q;

	string str(M + 1, ' ');
	S.resize(N + 1);
	S[0] = str;
	for (int j = 1; j <= N; ++j) {
		cin >> str;
		S[j] = " " + str;
	}

	make_data();

	for (int i = 1; i <= Q; ++i) {
		int x0, y0, x1, y1;
		cin >> y0 >> x0 >> y1 >> x1;
		int node = count_node(y0, x0, y1, x1);
		int edge = count_edge(y0, x0, y1, x1);
		int ans = node - edge;
		cout << ans << '\n';
	}

	return 0;
}


Measured memory_bytes: 52992
// Aizu Vol0 0002: Digit Number
// 2017.7.28

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

#define MAX 8
int max[MAX] = {
	0,
	0,
	10,
	100,
	1000,
	10000,
	100000,
	1000000
};

int main()
{
	int a, b, c;
	int i;

	while (scanf("%d%d", &a, &b) == 2) {
		c = a + b;
		for (i = MAX - 1; i >= 0; i--) {
			if (c >= max[i]) break;
		}
		putchar('0' + i);
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 572
def toValue(arr):
    s = 0
    l = len(arr) - 1
    i = 0
    while l >= 0:
        s += int(arr[i]) * pow(10,l)
        i += 1
        l -= 1
    return s
    
n = int(input())

for i in range(0,n):
    s = input()
    max = []
    for j in s:
        max.append(j)
    max = sorted(max,reverse=True)
    min = sorted(max)
    print(toValue(max) - toValue(min))   


Measured memory_bytes: 5600
x,n = map(int,input().split())
p = list(map(int,input().split()))
ans = 0
c = 1
i = 0
y = x
z = x
while c:
    y = x-i
    z = x+i
    a = 0
    b = 0
    for j in range(n):
        if y == p[j]:
            a = 1
        if z == p[j]:
            b = 1
    if b == 0:
        ans = z
        c = 0
    if a == 0:
        ans = y
        c = 0
    i+=1
print(ans)

Measured memory_bytes: 9216
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int n,x,a[100005],b[100005];
int main()
{
	scanf("%d%d",&n,&x);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	for(int i=1;i<=n;++i) b[i]=abs(a[i]-x);int now=b[1];
	for(int i=2;i<=n;++i) now=__gcd(now,b[i]);
	printf("%d\n",now);
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	string t;
	 t="";
	for(int i=0;i<s.size();i++){
		if(s[i]=='1') t+='1';
		else if(s[i]=='0') t+='0';
		else if(t.size()>0) t.erase(t.end()-1);
	} 
	cout<<t;
	return 0; 
} 

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
void Unused(...) {}
#ifndef DEBUG
  #define echo(...) Unused(__VA_ARGS__)
#else
  #define echo(...) fprintf(stderr, __VA_ARGS__)
#endif

int a, b, c;

int main()
{
    scanf("%d %d %d", &a, &b, &c);
    printf("%d\n", std::max(0, c - (a - b)));
    return 0;
}



Measured memory_bytes: 128
import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args){
		solve();
	}
	public static void solve(){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		for(int i=0;i<n;i++){
			a[i] = sc.nextInt();
			b[i] = 1+i;
		}
		int[][] map = new int[h][w];

		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				if(a[i]<a[j]){
					int temp = a[i];
					a[i] = a[j];
					a[j] = temp;
					temp = b[i];
					b[i] = b[j];
					b[j] = temp; 
				}
			}
		}
		int hnow = 0;
		int wnow = 0;
		for(int i=0;i<n;i++){
			while(true){
				if(hnow%2==0){
					if(a[i]>=w-wnow){
						for(int j=wnow;j<w;j++){
							map[hnow][j] = b[i];
						}
						a[i] -= (w - wnow);
						hnow++;
						wnow = w -1;
					}
					else{
						for(int j=wnow;j<wnow+a[i];j++){
							map[hnow][j] = b[i];
						}
						wnow += a[i];
						a[i] = 0;
					}
				}
				else{
					if(a[i]>wnow){
						for(int j=wnow;j>=0;j--){
							map[hnow][j] = b[i];
						}
						a[i] -= (wnow + 1);
						hnow++;
						wnow = 0;
					}
					else{
						for(int j=wnow;j>wnow-a[i];j--){
							map[hnow][j] = b[i];
						}
						wnow -= a[i];
						a[i] = 0;
					}
				}
				if(a[i]==0){
					break;
				}
			}
		}


		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				System.out.print(map[i][j]);
				if(j!=w-1){
					System.out.print(" ");
				}
				else{
					System.out.println();
				}
			}
		}
	}
}


Measured memory_bytes: 30244
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

	int n;
	int field[256][256];
	while(cin>>n&&n!=0){
		int maxLength=0;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				char ch;
				cin>>ch;
				field[i][j]=ch-'0';
			}
		}
		for(int i = 0; i < n; i++){
			int len=0;
			for(int j = 0; j < n; j++){
				if(field[i][j]==1){
					len++;
					maxLength=max(maxLength,len);
				}
				else{
					len=0;
				}
			}
		}
		for(int i = 0; i < n; i++){
			int len=0;
			for(int j = 0; j < n; j++){
				if(field[j][i]==1){
					len++;
					maxLength=max(maxLength,len);
				}
				else{
					len=0;
				}
			}
		}
		// ÈÈß
		for(int j = 0; j < 2*n-1; j++){
			int len=0;
			int cy=0;
			int cx=j;
			if(j>=n){
				cy=j-n+1;
				cx=n-1;
			}
			while(1){
				if(field[cy][cx]==1){
					len++;
					maxLength=max(maxLength,len);
				}				else{
					len=0;
				}
				int ny=cy+1;
				int nx=cx-1;
				if(!(ny>=0&&nx>=0&&ny<n&&nx<n)){
					break;
				}
				cx=nx;
				cy=ny;
			}
		}
		// ÈÈß
		for(int j = 0; j < 2*n-1; j++){
			int len=0;
			int cy=0;
			int cx=j;
			if(j>=n){
				cx=0;
				cy=j-n+1;
			}
			while(1){
				if(field[cy][cx]==1){
					len++;
					maxLength=max(maxLength,len);
				}
				else{
					len=0;
				}
				int ny=cy+1;
				int nx=cx+1;
				if(!(ny>=0&&nx>=0&&ny<n&&nx<n)){
					break;
				}
				cx=nx;
				cy=ny;
			}
		}
		cout<<maxLength<<endl;
	}


	return 0;
}

Measured memory_bytes: 0
from math import inf

n, k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]

dp = [inf for i in range(n)]
dp[0] = 0

for i in range(1, n):
    for j in range(k + 1):
        if i - j >= 0:
            dp[i] = min(dp[i - j] + abs(h[i] - h[i - j]), dp[i])

print(dp[-1])


Measured memory_bytes: 90872
#include <stdio.h> 

#define MAX 200

void sort(int*,int );
int input(int*, int);

int main()
{
	int a[MAX];
	int n, m;
	int count = 0;
	int sum;
    float standard;

	scanf("%d %d", &n, &m);
	sum=input(a, n);
	standard = (float)1 / (4 * m) * sum;
	sort(a, n);

	for (int i = 0; i < n; i++) {
		if (a[i] < standard)
			break;
		count++;
	}

	if (count >= m)
		printf("Yes\n");
	else
		printf("No");

	return 0;
}

int input(int* a, int n)
{
	int sum = 0;

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

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

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

Measured memory_bytes: 128
//https://atcoder.jp/contests/dp/tasks/dp_a

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

int ara[100005];
int sol[100005];

int main()
{
    int n, k;
    while(cin >> n >> k)
    {
        memset(sol, 0, sizeof(sol));
        for(int i=0; i<n; i++){
            cin >> ara[i];
        }

        sol[0] = 0;
        sol[1] = abs(ara[0] - ara[1]);
        for(int i=2; i<n; i++){
            int mn = INT_MAX;
            for(int j=1; j<=k; j++){
                if(i >= j) mn = min(mn, (sol[i-j] + abs(ara[i] - ara[i-j])));
            }
            sol[i] = mn;
        }
        cout << sol[n-1] << "\n";
    }

    return 0;
}


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

int main(){
  int n;
  string s;
  int ans = 0;
  cin >> n >> s;
  for(int i=0;i<n-2;i++){
    if(s.at(i) == 'A' && s.at(i+1) == 'B' && s.at(i+2) == 'C') ans++;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for (int i = 0; i + 2 < s.length(); i++) {
        if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') {
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  int road[n];
  for (int i=0; i<n; i++) {
    road[i] = 0;
  }
  for (int i=0; i<m; i++) {
    int a, b;
    cin >> a >> b;
    road[a-1]++;
    road[b-1]++;
  }
  for (int i=0; i<n; i++) {
    cout << road[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    char str[100];
    long int K,i,count=0,num[100];
    scanf("%s",str);
    scanf("%ld",&K);
    for(i=0;i<100;i++) num[i] = (int)str[i] - 48;
    for(i=0;i<100;i++){
        if(num[i]!=1) break;
        else count++;
    }
    if(count!=0){
        if(K>count) printf("%ld\n",num[count]);
        else        printf("%d\n",1);
    }else printf("%ld\n",num[0]);
    return 0;
}

Measured memory_bytes: 128
/*
 * author :Sadik Hassan
 *
*/
#include "bits/stdc++.h"
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define fi            first
#define se            second
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define rep(i,n)      for(int i=0;i<n;i++)
#define repn(i,n)     for(int i=1;i<=n;i++)
#define rrep(i,n)     for(int i=n-1;i>=0;i--)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
#define TSFL(s)       transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSFH(s)       transform(s.begin(),s.end(),s.begin(),::tolower);
/*---------------------------------------------------------------------*/
const int N = 2e5+10;
const int INF = (int)1e9+5;

int main()
{
    _SAD()
    int a,b,c;
    cin>>a>>b>>c;
    if((a==b&&b!=c)||(a==c&&c!=b)||(b==c&&c!=a))
    {
        cout<<"Yes"<<nl;
    }
    else
    {
        cout<<"No"<<nl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
typedef pair<int,int> P;
#define INF 1e9
#define rep(i,N) for(int i=0;i<N;i++)

int main(){
    int n;
    cin>>n;
        int d[n];
        rep(i,n)cin>>d[i];
        int cnt = -1;
        while(cnt<=10000){
            bool flag = false;
            cnt++;
            if(cnt<10){
                for(int i=0;i<n;i++){
                    if(cnt == d[i]){
                        flag = true;
                        break;
                    }
                }
            }else if(cnt<100){
                for(int i=0;i<n-1;i++){
                    if(cnt == (d[i]*10+d[i+1])){
                        flag = true;
                        break;
                    }
                }
            }else if(cnt<1000){
                for(int i=0;i<n-2;i++){
                    if(cnt == (d[i]*100+d[i+1]*10+d[i+2])){
                        flag = true;
                        break;
                    }
                }
            }else{
                for(int i=0;i<n-3;i++){
                    if(cnt == (d[i]*1000+d[i+1]*100+d[i+2]*10+d[i+3])){
                        flag = true;
                        break;
                    }
                }
            }
            if(!flag)break;
        }
        cout<<cnt<<endl;
}


Measured memory_bytes: 3088
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
#include <list>
using namespace std;
 
int main()
{
    int n;
    cin>> n;
    string str1,str2;
    vector<string>s1;
    vector<string>s2;
    for(int i=0;i<n;i++){
       cin>>str1;
       s1.push_back(str1);  
       cin>>str2;    
       s2.push_back(str2);       
    }
    for(int i=0;i<n;i++){
           string str3=s1[i];
           string str4=s2[i];
           int k=str3.size();
           int l=str4.size();           
           int max=k>l?k:l;
           if(max>80) cout<<"overflow"<<endl;
           else{
           int a[80]={0};
           int b[80]={0};
           for(int j=0;j<k;j++){
                a[j]=str3[j]-'0'; } 
           for(int j=0;j<l;j++){
                b[j]=str4[j]-'0'; }
           int temp=0;
           char s[80];
           for(int i=0;i<max;i++){
               int d;
               if(l>i&&k>i) d=a[k-1-i]+ b[l-1-i]+temp;
               if(l<=i&&k>i) d=a[k-1-i]+temp;
               if(l>i&&k<=i) d=b[l-1-i]+temp;
               s[max-1-i]=(d%10)+'0';
               if(d>=10) temp=1;
               else temp=0;
           }
           if((max+temp)>80) cout<<"overflow";
           else{ 
                 if(temp==1) cout<<"1";
                 for(int i=0;i<max;i++){
                    cout<<s[i];}
                }
           cout<<endl;
        }
    }   
    return 0; 
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
    int n;
    cin>>n;
    vector<ll> x(n),l(n);
    for(int i=0; i<n; i++) cin>>x[i]>>l[i];
    vector<pair<ll,ll>> range(n);
    for(int i=0; i<n; i++){
        range[i].second=x[i]-l[i];
        range[i].first=x[i]+l[i];
    }
    sort(range.begin(),range.end());
    int cnt=0;
    ll prev=-1e9;
    for(int i=0; i<n; i++){
        if(prev<=range[i].second){
            cnt++;
            prev=range[i].first;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string ans="APPROVED";
    cin >> n;
    vector<int> visiter(n);
    for (int i = 0; i <n;i++){
        cin >> visiter[i];
    }
    for (int i = 0; i < n;i++){
        if(visiter[i]%2==0&&visiter[i]%3!=0&&visiter[i]%5!=0){
            ans = "DENIED";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#18:51
n,A,B,C = map(int,input().split())
D = [A,B,C]
l = []
for _ in range(n):
  l.append(int(input()))
l.sort(reverse=True)
def nex(time):
  for i in range(n-1,-1,-1):
    if time[i] < 3:
      time[i] += 1
      break
    else:
      time[i] = 0
  else:
    time = 'over'
  return time
#print(nex([0,0,0,0]),nex([0,3,3,3]),nex([3,3,3,3]))
can = []
time = [0 for _ in range(n)]
while time != 'over':
  ans = (n-3) * 10
  d = [0,0,0]
  for i in range(n):
    t = time[i]
    if t == 3:
      ans -= 10
    else:
      d[t] += l[i]
  if all(d[k] != 0 for k in range(3)):
    for k in range(3):
      ans += abs(D[k] - d[k])
    can.append([ans,d])
  time = nex(time)
print(min(can,key=lambda x:x[0])[0])

Measured memory_bytes: 18020
let [| a; b; |] = stdin.ReadLine().Split() |> Array.map int64

let gcd a b =
    let rec f a b=
        let a, b =
            if a < b then  b, a
            else a, b
        match a % b with
        | 0L -> min a b
        | x -> f (min a b) x
    f a b

let factorization n =
    if n = 1L then Set.empty
    else
    let rec f (i:int64) nTmp (result:Set<_>)=
        match nTmp % i , i * i > nTmp with
        | _, true -> result.Add(nTmp)
        | 0L, _ -> f i (nTmp/i) (result.Add(i))
        | _, _ -> f (i+1L) nTmp result
    f 2L n Set.empty

(gcd a b |>factorization |> Set.count) + 1 |> stdout.WriteLine

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

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

  const int MAX_SIZE = 2000001;
  const int MAX_VALUE = 10000;

  int n;
  cin >> n;

  unsigned short *A, *B;
  A = new unsigned short[n + 1];
  B = new unsigned short[n + 1];
  int cnt[MAX_VALUE + 1];

  for (int i = 0; i <= MAX_VALUE; i++) cnt[i] = 0;

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

  for (int i = 1; i <= MAX_VALUE; i++) cnt[i] += cnt[i-1];

  for (int i = 1; i <= n; i++) B[cnt[A[i]]--] = A[i];

  for (int i = 1; i <= n; i++) {
    if (i > 1) cout << " ";
    cout << B[i];
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 11044
#include <iostream>
#include <string>
#include <deque>
#include <vector>
using namespace std;

typedef long long ll;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N+1);
    vector<ll> B(N+1);
    vector<ll> C(N);
    for(int i=1; i<=N; i++) {
        cin >> A[i];
    }
    for(int i=1; i<=N; i++) {
        cin >> B[i];
    }
    for(int i=1; i<N; i++) {
        cin >> C[i];
    }


    ll sum=0;
    ll j=-1;
    for(int i=1; i<=N; i++) {
        if(j+1 == A[i]) {
            sum += C[j];
        }
        j = A[i];
        sum += B[j];
    }

    cout << sum << endl;



    return 0;


}


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

int main() {
	long long n,m,i,j,k,ans,cur,res,a;
	cin >> n;
	if(n==1){
		cout << 0 << endl; return 0;
	}
	
	ans=0;
	for(i=2; i*i<=n; i++){
		if(n%i==0){
			cur=0;
			while(n%i==0){
				n/=i;
				cur++;
			}
			res=1;
			while(cur>0){
				if(cur>=res){
					ans++;
				}
				cur-=res;
				res++;
			}
		}
	}
	if(n>1){
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    set<int> s;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        s.insert(x);
    }
    if (s.size() == n) {
        cout << "YES";
    } else {
        cout << "NO";
    }
    return 0;
} 

Measured memory_bytes: 9600
#include <iostream>
#include <stack>
#include <string>

using namespace std;

void solve(){
	stack<int> numStack;
	string str;
	getline(cin, str);
	for (int i = 0; i < str.size(); ++i){
		if (str[i] =='+'){
			int x = numStack.top();
			numStack.pop();
			int y = numStack.top();
			numStack.pop();
			numStack.push(y + x);
		}
		else if (str[i] =='-'){
			int x = numStack.top();
			numStack.pop();
			int y = numStack.top();
			numStack.pop();
			numStack.push(y-x);
		}
		else if (str[i] == '*'){
			int x = numStack.top();
			numStack.pop();
			int y = numStack.top();
			numStack.pop();
			numStack.push(y * x);
		}
		else if (str[i]!= ' '){
			int temp = str[i] - '0';
			while (str[++i] !=' '){
				temp=temp*10+str[i]-'0';
			}
			numStack.push(temp);
		}
	}
	cout << numStack.top() << endl;
}



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


Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
int n, m, h[100005], ans=0;
vector<int> r[100005];
int main() {
    cin >> n >> m;
    for (int i=1; i<=n; i++) cin >> h[i];
    for (int i=0; i<m; i++) {
        int a, b; cin >> a >> b;
        r[a].push_back(b);
        r[b].push_back(a);
    }
    bool ok=1;
    for (int i=1; i<=n; i++) {
        ok=1;
        for (int j=0; j<r[i].size(); j++) {
            if (h[i]<=h[r[i][j]]) ok=0;
        }
        if (ok) ans++;
    }
    
    cout << ans;
}

Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, X;
    cin >> N >> X;
    int L[N];
    int D = 0;
    int count = 1;
    for (int i = 0; i < N; i++)
    {
        cin >> L[i];
    }
    for (int i = 0; i < N; i++)
    {
        D += L[i];
        if (D <= X)
        {
            ++count;
        }
        else
        {
            break;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
import sys
def q(a,h):
 d[a]=str(h)
 for b in t[a]:q(b,h+1)
t,p,d={},{},{}
input()
for e in sys.stdin:
 e=e.split()
 t[e[0]]=e[2:]
 for i in e[2:]:p[i]=e[0]
r=(set(t)-set(p)).pop()
p[r]='-1'
q(r,0)
print('\n'.join(f"node {i}: parent = {p[i]}, depth = {d[i]}, {'root'if'-1'==p[i]else'internal node'if t[i]else'leaf'}, [{', '.join(t[i])}]"for i in map(str,sorted(map(int,t)))))


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

int isPrime(int n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0)
        return 0;
    }
    return 1;
}

int main() {
	// your code goes here
	

    int x,i;
	cin>>x;
	
	for(i=x;;i++)
	    if(isPrime(i))
	    break;
	 cout<<i<<endl;

	
	return 0;
}


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

void judge(int x){
  
  static int sum = 0;
  int flag=0,i;

  if(x == 0){
    printf("%d\n",sum);
    exit(0);
  }
  
   for( i=2;i*i<=x;++i ) {
    if( x%i==0 ) {
      flag = 1;
      break;
    }
  }
   if(flag == 0) sum += 1;
}

int main(){
  int a,n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    judge(a);
  }
  judge(0);
  return 0;
}



Measured memory_bytes: 2124
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if(A%3==0||B%3==0||(A+B)%3==0){
            System.out.println("Possible");
        }else{
            System.out.println("Impossible");
        }
    }
}


Measured memory_bytes: 20820
#!/usr/bin/env python

H, W, M = map(int, input().split())
h = [-1 for _ in range(M)]
w = [-1 for _ in range(M)]
s = set()
for i in range(M):
    h[i], w[i] = map(int, input().split())
    h[i] -= 1
    w[i] -= 1
    s.add((h[i], w[i]))

# calc
hs = [0 for _ in range(H)]
ws = [0 for _ in range(W)]
for i in range(M):
    hs[h[i]] += 1
    ws[w[i]] += 1

#print('hs =', hs)
#print('ws =', ws)

hmax = max(hs)
wmax = max(ws)

ks = []
js = []

# 最大値の荷物がある場所を覚えておく
for k in range(H):
    if hmax == hs[k]:
        ks.append(k)
for j in range(W):
    if wmax == ws[j]:
        js.append(j)

ans = hmax + wmax

# クロスする場所に荷物があるかないかの確認
for k in range(len(ks)):
    for j in range(len(js)):
        if (ks[k], js[j]) not in s:
            print(ans)
            exit()
print(ans-1)

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

using namespace std;

size_t dfs(const vector<vector<size_t>>& mat, vector<bool>& visited, size_t v, size_t disabledEdge)
{
    visited[v] = true;

    size_t visitedCnt = 1;
    for (size_t to = 0; to < mat.size(); ++to)
    {
        if (mat[v][to] != 0 && mat[v][to] != disabledEdge && !visited[to])
            visitedCnt += dfs(mat, visited, to, disabledEdge);
    }
    return visitedCnt;
}

int main()
{
    size_t n, m;
    cin >> n >> m;

    vector<vector<size_t>> mat(n, vector<size_t>(n, 0));

    size_t from, to;
    for (size_t i = 0; i < m; ++i)
    {
        cin >> from >> to;
        --from; --to;
        mat[from][to] = i + 1;
        mat[to][from] = i + 1;
    }

    vector<bool> visited(n);
    size_t ans = 0;
    for (size_t i = 1; i <= m; ++i)
    {
        visited.assign(n, false);
        if (dfs(mat, visited, 0, i) != n)
            ++ans;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256