akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque

def run():
    A,B = map(int, sysread().split())
    K = math.gcd(A,B)
    factorials = []
    L = int(max(A,B)**0.5)
    for i in range(2, L+1):
        done = False
        limit = int(i ** 0.5)
        for j in factorials:
            if j > limit:break
            if not i % j:
                done = True
                break
        if not done:
            factorials.append(i)

    factors = [1]
    for f in factorials:
        if f > K:break
        if not K % f:
            factors.append(f)
            while not K % f:
                K = K // f

    if K != 1:
        factors.append(K)
    print(len(factors))


    #print(factorials)
if __name__ == "__main__":
    run()

Measured memory_bytes: 76924
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds ;
#define ll long long
#define pp pair<ll,ll>
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define sz(a) int((a).size())
#define present(c,x) ((c).find(x) != (c).end())
#define mp make_pair
#define hell 1000000007
#define F first
#define S second
#define sll(x) scanf("%lld",&x)
#define si(x) scanf("%d",&x)
typedef tree<pp , null_type , less<pp> , rb_tree_tag , tree_order_statistics_node_update > ordered_set ;
ll t=1 ;
void solve()
{
    ll x , y ;
    cin >> x >> y ;
    cout << x + ( y / 2 ) ;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //cin>>t;
    while(t--)
        solve() ;
    return 0 ;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def prime_factorize(n, ex_table):
    for i in range(2, int(n**0.5)+1):
        if n % i != 0:continue
        while n % i == 0:
            ex_table[i] += 1
            n = n//i
    if n != 1:ex_table[n] += 1
def main():
    N = int(input())
    ex_table = {i:0 for i in range(2, N+1)}
    for i in range(1, N+1):
        prime_factorize(i, ex_table)
    ans = 1
    MOD = 10 ** 9 + 7
    for k in ex_table:
        ans *= (ex_table[k] + 1)
        ans %= MOD
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 39280
#include <iostream>

using namespace std;

int main() {

	int A, B, C;
	int sum=0;

	cin >> A >> B >> C;

	sum = A + B;
	 
	if (sum - C >= 0) {

		cout << "Yes" << endl;

	}

	else {

		cout << "No" << endl;

	}

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,ans,maxn;
char s;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        if(s=='I')ans++;else ans--;
        maxn=max(maxn,ans);
    }
    cout<<maxn<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}

int main(void){
	int x=in(),y=in(),z=in(),ans=1;
	while(x>=(y*(ans+1)+z*(2+ans)))ans++;
	print(ans);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#define ABS(a) ((a)>(0)?(a):-(a))
long long min(long long a, long long b){ return a > b ? b : a; }

long long rec(long long i, long long *H, long long *memo){
    if (i == 0)  return 0; 
    if (i - 2 < 0) return ABS(H[i - 1] - H[i]);
    if (memo[i] != -1) return memo[i];
    long long ret =  min( rec(i - 1,H, memo) + ABS(H[i - 1] - H[i]),
                     rec(i - 2,H,memo) + ABS(H[i - 2] - H[i]) );
    return memo[i] = ret;
}

int main(void){
    long long N;
    long long H[100000];
    long long memo[100000];
    scanf("%lld", &N);
    for (long long  i = 0; i < N; i++) memo[i] = -1;
    for (long long i = 0; i < N; i++) scanf("%lld", &H[i]);
    long long ans = rec(N - 1,H, memo);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 5632
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double PI = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n, y;
	cin >> n >> y;
	if (10000 * n < y) {
		//ok1
		cout << "-1 -1 -1" << endl;
		return 0;
	}
	//cout << y << endl;
	for (int i = 0; i < n+1; i++) {
		for (int j = 0; j < n+1; j++) {
			//cout << 10000 * i + 5000 * j + 1000 * (n - i - j) << endl;
			if ((10000 * i + 5000 * j + 1000 * (n - i - j)) == y && (n - i - j) > -1) {
				cout << i << " " << j << " " << (n - i - j) << endl;
				return 0;
			}
		}
	}
	//cout << 10000 * n;
	cout << "-1 -1 -1" << endl;
	return 0;
}

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

int n;
int a[200005];
long long ans;

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	for (int i = 1; i < n; i++) {
		if (a[i] < a[i - 1]) {
			ans += a[i - 1] - a[i];
			a[i] = a[i - 1];
		}
	}
	printf("%lld\n", ans);
}


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

int main(){
  int i,j,count=0,countsum=0,ans=0,n,q,a,b;
  cin >> n >> q;
  char  c[n];
  for(i=0;i<n;i++){
    cin >> c[i];
  }
  int acnum[n];
  acnum[0]=0;
  for(i=0;i<n;i++){
    if(c[i] == 'A' && c[i+1] == 'C'){
      count++;
    }
    acnum[i+1] = acnum[i] + count;
    //cout << "acnum[" << i << "]" <<acnum[i] << endl;
    count = 0; 
  }
  for(i=0;i<q;i++){
    cin >> a >> b;
    cout << (acnum[b-1] - acnum[a-1]) << endl;
    }
  return 0;
}

Measured memory_bytes: 1280
N = int(input())
F=[]
for _ in range(N):
    F.append(int(''.join(input().split()), 2))
