akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)

signed main() {
  int n;
  cin >> n;
  bool ok = true;
  rep(i, n) {
    int x;
    cin >> x;
    if(x % 2 == 0 && x % 3 != 0 && x % 5 != 0) {
      ok = false;
    }
  }
  if(ok) {
    cout << "APPROVED" << endl;
  } else {
    cout << "DENIED" << endl;
  }
}


Measured memory_bytes: 256
# abc129_a.py
# https://atcoder.jp/contests/abc129/tasks/abc129_a

# A - Airplane /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 100点

# 問題文
# 空港 A, B, C があり、それぞれの空港の間では、双方向に飛行機が運航しています。
# 空港 A, B 間の飛行時間は片道 P時間、空港 B, C 間の飛行時間は片道 Q 時間、空港 C, A 間の飛行時間は片道 R時間です。
# いずれかの空港からスタートして他の空港に飛行機で移動し、さらにそのどちらでもない空港に飛行機で移動するような経路を考えます。
# 飛行時間の和は最短で何時間になるでしょうか。

# 制約
#     1≤P,Q,R≤100
#     入力は全て整数である

# 入力
# 入力は以下の形式で標準入力から与えられる。
# P Q R

# 出力
# 飛行時間の和の最小値を出力せよ。

# 入力例 1
# 1 3 4

# 出力例 1
# 4

# A, B, C の順に移動する経路の飛行時間の和は、1+3=4時間
# A, C, B の順に移動する経路の飛行時間の和は、4+3=7時間
# B, A, C の順に移動する経路の飛行時間の和は、1+4=5時間
# B, C, A の順に移動する経路の飛行時間の和は、3+4=7時間
# C, A, B の順に移動する経路の飛行時間の和は、4+1=5時間
# C, B, A の順に移動する経路の飛行時間の和は、3+1=4時間
# であるので、これらの最小値は 4時間です。

# 入力例 2
# 3 2 3

# 出力例 2
# 5


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    # N = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    values = list(map(int, lines[0].split()))
    # values_p = list(map(int, lines[M+1].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(M):
    #     valueses.append(list(map(int, lines[i+1].split())))

    return [sum(values)-max(values)]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['1 3 4']
        lines_export = [4]
    if pattern == 2:
        lines_input = ['3 2 3']
        lines_export = [5]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9196
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
#define EPS (long double) 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;

int main() {
	while(1) {
		int w, h;
		cin>>w>>h;
		if(w == 0 && h== 0) break;
		int yoko[h][w - 1];
		int tate[h - 1][w];
		REP(i, 2 * h - 1) {
			if(i % 2 == 0) {
				REP(j, w - 1) cin>>yoko[i / 2][j];
			} else {
				REP(j, w) cin>>tate[i / 2][j];
			}
		}
		int d[h][w];
		REP(i, h) {
			REP(j, w) d[i][j] = INF;
		}
		d[0][0] = 0;
		queue<P> q;
		q.push(P(0, 0));
		while(!q.empty()) {
			P p = q.front();
			q.pop();
			if(p.first - 1 >= 0 && tate[p.first - 1][p.second] == 0 && d[p.first - 1][p.second] == INF) {
				d[p.first - 1][p.second] = d[p.first][p.second] + 1;
				q.push(P(p.first - 1, p.second));
			}
			if(p.first + 1 < h && tate[p.first][p.second] == 0 && d[p.first + 1][p.second] == INF) {
				d[p.first + 1][p.second] = d[p.first][p.second] + 1;
				q.push(P(p.first + 1, p.second));
			}
			if(p.second - 1 >= 0 && yoko[p.first][p.second - 1] == 0 && d[p.first][p.second - 1] == INF) {
				d[p.first][p.second - 1] = d[p.first][p.second] + 1;
				q.push(P(p.first, p.second - 1));
			}
			if(p.second + 1 < w && yoko[p.first][p.second] == 0 && d[p.first][p.second + 1] == INF) {
				d[p.first][p.second + 1] = d[p.first][p.second] + 1;
				q.push(P(p.first, p.second + 1));
			}
		}
		if(d[h - 1][w - 1] == INF) cout<<0<<endl;
		else cout<<d[h - 1][w - 1] + 1<<endl;
	}
}

Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
const int Max=200000;
long A[Max]={}, f[Max]={}, seen[Max]={}, E[Max]={0};
long F(int n){
long M=0;
if(n==2){ M=max(A[0], A[1]); return M; }
if(n==3){ M=max(F(2), A[2]); return M; }
if(seen[n]){ return f[n]; }
seen[n]=1; 
if(n%2){ return f[n]=max(F(n-1), F(n-2)+A[n-1]); }
else{ return f[n]=max(E[n-2], F(n-2)+A[n-1]); }
}

int main(){
int N, i; cin >> N;
for(i=0; i<N; i++){ cin >> A[i]; }
E[0]=A[0];
for(i=2; i<N; i+=2){ E[i]=E[i-2]+A[i]; }  
cout << F(N) << "\n";
}

Measured memory_bytes: 14520
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
template <class type> void printVector(vector<type> vec){
    stringstream ss;
    for(ll i=0;i<vec.size();i++)
    {
        ss<<vec[i];
    }
    cout<<ss.str()<<endl;
}

