akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

  vector<int> A(n);

  bool approved = true;
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    A[i] = a;
  }

  for (int i = 0; i < n; i++) {
    int a = A[i];
    if (a % 2 == 0) {
      if (!((a % 3 == 0) || (a % 5 == 0))) {
        approved = false;
        break;
      }
    }
  }

  cout << (approved ? "APPROVED" : "DENIED") << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int n,k,x,y,sum=0;
  scanf("%d", &n);
  scanf("%d", &k);
  scanf("%d", &x);
  scanf("%d", &y);
  if(n<k) k=n;
  for(int i=1;i<=k;i++) sum+=x;
  for(int j=k+1;j<=n;j++) sum+=y;
  
  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
using namespace std;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
#define pb push_back
template<class T> void print(const T& x){cout << x << endl;}
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;

ll G[3001][3001];
ll dp[3001][3001][4];

int main(){
    ll R, C, K; cin >> R >> C >> K;
    rep(r, 0, 3001){
        rep(c, 0, 3001){
            rep(k, 0, 4){
                dp[r][c][k] = 0;
            }
            G[r][c] = 0;
        }
    }
    rep(i, 0, K){
        ll r, c, v; cin >> r >> c >> v;
        r--; c--;
        G[r][c] = v;
    }
    dp[0][0][0] = 0;
    dp[0][0][1] = G[0][0];

    rep(r, 0, R){
        rep(c, 0, C){
            rep(k, 0, 4){
                if(0 <= c+1 < C && k+1 <= 3){
                    dp[r][c+1][k+1] = max(
                        dp[r][c][k] + G[r][c+1],
                        dp[r][c+1][k+1]
                    );
                }
                if(0 <= c+1 < C){
                    dp[r][c+1][k] = max(
                        dp[r][c+1][k], 
                        dp[r][c][k]
                    );
                }
                if(0 < r+1 < R){
                    dp[r+1][c][1] = max(
                        dp[r][c][k] + G[r+1][c],
                        dp[r+1][c][1]
                    );
                    dp[r+1][c][0] = max(
                        dp[r][c][k],
                        dp[r+1][c][0]
                    );
                }
            }
        }
    }
    ll ans = max(dp[R-1][C-1][0], dp[R-1][C-1][1]);
    ll ans2 = max(dp[R-1][C-1][2], dp[R-1][C-1][3]);
    ans = max(ans, ans2);
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 355432
/*
 * atcoder/abc141_2nd/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
#include <queue>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/*
 * ある時点で最も高いものに使うと最大効果なので、それで貪欲.
 * こういうものは優先度付きキューを使える.
 */
int N, M;
void solve() {
  cin >> N >> M;
  priority_queue<ll> Q;
  ll a;
  loop(n,0,N) {
    cin >> a;
    Q.push(a);
  }

  loop(i,0,M) {
    if (Q.empty()) break;
    ll top = Q.top(); Q.pop();
    top /= 2;
    if (top) Q.push(top);
  }

  ll total = 0;
  while (Q.size()) { total += Q.top(); Q.pop(); }
  cout << total << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 1400
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main(){
	int A, B, X;
	cin >> A >> B >> X;
	int min = 100000000;
	for(int i = 0; true; i++){
		for(int j = 0; true; j++){
			int water = i * 1000 + j * 500;
			if(water >= X){
				int price = i * A + j * B;
				if(price < min){
					min = price;
				}
				break;
			}
		}
		if(i*1000 >= X){
			break;
		}
	}
	cout << min << "\n";
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define l first
#define r second

using namespace std;

const int maxn = 2e5 + 1;

int a[maxn], b[maxn];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int oc = 0;
    for (int i = 0; i < n; i++)
        oc += (a[i] % 2);
    cout << (oc % 2 ? "NO" : "YES");
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int n, m; cin >> n >> m;
	priority_queue<ll> pq;
	int k = n;
	while( k-- ){
		ll a; cin >> a;
		pq.push(a);
	}
	while( m-- ){
		ll a = pq.top();
		pq.pop();
		pq.push(a/2);
	}
	ll ans = 0;
	while( n-- ){
		ans += pq.top();
		pq.pop();
	}
	cout << ans << endl;
}


Measured memory_bytes: 1400
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = list(map(int, input().split()))
for _ in range(K):
  imos = [0] * (N + 1)
  for i in range(N):
    l = max(0, i - a[i])
    r = min(N - 1, i + a[i]) + 1
    imos[l] += 1
    imos[r] -= 1
  for i in range(N): imos[i + 1] += imos[i]
  a = imos[: -1]
  if a.count(N) == N: break
print(*a)

Measured memory_bytes: 128436
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;


int main(){
  int N; cin >> N;
  int parity = -1;

  stack<int> ans;
  if (N==0) ans.push(N);

  while (N!=0){
    int m = abs(N)%2;
    ans.push(m);
    (N += m*parity) /= 2;
    parity *= -1;
    // cout << N << endl;
  }
  while (!ans.empty()) {
    cout << ans.top();
    ans.pop();
  }

  // cout << fixed << setprecision(10);
  
  return 0;
}

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

#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) \
  for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) \
  for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int;  // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9) + 7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector<pair<ll, ll>> prime_factorize(ll n) {
  vector<pair<ll, ll>> p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    pair<ll, ll> a = make_pair(i, 0);
    while ((n % i) == 0) {
      n /= i;
      a.second += 1;
    }
    p.push_back(a);
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
  ll b = MOD, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= MOD;
  if (u < 0) {
    u += MOD;
  }
  return u;
}
// 順列
ll permutation(const ll n, const ll m) {
  ll result = 1;
  for (ll i = n; i > n - m; i--) {
    result = (result * i) % MOD;
  }
  return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
  if (x == 0) return 1;
  ll res = repeat_square(n, x / 2);
  res = res * res % MOD;
  if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m) {
  ll p = permutation(n, m);
  ll div = 1;
  for (ll i = 2; i <= m; i++) {
    div = (div * i) % MOD;
  }
  return (p * modinv(div)) % MOD;
}