P=[]
for _ in range(N):
    P.append(list(map(int, input().split())))
#print(N)
#print(list(map(bin, F)))
#print(P)

profit_list=[]
for i in range(1, 2 ** 10):
    profit=0
    for k in range(N):
        kaburi = i & F[k]
        #print(bin(i), bin(F[k]), bin(kaburi))
        kaburi_count=0
        for j in range(10):
            if ((kaburi >> j) & 1):
                kaburi_count+=1
        profit+=P[k][kaburi_count]
    profit_list.append(profit)
#print(profit_list)
print(max(profit_list))


Measured memory_bytes: 42092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using piii = pair<int, pair<int, int>>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

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

    int N, Ma, Mb;
    cin >> N >> Ma >> Mb;
    vector<vector<int>> dp(405, vector<int>(405, 1e9));
    dp[0][0] = 0;
    for (int i = 0; i < N; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        for (int j = 400; j >= a; --j)
            for (int k = 400; k >= b; --k)
                dp[j][k] = min(dp[j][k], dp[j - a][k - b] + c);
    }

    int ans = 1e9;
    for (int i = 1; i * max(Ma, Mb) <= 400; ++i)
        ans = min(ans, dp[i * Ma][i * Mb]);

    cout << (ans < 1e9 ? ans : -1) << endl;
    return 0;
}


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

int main()
{
  int n;
  cin>>n;
  int r=n%10;
  if(r==2||r==4||r==5||r==7||r==9)
    cout<<"hon"<<endl;
  else if(r==0||r==1||r==6||r==8)
    cout<<"pon"<<endl;
  else
    cout<<"bon"<<endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int inf = 1001001001;
 
int main(){

    string S;
    cin >> S;
    ll flaga=0;
    ll flagb=0;
    ll a=S.at(0)-'0';
    ll b=S.at(1)-'0';
    ll c=S.at(2)-'0';
    ll d=S.at(3)-'0';
    ll e=10*a+b;
    ll f=10*c+d;
    if(e<=12 && 1<=e) flaga=1;
    if(f<=12 && 1<=f) flagb=1;
    if(flaga==1 && flagb==1) cout << "AMBIGUOUS" << endl;
    else if(flaga==1) cout << "MMYY" << endl;
    else if(flagb==1) cout << "YYMM" << endl;
    else{
        cout << "NA" << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static java.lang.System.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		C(sc);
	}
	
	public static void A(Scanner sc) {
		int m = sc.nextInt();
		out.println(24-m+24);
	}
	
	public static void B(Scanner sc) {
		int a = sc.nextInt();
		int b = sc.nextInt();
		String s = sc.next();
		Pattern p = Pattern.compile("[0-9]{"+ a + "}-[0-9]{" + b + "}");
		Matcher m = p.matcher(s);
		if(m.find()) out.println("Yes");
		else out.println("No");
	}
	
	// t+e%f == 0 満たす最初のe>0を求め、eを返す
	public static int rete(int t, int f) {
		return (int)Math.ceil(t/(double)f)*f - t;
	}
	
	//受け取ったi -> Nの所要時間を返す
	public static int calctime(int i, int[] S, int[] F, int[] C) {
		if(i==S.length) return 0;
		int t = S[i]+C[i];
		for(int j=i+1;j<S.length;j++) {
			if(t<=S[j]) t+=(S[j]-t)+C[j];
			else t+=rete(t,F[j])+C[j];
		}
		return t;
	}
	
	public static void C(Scanner sc) {
		int N = sc.nextInt();
		int[] C = new int[N-1];
		int[] S = new int[N-1];
		int[] F = new int[N-1];
		for(int i=0;i<N-1;i++) {
			C[i] = sc.nextInt();
			S[i] = sc.nextInt();
			F[i] = sc.nextInt();
		}
		for(int i=0;i<N;i++) {
			out.println(calctime(i,S,F,C));
		}
	}
}


Measured memory_bytes: 26516
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long N; cin >> N;
    long double R = sqrtl((double)N);
    long long rout = (int)R;
    for (int i=rout;i>0;i--){
        long long a = N/i;
        if (N == i*a){
            cout << a+i-2 <<"\n";
            break;
        }
    }
}

Measured memory_bytes: 256
def calc(A, B, C, X):
    return (A * X + B) % C


while True:
    N, A, B, C, X = map(int, input().split())
    if N == 0 and A == 0 and B == 0 and C == 0 and X == 0:
        break
    Y = list(map(int, input().split()))
    flame = 0
    while True:
        if flame > 10000:
            print(-1)
            break
        elif X == Y[0]:
            del Y[0]
            if len(Y) == 0:
                print(flame)
                break
        X = calc(A, B, C, X)
        flame += 1


Measured memory_bytes: 5612
using System;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        string[] inputnm = Console.ReadLine().Split(' '); 
 int A = int.Parse(inputnm[0]);
        int P = int.Parse(inputnm[1]);

        int ans = (3 * A + P) / 2;
        Console.WriteLine(ans);
    }
}


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

string rev(string s) {
    string ret = "";
    for (int i=0; i<(int)s.size(); ++i) {
        ret = s[i] + ret;
    }
    return ret;
}

