akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define INF 100000000
using namespace std;
const int mod = 1000000007;


int combi(int n, int k) {
  if (n == k || k == 0 )
    return 1;
  else {
    return combi(n - 1, k - 1) + combi(n - 1, k);
  }
}
int main() {

  int N,M;
  cin>>N>>M;
  //vector<int> A(N);
  //for(int i=0; i<N; i++){cin>>A[i];}
  //vector<vector<int>> A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  if(N<=1&&M<=1)cout<<0<<endl;
  else if(N<=1)cout<<combi(M,2)<<endl;
  else if(M<=1)cout<<combi(N,2)<<endl;
  else cout << combi(N,2)+combi(M,2) << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();
        int f = 0, c = 0;
        Queue<Integer> que = new ArrayDeque<>();
        for (int i = 0; i < s.length(); i++) {
            if (s.substring(i, i + 1).equals("R")) {
                if (f == 1) {
                    f = 0;
                    que.add(c);
                    c = 0;
                }
                c++;
            } else {
                if (f == 0) {
                    f = 1;
                    que.add(c);
                    c = 0;
                }
                c++;
                if (i == s.length() - 1) {
                    que.add(c);
                }
            }
        }
        StringBuilder sb = new StringBuilder();
        while (que.size() > 0) {
            int x = que.poll();
            int y = que.poll();
            if ((x + y) % 2 == 0) {
                for (int i = 0; i < x - 1; i++) {
                    sb.append("0 ");
                }
                sb.append((x + y) / 2);
                sb.append(" ");
                sb.append((x + y) / 2);
                sb.append(" ");
                for (int i = 0; i < y - 1; i++) {
                    sb.append("0 ");
                }
            } else if (x % 2 == 0) {
                for (int i = 0; i < x - 1; i++) {
                    sb.append("0 ");
                }
                sb.append((x + y) / 2);
                sb.append(" ");
                sb.append((x + y) / 2 + 1);
                sb.append(" ");
                for (int i = 0; i < y - 1; i++) {
                    sb.append("0 ");
                }
            } else {
                for (int i = 0; i < x - 1; i++) {
                    sb.append("0 ");
                }
                sb.append((x + y) / 2 + 1);
                sb.append(" ");
                sb.append((x + y) / 2);
                sb.append(" ");
                for (int i = 0; i < y - 1; i++) {
                    sb.append("0 ");
                }
            }
        }
        System.out.println(sb);
    }
}

Measured memory_bytes: 34128
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int length;
string line;
string dp[51][51];


string calc_max(string A,string B){

	if(B == "invalid")return A;
	if(A == "invalid")return B;

	if(A.size() > B.size())return A;
	if(B.size() > A.size())return B;

	int index = 0;

	while(A[index] == B[index]){
		index++;
	}

	if(A[index] > B[index])return A;
	else{
		return B;
	}
}

string make_number(int left,int right) {

	if(left < right && line[left] == '0'){
		return "invalid";
	}

	string ret;

    for(int i = left; i <= right; i++) {
        if(line[i] == 'L' || line[i] == 'R' || line[i] == '(' || line[i] == ')' || line[i] == ',') {
            return "invalid";
        }

        if(line[i] == '?'){
        	ret += '9';
        }else{
        	ret += line[i];
        }
    }
    return ret;
}


string recursive(int left,int right){

	if(left > right)return "invalid";

	if(dp[left][right] != "")return dp[left][right];


	string number = make_number(left,right);
	if(number != "invalid"){
		return dp[left][right] = number;
	}

	if((line[left+1] != '?' && line[left+1] != '(') || (line[right] != '?' && line[right] != ')')) {
		return "invalid";
	}


	vector<int> DIV_POS;

	for(int i = left; i <= right; i++){
		if(line[i] == ',')DIV_POS.push_back(i);
	}

	string ans = "invalid",left_str,right_str;

	for(int div_pos = left+3; div_pos <= right-2; div_pos++){

		if(line[div_pos] != '?' && line[div_pos] != ',')continue;
		if(line[left+1] != '?' && line[left+1] != '(')continue;
		if(line[right] != '?' && line[right] != ')')continue;

		left_str = recursive(left+2,div_pos-1); // LorR(  ,  )
		right_str = recursive(div_pos+1,right-1);

		if(left_str == "invalid" || right_str == "invalid")continue;

		if(line[left] == 'L' || line[left] == '?'){
			ans = calc_max(ans,left_str);
		}

		if(line[left] == 'R' || line[left] == '?'){
			ans = calc_max(ans,right_str);
		}
	}
	return dp[left][right] = ans;
}


int main(){

	getline(cin,line);

	length = line.length();

	for(int left = 0; left < length; left++){
		for(int right = left; right < length; right++)dp[left][right] = "";
	}

	printf("%s\n",recursive(0,length-1).c_str());

	return 0;
}



Measured memory_bytes: 3188
m,d = map(int, input().split())
ans = 0



for i in range(m):
    i += 1
    for j in range(d):
        j += 1
        if j >= 22:
            r = str(j)
            a = int(r[0])
            b = int(r[1])
            if a >= 2 and b >= 2 and a*b == i:
                ans += 1

print(ans) 

Measured memory_bytes: 39280
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
int main(void){
    int a, b;
    cin>>a>>b;
    int d=a/b;
    int r=a%b;
    double f=(double)a/b;
    cout<<d<<' '<<r<<' ';
    cout<<fixed;
    cout<<setprecision(5);
    cout<<f;
    cout<<endl;
}



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

using namespace std;