// アルファベットの取得
string get_alphabet(ll n) {
  n--;
  return string(1, 'a' + (n % 26));
}

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

  ll ans = 0;
  if (abs(N - M) > 1) {
    cout << ans << endl;
    return 0;
  }

  ll a = permutation(N, N);
  ll b = permutation(M, M);
  if (N == M) ans = 2 * a * b;
  else ans = a * b;
  ans %= MOD;

  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main(void){
    string S,T;
    
    cin >> S ;
    cin >> T ;
    int counter ;
    int res = 0;
    for(int i = 0 ; i < S.length()-T.length()+1; i++)
    {
        counter = 0;
        for(int j = 0; j < T.length(); j++)
        {
            if(S[i+j] == T[j])
            {
                counter++;
            }
        }
        if(res < counter)
        {
            res = counter;
        }
    }
    cout << T.length() - res << endl;
   
    
}

Measured memory_bytes: 3556
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(decimal.Parse).ToArray();
        var A = vals[0];
        var B = vals[1];

        Console.WriteLine((long)(A * B));
    }
}

Measured memory_bytes: 28204
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,m,x,y,z,par[100010],ans=0;

int FIND(int pos)
{
	if(par[pos]!=pos) par[pos]=FIND(par[pos]);
	return par[pos];
}

void UNION(int pos1,int pos2)
{
	par[FIND(pos1)]=FIND(pos2);
}

int main()
{
	rep(i,100005) par[i]=i;
	cin>>n>>m;
	rep(i,m)
	{
		scanf("%d%d%d",&x,&y,&z);
		UNION(x,y);
	}
	repn(i,n) if(par[i]==i) ans++;
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 640
import functools
n, x = map(int,input().split())
place = list(map(int,input().split()))
place.append(x)
place.sort()
if n == 1:
    print(place[1] - place[0])
    exit()

k = []
for i in range(1, n+1):
    k.append(place[i] - place[i-1])

def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a%b)

def gcd(nums):
    return functools.reduce(euclid, nums)

print(gcd(k))

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

	string S;
	cin >> S;
	ll N = S.size();
	ll res1 = 0, res2 = 0;
	REP(i, N){
		if(i%2 == 0){
			if(S[i] == '1') res1++;
			if(S[i] == '0') res2++;
		}else{
			if(S[i] == '1') res2++;
			if(S[i] == '0') res1++;
		}
	}   
	cout << min(res1, res2) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