int main() {
    int m;
    cin >> m;
    while (m--) {
        string s; cin >> s;
        set<string> st;
        st.insert(s);
        for (int i=1; i<(int)s.size(); ++i) {
            st.insert(rev(s.substr(0,i)) + s.substr(i));
            st.insert(s.substr(0,i) + rev(s.substr(i)));
            st.insert(rev(s.substr(0,i)) + rev(s.substr(i)));
            st.insert(s.substr(i) + s.substr(0,i));
            st.insert(rev(s.substr(i)) + s.substr(0,i));
            st.insert(s.substr(i) + rev(s.substr(0,i)));
            st.insert(rev(s.substr(i)) + rev(s.substr(0,i)));
        }
        cout << st.size() << endl;
    }
    return 0;
}

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


int main(){
    ll n,a=0,b=0; cin >> n;
    vector<int>x(n);
    rep(i,n) cin >> x.at(i);
    rep(i,n-1){
        if(x[i]>=x[i+1]){
            b++;
            a=max(a,b);
        }
        else
        {
            b=0;
        }
        
    }
    cout << a << endl;
  }


Measured memory_bytes: 640
N = int(input())
A = list(map(int,input().split()))
tot = 0
for i in range(N):
    tot += abs(A[i])
if A.count(0)>0:
    print(tot)
else:
    cur = 0
    cnt = 0
    for i in range(N):
        if A[i]>0:
            c = i-cur
            if c%2==1:
                cnt += 1
            cur =i+1
    if A[-1]<0:
        c = N-cur
        if c%2==1:
            cnt += 1
    if cnt%2==0:
        print(tot)
    else:
        cmin = 10**10
        for i in range(N):
            cmin = min(cmin,abs(A[i]))
        print(tot-2*cmin)

Measured memory_bytes: 14412
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
#include <bitset>

int bit_count(int n) {
	return n == 0 ? 0 : (n & 1) + bit_count(n >> 1);
}
int main() {
	while (true) {
		int n, m; std::cin >> n >> m; if (n == 0) break;
		std::vector<std::string> state(n); for (auto& line : state) std::cin >> line;
		if (n < m) {
			int max = 0;
			std::vector<bool> is_rest(m);
			for (auto i = 1; i < (1 << n); ++i) {
				const int bit = bit_count(i);
				if (bit > max) {
					std::fill(is_rest.begin(), is_rest.end(), false);
					for (auto j = 0; j < n; ++j) if ((i & (1 << j)) != 0) {
						for (auto k = 0; k < m; ++k) if (state[j][k] == '1') {
							is_rest[k] = !is_rest[k];
						}
					}
					if (std::all_of(is_rest.begin(), is_rest.end(), [](bool b) {return !b; })) {
						max = bit;
					}
				}
			}
			std::cout << max << std::endl;
		}
		else {
			std::vector<std::vector<short>> max(n + 1, std::vector<short>(1 << m, -1));
			max[0][0] = 0;
			for (auto i = 0; i < n; ++i) {
				int bit = 0;
				for (auto j = 0; j < m; ++j) {
					bit = (bit << 1) + state[i][j] - '0';
				}
				for (auto j = 0; j < (1 << m); ++j) if (max[i][j] >= 0) {
					max[i + 1][j] = std::max(max[i + 1][j], max[i][j]);
					max[i + 1][j ^ bit] = std::max(max[i + 1][j ^ bit], static_cast<short>(max[i][j] + 1));
				}
			}
			std::cout << max.back().front() << std::endl;
		}
	}
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N,M;
vector<double> dp,dp2;
vector<ll> stv[666],rstv[666];
ll i, j, k;
double ans;



void dpsolve(vector<double>& dp,pll stp){
    ll i, j;
    for (i = N; i > 0; i--)
    {
        if(stv[i].size()){
            dp[i] /= (stv[i].size()-(stp.first==i));
        }
        fornum(j,0,rstv[i].size()){
            if(stp.first!=rstv[i][j]||stp.second!=i)
                dp[rstv[i][j]] += dp[i] + 1;
        }
    }
}

int main(){
    scanf("%lld%lld",&N,&M);
    fornum(i,0,M){
        ll s, t;
        scanf("%lld%lld", &s,&t);
        stv[s].push_back(t);
        rstv[t].push_back(s);
    }
    dp.assign(N + 1, 0);
    dpsolve(dp, {0, 0});
    ans = dp[1];
    fornum(i,1,N){
        if(stv[i].size()<=1)
            continue;
        ll a = stv[i][0];
        fornum(j,1,stv[i].size()){
            if(dp[a]<dp[stv[i][j]])
                a = stv[i][j];
        }
        dp2.assign(N + 1, 0);
        dpsolve(dp2, {i, a});
        ans = min(ans, dp2[1]);
    }
    printf("%.12lf", ans);

    return 0;
}

Measured memory_bytes: 4864
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;


int main(){

  string s;
  cin >> s;
  
  ll sum[26] = {};
  REP(i,s.size())
    sum[s[i]-'a']++;
  
  
  ll ans = s.size()*(s.size()-1)/2;
  REP(i,26){
    ans -= sum[i]*(sum[i]-1)/2;
  }
  
  cout << ans + 1 << endl;

 return 0;
}

Measured memory_bytes: 640
/*
  ID: oodt
  PROG:
  LANG:C++
*/
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<set>

using namespace std;

const int maxx=10005;
int n,m,k;
vector<int> a;
int ans = 0,cnt = 0,pos = 0;
int l = 0,r = 0;

int main()
{
#ifdef LOCAL
//    freopen("","r",stdin);
#endif
    scanf("%d",&n);
    for(int i = 0; i < n; i++)
    {
        int x;
        scanf("%d",&x);
        a.push_back(x);
    }
    a.push_back(0);
    int mi = 24;
    sort(a.begin(),a.end());
    for(int i = 1; i <= n; i++)
    {
        if(i%2) a[i] *= -1;
    }
    sort(a.begin(),a.end());
    for(int i = 1; i <= n; i++)
    {
        mi = min(mi,a[i]-a[i-1]);
    }
    mi = min(mi,a[0]+24-a[n]);
    printf("%d\n",mi);
    return 0;
}


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

using namespace std;

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

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

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


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

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

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

/// template

#define int long long

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cini(N);
    vector<long long> A(N);
    rep(i,N) cin >> A[i];
    rep(i,N) if(A[i]==0){
        cout << 0 << nn;
        return 0;
    }
    long long prod = 1LL;
    long long Max = 1000000000000000000LL;
    rep(i,N){
        long long tempProd = prod * A[i];
        if(Max/prod < A[i] || Max/A[i]<prod){
            cout << -1 << nn;
            return 0;
        }
        prod *= (long long)A[i];
    }
    cout << prod << nn;
    return 0;
}

