akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cmath>
#define EPS 1e-10
int n,k;
double t,u,v,l;
double d[201];

double add(double a,double b){
	if(fabs(a+b)<EPS*(fabs(a)+fabs(b)))return 0.0;
	return a+b;
}

int main(void){
	scanf("%d %d %lf %lf %lf %lf",&n,&k,&t,&u,&v,&l);
	for(int i=1;i<=n;i++){
		scanf("%lf",&d[i]);
	}
	d[n+1]=l;
	int now=0;
	double tim=0.0,rest=0.0;
	for(int i=1;i<=n+1;i++){
		if(rest==0.0 && now==0){
			tim+=(d[i]-d[i-1])/u;
			if(now<k)now++;
			else if(now==k)rest=l;
		}else{
			double dist=d[i-1];
			while(add(dist,-d[i])!=0.0){
				if(rest>0.0){
					double cost=(d[i]-dist)/v;
					if(cost>rest){
						dist+=v*rest;
						tim+=rest;
						rest=0.0;
					}else{
						dist=d[i];
						tim+=cost;
						rest-=cost;
					}
				}else{
					if(now>0){
						now--;
						rest=t;
					}else{
						tim+=(d[i]-dist)/u;
						dist=d[i];
					}
				}
			}
			if(now<k)now++;
			else if(now==k)rest=t;
		}
		//printf("%f %f %d %lf\n",tim,d[i],now,rest);
	}
	printf("%.10f\n",tim);
	return 0;
}

Measured memory_bytes: 1084
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 998244353
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    lint N;
    cin >> N;
    lint a[3*N];
    rep(i,3*N) cin >> a[i];
    sort(a,a+3*N,greater<lint>());
    lint count=0,ans=0,p=1;
    while(count<N){
        ans+=a[p];
        p+=2;
        count++;
    }
    cout << ans << endl;
}

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

int main() {
    int n, l;
    cin >> n >> l;
    vector<string> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    std::sort(v.begin(), v.end());
    for (int i = 0; i < n; i++) {
        cout << v[i];
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return float64(i)
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

const Mod = 1000000007

func ModComb(n, k int) int {
	if k == 0 {
		return 1
	}
	x, y := n, k
	for i := 1; i < k; i++ {
		x = x * (n - i) % Mod
		y = y * (k - i) % Mod
	}
	inv := ModInv(y)
	return x * inv % Mod
}

func ModFact(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		fact = fact * i % Mod
	}
	return fact
}

func ModInv(x int) int {
	return ModPow(x, Mod-2)
}

func ModPow(a, n int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % Mod
		}
		a = a * a % Mod
		n /= 2
	}
	return res
}