int main(){
    ll N;
    cin>>N;
    ll mod =(int)pow(10,9)+7;

    vector<ll> A(N,0);

    for(ll i=0;i<N;i++)
    {
        cin>>A[i];
    }

    ll sum=0;
    ll res=0;
    for(ll i=N-2;0<=i;i--)
    {
        sum += A[i+1];
        sum %= mod;
        res += (A[i] * sum) % mod;
        res %= mod;
    }
    cout<<res;
    return 0;
}

Measured memory_bytes: 4764
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func convertInt(str string) int {
	num, e := strconv.Atoi(str)
	if e != nil {
		panic(e)
	}
	return num
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b := nextLine(), nextLine()
	mul := convertInt(a) * convertInt(b)
	if mul % 2 == 1 {
		fmt.Println("Odd")
	} else {
		fmt.Println("Even")
	}
}

Measured memory_bytes: 640
# https://atcoder.jp/contests/abc094/tasks/arc095_b
n = int(input())
nums = [int(i) for i in input().split()]

# すべてを計算する時間はなさそう
# 最大のモノを選らんで、それと絶対値差が大きいモノを選ぶ。いや、ここは全部やればいいのかな。
# numsの値がめちゃくちゃでかいので、全部はできない。

MAX = max(nums)
t = 0
ans = 0
for num in nums:
    if num == MAX:
        continue
    d = min(MAX - num, num)
    if t < d:
        t = d
        ans = num
print(MAX, ans)

Measured memory_bytes: 62832
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

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

        int N = sc.nextInt();
        int[] a = new int[N + 1];
        for (int i = 1; i < a.length; ++i) {
            a[i] = sc.nextInt();
        }

        System.out.println(solve(a));

        sc.close();
    }

    static String solve(int[] a) {
        boolean[] balls = new boolean[a.length];
        for (int i = a.length - 1; i >= 1; --i) {
            balls[i] = a[i] == 1;
            for (int j = i + i; j < balls.length; j += i) {
                if (balls[j]) {
                    balls[i] = !balls[i];
                }
            }
        }

        int[] b = IntStream.range(1, balls.length).filter(i -> balls[i]).toArray();

        return String.format("%d\n%s", b.length,
                Arrays.stream(b).mapToObj(String::valueOf).collect(Collectors.joining("\n")));
    }
}

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

#define REP(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define REPS(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define RREP(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define RREPS(i, n) for (int i = ((int)(n)); i > 0; i--)
#define IREP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define IREPS(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVISORT(v) sort(v.begin(), v.end(), greater<int>());
#define ALL(v) v.begin(), v.end()
#define MP(n, m) make_pair(n, m);

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using ll = long long;
using ul = unsigned long;

typedef long long ll;

template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

const int mod=1e9+7;

void printv(VI& v){
  REP(i,v.size()) cout << v[i] << " ";
  cout << endl;
}

int vtotal(VI& v){
  int total=0;
  REP(i,v.size()) total+=v[i];
  return total;
}

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

  // string n;
	// getline(cin,n);

  string s;
  cin>>s;
  VVI dp(s.size()+1,VI(13,0));
  dp[0][0]=1;
  REPS(i,s.size()){
    int c;
    if(s[i-1]!='?')c=s[i-1]-'0';
    else c=-1;
    REP(j,10){
      if(c!=-1&&c!=j)continue;
      REP(ki,13){
        dp[i][(ki*10+j)%13]+=dp[i-1][ki];
        dp[i][(ki*10+j)%13]%=mod;
      }
      // 
    }
  }
    
  cout<<dp[s.size()][5]<<endl;

  // cout<<std::setprecision(10)<<ans<<endl;

  return 0;
}


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

int main() {
 int A, B;
  cin >> A >> B;
  int answer = -1;
  for (int i = 0; i <= 1250; i++) {
    if ((i*8)/100 == A && (i*10)/100 == B) {
      answer = i;
      break;
    }
  }
    cout << answer << endl;
}

Measured memory_bytes: 256
n = int(input())
a = [[0 for i in range(n)] for j in range(n)]

for i in range(n):
    inp = list(map(int, input().split()))
    u = inp[0]
    k = inp[1]
    for j in range(k):
        a[u - 1][inp[2 + j] - 1] = 1
    print(*a[u - 1])

Measured memory_bytes: 7784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long MOD = 1000000007;
int N,X,Y,Z;
ll dp[44][133333];
ll tenmul[44];
bool check(unsigned state)
{
    return state>>X+Y+Z-1&1 && state>>Y+Z-1&1 && state>>Z-1&1;
}
ll dfs(int pos,unsigned state)
{
    if(pos > N) return 0;
    if(dp[pos][state]!=-1)return dp[pos][state];
    dp[pos][state] = 0;

    for(int i=1;i<=10;++i)
    {
        unsigned state_nxt = ((state << i) + (1 << i-1)) & ((1<<17)-1);
        if(check(state_nxt))
            dp[pos][state] += tenmul[N-pos];
        else
            dp[pos][state] += dfs(pos+1,state_nxt);
        dp[pos][state] %= MOD;
    }
    return dp[pos][state];
}
void solve(){
    cout<<dfs(1,0)<<endl;
}
void init()
{
    tenmul[0]=1;
    for(int i=1;i<=40;++i)tenmul[i]=tenmul[i-1]*10%MOD;
    memset(dp,-1,sizeof dp);
}
int main()
{
    init();
    cin>>N>>X>>Y>>Z;
    solve();
    return 0;
}


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