using i64 = int64_t;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
int main() {
	i64 n; cin >> n;
	vector<pair<i64, i64>> a;
	rep(i, 1, n + 1) {
		int t;
		cin >> t;
		a.emplace_back(t, i);
	}

	// 小さいほう/大きいほうから埋めていって考える状態数を減らすのは常套手段ですよね！
	sort(a.begin(), a.end());

	set<i64> ids;
	ids.insert(0);
	ids.insert(n + 1);
	i64 ans = 0;
	rep(i, 0, n) {
		i64 val = a[i].first;
		i64 idx = a[i].second;
		ids.insert(idx);
		auto itr = ids.find(idx);
		ans += val * (idx - *--itr) * (*++++itr - idx);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 15864
S = input()
if S[0] == "A" and S[2:-1].count("C") > 0:
    S = S[:S.index("C")] + S[1+S.index("C"):] 
    if str.islower(S[1:]):
        print("AC")
    else:
        print("WA")
        
else:
    print("WA")

Measured memory_bytes: 3060
/*

                                  In the name of Allah, Most Gracious, Most Merciful


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

//*** constant value ***
const long double PI = 3.141592653589793238;
const double EPS = 1e-6 ;
//*** constant value ***

//****** define ********
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define dd double
#define vll vector<ll>
#define vs vector<string>
#define fn(i,n) for(ll i = 0; i<n; i++)
#define f(i,a,b) for(i=a;i<b;i++)
#define f1(i,a,b) for(i=b-1;i>=a;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pls pair<ll,string>
#define vpl vector<pll>
#define pb push_back
#define mk make_pair
#define x first
#define y second
#define tt cout<<"Came here"<<endl;
//****** define ********
void solve()
{


}

int main()
{
    IOS;
    ll tc;
    cin>>tc;
    string s;
    ll ac,tle,wa,re;
    ac = tle = wa = re = 0;
    while(tc--)
    {
        cin>>s;
        if(s=="AC")
            ac++;
        else if(s=="TLE")
            tle++;
        else if(s=="WA")
            wa++;
        else if(s=="RE")
            re++;
    }

    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;



return 0;
}



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

using namespace std;

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

    vector<int> d(N);
    for (int i = 0; i < N; i++) cin >> d.at(i);

    sort(d.begin(), d.end());

    int cnt = 0;
    int now = 9999999;
    for (int i = 0; i < N; i++) {
        if (now != d.at(i)) {
            cnt++;
            now = d.at(i);
        }
    }

    cout << cnt << endl;

}

Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


n = onem()

po = []
su = 0
for i in range(n):
    a,b = m()
    po.append([a+b,a])
po.sort(reverse = True)

for i in range(n):
    if i % 2 == 0:
        su += po[i][1]
    else:
        su -= po[i][0] - po[i][1]
print(su)



Measured memory_bytes: 54236
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
 
  // ここにプログラムを追記
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}

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

using namespace std;

int N, needRepair, atLeast[509];
char a[509][509];

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d\n", &N);
for (int i=1; i<=N; i++)
    scanf ("%s", a[i] + 1);
bool allWhite = 1;
for (int i=1; i<=N; i++)
    for (int j=1; j<=N; j++)
        a[i][j] = (a[i][j] == '#'), allWhite &= (a[i][j] == 0);
if (allWhite)
{
    printf ("-1\n");
    return 0;
}
for (int j=1; j<=N; j++)
    for (int i=1; i<=N; i++)
        atLeast[j] |= a[i][j];
for (int j=1; j<=N; j++)
{
    bool allBlack = 1;
    for (int i=1; i<=N; i++)
        allBlack &= a[i][j];
    if (!allBlack) needRepair ++;
}
int ans = 2 * N;
for (int k=1; k<=N; k++)
{
    int curr = 0;
    for (int i=1; i<=N; i++)
        curr += (a[k][i] == 0);
    curr += needRepair;
    if (!atLeast[k]) curr ++;
    if (curr < ans)
        ans = curr;
}
printf ("%d\n", ans);
return 0;
}


Measured memory_bytes: 512
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

ll power(ll a, ll b){
  ll s = 1;
  while (b){
    if (b & 1) s = s * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return s;
}

ll fact[1010], ifact[1010], inv[1010], pifact[1010][1010];
ll n, a, b, c, d;
ll dp[1010];

int main(){
  rep(i, 1, 1010) inv[i] = power(i, mod - 2);
  fact[0] = ifact[0] = 1;
  rep(i, 1, 1010) fact[i] = fact[i - 1] * i % mod;
  rep(i, 1, 1010) ifact[i] = ifact[i - 1] * inv[i] % mod;
  rep(i, 1010){
    pifact[i][0] = 1;
    rep(j, 1, 1010) pifact[i][j] = pifact[i][j - 1] * ifact[i] % mod;
  }

  cin >> n >> a >> b >> c >> d;
  dp[0] = 1;
  rep(i, a, b + 1) rrep(j, n + 1) rep(k, c, min(d, j / i) + 1){
    ll t = dp[j - i * k] * fact[n - j + i * k] % mod * ifact[n - j] % mod * pifact[i][k] % mod * ifact[k] % mod;
    dp[j] = (dp[j] + t) % mod;
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 8320
use std::io::stdin;

fn read_line() -> Vec<String> {
    let mut line = String::new();
    stdin().read_line(&mut line).expect("Failed to read line");
    return line.trim().split_whitespace().map(|s| s.to_string()).collect();
}

struct Reader {
    v: Vec<String>,
    n: usize,
}

impl Reader {
    fn new() -> Reader {
        let v = read_line();
        return Reader { v: v, n: 0 };
    }
    fn next<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug {
        if self.n == self.v.len() {
            self.v = read_line();
            self.n = 0;
        }
        let x = self.v[self.n].parse().unwrap();
        self.n += 1;
        return x;
    }
    fn nexts<T>(&mut self, n: usize) -> Vec<T>
    where T: std::str::FromStr, T::Err: std::fmt::Debug {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            v.push(self.next());
        }
        return v;
    }
}

fn main() {
    let mut r = Reader::new();
    let n: usize = r.next();
    let mut a: Vec<Vec<u64>> = Vec::with_capacity(n);
    for _ in 0..n {
        a.push(r.nexts(n));
    }

    let mut dist = a.clone();
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                dist[i][j] = std::cmp::min(dist[i][j], dist[i][k]+dist[k][j]);
            }
        }
    }

    let mut ans: u64 = 0;
    for i in 0..n {
        for j in (i+1)..n {
            if dist[i][j] < a[i][j] {
                println!("-1");
                return;
            }
            let mut used = true;
            for k in 0..n {
                if k == i || k == j { continue };
                if dist[i][j] == dist[i][k]+dist[k][j] {
                    used = false;
                }
            }
            if used {
                ans += dist[i][j];
            }
        }
    }
    println!("{}", ans);
}


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

int main() {
  int N, K;
  cin >> N >> K;
  
  int total = 0;;
  for (int i=0; i<N; i++) {
    int x;
    cin >> x;
    if (x * x < (K-x)*(K-x)) {
      total += 2 * x;
    } else {
      total += 2 * (K-x);
    }
  }
  cout << total << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
//#include <algorithm>
//#include <math.h>
#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
#define NIL -1
//#define INFTY 1000000000000000000

LL h;
LL w;
vector<vector<LL>> s_num(1100,vector<LL>(1100,1));
vector<vector<LL>> d(1100, vector<LL>(1100, NIL));

void bfs(LL y, LL x){
    queue<pair<LL, LL>> q1;
    queue<pair<LL, LL>> q2;
    q1.push(make_pair(y, x));
    d[y][x]=0;
    pair<LL, LL> u;
    while(!q1.empty() || !q2.empty()){
        if(!q1.empty()){
            u=q1.front();
            q1.pop();
        }else{
            u=q2.front();
            q2.pop();            
        }
        LL tmp_y=u.first;
        LL tmp_x=u.second;
        //cout << tmp_y << " " << tmp_x << endl;
        for(LL i=-2; i<=2; i++){
            for(LL j=-2; j<=2; j++){
                //cout << tmp_y+i << " " << tmp_x+j << " " << h << " " << w << endl;
                if(tmp_y+i<0 || tmp_y+i>=h){
                    //cout << "test0" << endl;
                    continue;
                }
                if(tmp_x+j<0 || tmp_x+j>=w){
                    //cout << "test1" << endl;
                    continue;
                }
                if(i==0 && j==0){
                    continue;
                }
                if(s_num[tmp_y+i][tmp_x+j]==1){
                    //cout << "test2" << endl;
                    continue;
                }
                if(((i==-1 || i==1) && j==0) || (i==0 && (j==-1 || j==1))){
                    if(d[tmp_y+i][tmp_x+j]==NIL || d[tmp_y+i][tmp_x+j]>d[tmp_y][tmp_x]){
                        d[tmp_y+i][tmp_x+j]=d[tmp_y][tmp_x];
                        q1.push(make_pair(tmp_y+i, tmp_x+j));
                    }else{
                        continue;
                    }
                }else{
                    if(d[tmp_y+i][tmp_x+j]==NIL || d[tmp_y+i][tmp_x+j]>d[tmp_y][tmp_x]+1){
                        d[tmp_y+i][tmp_x+j]=d[tmp_y][tmp_x]+1;
                        q2.push(make_pair(tmp_y+i, tmp_x+j));
                    }else{
                        continue;
                    }                        
                }
            }
        }
    }


}

int main(){
    LL ch;
    LL cw;
    LL dh;
    LL dw;
    cin >> h >> w;
    cin >> ch >> cw;
    cin >> dh >> dw;
    ch--;
    cw--;
    dh--;
    dw--;
    string s;
    for(LL i=0; i<h; i++){
        cin >> s;
        for(LL j=0; j<w; j++){
            if(s[j]=='.'){
                s_num[i][j]=0;
            }
        }
    }

    bfs(ch,cw);
    cout << d[dh][dw] << endl;

    return 0;
}


Measured memory_bytes: 22652
#include <iostream>
#include <string.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

bool dis[10]={0};
int n,k,num;

bool valid(int x) {
    while (x) {
        if (dis[x%10]) return false;
        x=x/10;
    }
    return true;
}

int main() {
    scanf("%d%d",&n,&k);
    for (int i=0;i<n;i++) {
        scanf("%d",&num);
        dis[num]=true;
    }
    for (int j=n;j<=99999;j++) {
        if (valid(j)) {
            printf("%d\n",j);
            break;
        }
    }
}

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

int main() {
  int X,A,B,C,D;
  cin >> X ;
  A =X/1000 ;
  B =X%1000/100 ;
  C =X%100/10 ;
  D =X%10 ;
  
  
  if (A == B&& B== C && C== D) {
    cout << "Yes" << endl;
  }
  
  else if  (A == B&& B == C) {
    cout << "Yes" << endl;
  }
  else if (B == C && C== D) {
    cout << "Yes" << endl;
  }
  else{ 
  cout << "No" << endl; 
  }
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define f_in freopen("test.in","r",stdin);
#define f_out freopen("test.in","w",stdout);
#define dbg(x) cerr << #x << " : " << x << "\n";
#define _ cin.sync_with_stdio(0); cin.tie(0);


inline char nc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}

template<typename T = int>
inline T nxt(){
    char c=nc();T x=0; int f=1;
    for(;c>'9'||c<'0';c=nc())if(c=='-')f=-1;
    for(;c>='0'&&c<='9';x=x*10+c-'0',c=nc());
    x*=f;
    return x;
}

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


int main(){
#ifdef LOCAL_DEFINE
    f_in
#else
    _
#endif
    int a = nxt(), b = nxt(), c = nxt();
    ll k = nxt<ll>();
    int ans = b - a;
    if(k % 2 == 0)  ans = -ans;
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cout <<"\nTime elapsed: "<<(1000 * clock() / CLOCKS_PER_SEC)<<"ms\n";
 #endif
}

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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	string S, T;
    cin >> S >> T;

    rep(i, S.length()){
        if(S[i] != T[i]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll ,P> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
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 SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()



int main() {
    string s;
    cin >> s;
    for(auto &c : s){
        if(c == 'A') c = 'T';
        else if(c == 'T') c = 'A';
        else if(c == 'C') c = 'G';
        else if(c == 'G') c = 'C';
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) {rep(i,x.size()) cout << x[i] << " "; cout << endl;}
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    int x = n/1000;
    if (n % 1000 == 0) cout << 0 << endl;
    else {
        int x = n/1000;
        cout << (x+1)*1000-n << endl;
    }
}

Measured memory_bytes: 3636
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()


int main() {
	int n, a, b;
	cin >> n >> a >> b;
	if ((b - a - 1) % 2 == 0)cout <<"Borys"  << endl;
	else cout << "Alice" << endl;

	return 0;
}





Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    int n;
    cin >> n;

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    vector<pair<int, int64_t>> b(n);
    for (int i = 0; i < n; i++) {
        cin >> b[i].first;
    }
    sort(b.begin(), b.end());

    vector<int> c(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    sort(c.begin(), c.end());

    for (int i = 0; i < n; i++) {
        auto it = upper_bound(c.begin(), c.end(), b[i].first);
        b[i].second = c.end() - it;
    }
    for (int i = n - 2; i >= 0; i--) {
        b[i].second += b[i + 1].second;
    }

    int64_t r = 0;
    for (int i = 0; i < n; i++) {
        auto it = lower_bound(b.begin(), b.end(), pair<int, int64_t>(a[i] + 1, 0));
        if (it == b.end()) continue;
        r += it->second;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 10000000;
typedef pair<int,int> P;
typedef long long ll;
/*Aの累積和を取り(s[i]=Aの第i-1項までの和とする),s[i] == s[j](i>j)なら
A[j]~A[i-1]までの部分和は0になるので、

*/

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N){
    cin >> A[i];
  }
  vector<ll> s(N+1);
  s[0] = 0;
  for(int i = 1;i<=N;i++){
     s[i] = s[i-1] + A[i-1];
  }
  /*rep(i,N+1){
    cout << s[i] << endl;
  }*/
  sort(s.begin(),s.end());
  s.push_back(1000000000000000000+1);
  ll ans = 0;
  ll count = 1;
  rep(i,N+1){
    
    if(s[i] == s[i+1]) count++;
    else{
      ans += count*(count-1)/2;
      count = 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;

int main(){
	int r;
	cin>>r;
	double pi=2*acos(-1);
	double res=pi*r;
	cout<<fixed<<setprecision(20)<<res;
	
	
	
	
	
	
	
}

Measured memory_bytes: 3784
#include<stdio.h>
#define COUNT_RESET 0
#define ARRAY_RESET 0
#define LOOP_RESET 0

void array_reset(unsigned char * array, unsigned short size);
unsigned short scan_word(unsigned char * str, unsigned short length_max);
void print_word(unsigned char * str, unsigned short length);
void card_shuffle(unsigned char * card, unsigned short num);
unsigned short str_to_int(unsigned char * str, unsigned short digit);

int main(){
	unsigned char ubW_D_card[201];
	unsigned short usW_D_card_num;
	unsigned char ubW_D_char_times[4];
	unsigned short usW_D_int_times;
	unsigned short usW_D_times_digit;
	unsigned short usW_C_i;
	
	while(1){
		usW_D_card_num = scan_word(ubW_D_card, 201);
		if(*ubW_D_card == '-'){
			break;
		}

		usW_D_times_digit = scan_word(ubW_D_char_times, 4);
		usW_D_int_times = str_to_int(ubW_D_char_times, usW_D_times_digit);
		for(usW_C_i = 0;usW_C_i < usW_D_int_times;usW_C_i++){
			card_shuffle(ubW_D_card, usW_D_card_num);
		}

		print_word(ubW_D_card, usW_D_card_num);
	}
	return 0;
}

/* 関数名：配列初期化 */
/* 概要：渡されたアドレスを先頭とする配列の値を初期化する */
/* 引数：初期化する配列の先頭アドレス、その配列の大きさ */
/* 戻り値：なし */
void array_reset(unsigned char * array, unsigned short size)
{
	unsigned short usW_C_i; 	/* ループ変数 */
	/* 配列の初期化 */
	for(usW_C_i = COUNT_RESET;usW_C_i < size;usW_C_i++){
		*(array + usW_C_i) = ARRAY_RESET;
	}
}

/* 関数名：文字列入力 */
/* 概要：文字列を入力する。入力された文字列の長さを返す */
/* 引数：文字列を格納する配列の先頭アドレス、その配列の大きさ */
/* 戻り値：入力された文字列の長さ */
unsigned short scan_word(unsigned char * str, unsigned short length_max)
{
	unsigned short usW_C_count_text = COUNT_RESET;  	/* 文字列長カウンタ */
	unsigned short usW_C_i;                         	/* ループ変数 */

	/* 配列の初期化 */
	for(usW_C_i = COUNT_RESET;usW_C_i < length_max;usW_C_i++){
		*(str + usW_C_i) = ARRAY_RESET;
	}
	
	/* 文字列の入力 */
	for(usW_C_i = LOOP_RESET;usW_C_i < length_max;usW_C_i++){
		scanf("%c", str + usW_C_i);
		/* 入力終了の処理 */
		if((*(str + usW_C_i) == ' ') || (*(str + usW_C_i) == '\n')){
			break;
		}
		/* 文字数をカウント */
		usW_C_count_text++;
	}

	/* 文字列長を返す */
	return usW_C_count_text;
}

void print_word(unsigned char * str, unsigned short length)
{
	unsigned short usW_C_i;
	for(usW_C_i = 0;usW_C_i < length;usW_C_i++){
		printf("%c", *(str + usW_C_i));
	}
	printf("\n");
}

void card_shuffle(unsigned char * card, unsigned short num)
{
	unsigned char card_memo[200 * 2];
	unsigned char char_stage[4];
	unsigned short int_stage = 0;
	unsigned short stage_digit;
	unsigned short usW_C_i;
	
	for(usW_C_i = 0;usW_C_i < num;usW_C_i++){
		card_memo[usW_C_i] = *(card + usW_C_i);
	}

	for(usW_C_i = 0;usW_C_i < num;usW_C_i++){
		card_memo[usW_C_i + num] = *(card + usW_C_i);
	}
	
	stage_digit = scan_word(char_stage, 4);
	int_stage = str_to_int(char_stage, stage_digit);

	for(usW_C_i = 0;usW_C_i < num;usW_C_i++){
		*(card + usW_C_i) = card_memo[usW_C_i + int_stage];
	}
}

unsigned short str_to_int(unsigned char * str, unsigned short digit)
{
	unsigned short multi;
	unsigned short ans = 0;
	unsigned short usW_C_i, j;

	for(usW_C_i = 0;usW_C_i < digit;usW_C_i++){
		multi = 1;
		for(j = 0;j < usW_C_i;j++){
			multi *= 10;
		}
		ans += (*(str + digit - usW_C_i -1) -48) * multi;
	}

	return ans;
}


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

int main()
{
    string line;
    getline(cin, line);
    for (auto &c: line){
        if (islower(c)){
            putchar(toupper(c));
        }else{
            putchar(tolower(c));
        }
    }
    cout << endl;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int a[128];

int main(){
	int n; scanf("%d", &n);
	REP(i, n) scanf("%d", a+i);
	int ans = 0;
	REP(i, n){
		FOR(j, i+1, n){
			FOR(k, j+1, n){
				if(a[i] == a[j] || a[j] == a[k] || a[k] == a[i]) continue;
				if(abs(a[j]-a[i]) < a[k] && a[k] < abs(a[j]+a[i])) ans++;
			}
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
   /* #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    for(int i=k;i<=n;i++)
    {   
        ll mn=(ll)(i*(ll)(i-1))/2;

        double mx=((double(i/double(2.0)))*((2*(n-i+1)+(i-1))));
         ll mxx=mx;
        //cerr<<mxx<<" "<<mn<<endl;
        ans=((ans%mod+(mxx%mod-mn%mod+mod)%mod) + 1);
        //cout<<ans<<endl;
    }
    cout<<(ans%mod+1%mod)%mod<<endl;
    
}
return 0;
}

Measured memory_bytes: 3648
import bisect
import math
n = int(input())
if n == 1:
    print(0)
    exit()

def get_primenumber(N):
    #素数リスト
    prime_list = [2]
    #3からNまでの数字を一つずつ取り出す
    for num in range(3,N+1,2):
      #取り出した数字が素数リストの要素で割れなければ素数リストに追加する
      if all( num % prime != 0 for prime in prime_list):
        prime_list.append(num)

    return prime_list

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

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

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

    return arr

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

sosuu = get_primenumber(100)

sosuu_list = [0] * len(sosuu)

for i in range(2, n+1):
    a = factorization(i)
    for j in a:
        index = bisect.bisect_left(sosuu, j[0])
        sosuu_list[index] += j[1]
    over_74 = len([x for x in sosuu_list if x >= 74])
    over_24 = len([x for x in sosuu_list if x >= 24])
    over_14 = len([x for x in sosuu_list if x >= 14])
    over_4  = len([x for x in sosuu_list if x >= 4])
    over_2  = len([x for x in sosuu_list if x >= 2])
    ans = over_74 + over_24 * (over_2 - 1) + over_14 * (over_4 - 1)
    if over_4 >= 2:
        ans += combinations_count(over_4, 2) * max(0, (over_2 - 2))

print(ans)

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

double dp[3030][3030];
double P[3030];

int main(){
  int N; cin>>N;
  rep(i,N) cin>>P[i];
  dp[0][0]=1;
  rep(i,N) rep(j,N+1){
    dp[i+1][j]+=dp[i][j]*(1-P[i]);
    dp[i+1][j+1]+=dp[i][j]*P[i];
  }
  double ans=0.0;
  for(int i=N/2+1;i<=N;i++) ans+=dp[N][i];
  cout<<setprecision(15);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 71936
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef queue<P> Q;

#define _CRT_SECURE_NO_WARNINGS

int a,b,c;
int x[1000];
int main() {
	cin >>x[0]>>x[1]>>x[2] ;
	sort(x, x + 3);
	
	cout << x[2]*10+x[1]+x[0];
	return 0;
}

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

void comb(vector<vector<long long> > &vec){
  for(int i=0;i<vec.size();i++){
    vec[i][0]=1;
    vec[i][i]=1;
  }
  for(int i=1;i<vec.size();i++){
    for(int j=1;j<i;j++){
      vec[i][j]=vec[i-1][j-1]+vec[i-1][j];
    }
  }
}

int main(){
  long long n,a,b,ans=0,sum=0;
  double ave=0.0;
  cin >> n >> a >> b;
  long long v[n];
  map<long long,int> mp;
  for(int i=0;i<n;i++){
    cin >> v[i];
    mp[v[i]]++;
  }
  sort(v,v+n);
  reverse(v,v+n);
  for(long long i=a;i<=b;i++){
    sum=0;
    map<long long,int> cnt;
    for(long long j=0;j<i;j++){
      sum+=v[j];
      cnt[v[j]]++;
    }
    double tmp=(double)sum/(double)i;
    if(sum%i==0){
      tmp=sum/i;
    }
    if(ave<=tmp){
      if(ave<tmp){
        ave=tmp;
        ans=0;
      }
      long long N=mp[v[i-1]],R=cnt[v[i-1]];
      vector<vector<long long> > vec(N+1,vector<long long>(N+1,0));
      comb(vec);
      ans+=vec[N][R];
    }
  }
  printf("%.10lf\n%lld\n",ave,ans);
  return 0;
}

Measured memory_bytes: 256
function main (input) {
    const args = input.split(' ');
    const a = parseInt(args[0], 10);
    const b = parseInt(args[1], 10);

    if ((a * b) % 2 === 0) {
        console.log('Even');
    } else {
        console.log('Odd');
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <cstdio>
#include <vector>
#include <complex>
using namespace std;
typedef complex<double> P;
static const double EPS = 1e-8;

bool check(const vector<P>& v, P& ans)
{
  int N = v.size();
  if (N % 2 != 0) {
    return false;
  }
  N /= 2;
  ans = (v[0] + v[N])*0.5;
  for (int i = 1; i < N; i++) {
    const P p = (v[i] + v[N+i])*0.5;
    if (abs(p - ans) > EPS) {
      return false;
    }
  }
  return true;
}

int main()
{
  int N;
  scanf("%d", &N);
  vector<P> v;
  for (int i = 0; i < N; i++) {
    double x, y;
    scanf("%lf %lf", &x, &y);
    v.push_back(P(x, y));
  }
  P ans;
  if (check(v, ans)) {
    printf("%.6f %.6f\n", ans.real(), ans.imag());
  } else {
    puts("NA");
  }
  return 0;
}

Measured memory_bytes: 1112
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<28)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    string ans = "";
    if (n == 0) cout << 0 << endl;
    else {
        while (n != 0) {
            if (n & 1) {
                ans = "1" + ans;
                n--;
            }
            else ans = "0" + ans;
            n /= -2;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
c = list(input())

count = 0
left = 0
right = N-1
while True:
    while left <= N-1 and c[left] != 'W':
        left += 1
    while 0 <= right and c[right] != 'R':
        right -= 1
    if not left < right:
        break
    c[left] = 'R'
    c[right] = 'W'
    count += 1

print(count)


Measured memory_bytes: 10768
#include<bits/stdc++.h>
using namespace std;
int MOD = 1000000007;
//g++ -std==c++14
//setprecision(10)
int main(){
    int n;
    cin >> n;
    int va;
    map <int, int> mp;
    for(int i = 0; i < n; i++){
        cin >> va;
        mp[va - 1]++;
        mp[va]++;
        mp[va + 1]++;
    }
    int macs = 0;
    for(auto itr = mp.begin(); itr != mp.end(); itr++)
        macs = max(macs, itr->second);
    cout << macs << endl;
}

Measured memory_bytes: 4736
while True:
    n, k = map(int, input().split())
    if n + k == 0: break

    s = list(map(int, input().split()))
    for _ in range(n):
        b = list(map(int, input().split()))
        for j, _b in enumerate(b):
            s[j] = s[j] - _b

    bool_list = list(map(lambda x: x >= 0,s))
    if False in bool_list:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 7736
from numba import jit


@jit
def solve(N, K, A):
    for _ in range(K):
        imos = [0] * (N+1)
        for i in range(N):
            left = max(0, i-A[i])
            right = min(N-1, i+A[i])+1
            imos[left] += 1
            imos[right] += -1

        next_A = [0] * N
        next_A[0] = imos[0]
        for i in range(1, N):
            next_A[i] = next_A[i-1] + imos[i]

        if A == next_A:
            return A
        A = next_A
    return A


N, K = map(int, input().split())
A = [int(x) for x in input().split()]
print(" ".join([str(x) for x in solve(N, K, A)]))


Measured memory_bytes: 142592
#include<bits/stdc++.h>
#define INF 2147483640
using namespace std;
unsigned long long a[20];
int main()
{
	//freopen("out.txt","w",stdout);
	for(unsigned long long i=1,j=26; i<=11; i++,j*=26) a[i]=j;
	unsigned long long n,len,sum=0;
	cin >> n; n--;
	for(len=1; ; len++)
	{
		if(sum+a[len] > n) break;
		sum+=a[len];
	}
	n-=sum;
	string ans;
	for(int i=len-1; i>0; i--)
	{
		ans.push_back('a'+n/a[i]);
		n=n%a[i];
	}
	ans.push_back('a'+n);
	cout << ans;
	return 0;
}

Measured memory_bytes: 3616