func main() {
	sc.Split(bufio.ScanWords)
	n, a, b := readInt(), readInt(), readInt()

	ans := ModPow(2, n)

	ans -= 1

	if ans -= ModComb(n, a); ans < 0 {
		ans += Mod
	}

	if ans -= ModComb(n, b); ans < 0 {
		ans += Mod

	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

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

    int N, X, Y;
    cin >> N >> X >> Y;
    --X;
    --Y;
  
    vector<vector<int>> a(N, vector<int>(N, 0));
    map<int, ll> mp;
    rep(i, N - 1){
        for (int j = i + 1; j < N; j++) {
            a[i][j] = min(j - i, abs(X - i) + 1 + abs(Y - j));
            mp[a[i][j]]++;
        }
    }

    REP(i, N - 1){
        cout << mp[i] << endl;
    }
}


Measured memory_bytes: 16128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(2e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n,m, d[55][55]{}, ans=0;
    bool visited[55], bridge;
    queue<int> que;
    cin >> n >> m;
    REP(i,m){
        int a, b;
        cin >> a >> b;
        d[a][b] = i+1;
        d[b][a] = i+1;
    }
    REP(i,m){
        fill(visited,visited+n+1,false);
        bridge = false;
        que.push(1);
        while(!que.empty()){
            int p = que.front();
            que.pop();
            if(visited[p])continue;
            visited[p] = true;
            REP(j,n+1){
                if(d[p][j]>0 && !visited[j] && d[p][j] != i+1){
                    que.push(j);
                }
            }
        }
        REP(j,n){
            if(!visited[j+1])bridge = true;
        }
        ans += bridge;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

ll n,a,b;

int main(){
  cin >> n >> a >> b;
  ll x[n];
  rep(i,n){
    cin >> x[i];
  }
  ll ans=0;
  rep(i,n-1)ans+=min((x[i+1]-x[i])*a,b);
  cout << ans << endl;
return 0;}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <iomanip>
#include <sstream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int ans=0;
    for(int i=1; i<=n; i++){
        string hoge=to_string(i);
        if(hoge.length()%2 != 0){
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static final int mmax = (int)1.0e9;

	static void doIt(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		while(0 < n + m){
			int[][] costs = new int[m][m];
			int[][] times = new int[m][m];
			for(int i = 0; i < m; i++)
				for(int j = 0; j < m; j++) costs[i][j] = times[i][j] = i==j? 0 : mmax;
			for(int i = 0; i < n; i++){
				int a = sc.nextInt() - 1;
				int b = sc.nextInt() - 1;
				int cost = sc.nextInt();
				int time = sc.nextInt();
				costs[a][b] = costs[b][a] = cost;
				times[a][b] = times[b][a] = time;
			}

			//Warshall-Floyd Algorithm
			for(int k = 0; k < m; k++)
				for(int i = 0; i < m; i++)
					for(int j = i+1; j < m; j++){
						costs[i][j] = costs[j][i] = Math.min(costs[i][j], costs[i][k] + costs[k][j]);
						times[i][j] = times[j][i] = Math.min(times[i][j], times[i][k] + times[k][j]);
					}
			int k = sc.nextInt();
			for(int i = 0; i < k; i++){
				int p = sc.nextInt() - 1;
				int q = sc.nextInt() - 1;
				int r = sc.nextInt();
				if(r == 0) System.out.println(costs[p][q]);
				else System.out.println(times[p][q]);
			}
			n = sc.nextInt();
			m = sc.nextInt();
		}
	}
	public static void main(String[] args) {
		doIt();
	}
}

Measured memory_bytes: 14000
N = int(input())
T, A = map(int, input().split())
H = [int(i) for i in input().split()]
H_t = [T - 0.006 * h for h in H]
min_dif = abs(H_t[0] - A)
ans = 0
for i in range(1, len(H_t)):
    if abs(H_t[i] - A) < min_dif:
        min_dif = abs(H_t[i] - A)
        ans = i
print(ans + 1)


Measured memory_bytes: 38384
import sys

k=int(input())

def dfs(keta,num):
  global ans
  ans.append(int(''.join(num)))

  if keta==10:
    return

  min_n=max(0,int(num[-1])-1)
  max_n=min(9,int(num[-1])+1)
  for i in range(min_n,max_n+1):
    dfs(keta+1,num+[str(i)])

ans=[]
for i in range(1,10):
  dfs(1,[str(i)])

ans.sort()
print(ans[k-1])

Measured memory_bytes: 17332
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N,K;
	cin >> N >> K;
	vector< pair<int,int> > A(N);
	for(int i=0;i<N;++i){
		//数字,価値
		cin >> A[i].first >> A[i].second;
	}
	int s = K;
	LL ans = 0;
	
	while(s){
		LL res = 0;
		for(int i=0;i<N;++i){
			int val = A[i].first;
			if( (s|val) != s ) continue;
			res += A[i].second;
		}
		ans = max(ans,res);
		
		if( s&1 ){
			int pos = 0;
			while(s&1){
				s >>=1;
				++pos;
			}
			s<<=pos;
		}
		if(s==0)break;
		--s;
	}
	//0の場合をチェック
	LL res = 0;
	for(int i=0;i<N;++i){
		if( A[i].first == 0 ){
			res += A[i].second;
		}
	}
	ans = max(ans,res);

	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 1152
import collections

n = int(input())
ans = ''
z = 'abcdefghijklmnopqrstuvwxyz'
c = collections.Counter(z)
for key in c:
    c[key] = 1000
for i in range(n):
    s = input()
    s_1 = collections.Counter(s)
    for j in z:
        if j in s:
            c[j] = min(c[j], s_1[j])
        else:
            c[j] = 0

# print(c)
for key in c:
    if c[key] != 0:
        for i in range(c[key]):
            ans += key
new_str_list = sorted(ans)
new_str = ''.join(new_str_list)
print(new_str)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
//#include <ext/numeric>


using namespace std;
//using namespace __gnu_cxx;

const int MAXN = (int)1e3 + 5;
const int MAXM = (int)1e4 + 5;

const int MOD = 1000000007;

long long mul(long long a , long long b) {
    return a * b % MOD;
}

long long power(long long a , long long b) {
    if (!b) return 1;
    long long r = power(a , b / 2);
    r = mul(r , r);
    if (b&1) return mul(r , a);
    return r;
}

long long mod_inv(long long x) {
    return power(x , MOD - 2);
}



int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    string str;
    int k;
    cin >> str >> k;
    int n = (int) str.size();
    long long ans = 0;
    for (int i = 1; i < n; ++i) {
        if (k == 1)
            ans += 9;
        else if (k == 2) {
            for (int j = 2; j <= i; ++j) {
                ans += 81;
            }
        } else {
            for (int j = 2; j <= i; ++j) {
                for (int jj = j + 1; jj <= i; ++jj) {
                    ans += 81 * 9;
                }
            }
        }
    }

    if (k == 1)
        ans += str[0] - '0';
    else if (k == 2) {
        for (int i = 1; i <= str[0] - '0'; ++i) {
            bool f = i == str[0] - '0';
            for (int j = 1; j < n; ++j) {
                if (!f)
                    ans += 9;
                else
                    ans += str[j] - '0';
                f &= str[j] - '0' == 0;
            }
        }
    } else {
        for (int i = 1; i <= str[0] - '0'; ++i) {
            bool f = i == str[0] - '0';
            for (int j = 1; j < n; ++j) {
                for (int a = 1; a <= (f ? str[j] - '0' : 9); ++a) {
                    bool ff = f;
                    ff &= a == str[j] - '0';
                    for (int jj = j + 1; jj < n; ++jj) {
                        if (!ff)
                            ans += 9;
                        else
                            ans += str[jj] - '0';
                        ff &= str[jj] == '0';
                    }
                }
                f &= str[j] - '0' == 0;
            }
        }
    }


    cout << ans << '\n';


    return 0;
}

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

const int INF = 1e18;
int n,cnt;
int a[200010];
int L[100010],R[100010];

void merge(int l,int m,int r){
  int n1 = m-l;
  int n2 = r-m;
  for(int i = 0; i < n1; i++) L[i] = a[l+i];
  for(int i = 0; i < n2; i++) R[i] = a[m+i];
  L[n1] = R[n2] = INF;
  int i = 0,j = 0;
  for(int k = l; k < r; k++){
    if(L[i] <= R[j]) a[k] = L[i++];
    else {
      a[k] = R[j++];
      cnt += n1-i; //mid + j - k -1;
    }
  }
}

void mergesort(int l,int r){
  if(l+1 < r){
    int m = (l+r)/2;
    mergesort(l,m);
    mergesort(m,r);
    merge(l,m,r);
  }
}

signed main(){

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

  mergesort(0,n);

  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 6224
#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;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define INT_INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define MOD 998244353
#define MOD2 1494318097
#define SEED 131
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

#define MAXN 10000005

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unordered_map<int,int> umii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

mt19937 g1(time(0));

int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);}
ll randlong(ll a,ll b){return uniform_int_distribution<long long>(a, b)(g1);}

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

int len;
ll res,f[MAXN],power[MAXN];

ll inv(ll a){
	ll x1 = 1, b1 = a, x2 = 0, b2 = MOD;
	while (b2) {
		ll q = b1/b2;
		b1-=q*b2, x1-=q*x2;
		swap(x1,x2);
		swap(b1,b2);
	}
	return ((x1%MOD)+MOD)%MOD;
}

ll cnk(ll n, ll k){
	if(k > n) return 0;
	ll q = (inv(f[k])*inv(f[n - k]))%MOD;
	return (f[n]*q)%MOD;
}

int main(){
	scanf("%d",&len);
	f[0] = power[0] = 1;
	for(int i=1; i<=len; i++){
		f[i] = (f[i-1]*i)%MOD;
		power[i] = (power[i-1]*2)%MOD;
	}
	res = fpow(3,len,MOD);
	for(int i=len/2+1; i<=len; i++){
		ll add = (cnk(len,i)*2)%MOD;
		add = (add*power[len-i])%MOD;
		res = (res-add+MOD)%MOD;
	}
	printf("%lld\n",res);
}

Measured memory_bytes: 156544
str1 = int(input())
str2 = input().split()
 
use = int(str2[0])
 
ok_count = 0
 
while int(str2[1]) >= use:
    if use % str1 == 0:
        ok_count = 1
    use = use + 1
 
if ok_count == 1 :
    print("OK")
else:
    print("NG")

Measured memory_bytes: 9144
n=int(input())

x=[]
y=[]
for _ in range(n):
    xx,yy=map(int,input().split())
    x.append(xx)
    y.append(yy)

def maxAbsValExpr(arr1, arr2):
    minX, maxX = min(arr1), max(arr1)
    minY, maxY = min(arr2), max(arr2)
    
    ans = 0
    # For all four corners, calculate the max distance differences
    for point in [(minX, minY), (maxX, minY), (minX, maxY), (maxX, maxY)]:
        minD = float('inf')
        maxD = float('-inf')
        for i in range(0, len(arr1)):
            distance = abs(arr1[i]-point[0]) + abs(arr2[i]-point[1]) 
            minD = min(minD, distance)
            maxD = max(maxD, distance)
            ans = max(ans, maxD - minD)
    return ans


print(maxAbsValExpr(x, y))


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

inline void chmin(int &a, int b){a = min(a, b);}

int n;
int c[1000], w[1000];

int sw[1001];
bool f[1000][1000];
int dp[1001];

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d %d", c + i, w + i);
		sw[i + 1] = sw[i] + w[i];
	}
	
	for (int i = 0; i < n; i++){
		f[i][i] = true;
	}
	
	for (int w = 0; w < n; w++){
		for (int i = 0; i + w < n; i++){
			int W = sw[i + w + 1] - sw[i];
			if (i > 0 && W <= c[i - 1]){
				f[i - 1][i + w] |= f[i][i + w];
			}
			if (i + w + 1 < n && W <= c[i + w + 1]){
				f[i][i + w + 1] |= f[i][i + w];
			}
		}
	}
	
	for (int i = 1; i <= n; i++) dp[i] = 1 << 28;
	for (int i = 0; i < n; i++){
		for (int j = i; j < n; j++){
			if (f[i][j]) chmin(dp[j + 1], dp[i] + 1);
		}
	}
	
	printf("%d\n", dp[n]);
	
	return 0;
}