int main() {
    ll X;
    cin>>X;
    ll i=100;
    ll cnt=0;
    while(i<X){
        i=1.01*i;
        cnt++;
    }
    cout<<cnt<<endl;
   return 0; 
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <set>
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 1000000007
#define writeln(n) cout<<n<<endl
//setprecision(10);
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

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

const int inf=100000000;

long long modpow(long long a, long long n, long long mod) //a^n
{
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

llong gcd(llong a, llong b) {
        return b != 0 ? gcd(b, a % b) : a;
    }

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,h,w; cin>>n>>h>>w;
    cout<<(n-h+1)*(n-w+1)<<endl;
    return  0;
}


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

using namespace std;
#define ll long long
const ll MAXN=1e8;
bool f[MAXN]={0};
int n;
ll sqr(ll a){return a*a;};
void s(int i,string h)
{
    if (h.length()==n)
    cout<<h<<'\n';
    else
    for (int j=0;j<=i;j++)
        if (j==i)
        s(i+1,h+(char)('a'+j));
    else
        s(i,h+(char)('a'+j));
}
int main()
{
    cin>>n;
    s(0,"");
    return 0;
}


Measured memory_bytes: 1536
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 405;

ll A[MAXN];
ll dp[MAXN][MAXN];

int main() {
  memset(dp, 0x3f3f3f, sizeof dp);
  int N;
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> A[i + 1];
    A[i + 1] += A[i];
    dp[i][i + 1] = 0;
  }

  for (int i = 2; i <= N; i++) {
    for (int j = 0; i + j <= N; j++) {
      for (int k = 1; k < i; k++) {
        dp[j][j + i] = min(dp[j][j + i], dp[j][j + k] + dp[j + k][j + i]);
      }
      dp[j][j + i] += A[j + i] - A[j];
    }
  }

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

  return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll a, b; cin >> a >> b;
  if (a<=0&&b>=0) cout << "Zero" << endl;
  else if (a > 0) cout << "Positive" << endl;
  else if ((b-a)%2==0) cout << "Negative" << endl;
  else cout << "Positive" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
const long long int mod1=1000000007;
const long long int mod2 = -1;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back                                       
#define ff first
#define ss second
#define ll long long int
#define ull unsigned long long int
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define ordered1 tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
 
ll gcd(ll a, ll b){
    ll c;
     while(b){
        c = b;
        b = a % b;
        a = c;
     }
     return a;
}
ll power1(ll a, ll b){
     if(b == 0) return 1;
     else if(b % 2) return a * power1(a, b - 1);
     else {
        ll temp = power1(a, b / 2);
        return temp * temp;
     }
}
ll power2(ll a, ll b, ll m){
     a %= m;
     if(b == 0) return 1;
     else if(b % 2) return (a * power2(a, b - 1, m)) % m;
     else{
        ll temp = power2(a, b / 2, m);
        return (temp * temp) % m;
     }
}
ll mod(ll x, ll p){
return (x % p + p) % p;
}
ll lcm(ll x, ll y){
return (x * y)/gcd(x, y);
}
int main(){
	fast;
	ll h = 1;
	//cin >> h;
	while(h--){
	ll n;
	cin >> n ;
	ll a[n];
	set<ll> hmm[n+1];
	for(int i=0;i<n;i++){
		cin >> a[i];
		hmm[a[i]].insert(i);
	}
	ll ans = 0;
	if(hmm[1].size()==0){
		cout << -1 << endl;
		return 0;
	}
	ll cur = (*hmm[1].begin());
	//cout << cur << endl;
	ans = 1;
	for(int i=2;i<=n;i++){
		set<ll>::iterator p = upper_bound(hmm[i].begin(),hmm[i].end(),cur);
		if(p == hmm[i].end()){
			break;
		}
		else{
			cur = *p;
			ans++;
			//cout << cur << endl;
		}
	}
	cout << n - ans << endl;
	}}

Measured memory_bytes: 20608
antenas = []
distance = 0
for i in range(6):
    if i <= 4:
        antenas.append(int(input()))
    else:
        distance = int(input())
cand = []
for i in range(len(antenas)):
    for j in range(i, len(antenas)):
        cand.append(antenas[j] - antenas[i])
flag = True
for i in range(len(cand)):
    if cand[i] > distance:
        print(':(')
        flag = False
        break
if flag:
    print('Yay!')


Measured memory_bytes: 3064
n = gets.to_i
a = gets.split().map(&:to_i)
a.sort!
e = false
if n % 2 != 0
  if a.count(0) != 1
    e = true
  end
  b = a.select {|i| i % 2 != 0}
  if b.size != 0
    e = true
  end
  b = a.select {|i| i % 2 == 0}
  b.uniq!
  ans =2**((b.size)-1) % 1000000007
else
  b = a.select {|i| i % 2 == 0}
  if b.size != 0
    e = true
  end
  b = a.select {|i| i % 2 != 0}
  b.uniq!
  ans = 2**(b.size) % 1000000007
end
if e
  puts 0
else
  puts ans
end

Measured memory_bytes: 12928
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll lcm(ll n,ll m)
{
	return ((n*m)/(__gcd(n,m)));
}
int main()
{
	cin.tie(0);
	cout.tie(0);
	ll n;
	string s;
	cin>>n;
	cin>>s;
	if(s.length()<=n)
	cout<<s<<endl;
	else
	{
		cout<<s.substr(0,n)<<"..."<<endl;
	}
	return 0;
}

Measured memory_bytes: 3628
# Greatly refered to the solution: https://atcoder.jp/contests/abc091/submissions/3549633
from sys import stdin
import numpy as np
ORD = 28

n = int(stdin.readline())
a = np.array(list(map(int, stdin.readline().split())))
b = np.array(list(map(int, stdin.readline().split())))

def search(a_, b_, pow2):
    c1 = np.searchsorted(a_, pow2 - b_)
    c2 = np.searchsorted(a_, 2*pow2 - b_)
    c3 = np.searchsorted(a_, 3*pow2 - b_)
    return n**2 - np.sum(c3) + np.sum(c2) - np.sum(c1)

a_ord = np.zeros((ORD, n), dtype = int)
b_ord = np.zeros((ORD, n), dtype = int)
for i in range(1, ORD+1):
    a_ord[i-1, :] = a%(2**i)
    b_ord[i-1, :] = b%(2**i)
a_ord = np.sort(a_ord, axis = 1)

ans = ''
for i in range(ORD):
    count = search(a_ord[i], b_ord[i], 2**i)
    ans += '0' if count%2 == 0 else '1'
    
count = search(a_ord[-1], b_ord[-1], 2**ORD)
ans += '0' if count%2 == 0 else '1'

print(int(ans[::-1], 2))


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

int main()
{
    int N;
    string S;
    cin >> N;
    cin >>S;
    int i,j,k;
    long count=0;
    int R[N],G[N],B[N];
    for(i=0;i<N;i++){
        R[i]=G[i]=B[i]=0;
    }
    int p=0;
    int q=0;
    int r=0;
    for(i=0;i<N;i++){
        if(S[i]=='R'){
            p++;
        }
        else if(S[i]=='G'){
            q++;
        }
        else if(S[i]=='B'){
            r++;
        }
    }
    
    count=p*q;
    count*=r;
    
    for(i=0;i<N-2;i++){
        for(j=i+1;(2*j-i)<N;j++){
            k=2*j-i;
            if(k<N){
                if(S[i]!=S[k]&&S[i]!=S[j]&&S[j]!=S[k])
                    count--;
            }
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>

using namespace std;
#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(),x.end()

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

int main() {
	int s;
	cin >> s;
    if (s == 25) printf("Christmas");
    if (s == 24) printf("Christmas Eve");
    if (s == 23) printf("Christmas Eve Eve");
    if (s == 22) printf("Christmas Eve Eve Eve");
}

Measured memory_bytes: 256
N, K = map(int, input().split())
LARGE = 10 ** 9 + 7

# SQRT
R = 1
while (R + 1) ** 2 < N:
    R += 1

square = False
if (R + 1) ** 2 == N:
    square = True


DP_S = [1] * R
DP_L = [1] * R
N_L = [1] * R
DP_M = 0
L = R
if square:
    DP_M = 1
    L += 1


for i in range(R, 0, -1):
    Q = N // i
    DP_L[i - 1] = Q - L
    N_L[i - 1] = Q - L
    L = Q

for _ in range(K - 1):
    S = 0
    L = sum(DP_L) + DP_M
    SS = sum(DP_S)
    for i in range(R):
        S = (S + DP_S[i]) % LARGE
        DP_S[i] = (L + SS) % LARGE
        L = (L - DP_L[i]) % LARGE
        DP_L[i] = (S * N_L[i]) % LARGE

    if square:
        DP_M = (DP_M + SS) % LARGE

print((sum(DP_L) + sum(DP_S) + DP_M) % LARGE)


Measured memory_bytes: 44780
from itertools import combinations_with_replacement as combinations
n,m,q = map(int,input().split())
r = tuple(range(1,m+1))
l = [tuple(map(int,input().split())) for i in range(q)]
ans = 0
for a in combinations(r,n):
    x=0
    for t in l:
        if a[t[1]-1]-a[t[0]-1]==t[2]:
            x+=t[3]
    ans=max(ans,x)
print(ans)

Measured memory_bytes: 9204
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, vector<ll>> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    char c;
    cin >> c;
    if('a' <= c && c <= 'z') cout << "a" << endl;
    else cout << "A" << endl;
    return 0;
}


Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		
		int N = scan.nextInt();
		int a[] = new int[N + 1];
		int b[] = new int[N];
		for(int i = 0; i < N + 1; i++) {
			a[i] = scan.nextInt();
		}
		
		for(int i = 0; i < N; i++) {
			b[i] = scan.nextInt();
		}
		
		long total = 0;
		for(int i = 0; i < N; i++) {
			if(b[i] <= a[i]) {
				total += b[i];
			}else {
				b[i] -= a[i];
				total += a[i];
				
				int nextBaster = Math.min(a[i + 1], b[i]);
				total += nextBaster;
				a[i + 1] -= nextBaster;
			}
		}
		
		System.out.println(total);
 	}
}


Measured memory_bytes: 50380
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define nl '\n'
// ROAD to...                                                                                                                                                                                                                Red

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
 
int rnd (int l, int r) {
	return uniform_int_distribution<int> (l, r)(gen);
}
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;

int main () {
	SpeedForce;
	setIO();
	int l, r, d;
	cin >> l >> r >> d;
	cout << (r/d) - (l-1)/d << nl;

	return Accepted;
}

// B...a

Measured memory_bytes: 17688
import java.util.Scanner;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        sc.close();
        String[] C = S.split("");
        String I1 = C[0] + C[1];
        String I2 = C[2] + C[3];
        int N1 = Integer.parseInt(I1);
        int N2 = Integer.parseInt(I2);
        String ans;
        if(N1 != 00 && N2 != 00){
            if(N1 <= 12){
                ans = (N2<=12)? "AMBIGUOUS" : "MMYY";
            }
            else{
                ans = (N2<=12)? "YYMM":"NA";
            }
        }
        else if(N1==00) {
            ans = (N2<=12 && N2 > 0)? "YYMM":"NA";
        }
        else if(N2==00){
            ans = (N1<=12 && N1 > 0)? "MMYY":"NA";
        }
        else {ans = "NA";}
        System.out.print(ans);
    }
}