Measured memory_bytes: 3612
# frame, ティツδ古ァツ閉ェテ・ツ渉キ, テ」ツδ?」ツδシテ」ツδ?x, y

def distance(x, y, x2, y2)
  Math.sqrt( ( (x - x2) ** 2 + (y - y2) ** 2 ) )
end

def result_sort(pass)
  pass.sort!{|a, b|
    if a[:distance] != b[:distance]
      b[:distance] <=> a[:distance]
    else
      a[:time] <=> b[:time]
    end
  }
end

def solve(data)
  pass = {0.0 => [], 1.0 => []}
  (0 .. data.length - 2).each{|i|
    if data[i][2] == data[i + 1][2] && data[i][1] != data[i + 1][1]
      pass[ data[i][2] ].push({
        :team     => data[i][2],
        :time     => ( data[i + 1][0] - data[i][0] ) * (1.0 / 60.0),
        :distance => distance(data[i][3], data[i][4], data[i + 1][3], data[i + 1][4]),
      })
    end
  }
  result_sort pass[0.0]
  result_sort pass[1.0]
  pass
end

def main
  n = gets.to_i
  data = (0 .. n - 1).map{|n|
    STDIN.gets.split(" ").map{|x| x.to_f }
  }
  result = solve(data)
  puts result[0.0].empty? ? "-1 -1" : "#{ result[0.0][0][:distance] } #{ result[0.0][0][:time] }"
  puts result[1.0].empty? ? "-1 -1" : "#{ result[1.0][0][:distance] } #{ result[1.0][0][:time] }"
end