int main() {
	// your code goes here
	string s; int dem=0;
	cin >> s;
	for (int i=0;i<s.length();i++)
	  if ((i+1)%2==1)
	  	{if (s[i]=='R'||s[i]=='U'||s[i]=='D') dem++;}
	  else {
	  	if (s[i]=='L'||s[i]=='D'||s[i]=='U') dem++;
	  }
	if (dem==s.length()) cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
A, B = map(int, input().split())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt = 0
            while temp%i==0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

from fractions import gcd

g = gcd(A, B)
 
if g == 1:
    print(1)
else:
    l = factorization(g)
    print(len(l)+1)

Measured memory_bytes: 5304
#include<bits/stdc++.h>
#define F first
#define S second
#define eb emplace_back
#define m 1000000007
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n,k,ans;
  cin>>n>>k;
  ans=k*pow(k-1,n-1);
  cout<<ans;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
ll N;
  ll K;
  cin >>N>>K;
  if(N==1) {
    cout<<K<<endl;
  }
 
  
  else {
    ll x=K-1;
    ll ex=K-1;
    repl(i,1,N-1) {
      ex=ex*(K-1);
    }
     //cout<<ex<<endl;
    cout<<ex*K<<endl;
  }
  
}
      
      
 

Measured memory_bytes: 256
N = int(input())
B = list(map(int, input().split()))

stack = []
for i in range(N):
    tmp = []
    flag = True
    for j in range(len(B)):
        if B[j]==j+1:
            tmp.append(j)
    if tmp:
        tmp.sort(reverse=True)
        ans = tmp[0]
        B = B[:ans] + B[ans+1:]
        stack.append(ans+1)
    else:
        flag = False
        break
if flag:
    stack = stack[::-1]
    for i in stack:
        print(i)
else:
    print(-1)

Measured memory_bytes: 3064
import sys
from heapq import heappush, heappop
def input(): return sys.stdin.readline().strip()

N, M = map(int, input().split())
A = []
for i in input().split():
    heappush(A, -1 * int(i))
# print(A)

for _ in range(M):
    val = heappop(A)
    if val == 0:
        break
    heappush(A, (val+1)//2)

print(-1 * sum(A))


Measured memory_bytes: 14180
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[100005] = {0};
void solve() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] == 0) {
			cout << 0;
			return;
		}
	}

	ll ans = 1;
	for (int i = 0; i < n; i++) {
		if (a[i] <= 1000000000000000000 / ans) {
			ans = ans * a[i];
		}
		else {
			cout << -1;
			return;
		}
	}
	cout << ans;

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

	solve();
}

Measured memory_bytes: 4396
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double db;
#define go(u) for(int i = head[u], v = e[i].to; i; i=e[i].lst, v=e[i].to)
#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define pb push_back
#define re(x) memset(x, 0, sizeof x)
inline int gi() {
    int x = 0,f = 1;
    char ch = getchar();
    while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getchar();}
    while(isdigit(ch)) { x = (x << 3) + (x << 1) + ch - 48; ch = getchar();}
    return x * f;
}
template <typename T> inline bool Max(T &a, T b){return a < b ? a = b, 1 : 0;}
template <typename T> inline bool Min(T &a, T b){return a > b ? a = b, 1 : 0;}
const int N = 207;
int n;
int l[N];
int main() {
#ifndef ONLINE_JUDGE
#endif
	n = gi();
	rep(i, 1, n + n) l[i] = gi();
	sort(l + 1, l + 1 + n + n);
	int ans = 0;
	for(int i = n + n - 1; i >= 1; i -= 2) ans += l[i];
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func reverseStr(s string) string {

	runes := []rune(s)

	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}

	return string(runes)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for D - String Formation
	var S string
	fmt.Scan(&S)

	var Q int
	fmt.Scan(&Q)

	var ans [1000000]string
	//ans := make([]string, 0, Q)
	//ans = append(ans, S)
	ans[500000] = S

	sc.Split(bufio.ScanWords)

	var T int
	var F int
	var C string
	var flag int
	var l, m int
	l++
	m++
	for i := 0; i < Q; i++ {
		T = nextInt()
		if T == 1 {
			if flag == 0 {
				flag++
			} else {
				flag--
			}
		} else {
			F, C = nextInt(), nextStr()
			if (F == 1 && flag == 0) || (F == 2 && flag == 1) {
				//temp := make([]string, 0)
				//temp = append(temp, C)
				//ans = append(temp, ans...)
				ans[500000-l] = C
				l++
			} else {
				//ans = append(ans, C)
				ans[500000+m] = C
				m++
			}
		}
	}

	ans2 := make([]string, 0)
	for _, v := range ans {
		if v != "" {
			ans2 = append(ans2, v)
		}
	}

	S = strings.Join(ans2, "")

	if flag == 1 {
		S = reverseStr(S)
	}

	fmt.Println(S)
}


Measured memory_bytes: 40316
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int ans = 0;

		switch (s) {
		case "SUN":
			ans = 7;
			break;
		case "MON":
			ans = 6;
			break;
		case "TUE":
			ans = 5;
			break;
		case "WED":
			ans = 4;
			break;
		case "THU":
			ans = 3;
			break;
		case "FRI":
			ans = 2;
			break;
		case "SAT":
			ans = 1;
			break;
		default:
			ans = 0;
		}

		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 21844
let rs, bs, xys = Scanf.(scanf "%d %d" @@ fun n m -> Array.(make n false, make n 1, init m @@ fun _ -> scanf " %d %d" @@ fun a b -> a - 1, b - 1))
let _ = rs.(0) <- true; Array.(iter (fun (x, y) -> rs.(y) <- rs.(y) || rs.(x); bs.(x) <- bs.(x) - 1; rs.(x) <- rs.(x) && bs.(x) > 0; bs.(y) <- bs.(y) + 1) xys; Printf.printf "%d\n" @@ fold_left (fun c b -> c + if b then 1 else 0) 0 rs)