Measured memory_bytes: 21716
#include <stdio.h>
#include <string.h>

void printFunc(int a, int b ,char str[1001]) {
	
	int i;
	//printf("print");
	for(i = a; i <= b; i++) {
		printf("%c",str[i]);
	}

	printf("\n");
	
}

void replaceFunc(int a, int b, char str[1001], char p[1001]) {
	int i;	
	//printf("replace");
	for(i = a ; i <= b; i++) {
		str[i] = p[i-a];
	}
	
}

void reverseFunc(int a, int b, char str[1001]) {
	int i;
	char tmp;
	//printf("reverse");
	for(i = 0 ; i <(b-a+1)/2 ; i++) {
		tmp = str[a+i];
		str[a+i] = str[b-i];
		str[b-i] = tmp;
	}
	
}

int main(int argc, const char * argv[]) {
	
	char str[1001],order[8],p[1001];
	int q,i,a,b;
	
	scanf("%s",str);
	
	scanf("%d",&q);
	
	for(i = 0 ; i < q ; i++){
		
		//printf("%s\n",str);
		scanf("%s",order);
		
		if(strcmp(order, "replace") == 0){
			scanf("%d %d",&a,&b);
			scanf("%s",p);
			replaceFunc(a,b,str,p);
			
		} else if(strcmp(order, "reverse") == 0) {
			scanf("%d %d",&a,&b);
			reverseFunc(a,b,str);
			
		}  else if(strcmp(order, "print") == 0) {
			scanf("%d %d",&a,&b);
			printFunc(a,b,str);
		} 
		
	}
	return 0;
	
}



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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef long long ll;
const long long MOD = 1000000000 + 7;