Measured memory_bytes: 2180
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N = read_a_int()
A = read_ints()

for a in A:
    if a % 2 == 0:  # 偶数であるものは
        if a % 3 == 0 or a % 5 == 0:
            pass
        else:
            print('DENIED')
            exit()
print('APPROVED')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	int arr[32]={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};
	int k;
	cin>>k;
	cout<<arr[k-1]<<endl;
}

Measured memory_bytes: 256
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    K = int(input())
    S = str(input())

    #output
    # %%
    T = len(S)
    if T <= K:
        print(S)
    else:
        print(S[:K] + "...")    

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

Measured memory_bytes: 9180
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <functional>
 
using namespace std;
 
int main() {
    int n;
    string s;
    cin>>n;
    if (n<3){
        cout<<0;
        return 0;
    }
    cin>>s;
    long long r=0,g=0,b=0;
    for (char c : s) {
        r+=c=='R';
        g+=c=='G';
        b+=c=='B';
    }
    long long cnt=r*g*b;
    for (int p=1;p<n;++p){
        for (int i=0,j=p,k=2*p;k<n;++i,++j,++k){
            if (s[i]!=s[j]&&s[j]!=s[k]&&s[k]!=s[i])
                --cnt;
        }
    }
    cout<<cnt;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
int main(void){
    int k;cin>>k;
    if(k<=10){
        cout<<k<<endl;
        return 0;
    }
    priority_queue<ll, vector<ll>, greater<ll> > que;
    rep(i,10){
        if(i==0)continue;
        que.push(i);
    }
    for(int i=1;i<k;i++){
        ll now=que.top();que.pop();//i番目に小さいルンルン数
        ll d=now%10;
        now*=10;
        
        if(d!=0)que.push(now+d-1);
        que.push(now+d);
        if((d+1)%10!=0)que.push(now+d+1);
    }
    ll res=que.top();
    cout<<res<<endl;
}


Measured memory_bytes: 2420
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str;
        char[] c = new char[100];
        int breakkeep, judge;
        while(true){
            int lmaru=0, rmaru=0, lkaku=0, rkaku=0, countlm=0, countrm=0, countlk=0, countrk=0, k=0, m=0;
            int[] locm = new int[100];
            int[] lock = new int[100];
            for(int i=0;i<100;i++){
                locm[i] = -1;
                lock[i] = -1;
            }
            breakkeep = 0;
            judge = 0;
            while(true){
                str = sc.nextLine();
                for(int i=0;i<str.length();i++){
                    c[i] = str.charAt(i);
                    if(c[i]=='.') breakkeep++;
                    judge = i;
                }
                if(breakkeep != 0) break;
            }
            if(judge == 0) break;
            for(int i=0;i<=judge;i++){
                if(c[i]=='('){
                    lmaru++;
                    countlm++;
                    m++;
                    locm[m] = i;
                }
                if(c[i]==')'){
                   countrm++;
                   if(locm[m] > lock[k] && lmaru > rmaru){
                       m--;
                       rmaru++;
                   }
                }
                if(c[i]=='['){
                    lkaku++;
                    countlk++;
                    k++;
                    lock[k] = i;
                }
                if(c[i]==']'){
                    countrk++;
                    if(lock[k] > locm[m] && lkaku > rkaku){
                        rkaku++;
                        k--;
                    }
                }
            }
            if((lmaru == rmaru && countlm == countrm) && (lkaku == rkaku && countlk == countrk)){
                System.out.println("yes");
            }else{
                System.out.println("no");
            }
        }
    }
}