Measured memory_bytes: 7680
#include<iostream>

using namespace std;

int main() 
{
    char alpha;
    cin >> alpha;

    int a = static_cast<int>(alpha);

    if(a >= 65 && a <= 90)
    {
        cout << "A" << endl;
        return 0;
    }
    else if(a >= 97 && a <= 122)
    {
        cout << "a" << endl;
        return 0;
    }
}

Measured memory_bytes: 3672
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
int main() {
    int S;
    int F,B;
    cin>>S;
    F=S/100;
    B=S%100;
    if(F<13&&F>0){
        if(B<13&&B>0){
            cout<<"AMBIGUOUS"<<endl;
        }else{
            
            cout<<"MMYY"<<endl;
        }
    }else{
        if(B<13&&B>0){
        
            cout<<"YYMM"<<endl;
        }else{

            cout<<"NA"<<endl;
        }
    }
    
}



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

int main(void){
    int n, t, sum = 0;
    scanf("%d", &n);
    set<int> s;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &t);
        if (s.find(t) == s.end()) { s.insert(t); sum++; }
    }
    printf("%d\n", sum);
    return 0;
}



Measured memory_bytes: 7360
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <map>
using namespace std;
typedef long long lint;

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

    int ans=0;
    ans+=(x/500)*1000;
    x%=500;
    ans+=(x/5)*5;

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define PI 3.1415926535897932384626433832795
#define F first
#define S second
#define V vector<ll>
#define ALL(sss) sss.begin(),sss.end()
#define arall(rr,n) rr+0,rr+n 
#define mod 1000000007
#define M 100
#define MAXN 1000000000

 
ll dp[101][100001];
int ans=INT_MAX;
ll n;
using namespace std;


void fileio(){
    #ifndef ONLINE_JUDGE
    freopen("input.in", "r", stdin);
    freopen("output.out", "w", stdout);
    #endif
}

ll fun(ll v[], ll ind, ll w[], ll W){
    
    //if(fl)cout<<ind<<" "<<W<<endl;
    
    if(ind>=n)return 0;
    if(dp[ind][W]!=-1)return dp[ind][W];
    
    ll b=INT_MIN,a=fun(v,ind+1,w,W);
    if(W>=w[ind])
    b=v[ind]+fun(v,ind+1,w,W-w[ind]);

    dp[ind][W]=max(a,b);
   
    return dp[ind][W];
}