long long max_fact(ll n){
    ll min_fact = 0;
    for(ll a = 2; a*a <= n; a++ ){
        if(n%a==0){
            min_fact = MAX(min_fact,a);
        }
    }
    return min_fact;
}

int main(){
    ll n;
    cin >> n;
    if(n==1){
        cout << 1 << endl;
        return 0;
    }
    ll min_fact;
    min_fact = max_fact(n);
    if(min_fact == 0) min_fact = 1;
    ll max_f;
    max_f = n/min_fact;
    int digit=1;
    while(max_f/10>0){
        digit++;
        max_f/=10;
    }
    cout << digit << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
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 MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int w, h, x, y; cin >> w >> h >> x >> y;
    bool f = false;
    if (x + x == w && y + y == h) f = true;

    double ans = double(w) * double(h) / 2;
    if (f) cout << fixed << setprecision(10) << ans << " 1" << endl;
    else cout << fixed << setprecision(10) << ans << " 0" << endl;
}

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

using namespace std;

#define boost                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<ll, ll>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for (auto &z : v)
#define sp << ' ' <<
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353
#define PI_2 1.57079632679489661923

int main()
{
    boost;
    time_t tic, toc;

    ll tt = 1, n, m, k = 0, i, j, p, q;
    ll a, b, c, h, w, u, v, x, y, t;
    ll l = 0, r = 0;
    ll ans = 0;

    bool poss = true;

    string s, tmp;

    // cin >> tt;
    tic = clock();
    for(int _ = 1; _ <= tt; _++){
        // cout << "Case #" << _ << ": ";
        cin >> n;
        vi arr(n);
        loop(z, arr) cin >> z;
        sort(arr.B, arr.E, greater<ll>());

        ans = arr[0];
        m = n - 1;
        if(m%2 == 0){
            t = (m - 2) / 2;
            for(i = 1; i <= t; i++){
                ans += 2*arr[i];
            }
            ans += arr[t + 1];
        }
        else{
            t = (m - 1) / 2;
            for(i = 1; i <= t; i++){
                ans += 2*arr[i];
            }
        }
        cout << ans << nl;
    } 
    // cerr << (clock() - tic*1.0) / CLOCKS_PER_SEC << nl;
    return 0;
}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=(b);++i)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define pi pair<int, int>
#define mk make_pair
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N=1e3+10;
char s[N];
int n;
int main()
{
	double n;
	cin>>n;
	double l=n/3;
	printf("%.7f\n",l*l*l);

}


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