Measured memory_bytes: 47584
#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e4 + 7, W = 3e4;
int n, x, a[maxn], b[maxn];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		a[i] = b[n - i + 1] = i * W;
	}
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &x);
		a[x] -= (n - i);
	}
	for (int i = 1; i <= n; ++i) printf("%d ", a[i]); printf("\n");
	for (int i = 1; i <= n; ++i) printf("%d ", b[i]); printf("\n");
	return 0;
}

Measured memory_bytes: 3892
# region header
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
import copy
# @lru_cache(maxsize=None)
# sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7
# endregion
# region input function


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])

# endregion


n, k = inpl()
a = inpl()

l = 0
r = 10**9
while l + 1 < r:
    x = (l + r) // 2
    cnt = 0
    for i in range(n):
        cnt += math.ceil(a[i] / x) - 1
        if cnt > k:
            break
    if cnt <= k:
        r = x
    else:
        l = x
print(r)


Measured memory_bytes: 32344
use std::cmp::{min, max};
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let k:i64 = read();
    let x:i64 = read();
    let start = max(-1000000, x-k+1);
    let end = min(1000000, k+x);
    for i in start..end {
        print!("{} ", i);
    }
    println!("");
}


Measured memory_bytes: 2116
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

int main() {
    vector<int> a{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};
    int i;
    cin >> i;
    i--;
    cout << a[i] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
#define int long long
typedef long long ll;
using namespace std;

const int N = 111111;
int p[N], q[N], r[N];
int x, y, a, b, c;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> x >> y >> a >> b >> c;
    rep(i, 1, a) {
        cin >> p[i];
    }
    rep(i, 1, b) {
        cin >> q[i];
    }
    rep(i, 1, c) {
        cin >> r[i];
    }
    sort(p + 1, p + a + 1, std::greater<int>());
    sort(q + 1, q + b + 1, std::greater<int>());
    vector<int> v;
    rep(i, 1, x) {
        v.pb(p[i]);
    }
    rep(i, 1, y) {
        v.pb(q[i]);
    }
    rep(i, 1, c) {
        v.pb(r[i]);
    }
    sort(rng(v), std::greater<int>());
    int ans = 0;
    rep(i, 1, x + y) {
        ans += v[i - 1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8176
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

ll a, b, x;

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

  ll aa;
  if (a % x == 0) {
    aa = a;
  } else {
    aa = a + x - a % x;
  }

  ll bb;
  if (b % x == 0) {
    bb = b;
  } else {
    bb = b - b % x;
  }

  if (bb < aa) {
    cout << 0 << endl;
    return 0;
  }

  ll diff = bb - aa;
  cout << diff / x + 1 << endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb(x) (x&-(x))
const int N = 101010;
int pa[N];
int a[N];
int n,m;
int init()
{
	rep(i,0,N) pa[i]=i;
}
int find(int x) 
{
if(pa[x]==x) return x;
return pa[x]=find(pa[x]);
}
int Union(int x,int y)
{
	int fx=find(x),fy=find(y);
	if(fx!=fy)
	{
		if(fx>fy) swap(fx,fy);
		pa[fx]=fy;
	}
	return 0;
}
set<int> s[N];
set<int> ss[N];
int ord[N];
int main(){
	init();
	int tmp1,tmp2; 
	scanf("%d%d",&n,&m);
	rep(i,0,n) scanf("%d",&a[i+1]);
	rep(i,0,m)
	{
		scanf("%d%d",&tmp1,&tmp2);
		Union(tmp1,tmp2);
	} 
	rep(i,1,n+1) {s[find(i)].insert(i);ss[find(i)].insert(a[i]);}
	set<int>::iterator it;	
	rep(i,1,n+1) 
	{	
		if(s[i].size()!=0)
		{//	de(s[i].size());
			
			for(it=s[i].begin();it!=s[i].end();it++)
			{
			//	de(*it);
			if(ss[i].find(*it)!=ss[i].end()) 
			{
			ord[*it]=1;//de(*it);de(a[*it]);
			}
			}
		}
	}
	int cnt=0;
	rep(i,1,n+1) if(ord[i]==1) cnt++;
	printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 20224
// AUTHOR: ROSHAN SRIVASTAVA
// WEBSITE: https://www.youtube.com/channel/UC6uQdd7kLLOdlHSVklhV7Cw

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

// int n; 

int main(){

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    string x;
    cin >> x;

    int r = 0;
    int curr = 0;
    for(int i = 0; i < 3; i++) {
        if(x[i] == 'R') curr++;
        else {
            r = max(r, curr);
            curr = 0;
        }
    }

    r = max(r, curr);

    cout << r << endl;

    return 0;
}

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

int S;
int h, m, s;

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

    cin >> S;

    h = S / 3600;
    m = (S % 3600) / 60;
    s = (S % 60);

    cout << h << ':' << m << ':' << s << '\n';
    return 0;
}


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

void makePrimeNumber(int N, vector<bool>& prime) // 0ツ暗按湘」Nツ暗按可コツづ個青ョツ青板つゥツづァツ素ツ青板づーツ探ツつキ
{
    prime.assign(N+1, true);
    prime [0] = prime[1] = false;
    for(int i=2; i*i<=N; i++){
        if(prime[i]){
            for(int j=i; i*j<=N; j++){
                prime[i*j] = false;
            }
        }
    }
}

int main()
{
    vector<bool> prime;
    makePrimeNumber(50000, prime);

    for(;;){
        int m, a, b;
        cin >> m >> a >> b;
        if(m == 0)
            return 0;

        int p1 = 0;
        int q1 = 0;
        for(int p=1; p*p<=m; ++p){
            if(!prime[p])
                continue;
            int q = p;
            while(p * q <= m && a * q <= p * b){
                if(prime[q] && p * q >= p1 * q1){
                    p1 = p;
                    q1 = q;
                }
                ++ q;
            }
        }

        cout << p1 << ' ' << q1 << endl;
    }
}

Measured memory_bytes: 0
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = int;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1<<30;
const double pi=acos(-1.0);

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; }

ll H,W;
vector<string> grid;

bool movable(ll gx,ll gy){
  if(gx<0||gx>=W||gy<0||gy>=H) return false;
  if(grid[gy][gx]=='#') return false;
  
  return true;
}
  
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  cin>>H>>W;
  ll sy,sx; cin>>sy>>sx; sx--; sy--;
  ll gy,gx; cin>>gy>>gx; gx--; gy--;
  grid=vector<string>(H); rep(i,H) cin>>grid[i];
  
  //bfs
  priority_queue<tuple<ll,ll,ll>> que;
  vector<vector<ll>> dp(H,vector<ll>(W,INF));
  vector<vector<int>> checked(H,vector<int>(W,0));
  
  que.push({0,sx,sy}); dp[sy][sx]=0;
  
  vector<ll> dx={-1,0,1,0};
  vector<ll> dy={0,-1,0,1};
  while(!que.empty()){
    auto v=que.top(); que.pop();
    ll cost,vx,vy; tie(cost,vx,vy)=v;
    if(checked[vy][vx]) continue;
    if(vx==gx&&vy==gy) break;
    checked[vy][vx]=1;
    cost*=-1;
    rep(i,4){
      if(movable(vx+dx[i],vy+dy[i])&&chmin(dp[vy+dy[i]][vx+dx[i]],cost)){
        que.push({-cost,vx+dx[i],vy+dy[i]});
      }
    }
    if(movable(vx+dx[0],vy+dy[0])&&movable(vx+dx[1],vy+dy[1])&&movable(vx+dx[2],vy+dy[2])&&movable(vx+dx[3],vy+dy[3])) continue;
    rep(i,3){
      rep(j,3){
        if(abs(i)+abs(j)<=1) continue;
        if(movable(vx+i,vy+j)&&chmin(dp[vy+j][vx+i],cost+1)) que.push({-cost-1,vx+i,vy+j});
        if(movable(vx-i,vy+j)&&chmin(dp[vy+j][vx-i],cost+1)) que.push({-cost-1,vx-i,vy+j});
        if(movable(vx+i,vy-j)&&chmin(dp[vy-j][vx+i],cost+1)) que.push({-cost-1,vx+i,vy-j});
        if(movable(vx-i,vy-j)&&chmin(dp[vy-j][vx-i],cost+1)) que.push({-cost-1,vx-i,vy-j});
      }
    }
  }
  
  if(dp[gy][gx]==INF) cout<<-1<<endl;
  else cout<<dp[gy][gx]<<endl;
  return 0;
}


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

int main()
{
    int n;
    cin >> n;
    int cx=0, cy=0, cz=0;
    for(int i=0; i<n; i++)
    {
        bool check = true;
        int x;
        cin >> x;
        if(x%2)
            continue;
        if(x%5==0 || x%3==0)
            cx++;
        else
            cy++;
        cz++;
    }
    if(cz==cx)
        cout << "APPROVED" << endl;
    else
        cout << "DENIED" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	char c[9];
	char field[3][3];
	while(cin >>c){
		for(int i=0; i<9; i++){field[i%3][i/3] = c[i];}
		for(int i=0; i<3; i++){
			if(field[i][0] == field[i][1] && field[i][1] == field[i][2] && field[i][0] != 's'){cout <<field[i][0]<<endl;goto end;}
			if(field[0][i] == field[1][i] && field[1][i] == field[2][i] && field[0][i] != 's'){cout <<field[0][i]<<endl;goto end;}
		}
		if(field[0][0] == field[1][1] && field[1][1] == field[2][2] && field[0][0] != 's'){cout <<field[0][0]<<endl;goto end;}
		if(field[2][0] == field[1][1] && field[1][1] == field[0][2] && field[2][0] != 's'){cout <<field[2][0]<<endl;goto end;}		
		cout <<"d"<<endl;
		end:;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main{
	
	static final Scanner s=new Scanner(System.in);
	
	public static void main(String[] __){
		long n=s.nextLong(),k=s.nextLong(),res=k;
		for(int i=1;i<n;i++)
			res*=k-1;
		System.out.println(res);
	}
}

Measured memory_bytes: 23636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

void solve(){
	int a, b, c; cin >> a >> b >> c;
	int cnt = 0;
	while(1) {
		if(a % 2 || b % 2 || c % 2) {
			printf("%d\n", cnt); return;
		}
		if(a == b && b == c) {
			puts("-1");
			return;
		}
		int na = (b + c) / 2;
		int nb = (a + c) / 2;
		int nc = (a + b) / 2;
		a = na, b = nb, c = nc; ++cnt;
	}
}

int main(){
	int Tc = 1; // scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		// printf("Case #%d\n", tc);
		solve();
	}
	return 0;
};

Measured memory_bytes: 256
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
#define LEAD (lead && !i)
#define LIM (lim && i == buc[pos])
#define ABS(x) (x) < 0 ? (-x) : (x)
#define RG register
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 200000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e8 + 7;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int INF = 0x3f3f3f3f;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
// const double PI = acos(-1);
const double PI = 3.14159;

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

namespace Comb{
inline void exgcd(ll a, ll b, ll &g, ll &x, ll &y) {
    if (!b) g = a, x = 1, y = 0;
    else exgcd(b, a % b, g, y, x), y -= x * (a / b);
}
 
inline ll inv(ll a) {
    ll g, res, tmp;
    exgcd(a, MOD, g, res, tmp);
    return ((res % MOD) + MOD) % MOD;
}
 
ll f[N], invFact[N];
 
inline void prepare() {
    f[0] = 1;
    int n = 200000;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % MOD;
    invFact[n] = inv(f[n]);
    for (int i = n - 1; i >= 1; i--) invFact[i] = invFact[i + 1] * (i + 1) % MOD;
}
 
inline ll C(int m, int n) {
    /*
    if (!m) return 1;
    if (n == m) return 1;
    if (m > n) return 0;
    if (m < 0) return 0;
    */
    return f[n] * invFact[m] % MOD * invFact[n - m] % MOD;
}
}

int main() {
    std::ios::sync_with_stdio(false);
    int n, x, cnt = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> x;
        if (x & 1) cnt++;
    }
    if (cnt & 1) puts("NO");
    else puts("YES");
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=n;i>0;--i){
        cout << a[i-1];
        if(i!=1)cout << " ";
    }
   cout << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/


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

long long n, k, d;

int main() {
    cin >> n >> k >> d;
    long long tmp = min(abs(n)/d, k);
    if (n < 0) n += d*tmp;
    else n -= d*tmp;
    k -= tmp;
    k %= 2;
    if (k){
        if (n < 0) n += d;
        else n -= d;
    }
    cout << abs(n) << "\n";
}


Measured memory_bytes: 3628
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
const int N=5e5+5;
struct eg{int v,nx;}e[N<<1];int head[N],tot=1;
inline void add(R int u,R int v){e[++tot]={v,head[u]},head[u]=tot;}
int n,m,vis[N],ok[N],deg[N];
void dfs(int u,int fa){
	vis[u]=1;
	go(u)if(v!=fa){
		if(!vis[v])dfs(v,u);
		else if(!ok[i])printf("%d %d\n",u,v),ok[i]=ok[i^1]=1,deg[u]^=1;
	}
	if(fa){
		if(deg[u])printf("%d %d\n",u,fa);
		else printf("%d %d\n",fa,u),deg[fa]^=1;
	}
}
int main(){
	scanf("%d%d",&n,&m);
	if(m&1)return puts("-1"),0;
	for(R int i=1,u,v;i<=m;++i)scanf("%d%d",&u,&v),add(u,v),add(v,u);
	dfs(1,0);
	return 0;
}

Measured memory_bytes: 14720
#define s(a,b) (t=a,a=b,b=t)
char p[9],m;q,a,b,c,d,e,f,t,r;main(n){while(scanf("%d",&n),n){r=a=1,b=6,c=2,d=5,e=3,f=4;while(n--){scanf("%s",p);m=*p-70;if(m%6==0){s(c,e);s(d,f);q=m^6?s(e,f):s(c,d);}else if(7<m&&m<14){s(a,c);s(b,d);q=m^13?s(c,d):s(a,b);}else{s(a,e);s(b,f);q=m>0?s(e,f):s(a,b);}r+=a;}printf("%d\n",r);}}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
#define dbg1(x) cerr<<#x<<"="<<(x)<<" "
#define dbg2(x) cerr<<#x<<"="<<(x)<<"\n"
#define dbg3(x) cerr<<#x<<"\n"
using namespace std;
#define reg register
inline ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*f;
}
const int MN=1e5+5;
ll N,C,X[MN],W[MN];
ll p1,p2,s1,s2,p1m[MN],p2m[MN],s1m[MN],s2m[MN];
int main()
{
	N=read(),C=read();
	reg int i;
	for(i=1;i<=N;++i) X[i]=read(),W[i]=read();
	X[N+1]=C;
	for(i=1;i<=N;++i)
	{
		p1+=W[i]+X[i-1]-X[i];
		p2=p1-X[i];
		p1m[i]=max(p1m[i-1],p1);
		p2m[i]=max(p2m[i-1],p2);
	}
	for(i=N;i;--i)
	{
		s1+=W[i]-X[i+1]+X[i];
		s2=s1-C+X[i];
		s1m[i]=max(s1,s1m[i+1]);
		s2m[i]=max(s2,s2m[i+1]);
	}
	ll ans=0;
	for(i=1;i<=N;++i)
		ans=max(p2m[i]+s1m[i+1],ans),
		ans=max(p1m[i],ans);
	for(i=1;i<=N;++i)
 		ans=max(s2m[i]+p1m[i-1],ans),
 		ans=max(s1m[i],ans);
 	return 0*printf("%lld\n",ans);
}

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