int main(){


     fileio();
    
   
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  

    ll T=1,q;
    //cin>>T;
    while(T--){

        ll W;cin>>n>>W;
        ll w[n],v[n],st=0;
        for (int i = 0; i < n; ++i)
        {
            /* code */cin>>w[i]>>v[i];
        }

        memset(dp,-1,sizeof(dp));
        ll ans=fun(v,st,w,W);

     /*   ll dp[n+1][2];
        vector<ll> val(n,0);
        dp[0][0]=0;
        dp[0][1]=max(0,W-w[0]);

        if(w[0]<=W)val[0]=v[0];
        
        for (ll i = 1; i < n; ++i)
        {
            dp[i][0]=
        }
*/
        cout<<ans<<endl;
       // cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});

        // cout<<"Case #"<<q<<": "<<ans<<endl;
    }
    
//prllf("%.9f\n", x);//precision: 9 decimal places.

/*
    GP SUM:(
    (bk)-a)/k-1;//k is ratio and b is final term, a is initial term;

    Comparing two decimal numbers

    if (abs(a-b) < 1e-9) {
        // a and b are equal
    }
*/
    return 0;
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100000010

ll N;
int main()
{
    cin >> N;
    ll ans = 0;
    ll div = 1;
    REP(i, 8) {
        ll tmp = N;
        tmp /= div;
        ans += tmp % 10;
        div *= 10;
    }
    printf("%s\n", (N % ans == 0) ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define enter putchar('\n')
#define space putchar(' ')
#define fi first
#define se second
#define mp make_pair
#define MAXN 100005
//#define ivorysi
#define pii pair<int,int>
using namespace std;
typedef long long int64;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}

template<class T>
void out(T x) {
    if(x < 0) {putchar('-');x = -x;}
    if(x >= 10) out(x / 10);
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int N,M;
int x[MAXN],y[MAXN],tot,v[MAXN],cnt,tr[MAXN],f[MAXN];
pii poi[MAXN];
int lowbit(int x) {
    return x & -x;
}
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b; 
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void Insert(int x,int v) {
    while(x <= cnt) {
	tr[x] = inc(tr[x],v);
	x += lowbit(x);
    }
}
int Query(int x) {
    int res = 0;
    while(x > 0) {
	res = inc(res,tr[x]);
	x -= lowbit(x);
    }
    return res;
}
void Solve() {
    read(N);read(M);
    for(int i = 1 ; i <= N ; ++i) read(x[i]);
    for(int i = 1 ; i <= M ; ++i) read(y[i]);
    int p = 1;
    for(int i = 1 ; i <= N ; ++i) {
	while(p + 1 <= M && y[p + 1] < x[i]) ++p;
	if(p >= M) break;
	if(x[i] > y[p]) poi[++tot] = mp(x[i] - y[p],y[p + 1] - x[i]);
    }
    sort(poi + 1,poi + tot + 1);
    tot = unique(poi + 1,poi + tot + 1) - poi - 1;
    for(int i = 1 ; i <= tot ; ++i) {
	v[++cnt] = poi[i].se;
    }
    v[++cnt] = 0;
    sort(v + 1,v + cnt + 1);
    cnt = unique(v + 1,v + cnt + 1) - v - 1;
    Insert(1,1);
    int ans = 1;p = 0;
    for(int i = 1 ; i <= tot ; ++i) {
	while(p + 1 <= tot && poi[p + 1].fi < poi[i].fi) {
	    ++p;
	    int t = lower_bound(v + 1,v + cnt + 1,poi[p].se) - v;
	    Insert(t,f[p]);
	}
	int t = lower_bound(v + 1,v + cnt + 1,poi[i].se) - v;
	f[i] = Query(t - 1);
	ans = inc(ans,f[i]);
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 2688
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static void AGC011B();

#if 1
int main()
{
	AGC011B();
	fflush(stdout);
	return 0;
}
#endif

class AGC011Bdata {
public:
	LLONG size = 0;
	int color = 0;

	static bool by_size(const AGC011Bdata& a, const AGC011Bdata& b) {
		return a.size < b.size;
	}
};
static void AGC011B()
{
	int N;
	getint(N);

	std::vector<AGC011Bdata> ai(N);
	for (int i = 0; i < N; i++) {
		getint<LLONG>(ai[i].size);
		ai[i].color = i + 1;
	}

	std::sort(ai.begin(), ai.end(), AGC011Bdata::by_size);

	int ngCount = 0;
	LLONG sum = 0;
	for (int i = 0; i < N - 1; i++) {
		sum += ai[i].size;
		if ((sum * 2) < ai[i + 1].size) {
			ngCount = i + 1;
		}
	}
	printf("%d\n", N - ngCount);
}


Measured memory_bytes: 1792
#include <cstdio>  
#include <algorithm>  
using namespace std;  
#define mmax 200000+10  
int a[mmax],b[mmax],x[30][mmax],y[mmax];  
int fun(int k,int n,int v){//二分  
    int l=1,r=n;  
    int h=(l+r)/2;  
    while(l<=r){  
        if(v<=x[k][h]&&x[k][h-1]<v)  
            return h;  
        else if(v<=x[k][h])  
            r=h-1;  
        else if(v>x[k][h])  
            l=h+1;  
        h=(l+r)/2;  
    }  
    return n+1;  
}  
int main() {  
    int n;  
    scanf("%d",&n);  
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);  
    for(int i=1;i<=n;i++) scanf("%d",&b[i]);  
    for(int k=0;k<28;k++){  
        if(k==0)  
            for(int i=1;i<=n;i++) x[k][i]=a[i]&1;//2?0次幂,a[i]最后一位的拆分  
        else  
            for(int i=1;i<=n;i++) x[k][i]=x[k-1][i]^((1<<k)&a[i]);// 取出其a[i]后k位  
    }  
    long long ans=0;  
    for(int k=0;k<28;k++) sort(x[k]+1, x[k]+1+n);  
    for(int k=1;k<=28;k++){  
        for(int i=1;i<=n;i++){  
            y[i]^=(1<<(k-1))&b[i];//取出a[i]后k位  
            //int t=fun(k-1,n,(1<<k)-y[i]);//二分查找会产生进位项的位子,下的low_bound也对  
            int t=int(lower_bound(x[k-1]+1, x[k-1]+1+n, (1<<k)-y[i])-x[k-1]);  
            ans^=(((n-t+1)%2)<<k);//产生进位的异或和  
        }  
    }  
    int q,w,e,r;  
    for(int k=0;k<28;k++){  
        q=w=e=r=0;  
        for(int i=1;i<=n;i++){//算a[i]里的第k位的奇偶数量 0,1  
            if((1<<k)&a[i]) q++;  
            else w++;  
        }  
        for(int i=1;i<=n;i++){//算b[i]里的第k位的奇偶数量 0,1  
            if((1<<k)&b[i]) e++;  
            else r++;  
        }  
        ans^=(((((long long)1)*q*r%2+((long long)1)*w*e%2)%2)<<k);///产生不进位的异或和  
    }  
    printf("%lld\n",ans);  
    return 0;  
}  

Measured memory_bytes: 25984
#include <iostream>
using namespace std;
long long x, y;

void input(){
    cin >> x >> y;
}

int search(){
    int count=0;
    long long i=x;
    while (i<=y){
        count++;
        i*=2;
    }
    return count;
}

int main(){
    input();
    cout << search() << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rc(s) return cout<<s,0
#define pi pair <int, int>
#define sz(x) (int)((x).size())
#define int long long
#define dp down
#define dp1 up

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

const ll inf = 0x3f3f3f3f3f3f3f;
//const ll mod = 1e9 + 7;
const int N = 2e5 + 11;
const int NMAX = 1e4 + 11;
const ll INF64 = 3e18 + 1;
const double lil = 0.0000000000001;

//ifstream cin ("test.in");
//ofstream cout ("test.out");

int n, mod, down[N], up[N];

vector<int>v[N];


void dfs1(int nod, int p){

    ll cur = 1;

    for(auto it : v[nod]){
        if(it == p)continue;
        dfs1(it, nod);
        cur = ((cur*(down[it] + 1))%mod + mod)%mod;
    }

    down[nod] = cur;
}

void dfs2(int nod, int p){

    auto pos = find(all(v[nod]),p);
    if(pos != v[nod].end())v[nod].erase(pos);

    if(sz(v[nod]) >= 1){

        int len = sz(v[nod]);

        vector<int>L(len + 5, 0);
        vector<int>R(len + 5, 0);


        L[0] = 1;
        for(int i = 1; i < len; i++){
            L[i] = L[i - 1]*(down[v[nod][i - 1]] + 1)%mod;
        }

        R[len - 1] = 1;
        for(int i = len - 2; i >= 0; i--){
            R[i] = R[i + 1]*(down[v[nod][i + 1]] + 1)%mod;
        }

        for(int i = 0; i < len; i++){

            int it = v[nod][i];

            up[it] = (up[nod] + 1)*L[i]%mod*R[i]%mod;

            dfs2(it,nod);
        }
    }


}

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

    cin >> n >> mod;

    for(int i = 1,x,y; i < n; i++){
        cin >> x >> y;
        v[x].pb(y);
        v[y].pb(x);
    }

    dfs1(1,0);

    dfs2(1,0);

    for(int i = 1; i <= n; i++){
        cout << ((down[i]*(up[i] + 1))%mod + mod)%mod << '\n';
    }


}


Measured memory_bytes: 26112
#include <stdio.h>

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

    int c = 0;
    for (int x = 0; x <= k; x++) {
        for (int y = 0; y <= k; y++) {
            int z = s - (x + y);
            if (0 <= z && z <= k) {
                c += 1;
            }
        }
    }
    printf("%d\n", c);

    return 0;
}

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

int z(int x)
{
  if(x>=0)
    return x;
  else
    return x*-1;
}

int main()
{
  int n,ans;
  cin>>n;
  ans=10000000;
  vector<int> w(n);
  for(int i=0;i<n;i++)
  {
    cin>>w.at(i);
  }
  for(int i=0;i<n;i++)
  {
    int a,b,c;
    a=0;
    b=0;
    for(int j=0;j<n;j++)
    {
      if(j<=i)
        a+=w.at(j);
      else
        b+=w.at(j);
    }
    c=z(a-b);
    ans=min(ans,c);
  }
  cout<<ans<<endl;
}

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

int main() {
	// your code goes here
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	double c=0;
	ll n,p=0,a[101];
	cin>>n;
	for(int i=0;i<n;i++)
	{
	    cin>>a[i];
	    c+=a[i];
	}
	c/=(double)n;
	if(c-floor(c)<=ceil(c)-c)
	c=floor(c);
	else
	c=ceil(c);
	for(int i=0;i<n;i++)
	{
	    p+=abs(a[i]-c)*abs(a[i]-c);
	}
	cout<<p;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

/*
ll ncr(ll n, ll r){
  if(r>n)return 0;
  if(r*2>n) r=n-r;
  if(r==0) return 1;
  ll res = n;
  for(ll i=2;i<=r;i++){
    res *= (n-i+1);
    res /=i;
  }
  return res;
}

int main(){
  int N;
  cin >> N;
  vector<string> S(N);
  rep(i,N) cin >> S[i];
  rep(i,N) sort(S[i].begin(), S[i].end());
  sort(S.begin(), S.end());
  ll ans = 0;
  vector<ll> counter;
  int tmp=1;
  for(int i=1;i<N;i++){
    if(S[i-1]==S[i]) {
      tmp++;
      if(i==N-1) counter.pb(tmp);
    }
    else {counter.pb(tmp); tmp=1;}
  }
  for(int i=0;i<(int)counter.size();i++){
    ans += ncr(counter[i],2);
  }
  cout << ans << endl;
  return 0;
}
*/

int main(){
  ll N;
  cin >> N;
  vector<string> S(N);
  unordered_map<string,int> mp;
  rep(i,N) cin >> S[i];
  rep(i,N){
    sort(S[i].begin(), S[i].end());
    mp[S[i]]++;
  }
  ll ans = 0;
  for(auto x:mp){
    ans += (ll)x.second*(x.second-1)/2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 17700
{-# LANGUAGE BangPatterns #-}

import qualified Data.List as L

import Control.Applicative
import Control.Monad       (replicateM)

main :: IO ()
main = do
    [n, k] <- getSeq
    ps     <- replicateM n getLine
    print $ solve k ps

solve :: Int -> [String] -> Int
solve k ps = inner bag id
  where
    bag = fmap L.length . L.group . L.sort $ L.head <$> ps
    inner :: [Int] -> (Int -> Int) -> Int
    inner !bag cont
        | r /= 0    = cont 0
        | otherwise = inner xs (cont . succ)
      where
        (r, xs) = L.foldr f (k, []) $ L.sort bag
        f x (k, !xs)
          | k == 0    = (     0,      x : xs)
          | x == 1    = (pred k,          xs)
          | otherwise = (pred k, pred x : xs)

getSeq  = map read . words <$> getLine


Measured memory_bytes: 7548
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[5];
        for (int i = 0; i < 5; i++) {
            a[i] = sc.nextInt();
        }
        sc.close();

        int ans = 0;
        for (int i = 0; i < 5; i++) {
            int tmp = (a[i] / 10) * 10;
            if (a[i] % 10 != 0) {
                tmp += 10;
            }
//            System.out.println(tmp);
            ans += tmp;
        }
//        System.out.println(ans);

        int diff = 0;
        for (int i = 0; i < 5; i++) {
            if (a[i] % 10 != 0) {
                int tmp = 10 - (a[i] % 10);
                if (tmp > diff) {
                    diff = tmp;
                }
            }
        }

        ans -= diff;
        System.out.println(ans);
    }

}


Measured memory_bytes: 21844
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n, m, d = map(int, input().split())
    if d == 0:
        print((m - 1) / n)
    else:
        print(2 * (m - 1) * (n - d) / (n * n))
resolve()

Measured memory_bytes: 61824
a, b =map(int, input().split())
#A^2 -2AK-K^2=B^2 -2BK -K^2
#A^2-B^2=2(A-B)K

c = (a**2 -b**2)/(2*(a-b))
if c-int(c)!=0:
  print("IMPOSSIBLE")
else:
  print(int(c))

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

int main(){

  int n;

  cin >> n;

  while(n--){
    int y, m, d, ans = 0;
    cin >> y >> m >> d;
    if(y % 3 == 0){
      ans += 20 - d + 1 + 20 * (10 - m);
    }else{
      if(m % 2 == 0){
        ans += 19 - d + 1 + 39 * (5 - m/2);
      }else{
        ans += 20 - d + 1 + 19 + 39 * (4 - m/2);
      }
    }
    for(int i = y+1; i < 1000; i++){
      if(i % 3 == 0){
        ans += 200;
      }else{
        ans += 195;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3076
N, M = map(int, input().split())
S = [int(i) for i in input().split()]+['g']
T = [int(i) for i in input().split()]+['a']

MOD = 10 ** 9 + 7

dp = [[0] * (M + 1) for _ in range(N + 1)]

for i in range(N + 1) :
    dp[i][0] = 1
for i in range(M + 1) :
    dp[0][i] = 1

for i in range(1, N + 1) :
    for j in range(1, M + 1) :
        
        if S[i-1] == T[j-1] :
            dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD
        else :
            dp[i][j] = (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]) % MOD

print(dp[N][M])

Measured memory_bytes: 73052
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(cnt); ++(var))
#define REP(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define all(v) (v).begin(),(v).end()
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<ll,ll>;

int main(void){
  int N; cin>>N;
  string S1,S2; cin>>S1>>S2;
  vector<int> shape;
  rep(i,N){
    if(i!=N-1){
      if(S1[i]==S1[i+1]){
        shape.emplace_back(1);
        ++i;
      }
      else{
        shape.emplace_back(0);
      }
    }
    else{
      if(S1[i-1]!=S1[i]) shape.emplace_back(0);
    }
  }
  //for(auto &e:shape) cout<<e;
  //cout<<endl;

  ll ans;
  ll MOD=1e9+7;
  if(shape[0]==0) ans=3;
  else ans=6;
  REP(i,1,shape.size()){
    //cout<<ans<<" ";
    if(shape[i-1]==0){
      if(shape[i]==0){
        ans=ans*2%MOD;
      }
      else{
        ans=ans*2%MOD;
      }
    }
    else{
      if(shape[i]==1){
        ans=ans*3%MOD;
      }
    }
  }
  //cout<<endl;
  if(ans<0) ans+=MOD;
  cout<<ans%MOD<<endl;
}

Measured memory_bytes: 256
n=int(input())
l6=[]
l9=[]
num6=6
num9=9
while num6<=n:
  l6.append(num6)
  num6*=6
while num9<=n:
  l9.append(num9)
  num9*=9
count=[0,1,2,3,4,5,1,2,3,1,2,3]
for i in range(12,n+1):
  min=100000
  for j in l6:
    if i-j<0:
      pass
    else:
      if min>count[i-j]+1:
        min=count[i-j]+1
  for j in l9:
    if i-j<0:
      pass
    else:
      if min>count[i-j]+1:
        min=count[i-j]+1
  count.append(min)
print(count[n])

Measured memory_bytes: 3956
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const int INF = INT_MAX / 2;

class Edge
{
public:
    int to, cost;
    Edge(){};
    Edge(int to0, int cost0){to = to0; cost = cost0;}
};

int main()
{
    for(;;){
        int n, m;
        cin >> n >> m;
        if(n == 0)
            return 0;

        map<string, int> index;
        vector<int> x(n), y(n);
        for(int i=0; i<n; ++i){
            string s;
            cin >> s >> x[i] >> y[i];
            index[s] = i;
        }

        vector<vector<Edge> > edges(n, vector<Edge>(4, Edge(-1, -1)));
        for(int i=0; i<m; ++i){
            string s, t;
            cin >> s >> t;
            int a = index[s];
            int b = index[t];
            int d;
            if(x[b] > x[a])
                d = 0;
            else if(y[b] < y[a])
                d = 1;
            else if(x[b] < x[a])
                d = 2;
            else
                d = 3;
            edges[a][d] = Edge(b, abs(x[a] - x[b]) + abs(y[a] - y[b]));
            edges[b][(d+2)%4] = Edge(a, abs(x[a] - x[b]) + abs(y[a] - y[b]));
        }

        string startName, goalName;
        cin >> startName >> goalName;
        int start = index[startName];
        int goal = index[goalName];

        vector<vector<pair<int, int> > > dp(n, vector<pair<int, int> >(4, make_pair(INF, INF)));
        multimap<pair<int, int>, pair<int, int> > mm;
        for(int i=0; i<4; ++i){
            dp[start][i] = make_pair(0, 1);
            mm.insert(make_pair(make_pair(0, 1), make_pair(start, i)));
        }

        while(!mm.empty()){
            pair<int, int> cost = mm.begin()->first;
            int pos = mm.begin()->second.first;
            int d = mm.begin()->second.second;
            mm.erase(mm.begin());
            if(cost > dp[pos][d])
                continue;

            for(int i=0; i<2; ++i){
                int d2 = (d + 4 - i) % 4;
                pair<int, int> cost2(cost.first + edges[pos][d2].cost, cost.second + 1);
                int next = edges[pos][d2].to;
                if(next == -1)
                    continue;

                if(cost2 < dp[next][d2]){
                    dp[next][d2] = cost2;
                    mm.insert(make_pair(cost2, make_pair(next, d2)));
                }
            }
        }

        pair<int, int> ret(INF, INF);
        for(int i=0; i<4; ++i)
            ret = min(ret, dp[goal][i]);
        if(ret.first == INF)
            cout << "impossible" << endl;
        else
            cout << ret.second << endl;
    }
}

Measured memory_bytes: 1516
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;
int arr[105];
int main()
{
	int n, x; scanf("%d %d", &n, &x);
	for(int i = 1; i<= n; i++) scanf("%d", arr+i);
	sort(arr+1, arr+n+1);
	int res = 0;
	for(int i = 1; i<= n; i++)
	{
		if(i == n)
		{
			if(x == arr[i]) res++;
		}
		else if(x>= arr[i])
		{
			res++; x -= arr[i];
		}
	}
	printf("%d\n", res);
}

Measured memory_bytes: 256
#include<stdio.h>
 int main()
{
    double D,T,S,a;
    scanf("%lf%lf%lf",&D ,&T ,&S);
    a=D/S;
    if(a<=T){
        printf("Yes\n");
    }
    else{
        printf("No\n");}
    return 0;
}


Measured memory_bytes: 1716
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = LLONG_MAX;
/* テンプレートここまで */

int main() {
  ll N, x; cin >> N >> x;
  vector<ll> a(N);
  ll ans = 0;
  REP(i, N) cin >> a[i];

  REP(i, N-1){
    ll diff = max(a[i+1] + a[i] - x, 0LL);
    a[i+1] -= diff;
    ans += diff;
    if(a[i+1] < 0) a[i+1] = 0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

#define MAXN 1000005 
   
int spf[MAXN]; 
  
int hash1[MAXN] = { 0 }; 
  
void sieve() { 
    spf[1] = 1; 
    for (int i = 2; i < MAXN; i++) 
        spf[i] = i; 
  
    for (int i = 4; i < MAXN; i += 2) 
        spf[i] = 2; 
  
    for (int i = 3; i * i < MAXN; i++) { 
        if (spf[i] == i) { 
            for (int j = i * i; j < MAXN; j += i) 
                if (spf[j] == j) 
                    spf[j] = i; 
        } 
    } 
} 
  
void getFactorization(int x) { 
    int temp; 
    while (x != 1) { 
        temp = spf[x]; 
        if (x % temp == 0) { 
            hash1[spf[x]]++; 
            x = x / spf[x]; 
        } 
        while (x % temp == 0) 
            x = x / temp; 
    } 
} 

bool check(int x) { 
    int temp; 
    while (x != 1) { 
        temp = spf[x]; 
        if (x % temp == 0 && hash1[temp] > 1) 
            return false; 
        while (x % temp == 0) 
            x = x / temp; 
    } 
    return true; 
} 

bool hasValidNum(int arr[], int n) {    
    sieve(); 
  
    for (int i = 0; i < n; i++) 
        getFactorization(arr[i]); 

    bool ok = true;
    for (int i = 0; i < n; i++) 
        ok &= check(arr[i]) ;
    return ok; 
} 

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int n;
        cin >> n;
        int g = 0;
        int a[n];
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            g = __gcd(g, a[i]);
        }

        bool ok = hasValidNum(a, n);

        if (ok)
            cout << "pairwise coprime\n";
        else if (g == 1)
            cout << "setwise coprime\n";
        else
            cout << "not coprime\n";

    }
    
    return 0;
}



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

int main(){
	int n;
	int ary[] = { 512, 256, 128, 64, 32, 16, 8, 4, 2, 1 };

	while (cin >> n){
		vector<int> v;
		for (int i = 0; i < 10; i++){
			if (n >= ary[i]){
				n -= ary[i];
				v.push_back(ary[i]);
			}
		}
		for (auto i = v.rbegin(); i < v.rend(); i++){
			if (i != v.rbegin()) cout << " ";
			cout << *i;
		}
		cout << endl;
		n = 0;
	}
	return 0;
}

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

int main() {
  int n;cin>>n;
  vector<int> a(n),b(n);
  rep(i,n){
    cin>>a[i];
    b[i]=a[i];
  }
  sort(all(b));
  rep(i,n){
    if(a[i]==b[n-1])cout<<b[n-2]<<endl;
    else cout<<b[n-1]<<endl;
  }
}

Measured memory_bytes: 4748
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm> // sort
#include <iomanip>
#include <queue>
#include <map>
#include <bits/stdc++.h>

using namespace std;

#define DEBUG 0
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll INF = 1000000000000000000LL;
typedef pair<int,int> pint;

const int MOD = 1000000007;

//ボタンBを押すタイミングを場合わけ
//最初にボタンBを押す/押さない
//最後にボタンBを押す/押さない (yを反転させる)
int main(){

#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll x,y;
    cin >> x >> y;
    ll tmp = 0;
    ll res = INF;

    //最初にボタンを押さない最後にボタンを押さない
    tmp += y - x;
    if(tmp >= 0)res = min(res,tmp);
    //最初にボタンを押す最後にボタンを押さない
    tmp = 0;
    tmp += y - (-x);
    ++tmp;
    if(tmp >= 0)res = min(res,tmp);

    //最初にボタンを押さない最後にボタンを押す
    tmp = 0;
    tmp += (-y) - x;
    ++tmp;
    if(tmp >= 0)res = min(res,tmp);

    //最初にボタンを押す最後にボタンを押す
    tmp = 0;
    tmp += (-y) - (-x);
    tmp += 2;
    if(tmp >= 0)res = min(res,tmp);

    cout << res << endl;

    return 0;     
}



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

int main() {
  int N,p=1;
  cin >> N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec.at(i);
  }
  
  for(int i=0;i<N;i++){
    if(vec.at(i) % 2){
      continue;
    }else if(!(vec.at(i) % 15)){
      continue;
    }else if(vec.at(i) % 3 && vec.at(i) % 5){
      p=0;
      break;
    }else{
      continue;
    }
  }
  if(p){
    cout << "APPROVED" << endl;
  }else{
    cout << "DENIED" << endl;
  }
}


Measured memory_bytes: 256
/* 
   AOJ 2149
   Luck Manipulator
   2015.4.26
 */

#include<stdio.h>

int calc(int reel, int a, int b, int c, int init_random)
{
  int i, total_flames, random_num = init_random, target_number[100] = {0};


  for(i = 0; i < reel; i++)
    {
      scanf("%d", &target_number[i]);

    }

  for(total_flames = 0, i = 0; ; random_num = (a * random_num + b) % c, total_flames++)
    {
      if(random_num == target_number[i])
	{
	  i++;
	}

      if(total_flames > 10000 || i >= reel)
	{
	  break;
	}
    }

  if(total_flames > 10000)
    {
      return -1;
    }

  return total_flames;
}

int main(void)
{
  int n, a, b, c, x, flames;
  
  while(1)
    {
      scanf("%d %d %d %d %d", &n, &a, &b, &c, &x);
      if(n == 0 && a == 0 && b == 0 && c == 0 && x == 0)
	{
	  break;
	}
      
      flames = calc(n, a, b, c, x);
      printf("%d\n", flames);
      
    }
  return 0;
}

Measured memory_bytes: 600
fn rec(v: usize, used: &mut Vec<bool>, graph: &Vec<Vec<usize>>) -> u64 {
    used[v] = true;
    let n = graph.len();
    let goal = used.iter().all(|&x| x);
    let next: Vec<&usize> = graph[v].iter().filter(|&&x| !used[x]).collect();
    //println!("{:?} {:?} {:?}", v, used, goal);
    let res = match goal {
        true => 1,
        false => next.iter().map(|&&x| rec(x, used, graph)).sum()
    };
    used[v] = false;
    res
}

fn main() {
    let (n, m): (usize, usize) = readln();
    let mut g = vec![vec![]; n];
    for _ in 0..m {
        let (a_, b_): (usize, usize) = readln();
        let (a, b) = (a_-1, b_-1);
        g[a].push(b);
        g[b].push(a);
    }
    let mut used = vec![false; n];
    let ans: u64 = rec(0, &mut used, &g);
    println!("{}", ans);
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashSet;

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n { vs.push(readln()); }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(String, bool, f32, f64, isize, i8, i16, i32, i64, usize, u8, u16, u32, u64);
impl<T> FromLn for Vec<T> where T: FromLn {
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);

Measured memory_bytes: 4352
use std::cmp::*;

fn main() {
    let v = read_vec::<i64>();
    let (n, x) = (v[0] as usize, v[1]);
    let a = read_vec::<i64>();
    let mut range_min = vec![vec![0; n]; n];
    for i in 0..n {
        range_min[0][i] = a[i];
        for j in 1..n {
            let idx = (n + i - j) % n;
            range_min[j][i] = min(a[idx], range_min[j - 1][i]);
        }
    }
    let mut ans = a.iter().sum::<i64>();
    for i in 1..n {
        let temp = x * (i as i64) + range_min[i].iter().sum::<i64>();
        ans = min(temp, ans);
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 45308
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>

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

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<P, int> PP;
struct edge{ int to, time, cost; };
const double esp = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+17 + 10;

int n, m;
std::vector<int> g[100001];
std::vector<int> l;
int used[100001];
bool isClose = false;

//??????????????????
void topologicalSort(int n){
	if (used[n] == 1){
		isClose = true;
		return;
	}
	else if (!used[n]){
		used[n] = 1;
		rep(i, g[n].size())topologicalSort(g[n][i]);
		l.push_back(n);
		used[n] = 2;
	}
}

int main(){
	std::cin >> n >> m;
	rep(i, m){
		int a, b;
		std::cin >> a >> b;
		g[a].push_back(b);
	}

	rep(i, n)if (!used[i])topologicalSort(i);
	std::reverse(l.begin(), l.end());
	rep(i, l.size())std::cout << l[i] << std::endl;;
	return 0;
}

Measured memory_bytes: 4100
#include <iostream>
#include <vector>
using namespace std;
int main(void){
	int a,b,count;
	char c;
	cin >> a >> b;
	vector< vector<int> > v(a+2,vector<int>(b+2));
	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			cin >> c;
			if(c=='#'){
			    v[i+1][j+1]=-1;
			}
			else{
			     v[i+1][j+1]=0;
			}
		}
		getchar();
	}
	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
		    count=0;
		    if(v[i][j]==-1){
		        count++;
		    }
		    if(v[i][j+1]==-1){
		        count++;
		    }
		    if(v[i+1][j]==-1){
		        count++;
		    }
		    if(v[i+2][j+1]==-1){
		        count++;
		    }
		    if(v[i+1][j+2]==-1){
		        count++;
		    }
		    if(v[i+2][j+2]==-1){
		        count++;
		    }
		    if(v[i][j+2]==-1){
		        count++;
		    }
		    if(v[i+2][j]==-1){
		        count++;
		    }
		    if(v[i+1][j+1]==-1){
		        cout << "#";
		    }
		    else{
		        cout << count;
		    }
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}


int main() {
    int n, k; cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h[i];

    int ans = 0;
    rep(i, n) if (h[i] >= k) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-

N = int(input())

A = []
A.append([0] * (N + 1))
A.append([0] + [int(a) for a in input().split(" ")])
A.append([0] + [int(a) for a in input().split(" ")])

C = A.copy()

for i in range(1, 3):
    for j in range(1, N + 1):
        C[i][j] += max(C[i - 1][j], C[i][j - 1])

print(C[2][N])


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

std::string str;

int main() {
	std::cin >> str;
	char yaki[4] = { 'Y','A','K','I' };
	for (int i = 0; i < 4; i++) {
		if (str[i] != yaki[i]) {
			std::cout << "No" << std::endl;
			return 0;
		}
	}
	std::cout << "Yes" << std::endl;
	return 0;
}

Measured memory_bytes: 256