using namespace std;

const int mxn = 1e5;
long long a[mxn + 11];

int main(){
  //  freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);
    int n;
    long long k;
    scanf("%d %lld", &n, &k);
    for (int i = 0; i < n; i++){
        scanf("%lld", a + i);
    }
    long long res = 0LL;
    for (int i = 40; i >= 0; i--){
        int cnt = 0;
        for (int j = 0; j < n; j++){
            if ((a[j] >> i) & 1){
                cnt++;
            }
        }
        if ((n - cnt > cnt) && (res | (1LL << i)) <= k) {
            res |= (1LL << i);
        }
    }
    long long ans = 0;
    for (int i = 0; i < n; i++){
        ans += res ^ a[i];
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"sort"
	"strconv"
	//	"github.com/pkg/profile"
)

type card struct {
	suit   string
	number int
}

func (c card) toString() string {
	return fmt.Sprintf("%s %d", c.suit, c.number)
}

func isLTE(a, b card) bool {
	return a.number <= b.number
}

func isEQU(a, b card) bool {
	return a.suit == b.suit && a.number == b.number
}

func areEQU(a, b []card) bool {
	lenA := len(a)
	if lenA != len(b) {
		return false
	}
	for i, ca := range a {
		if isEQU(ca, b[i]) {
			continue
		} else {
			return false
		}
	}
	return true
}

func partition(ar []card, p, r int) int {
	x := ar[r]
	i := p - 1
	for j := p; j <= r-1; j++ {
		if isLTE(ar[j], x) {
			i++
			ar[i], ar[j] = ar[j], ar[i]
		}
	}
	ar[i+1], ar[r] = ar[r], ar[i+1]
	return i + 1
}

func qsort(ar []card, p, r int) {
	if p < r {
		q := partition(ar, p, r)
		qsort(ar, p, q-1)
		qsort(ar, q+1, r)
	}
}

func print(ar, ss []card) {
	var w = bufio.NewWriter(os.Stdout)

	if areEQU(ar, ss) {
		fmt.Fprintln(w, "Stable")
	} else {
		fmt.Fprintln(w, "Not stable")
	}

	n := len(ar)
	for i := 0; i < n; i++ {
		fmt.Fprintln(w, ar[i].toString())
	}

	_ = w.Flush()
}

func main() {
	//	defer profile.Start(profile.ProfilePath(".")).Stop()

	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)

	if !s.Scan() {
		log.Fatal("scan error")
	}

	n, _ := strconv.Atoi(s.Text())
	ar := make([]card, n)

	for i := 0; s.Scan() && i < n; i++ {
		su := s.Text()
		s.Scan()
		x, _ := strconv.Atoi(s.Text())
		ar[i] = card{su, x}
	}

	if s.Err() != nil {
		log.Fatal(s.Err())
	}

	ss := make([]card, len(ar))
	copy(ss, ar)
	sort.SliceStable(ss, func(i, j int) bool { return ss[i].number < ss[j].number })

	qsort(ar, 0, n-1)

	print(ar, ss)
}



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