int main() {
    int n,m;
  cin>>n>>m;
  scc_graph g(n);
  for (int i = 0; i < m; i++) {
        int u, v;
    	cin>>u>>v;
   	   	g.add_edge(u-1, v-1);
       	   	g.add_edge(v-1, u-1);

    }
  vector<vector<int>> scc = g.scc();
  cout<<int(scc.size())-1;

}

Measured memory_bytes: 11164
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> P;
 
#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 1e15;
 
__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int gcdd(int a,int b) {
  if (a%b==0) {
  return(b);
  } else {
    return(gcdd(b,a%b));
  }
}

signed main() {
	ll n, x, s[100001];
  cin >> n >> x;
  ll result;
  rep(i, n) {
    cin >> s[i];
    if(!i) result = abs(x - s[i]);
    if(i) result = gcdd(abs(x - s[i]), result);
  }
  cout << result << endl;
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<int>a(n+1);
    a[0]=0;
    for(int i=1;i<n+1;i++)cin>>a[i];
    ll saou=0;
    for(int i=1;i<n+1;i++){
        saou+=abs(a[i]-a[i-1]);
    }
    saou+=abs(a[n]);
    for(int i=1;i<n+1;i++){
        if(i<n){
            ll ans=saou-abs(a[i-1]-a[i])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]);
            cout<<ans<<endl;
        }
        else{
            ll ans=saou-abs(a[n])-abs(a[n]-a[n-1])+abs(a[n-1]);
            cout<<ans<<endl;
        }
    }
}
    

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	int i = 1;
    	while (true){   
    		int a = scan.nextInt();
    		if(a == 0){
    			break;
    		}else{
    			System.out.println("Case"+" "+i+":"+" "+a);
        		i= i + 1;
    		}
    	}
   }
}