main

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

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<int>> c(h, vector<int>(w));
    int black=0;
    rep(i,h){
        string s;
        cin >> s;
        rep(j,w){
            if(s[j] == '.') c[i][j]=0;
            else if(s[j] == '#'){
                c[i][j]=1;
                black++;
            }
        }
    }
    int ans = 0;
    for(int bit=0; bit<(1<<h); ++bit){
        vector<int> row;
        rep(i,h){
            if(bit&(1<<i)){
                row.push_back(i);
            }
        }
        for(int bit_=0; bit_<(1<<w); ++bit_){
            vector<int> colum;
            rep(j,w){
                if(bit_&(1<<j)){
                    colum.push_back(j);
                }
            }
            int black2red=0;
            vector<vector<int>> tmp=c;
            rep(x,row.size()){
                rep(a,w){
                    if(tmp[row[x]][a]==1){
                        black2red++;
                        tmp[row[x]][a] = 2;
                    }
                }
            }
            rep(y,colum.size()){
                rep(a,h){
                    if(tmp[a][colum[y]]==1){
                        black2red++;
                        tmp[a][colum[y]] = 2;
                    }
                }
            }
            if(black-black2red==k) ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main(){
    int N, p[11];
    scanf("%d\n", &N);
    int max = 0;
    int maxi = 0;
    int sum = 0;
    for(int i=0; i < N; i++){
        scanf("%d\n", &p[i]);
        if(max < p[i]) { 
            max = p[i];
            maxi = i;
        }
    }
    p[maxi] /= 2;
    for(int i = 0; i < N; i++){
        sum += p[i];
    }
    printf("%d\n", sum);
    return 0;
}

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

int gcm(int i, int j){
    if(i%j) return gcm(j, i%j);
    else return j;
}

int main() {
	int N, K; cin >> N >> K;
	int a, G, mx=0;
	for(int i=0; i<N; ++i){
	    cin >> a;
	    if(i) G=gcm(a, G);
	    else G=a;
	    mx=max(mx, a);
	}
	if(mx<K || K%G) cout << "IMPOSSIBLE" << endl;
	else cout << "POSSIBLE" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,T;
ll calc(ll k) {
  ll x=1;
  for(ll i=0; i<k; i++) {
    x*=n;
    if(x>1000000000) return x;
  }
  return x;
}
 
int main() {
  string s;
  cin >> n >> T >> s;
  s+="+";
  ll k=0,sum=0;
  for(int i=0; i<s.size(); i++) {
    if(s[i]=='^') k=0;
    if(isdigit(s[i])) {
      k*=10;
      k+=s[i]-'0';
    }
    if(s[i]=='+') sum+=calc(k);
    if(sum>1000000000||sum*T>1000000000) {
      cout << "TLE" << endl;
      return 0;
    }
  }
  cout << sum*T << endl;
  return 0;
}


Measured memory_bytes: 1204
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
using namespace std;


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


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  long int n, m, k;
  scanf("%ld %ld %ld", &n, &m, &k);

  long int a[n], b[m];
  for(int i=0;i<n;i++){
    scanf("%ld", &a[i]);
  }
  for(int i=0;i<m;i++){
    scanf("%ld", &b[i]);
  }

  long int x[n+1], y[m+1];
  for(int i=0;i<=n;i++){
    if(i==0) x[0] = 0;
    else x[i] = x[i-1] + a[i-1];
  }
  for(int i=0;i<=m;i++){
    if(i==0) y[0] = 0;
    else y[i] = y[i-1] + b[i-1];
  }

  long int time;
  long int ans=0;
  long int max;
  max = m;
  for(int i=0;i<=n;i++){
    time = x[i];
    for(int j=max;j>=0;j--){
      if(time + y[j]<=k){
	if(ans<i+j) ans = i+j;
	max = j;
	break;
      }
    }
  }

  printf("%ld\n", ans);

  return 0;
}


Measured memory_bytes: 7960
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,N-1,0)
#define RREPS(i,n) RFOR(i,N,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int INF=1e18;
const int MOD=1e9+7;
int ketawa(int x){
    int ret=0;
    while(x>0){
        ret+=x%10;
        x/=10;
    }
    return ret;
}

signed main(){
    int N;cin>>N;
    int ans=INF;
    for(int i=1;i<N;i++){
        int A=i,B=N-i;
        chmin(ans,ketawa(A)+ketawa(B));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define F first
#define S second
#define s(x) #x<<" "<<x<<" | "<<
#define f(i,j,k) for(int i = j;i<=k;i++)
#define fr(i,j,k) for(int i = j;i>=k;i--)
#define all(A)  A.begin(),A.end()  
#define has(m,x)   (m.find(x)!=m.end())
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);  
#define endl "\n"
const int MSIZE = 2e5+5;
const int MOD = 1e9+7 ;



int main(){

    FIO
    int n,k; cin>>n>>k;
    int arr[n];
    f(i,0,n-1)    cin>>arr[i];
    sort(arr,arr+n);
    cout<<accumulate(arr,arr+k,0)<<endl;
    
    
    return 0;
}
    


Measured memory_bytes: 3660
#include <stdio.h>

#define Max 1000000

void printA(int A[Max], int N) {
	int i;

	for (i = 0; i < N - 1; i++)
		printf("%d ", A[i]);
	printf("%d\n", A[i]);
}

int insertionSort(int A[Max], int N, int g) {
	int i, j, v;
	int cnt = 0;

	for (i = g; i < N; i++) {
		v = A[i];
		j = i - g;
		while (j >= 0 && A[j] > v) {
			A[j + g] = A[j];
			j -= g;
			cnt++;
		}
		A[j + g] = v;
	}

	return cnt;
}

void shellSort(int A[Max], int N) {
	int i = 0;
	int cnt = 0;
	int m = 0;
	int box[20];
	int G[Max];


	box[0] = 1;
	for (i = 1; i < 20; i++) box[i] = 3 * box[i - 1] + 1;

	for (i = 20 - 1; i >= 0; i--) {
		if (box[i] <= N) G[m++] = box[i];
	}

	printf("%d\n", m);

	printA(G, m);

	for (i = 0; i < m; i++) cnt += insertionSort(A, N, G[i]);

	printf("%d\n", cnt);

	for (i = 0; i < N; i++) printf("%d\n", A[i]);
}

int main( ) {
	int N, i, j;
	int A[Max];

	scanf("%d", &N);

	for (i = 0; i < N; i++) scanf("%d", &A[i]);

	shellSort(A, N);

	return 0;
}

Measured memory_bytes: 4504
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,int>;
const int MOD = 1000000007;

int main() {
    int k,a,b,temp;
    cin>>k>>a>>b;
    for (int i=1; i*k<=b; i++) {
        temp=k*i;
        if (a<=temp&&temp<=b) {
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;
}   


Measured memory_bytes: 3588
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
#define int long long
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
    const int MAX =200005;
const int MOD =1000000007;

signed main(){
  int n,ans1=1,ans2=1,ans3=1;
  cin>>n;
  for(int i=0;i<n;i++)ans1=(ans1*10)%MOD;
  for(int i=0;i<n;i++)ans2=(ans2*9)%MOD;
  for(int i=0;i<n;i++)ans3=(ans3*8)%MOD;
  cout<<(2*MOD+ans1-2*ans2+ans3)%MOD<<endl;
}

Measured memory_bytes: 3632
n = input()
f = [raw_input().split() for _ in xrange(n)]
p = [map(int, raw_input().split()) for _ in xrange(n)]
a = -9999999999L
for _ in xrange(1, 1024):
    cnt, b = 0, '0' * (12 - len(bin(_))) + bin(_)[2:]
    for i, n in enumerate(f):
        ci = 0
        for x in xrange(10):
            if b[x] == n[x] and b[x] == '1':
                ci += 1
        cnt += (p[i][ci])
    a = max(cnt, a)
print a

Measured memory_bytes: 2692
import sys
from collections import defaultdict

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')

N = I()
A = LMI()

d = defaultdict(int)
for a in A:
    d[a] += 1

# ad[i] := 数字iから作られるペアの数
ad = dict()
s = 0
for i, cnt in d.items():
    if cnt < 2:
        ad[i] = 0
    else:
        ad[i] = cnt * (cnt - 1) // 2
    s += ad[i]

for a in A:
    ans = s - ad[a]
    if d[a] >= 2:
        ans += (d[a] - 1) * (d[a] - 2) // 2
    print(ans)

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

template<typename T> T SQ(T val)
{
	return val * val;
}

int main()
{
	int N = 0;
	cin >> N;
	int a[N];
	cin >> a[0];
	double mean = a[0];
	for(int i = 1; i < N; i++){
		cin >> a[i];
		mean = (double)(i)/(i+1) * mean + 1.0/(i+1) * a[i];
	}
	// cout << mean << endl;
	int cost = 0;
	for(int i = 0; i < N; i++){
		cost += SQ(a[i] - round(mean));
	}
	cout << cost << endl;
	return 0;
}

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

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

	int count = 0;

	for( int i = 1; i <= N; ++i ) {
		int dg = 1;

		int t = i;
		while( t /= 10 ) { dg += 1; }

		if( dg & 1 ) {
			count += 1;
		}
	}

	cout << count << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }

    public static void WarshallFloyd(int[,] d, int v)
    {
	for (int k = 0; k < v; k++)
	    for (int i = 0; i < v; i++)
		for (int j = 0; j < v; j++)
		    d[i, j] = Math.Min(d[i, j], d[i, k] + d[k, j]);
    }
}

class Program
{
    public static void Main()
    {
	int INF = 3000000;
	
	int n = int.Parse(ReadLine());

	int[,] d = new int[n,n];
	int[,] v = new int[n,n];
	for (int i = 0; i < n; i++)
	    for (int j = 0; j < n; j++)
		d[i,j] = (i == j) ? 0 : INF;

	for (int i = 0; i < n; i++)
	{
	    string s = ReadLine();
	    for (int j = 0; j < s.Length; j++)
	    {
		if (s[j] == '1'){
		    d[i,j] = 1;
		    v[i,j] = 1;
		}
	    }
	}

	WarshallFloyd(d, n);

	int farNode1 = 0;
	int farNode2 = 0;
	int maxLen = 0;
	for (int i = 0; i < n; i++)
	    for (int j = 0; j < n; j++)
	    {
		if (d[i, j] > maxLen)
		{
		    farNode1 = i;
		    farNode2 = j;
		    maxLen = d[i, j];
		}
	    }

	int[] l = new int[n];
	for (int i = 0; i < n; i++)
	{
	    l[i] = d[farNode1, i];
	}

	for (int i = 0; i < n; i ++)
	    for (int j = 0; j < n; j++)
	    {
		if (v[i,j] == 1 && Math.Abs(l[i] - l[j]) != 1)
		{
		    WriteLine(-1);
		    return;
		}
	    }

	WriteLine(maxLen + 1);
    }
}


Measured memory_bytes: 13280
import sys
from collections import Counter
n = int(input())
a = list(map(int, input().split()))


# 全て0ならYes
if all([x == 0 for x in a]):
    print("Yes")
    sys.exit()

    
# 全て0でない場合、nは必ず3の倍数になる
if n % 3 != 0:
    print("No")
    sys.exit()

c = Counter(a)

cli = list(c.keys())
cval = list(c.values())


# 排他的論理和は3つずつ循環するため、keyは3種類、または0を含む場合2種類になる
if len(cli) > 3 or len(cli) <2:
    print("No")
    sys.exit()

# keyが2種類の場合、0が全体の1/3ならOK
if len(cli) == 2 and 0 in cli:
    if c[0] == n // 3:
        print("Yes")
        sys.exit()
    else:
        print("No")
        sys.exit()

# keyが3種類の場合、全ての値が同数、かつ排他的論理和の関係であればOK
if not all([x == cval[0] for x in cval]):
    print("No")
    sys.exit()

ans_0 = cli[1] ^ cli[2] == cli[0]
ans_1 = cli[2] ^ cli[0] == cli[1]
ans_2 = cli[0] ^ cli[1] == cli[2]

print("Yes" if all([ans_0, ans_1, ans_2]) else "No")

Measured memory_bytes: 14468
cards = list()
suit = ['S', 'H', 'C', 'D']
n = int(input())
for i in range(n):
    a, b = input().split()
    b = int(b)
    if a == 'S': cards.append(0 + b)
    elif a == 'H': cards.append(13 + b)
    elif a == 'C': cards.append(26 + b)
    elif a == 'D': cards.append(39 + b)
for i in range(1, 53):
    if not (i in cards):
        print(suit[(i - 1) // 13], (i - 1) % 13 + 1)


Measured memory_bytes: 5616
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
const double EPS = 1e-5;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vvector<vector<t>>;
template<class t>
using vvvvector = vvvector<vector<t>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){ return modpow(x, MOD-2); }
ll in(){ ll x; scanf("%lld",&x); return x; }
string in_s(){ string res;cin >> res;return res; }
bool was_output = false;
template<class t>
void output(t a){ if(was_output)cout << " "; cout << a; was_output = true; }
void outendl(){ was_output = false; cout << endl; }
string outopen = "";
string outclose = "";
string outsplit = " ";
string outenter = "\n";
template<class t>
ostream& operator<<(ostream& os,vector<t> &x){
	if(typeid(t)==typeid(int)||typeid(t)==typeid(long long)||typeid(t)==typeid(char)||typeid(t)==typeid(string)||typeid(t)==typeid(double)){
		bool flag = false;
		os << outopen;
		for(auto i:x){
			if(flag)os << outsplit;
			flag = true;
			os << i;
		}
		os << outclose;
		os << outenter;
		return os;
	}
	os << outopen;
	for(auto i:x){
		os << i;
	}
	os << outclose; 
	return os;
}
template<class t>
istream& operator>>(istream &is,vector<t> &x){
	for(auto &i:x){
		is >> i;
	}
	return is;
}

int main(){
	int n = in();
	vector<int> line(n);
	cin >> line;
	vector<int> ans;
	rep(i,n){
		per(j,n-i){
			if(line[j]==j+1){
				ans.push_back(j+1);
				line.erase(line.begin()+j);
				break;
			}
		}
	}
	if(ans.size()==n){
		reverse(all(ans));
		foreach(i,ans)cout << i << endl;
	}else{
		cout << -1 << endl;
	}
	return 0;
}


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

int last[] = { 31,28,31,30,31,30,31,31,30,31,30,31 };

int main() {

	int m1, d1;
	int m2, d2;
	cin >> m1 >> d1;
	cin >> m2 >> d2;
	int lastday = last[m1 - 1];
	//cout << lastday << endl;
	if (lastday == d1) {
		cout << '1' << endl;
	}
	else {
		cout << '0' << endl;
	}

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
using namespace std;
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}
//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}

struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(9);
    }
} All_init;


int main()
{
    ll n,count=0,count2=0;
    cin>>n;
    vector<ll>a(n),b;
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    for(ll i=0;i<n;i++){
        if(a[i]%2==0){
            count++;
        }
            
            
        
    }
    for(ll i=0;i<n;i++){
        if(a[i]%2==0&&(a[i]%3==0||a[i]%5==0)){
            count2++;
        }
    }
    if(count==count2){
        cout<<"APPROVED"<<endl;
    }
    else{
        cout<<"DENIED"<<endl;
    }

    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const int MAX_N = 100000;
ll fact[MAX_N + 1];
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll ans;
	fact[0] = 0;
	fact[1] = 1;
	ll fs = 1;
	for (int i = 2; i < MAX_N + 1; i++){
		fs = (fs*i) % MOD;
		fact[i] = (fact[i - 1] + fs) % MOD;
	}
	while (1){
		int N, R;
		cin >> N;
		if (N == 0) break;
		vector<int> word(N);
		for (int i = 0; i < N; i++) word[i] = i;
		word.push_back(0);
		ans = 0;
		cin >> R;
		vector<int> s(4 * R + 2, 0);
		s[2 * R + 1] = N;
		for (int i = 0; i < R; i++){
			int s1, s2;
			cin >> s1 >> s2;
			s[4 * i] = s1;
			s[4 * i + 1] = s2;
			s1--; s2--;
			s[4 * i + 2] = s1;
			s[4 * i + 3] = s2;
			swap(word[s1], word[s2]);
		}
		s[4 * R] = 0; s[4 * R + 1] = N;
		sort(s.begin(), s.end());
		s.erase(unique(s.begin(), s.end()), s.end());
		for (int i = 0, R = s.size() - 1; i < R; i++){
			ans = (ans + word[s[i]] * (fact[N - s[i] - 1] - fact[N - s[i + 1] - 1] + MOD)) % MOD;
			for (int j = i + 1, dif = s[i + 1] - s[i]; j < R; j++){
				word[s[j]] -= (word[s[j]] > word[s[i]] ? dif : 0);
			}
		}
		cout << ans % MOD << endl;
	}
	return 0;
}

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

const string YES = "YES";
const string NO = "NO";

void solve(long long X)
{
    if (X == 7 || X == 5 || X == 3)
    {
        cout << YES << endl;
    }
    else
    {
        cout << NO << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long X;
    scanf("%lld", &X);
    solve(X);
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

N = int(input())

count = defaultdict(int)
for i in range(N):
  s = input()
  count[s] += 1
print("AC x "+str(count['AC']))
print("WA x "+str(count['WA']))
print("TLE x "+str(count['TLE']))
print("RE x "+str(count['RE']))

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

int main() {
	int a, b;
	string s;
	cin >> a >> b >> s;
	
	for(int i=0; i<a+b+1; i++){
		if(i<a || i>a){
			if(s[i]<'0' || s[i]>'9'){
				cout << "No" << endl;
				return 0;
			}
		}
		else if(i==a){
			if(s[i]!='-'){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
const int INF = 100000000;
typedef pair<int,int> Point;
Point AllPoint[1000];
int W,H;
int x[4] = {0,1,0,-1};
int y[4] = {1,0,-1,0};
char map[1000][1000];
int deep[1000][1000];
int N;
void BFS(Point Start,Point Over){
    queue<Point> que;
    int FirstDeep = deep[Start.first][Start.second];
    for (int i = 0;i<H;i++){
        for (int j = 0;j<W;j++){
            deep[i][j] = INF;
        }
    }
    que.push(Start);
    deep[Start.first][Start.second] = FirstDeep;
    while (que.size()){
        Point p = que.front();
        que.pop();
        if (p.first== Over.first&&p.second == Over.second)
            break;
        for (int i = 0;i<4;i++){
            int ix = p.first+x[i];
            int iy = p.second+y[i];
            if (ix>=0&&ix<=H
                &&iy>=0&&iy<=W
                &&deep[ix][iy] == INF
                &&map[ix][iy]!='X'){
                que.push(Point(ix,iy));
                deep[ix][iy] = deep[p.first][p.second]+1;
            }
        }
    }
}



int main(){
    cin >> H >> W;
    cin >> N;
    for (int i = 0;i<H;i++){
        for (int j = 0;j<W;j++){
            cin >> map[i][j];
            if ((int)map[i][j]-48>=1&&(int)map[i][j]-48<=N){
                AllPoint[(int)map[i][j]-48].first = i;
                AllPoint[(int)map[i][j]-48].second = j;

            }
            if (map[i][j] == 'S'){
                AllPoint[0].first = i;
                AllPoint[0].second = j;
            }
        }
    }
    deep[AllPoint[0].first][AllPoint[0].second] = 0;
    for (int i = 0;i<N;i++){
        BFS(AllPoint[i],AllPoint[i+1]);
    }
    cout << deep[AllPoint[N].first][AllPoint[N].second]<<endl;

    return 0;
}
//#....
//S.##.
//###G.
//#####
//#####

//#S######.#
//......#..#
//.#.##.##.#
//.#........
//##.##.####
//....#....#
//.#######.#
//....#.....
//.####.###.
//....#...G#




Measured memory_bytes: 7976
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <tuple>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <random>
#include <queue>
#include <deque>
#include <iterator>
#include <map>
#include <functional>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define pb(a) push_back(a)
#define llong long long
#define INF 1145141919
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
int dy[] = { 1, 0, -1, 0 };
int dx[] = { 0, 1, 0, -1 };
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

string solve() {
	int a, b;
	cin >> a >> b;
	for (int i = 0; i <= 3; i++) {
		if (a*b*i % 2 == 1) {
			return "Yes";
		}
	}
	return "No";
}
int main() {
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int ans,a;
    cin >> a;
    if (a<=599){
        cout << 8;
    }else if(a<=799){
        cout << 7;
    }else if(a<=999){
        cout << 6;
    }else if(a<=1199){
        cout << 5;
    }else if(a<=1399){
        cout << 4;
    }else if(a<=1599){
        cout << 3;
    }else if(a<=1799){
        cout << 2;
    }else if(a<=1999){
        cout << 1;
    }
}

Measured memory_bytes: 3632
#include<stdio.h>

int main(void){
    int k;
    scanf("%d", &k);
    int ans;
    if(k % 2 == 0){
        ans = k * k / 4; 
    }
    else{
        ans = k / 2 * (k / 2 + 1);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 102000;
int n,a[N],b[N],c[N],d[N],bh[2][N],m,S;
int ind[N],outd[N],f[N];
int find(int x){return f[x]==x?x:f[x]=find(f[x]);}
void add(int u, int v){
//	printf("e %d %d\n",u,v);
	ind[v]++;outd[u]++;
	u=find(u);v=find(v);f[u]=v;
}
void GG(){puts("NO");exit(0);}
int main() {
	read(n);read(m);
	rep(j,0,1)rep(i,1,m)bh[j][i]=i+j*m;
	rep(i,1,n)read(a[i]),read(b[i]),read(c[i]),read(d[i]);
	rep(i,1,m*2+1)f[i]=i;
	//ao0 tu1
	rep(i,1,n){
		add(c[i]==0?bh[0][a[i]]:bh[1][c[i]],d[i]==0?bh[1][b[i]]:bh[0][d[i]]);
	}
	S=m*2+1;
	rep(i,1,m){
		while(ind[i]<outd[i])add(S,i);
		if(ind[i]>outd[i])GG();
	}
	rep(i,m+1,m+m){
		while(outd[i]<ind[i])add(i,S);
		if(outd[i]>ind[i])GG();
	}
//	rep(i,1,S)printf("%d:%d\n",i,find(i));
	set<int>Set;rep(i,1,S)if(ind[i]&&find(i)!=find(S))GG();
//	if(SZ(Set)>1)GG();
	puts("YES");
	return 0;
}


Measured memory_bytes: 1792