int main(){
	int n,s;
	cin>>n;
	for(int i=0;i<n;i++){
		cout<<"Case "<<i+1<<':'<<endl;
		cin>>s;
		for(int j=0;j<10;j++){
			s=s*s/100%10000;
			cout<<s<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N,K=get_i
A=get_i.sort
dp=array(K+1,false)
(K+1).times do|i|
    A.each do|a|
        break unless i-a>=0
        dp[i]|=!dp[i-a]
    end
end
puts yn_judge(dp[K],"First","Second")

Measured memory_bytes: 15176
-- Input format: N X T
-- N: number of takoyaki to be created
-- X: number of takoyaki that can be created in one time period
-- T: time of one timeperiod (used above)
-- Return: time to make all takoyaki

module Main where

ans :: Int -> Int -> Int -> Int
ans n x t = 
	t * case n `mod` x of
		0 -> n `div` x
		_ -> 1 + (n `div` x)

main :: IO ()
main = getLine >>= 
	  putStrLn 
	. show 
	. (\(n:x:t:_) -> ans n x t)
	. map read
	. words


Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
bool comapare_by_sc (P a,P b){
	if(a.sc!=b.sc){
		return a.sc < b.sc;
	}
	else{
		return a.fs < b.fs;
	}
}

int main(){
	ll n,m,x,y;
	cin >> n >> m;
	vector<P> a(1000000,mp(LINF,-LINF));
	for(ll i = 0; i < n; i++) {
		cin >> x >> y;
		a[i] = mp(x,y);
	}
	
	sort(ALL(a));
	priority_queue<ll> q;
	ll j = 0;
	ll ans = 0;
	for(ll i = 1; i <= m; i++) {
		while(a[j].fs <=i){
			q.push(a[j].sc);
			j++;
		}
		if (!(q.empty())){
			ans += q.top();
			q.pop();
		}
	}
	
	
	cout << ans<< endl;
	return 0;
}

Measured memory_bytes: 17016
def levenshtein_distance(str1, str2)
  #
  # O(str1.size * str2.size)
  #
  # references:
  #   - https://www.youtube.com/watch?v=MiqoA-yF-0M
  #
  n = str1.size
  m = str2.size
  dp = Array.new(n + 1) { Array.new(m + 1, 0) }
  (n + 1).times { |i| dp[i][0] = i }
  (m + 1).times { |j| dp[0][j] = j }
  str1 = str1.split("")
  str2 = str2.split("")
  str1.each_with_index do |c1, i|
    str2.each_with_index do |c2, j|
      min = [dp[i][j], dp[i + 1][j], dp[i][j + 1]].min
      dp[i + 1][j + 1] = (c1 == c2 ? dp[i][j] : min + 1)
    end
  end
  dp[n][m]
end


a = gets.chomp
b = gets.chomp
p levenshtein_distance(a, b)



Measured memory_bytes: 14724
#include<stdio.h>
    #include<string.h>
    #include<math.h>
    #include<stdlib.h>
    #include<limits.h>
     
    #define rep(i,begin,end) for(int i=begin; i<end; i++)
    #define lld long long int
     
    void initStrArray(char** p, int n, int len){
        for(int i=0; i<n; i++){
            *(p + i) = (char*)malloc(sizeof(char) * (len + 1));
        }
    }
     
    int main(){
        int n;
        scanf("%d", &n);
        char* w[n];
        initStrArray(w, n, 10);
        rep(i, 0, n){
            scanf("%s", w[i]);
        }
        int f = 1;
        rep(i, 1, n){
            if(*(w[i]) != *(w[i-1] + strlen(w[i-1]) - 1)){
                f = 0;
            }
        }
        rep(i, 0, n){
            rep(j, i+1, n){
                if(strcmp(w[i], w[j]) == 0){
                    f = 0;
                }
            }
        }
        printf(f? "Yes" : "No");
     
        return 0;
    }

Measured memory_bytes: 128
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

int att(ll H) {
	if (H == 1) {
		return 1;
	}
	else {
		return (2 * att(H / 2) + 1);
	}
}



int main() {

	ll N, M,ac=0,wa=0;
	cin >> N >> M;
	vector<ll> AC(N);
	vector<ll> WA(N);
	
	rep(i, M) {
		ll p;
		string S;
		cin >> p >> S;
		if (S == "AC" && AC.at(p - 1) == 0) {
			ac++;
			AC.at(p - 1) = 1;
		}
		else if (S == "WA" && AC.at(p - 1) == 0) {
			WA.at(p - 1) ++;
		}
	}
	rep(i, N) {
		if (AC.at(i) == 1)
		{
			wa += WA.at(i);
		}
	}
	cout << ac << " " << wa << endl;
}





Measured memory_bytes: 1792
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(l[K-1])

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

using namespace std;

#define rep(i,n) for (decay_t <decltype (n)> i = 0, i ## __len = (n); i < i ## __len; ++ i)

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  size_t n, m;
  cin >> n >> m;

  auto max_l = 0;
  auto min_r = static_cast <int> (1e9);

  rep (i, m)
  {
    int l, r;
    cin >> l >> r;
    max_l = max (max_l, l);
    min_r = min (min_r, r);
  }

  auto ans = min_r - max_l + 1;
  cout << max (ans, 0) << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>
#include <complex>

using int64 = long long;
using uint64 = unsigned long long;

using namespace std;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int k;
    cin >> k;
    string s;
    cin >> s;

    string ans = s.substr(0, k);
    if (s.size() > k) {
        ans += "...";
    }
    cout << ans << endl;

    return 0;
}



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

int n;
int main() {
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin >> n;
	while(n--) {
		char ch;
		cin >> ch;
		if (ch == 'Y')
			return cout << "Four",0;
	}
	cout << "Three";
}


Measured memory_bytes: 256
#include<cstdio>
long long max(long long a, long long b) {
	return a > b ? a : b;
}
int main() {
	long long n, k, a, b, sum = 0;
	scanf("%lld%lld", &n, &k);
	if (k == 0) {
		printf("%lld", n*n);
		return 0;
	}
	for (b = k + 1; b <= n; b++) {
		sum += (b - k)*(n / b) + max(0, n%b - k + 1);
	}
	printf("%lld", sum);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <cstring>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};

const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};


ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

/*
//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}
*/

ll N;
vector<ll> A(200010);
int main(){
  cin >> N;
  rep(i, N) cin >> A[i];
  bool l = 1;
  if(A[0]) l = 0;
  rep(i, N-1) if(A[i+1] - A[i] > 1) l = 0;
  if(l == 0){
    cout << -1 << endl;
    return 0;
  }

  ll ans = 0;
  ll at = N-1;
  ll sta = -1;
  while(at >= 0){
    if(sta != -1){
      if(A[at] != sta){
        ans += A[at];
        sta = A[at];
      }
    }else{
      ans += A[at];
      sta = A[at];
    }
    sta--;
    at--;
  }
  cout << ans << endl;

}


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

typedef long long ll;

const int N = 200;
const int INF = 1<<30;
const int LIM = 2000;

int n, a[N], tmp[N];

int sum = 0;

inline double _random() { return rand() * 1.0 / RAND_MAX; }

inline ll solve()
{
    for( int i = 1; i <= n; i ++ )
        tmp[i] = a[i];

    for( int i = n; i >= 1; i -- )
    {
        ll now = 0;
        for( int j = i; j <= n; j += i )
            now -= tmp[j];

//		printf( "now:%d, posbility:%f\n", now, exp( now * 5.0 / sum - 1.5 ) );
 
        if( now >= 0 || exp( now * 5.0 / sum - 1.5 ) >= _random() )
            for( int j = i; j <= n; j += i ) tmp[j] = 0;
    }

    ll ret = 0;
    for( int i = 1; i <= n; i ++ )
        ret += tmp[i];
    return ret;
}

int main()
{
//	freopen( "mul.in", "r", stdin );
//	freopen( "mul.out", "w", stdout );
	
    srand( time( 0 ) );

    scanf( "%d", &n );
    for( int i = 1; i <= n; i ++ )
        scanf( "%d", &a[i] ), sum = std::max( sum, a[i] );


    ll ans = 0;
    for( int i = 1; i <= LIM; i ++ ) {
    	ll tmp = solve();
//    	printf( "solve:%d\n", tmp );
        ans = std::max( ans, tmp );
	}
    printf( "%lld\n", ans );

    return 0;
}

Measured memory_bytes: 512
#include <iostream>

int main(void) {
	long N;
	long M[5] = {0, 0, 0, 0, 0};
	long ans = 0;
	char cap[] = {'M', 'A', 'R', 'C', 'H'};
	std::string buf;
	// stdin
	std::cin >> N;
	for(int i = 0; i < N; ++i) {
		std::cin >> buf;
		for(int j = 0; j < 5; ++j) {
			if(buf[0] == cap[j]) {
				M[j] += 1;
			}
		}
	}
	// calc
	for(int i = 0; i < 5; ++i) {
		for(int j = i + 1; j < 5; ++j) {
			for(int k = j + 1; k < 5; ++k) {
				ans += M[i] * M[j] * M[k];
			}
		}
	}
	// stdout
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
const ll MAX_H=1000,MAX_W=1000;
ll H,W,A,B;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>H>>W>>A>>B;
	REP(i,B){
		REP(j,A)cout<<0;
		REP(j,W-A)cout<<1;
		cout<<endl;
	}
	REP(i,H-B){
		REP(j,A)cout<<1;
		REP(j,W-A)cout<<0;
		cout<<endl;
	}
}


Measured memory_bytes: 1280
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

typedef long long LL;

LL cnt[20][20];
LL sum[20][20];

int main(int argc, char* argv[]) {
	LL n, ans = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		bool p = false;
		LL x = 0;
		int two = 0, five = 0;
		for (char c : s) {
			if (c == '.') {
				p = true;
			} else {
				x = (x * 10) + c - '0';
				two -= p;
				five -= p;
			}
		}
		while (x % 2 == 0) {
			++two;
			x /= 2;
		}
		while (x % 5 == 0) {
			++five;
			x /= 5;
		}
		two = min(two, 9);
		five = min(five, 9);
		cnt[10 + two][10 + five] += 1;
		sum[10 - two][10 - five] += 1;
	}
	for (int i = 0; i < 20; ++i) {
		for (int j = 1; j < 20; ++j) {
			sum[i][j] += sum[i][j - 1];
		}
	}
	for (int i = 1; i < 20; ++i) {
		for (int j = 0; j < 20; ++j) {
			sum[i][j] += sum[i - 1][j];
		}
	}
	for (int i = -9; i <= 9; ++i) {
		for (int j = -9; j <= 9; ++j) {
			ans += sum[10 + i][10 + j] * cnt[10 + i][10 + j];
			if (i >= 0 && j >= 0) {
				ans -= cnt[10 + i][10 + j];
			}
		}
	}
	cout << ans / 2 << endl;
	return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void) {
	int n, i, a[100003], t, d[100003] = {};
	ll asum;

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

	asum = 0;
	t = 0;
	for (i = 0; i < n; i++) {
		asum += a[i];
		if (a[i] == 0) {
			t++;
		}
		else {
			d[t] += (a[i] & 1);
		}
	}

	for (i = 0; i <= t; i++) {
		asum -= (d[i] & 1);
	}

	cout << asum / 2 << endl;

	return 0;
}

Measured memory_bytes: 1024