Measured memory_bytes: 13000
#include <cstdio>
#include <cstdlib>
//#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <queue>
#include <set>
using namespace std;

int main(void){

	int n;
	while (cin >> n, n){
		priority_queue<int> result;

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

			int buff; cin >> buff;
			result.push(buff);

		}
		
		long int num = 0;
		int i = 0;
		int buff = 0;

		result.pop();
		buff = result.top();
		result.pop();
		while (!result.empty()) {
			num += buff;
			buff = result.top();
			result.pop();
			i++;
		}

		cout << num / i << endl;
		
	}

	return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    int sa = b-a;
    int tmp=0;
    for (int i=1;i<=sa;i++){
        tmp += i;
    }
    cout << tmp-b << endl;
}

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

X, Y, Z = 0, 0, 0
for p in P:
    if p <= A:
        X += 1
    elif A + 1 <= p <= B:
        Y += 1
    elif B + 1 <= p:
        Z += 1

if X > 0 and Y > 0 and Z > 0:
    print(min(X, Y, Z))
else:
    print(0)


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

int main()
{
    int N;
    cin >> N;
    vector<string> S(N);
    int use[5] = {0};
    int M = 0;
    int A = 1;
    int R = 2;
    int C = 3;
    int H = 4;

    for (int i = 0; i < N; i++)
    {
        cin >> S[i];
        if (S[i][0] == 'M')
        {
            use[M]++;
        }
        else if (S[i][0] == 'A')
        {
            use[A]++;
        }
        else if (S[i][0] == 'R')
        {
            use[R]++;
        }
        else if (S[i][0] == 'C')
        {
            use[C]++;
        }
        else if (S[i][0] == 'H')
        {
            use[H]++;
        }
    }

    long long ans = 0;
    for (int i = 0; i <= 2; i++)
    {
        if (use[i] == 0)
        {
            continue;
        }
        for (int j = i + 1; j <= 3; j++)
        {
            if (use[j] == 0)
            {
                continue;
            }
            for (int k = j + 1; k <= 4; k++)
            {
                if (use[k] == 0)
                {
                    continue;
                }
                ans += (long long)use[i] * use[j] * use[k];
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6144
N=int(input())

# 約数の個数のテーブルを O(N loglog N) で作る
div = [1] * (N+1)
div[0] = 0

for p in range(2, N+1):
  if div[p] != 1:
    continue
  # p は素数
  pp = p  # power of p
  e = 1
  while pp <= N:
    for n in range(pp, N+1, pp):
      div[n] += div[n] // e
    e += 1
    pp *= p  

ans = sum(div[:N])
print(ans)

Measured memory_bytes: 24732