akhauriyash/Code-Regression huggingface dataset:
n=int(input())
a=list(map(int,input().split()))
a.sort()
from collections import Counter
c=Counter(a)
f=[1]*(10**6+1)
ans=0
for ai in a:  
  if c[ai]==1 and f[ai]==1:ans+=1
  if f[ai]==1:
    for i in range(ai,10**6+1,ai):
      f[i]=0
print(ans)

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

int main(){
  int64_t n;
  cin>> n;
  
  if (n%2==1 || n<10){ cout<< 0 << endl; return 0;}
  
  n/=10;
  int64_t ans=n;
  while (n!=0){
    n/=5;
    ans+=n;
  }
  cout<< ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> v;
    REP(i, n) 
    {
        int a;
        cin >> a;
        v.push_back(a);
    }

    int INF = 1000000000;
    int max_v = -INF;
    int min_v = v[0];
    FOR(j, 1, n)
    {
        max_v = max(max_v, v[j] - min_v);
        min_v = min(min_v, v[j]);
    }
    cout << max_v << endl;
}


Measured memory_bytes: 3924
#include <iostream>
using namespace std;
int main(void){
    long n,m;
    cin >> n >> m;
    int a[m];
    long sum=0;
    for(int i=0;i<m;i++){
        cin >>a[i];
        sum+=a[i];
    }
    
    if(sum>n){
        cout << "-1";
    }
    else {
        cout << n-sum;
    }
    return 0;
}

Measured memory_bytes: 3672
// https://atcoder.jp/contests/dp/tasks/dp_i

#include "algorithm"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  cin >> N;

  V<double> ps(N);
  rep(i, N) cin >> ps[i];

  // dp[i][j]: i (>=1) 番目のコインまでで j 枚表の確率
  V<V<double>> dp(N + 1, V<double>(N + 1));
  dp[0][0] = 1;

  // i, j から配る dp
  rep(i, N) rep(j, N) {
    dp[i + 1][j] += dp[i][j] * (1 - ps[i]);
    dp[i + 1][j + 1] += dp[i][j] * ps[i];
  }

  double res = 0;

  repf(i, (N + 1) / 2, N + 1) res += dp[N][i];

  cout << fixed << setprecision(10) << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 70784
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int A, B;
    cin >> A >> B;
    if (A >= 13)
    {
        cout << B << endl;
    }
    else if (A >= 6)
    {
        cout << B / 2 << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}


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

typedef long long ll;


int main() {
    //Xこの赤リンゴ、Yこの緑りんご
    //Aこの赤リンゴ、p1,p2,...pA
    //Bこの緑リンゴ、q1,q2,...qB
    //Cこの無色リンゴ、r1,r2,...rC
    //Aをおいしさ順にXことってくる->A'
    //Bをおいしさ順にYことってくる->B'
    //A'+B'+C'をおいしさ順にX+Yこ食べればよい
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<ll> p(A), q(B), r(C);
    for (ll i=0;i<A;i++) cin >> p[i];
    for (ll i=0;i<B;i++) cin >> q[i];
    for (ll i=0;i<C;i++) cin >> r[i];
    sort(p.begin(),p.end());
    reverse(p.begin(),p.end());
    sort(q.begin(),q.end());
    reverse(q.begin(),q.end());
    sort(r.begin(),r.end());
    reverse(r.begin(),r.end());
    vector<ll> mix;
    for (ll i=0;i<X;i++) mix.push_back(p[i]);
    for (ll i=0;i<Y;i++) mix.push_back(q[i]);
    for (ll i=0;i<C;i++) mix.push_back(r[i]);
    sort(mix.begin(),mix.end());
    reverse(mix.begin(),mix.end());
    ll ans = 0;
    for (ll i=0;i<X+Y;i++){
        ans += mix[i];
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 8688
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

H, W, A, B = mapint()
for i in range(1, H+1):
    if i<=B:
        print(''.join((['1']*A+['0']*(W-A))))
    else:
        print(''.join(['0']*A+['1']*(W-A)))

Measured memory_bytes: 73332
#include<iostream>
char d[100][100];
int H, W;
int ans;
char tmp;
int solve(int a, int b) {
	d[a][b] = 'a';
	if (b + 1 < W && d[a][b + 1] == tmp) {
		d[a][b + 1] = 'a';
		solve(a, b + 1);
	}
	if (a + 1 < H && d[a + 1][b] == tmp) {
		d[a + 1][b] = 'a';
		solve(a+1,b);
	}
	if (a - 1 >= 0 && d[a - 1][b] == tmp) {
		d[a - 1][b] = 'a';
		solve(a-1,b);
	}
	if (b - 1 >= 0 && d[a][b - 1] == tmp) {
		d[a][b - 1] = 'a';
		solve(a,b-1);
	}
	return 0;
}
int main() {
	while (true) {
		std::cin >> H >> W;
		if (H == 0 && W == 0) {
			break;
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				std::cin >> d[i][j];
			}
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (d[i][j] != 'a') {
					ans++;
					tmp = d[i][j];
					solve(i, j);
				}
			}
		}
		std::cout << ans << "\n";
		ans = 0;
	}
	return 0;
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {

	int x,y; cin >> x >> y;

	cout << x + y / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb  push_back
#define mod 1000000007
#define INF 1e18
typedef  long long ll;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	double d,t,s;
	cin>>d>>t>>s;
	double ans=(d/s);
	if(ans>t)
		cout<<"No";
	else
		cout<<"Yes";
	return 0;
}

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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;
int arr[N + 2];


void solve()
{
	int s, w; cin >> s >> w;
	if (w >= s) cout << "unsafe";
	else cout << "safe";

}

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

	int test = 1;
	// cin >> test;
	while (test--)solve();


}





Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
const int N = 1000000;


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

    bool ans = false;

    rep(i,n/4 + 1) rep(j,n/7 + 1){
        if(4 * i + 7 * j - n == 0){
            ans = true;
        }
    }
    if(ans)print("Yes");
    else print("No");
}

Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
d={}
chk=0
for i in a[::-1]:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
    if d[i]==4:
        print(i*i)
        exit()
    if d[i]==2 and chk==1:
        for j in d:
           if i!=j and d[j]>=2:
                print(i*j)
                exit()
    elif d[i]==2:
           chk=1
   
print(0)

Measured memory_bytes: 14252
#include"stdio.h"
int main(){
    int A[5],min=0,res=0,i;
    scanf("%d%d%d%d%d",&A[0],&A[1],&A[2],&A[3],&A[4]);
    for(i=0;i<5;i++){
        if(A[i]%10==0){
            res+=A[i];
            continue;
        }
        if(min<10-A[i]%10) min=10-A[i]%10;
        res+=(A[i]/10)*10+10;
    }
    printf("%d",res-min);
    return 0;
}


Measured memory_bytes: 1708
import sys
from functools import reduce
import copy
import math
from pprint import pprint


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    nums = string_to_int(inputs[0])
    sorted_nums = sorted(nums)
    N = len(nums)
    medians = []
    median_candidate = [sorted_nums[N//2 - 1], sorted_nums[N//2]]
    for a in nums:
        if a <= median_candidate[0]:
            medians.append(median_candidate[1])
        else:
            medians.append(median_candidate[0])
    return medians


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    for r in ret:
        print(r)


Measured memory_bytes: 29428
N=int(input())
AB={}
B=[]
base=0
answer="Yes"

for i in range(N):
    a,b=map(int,input().split())
    if b not in AB.keys():
        AB[b]=a
        B.append(b)
    else:
        AB[b]+=a
        
B=sorted(B)

for j in B:
    base+=AB[j]
    #print(base,j)
    if base>j:
        answer="No"

print(answer)

Measured memory_bytes: 32648
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int h, w, k, dp[110][130][10];
bool f[260];

bool isValid(int mask, int w) {
    FOR(i,1,w-1)
        if (mask & (1 << i))
            if (mask & (1 << (i-1))) return false;
    return true;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> h >> w >> k;
    k--;
    dp[0][0][0] = 1;
    FOR(mask,0,(1<<(w-1))-1)
        if (isValid(mask, w)) f[mask] = true;
    FOR(i,1,h) {
        FOR(mask,0,(1<<(w-1))-1) {
            if (!f[mask]) continue;
            FOR(mask2,0,(1<<(w-1))-1) {
                if (!f[mask2]) continue;
                FOR(j,0,w-1) {
                    bool lef = false, rig = false;
                    if (mask & (1<<j)) lef = true;
                    if (j > 0 && (mask & (1<<(j-1)))) rig = true;
                    if (!rig && !lef) dp[i][mask][j] = (dp[i][mask][j] + dp[i-1][mask2][j]) % MODBASE;
                    else if (rig) dp[i][mask][j-1] = (dp[i][mask][j-1] + dp[i-1][mask2][j]) % MODBASE;
                    else dp[i][mask][j+1] = (dp[i][mask][j+1] + dp[i-1][mask2][j]) % MODBASE;
                }
            }
        }
    }
    ll res = 0;
    FOR(mask,0,(1<<(w-1))-1) res = (res + dp[h][mask][k]) % MODBASE;
    cout << res;
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define PI 3.14159265359
ll gcd(ll a, ll b) {//最大公約数
    if(a<b){
        ll tmp = a;
        a = b;
        b = tmp; 
    }
    if (b==0) return a;
    else return gcd(b, a%b);
}
ll lcm(ll a, ll b) {//最小公倍数
    return a * b / gcd(a, b);
}

int main() {
    int n,m,work=0;
    cin >> n>> m;
    rep(i,m){
        int a;
        cin >> a;
        work+=a;
    }
    int ans = n-work;
    if(ans<0){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }

}




Measured memory_bytes: 3636
'''
包除原理 |A∪B∪C|=|A|+|B|+|C|−|A∩B|−|A∩C|−|B∩C|+|A∩B∩C|
悪魔の証明のような否定の個数を求めるのは難しい
具体的には、A[i], B[i], 1 <= i <= N のとき
A[i] != B[i] となる組み合わせの個数は求めにくい。
しかし、A[i] == B[i] となる項が少なくともk個ある組み合わせは求めやすい(nCk * (n-k)!)
そこで包除原理を使えば、
Σ[k=0,n](nCk * (n-k)! * (-1)^k) で求まる (k=0がここでは全事象を表す)
'''

mod = pow(10,9)+7
n,m = map(int,input().split()) # nCmに相当
inv = [0,1]
fact = [1,1]
ifact = [1,1]
for i in range(2,m+1):
    inv.append(inv[mod%i]*(mod-int(mod/i))%mod)
    fact.append(i*fact[-1]%mod)
    ifact.append(ifact[-1]*inv[i]%mod)

def combi(n,r):
    r = min(r, n - r)
    return fact[n]*ifact[r]*ifact[n-r]%mod
def permi(n,r):
    return fact[n]*ifact[n-r]%mod

ans = 0
sign = 1
for k in range(n+1):
    ans += combi(n,k) * permi(m-k,n-k) * sign % mod
    ans %= mod
    sign *= -1
ans = ans * permi(m,n) % mod
print(ans)

Measured memory_bytes: 192492
arr = [[1, 26], [27, 702], [703, 18278], [18279, 475254], [475255, 12356630], [12356631, 321272406], [321272407, 8353082582], [8353082583, 217180147158], [217180147159, 5646683826134], [5646683826135, 146813779479510], [146813779479511, 3817158266467286]]
alphabets = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
n = int(input())

def solve(n):
    if n <= 26:
        return alphabets[n-1]
    
    x = n % 26
    if x == 0:
        return alphabets[x-1] + solve((n // 26) - 1)
    return alphabets[x-1] + solve(n // 26)

print(solve(n)[::-1])

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

int main(){
    string s;
    cin >> s;

    int count = 0;
    
    if(s[0] == 'A'){
        for(int i = 1; i < s.length(); i++){
            if(i > 1 && i < s.length()-1){
                if(s[i] == 'C'){
                    count++;
                } else if(isupper(s[i])){
                    count = 0;
                    break;
                }
            } else {
                if(isupper(s[i])){
                    count = 0;
                    break;
                }
            }
        }
        if(count == 1){
            cout << "AC" << endl;
        } else {
            cout << "WA" << endl;
        }
    } else {
        cout << "WA" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        int H = sc.nextInt();
        int W = sc.nextInt();
        int[][] c = new int[10][10];
        int[][] A = new int[H][W];

        for(int i=0; i<=9; i++){
            for(int j=0; j<=9; j++){
                c[i][j] = sc.nextInt();
            }
        }
        for(int k=0; k<10; k++){
            for(int i=0; i<10; i++){
                for(int j=0; j<10; j++){
                    c[i][j] = Math.min(c[i][j], c[i][k] + c[k][j]);
                }
            }
        }
        long ans = 0L;
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                A[i][j] = sc.nextInt();
                if(A[i][j]!=-1){
                    ans += c[A[i][j]][1];
                }
            }
        }
        System.out.println(ans);
    }
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  string s; cin >> s;
  vector<int> freqs(30);
  for (int i = 0; i < (int)s.size(); ++i) {
    ++freqs[s[i] - 'a'];
  }
  string ans = "None";
  for (int i = 0; i < 26; ++i) {
    if (freqs[i] == 0) {
      ans = string(1, 'a' + i);
      break;
    }
  }
  printf("%s\n", ans.c_str());
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <unordered_set>

using namespace std;

int main(){
  int X, N, tmp;
  cin >> X >> N;
  unordered_set<int> app;
  for (int i=0; i<N; i++){
    cin >> tmp;
    app.insert(tmp);
  }
  int m = 0;
  int ans = 0;
  while (true){
    if (app.find(X - m) == app.end()){
      ans = X - m;
      break;
    }
    else if (app.find(X + m) == app.end()){
      ans = X + m;
      break;
    }
    m++;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3640
a,b=(int(i) for i in input().split())
#外側はタプルを表してるんだね。
#a,b = int(input()),int(input())

if 6<=a<=12 :
    ans = b/2

elif 6 > a :
    ans = 0

else :
    ans = b

print(int(ans))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    ll res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}
ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (int i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (int i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=nxtl(),a=nxtl(),b=nxtl();
    ll mod=1e9+7;
    ll test=power(2,n,mod);
    test=(test+mod-modBinomial(n,a,mod))%mod;
    test=(test+mod-modBinomial(n,b,mod))%mod;
    cout<<test-1<<endl;


    return 0;   
}


 
 


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

int main() {
	// your code goes here
	int n, a;
	cin>>n>>a;
	int black;
	
	if(n>=1 && n<=100){
		
		if(a>=0 && a<= (pow(n,2)) ){
			
			black = pow(n,2)-a;
			cout<<black<<endl;
			
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>

using namespace std;

int main() {
    size_t n;
    cin >> n;
    vector<size_t> l(n, 0);
    for (size_t i = 0; i < n; ++i)
        cin >> l[i];
    sort(begin(l), end(l), greater<size_t>());
    size_t d = 0;
    for (size_t i = 0; i < l.size(); ++i) {
        auto a = l[i];
        for (size_t j = i + 1; j < l.size(); ++j) {
            auto b = l[j];
            for (size_t k = j + 1; k < l.size(); ++k) {
                auto c = l[k];
                if (a < b + c && b < a + c && c < a + b)
                    ++d;
            }
        }
    }
    cout << d << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
const int M =998244353; 
#define int long long int
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define MAX 1e15+1
#define pi  pair<int,int>  
const int mod = 1e9 + 7;
const int N = 2e2 + 7;
 
int n,k;
int a[N];
int dp[100010][2];
int s=MAX;
int solve(int sum,int cha) {
	if(sum<0){
		return cha^1;
	}
	if(sum<s){
		return cha;
	}
	if(dp[sum][cha]!=-1)return dp[sum][cha];
	for(int i=0;i<n;i++){
		// if(sum-a[i]<0){
		// 	break;
		// }
		int x = solve(sum-a[i],(cha+1)%2);
		if(x==(cha+1)%2){
			dp[sum][cha] = x;
			return x;
		}
	}

	dp[sum][cha]=cha;
	return cha;

 
 
}
 
signed main() {
  fast;
  
  cin>>n>>k;
  for(int i=0;i<n;i++){
  	cin>>a[i];
  	s=min(s,a[i]);
  }
  memset(dp,-1,sizeof(dp));
  int x = solve(k,0);
  //cout<<x;

  if(x==0)cout<<"Second";
  else cout<<"First";



  	
}

Measured memory_bytes: 6528
typedef struct{double x,y,k;}w;w p[99],b;m,v[99],n,j,r;z(w*c,w*d){r=c->k>d->k?-1:1;}double o(w q,w r,w s){return q.x*(r.y-s.y)+r.x*(s.y-q.y)+s.x*(q.y-r.y);}main(i){for(;j=scanf("%d",&n)+~n;){for(m=i=0;i<n;i++)scanf("%lf,%lf",&p[i].x,&p[i].y),p[m].y>p[i].y?m=i:0;b=p[m];p[m]=*p;for(i=1;i<n;i++)p[i].k=(p[i].x-b.x)/hypot(p[i].x-b.x,p[i].y-b.y);qsort(p+1,n-1,24,z);*v=0;v[1]=1;v[2]=j=2;for(i=3;i<n;i++){for(;o(p[v[j-1]],p[v[j]],p[i])<=0;j--);v[++j]=i;}printf("%d\n",n+~j);}}

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

int main() {
	const string AIZUNYAN = "AIZUNYAN";
	string AIDUNYAN = "AIDUNYAN";
	sort(AIDUNYAN.begin(), AIDUNYAN.end());

	string D;
	cin >> D;

	for(unsigned i = 0; i + AIDUNYAN.size() <= D.size();) {
		string tmp = D.substr(i, AIDUNYAN.size());
		sort(tmp.begin(), tmp.end());

		if(AIDUNYAN == tmp) {
			for(const auto &e : AIZUNYAN) {
				D[i++] = e;
			}
		}
		else {
			++i;
		}
	}

	cout << D << endl;

	return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9+7;


bool check(int mid,vector<int>& w,int maxi_step){

    int now_step = 1;//現在の段数
    int sum = 0;//本の厚みの和
    for(int i = 0;i < w.size();i++){

        if(w[i] > mid){
            return false;//幅を超えている
        }

        if(sum + w[i] <= mid){
            sum += w[i];
        }else{
            sum = w[i];//次の段の最初の本
            now_step++;
        }
    }
    
    if(now_step <= maxi_step){
        return true;
    }else{
        return false;
    }
}

int solve(int maxi_step,vector<int>& w){//段数、本の厚み

    int ok = 1500000;
    int ng = 0;//(ng,ok]

    while(abs(ok-ng) > 1){
        int middle = (ok+ng)/2;//本棚1段の厚み
        if(check(middle,w,maxi_step)){
            ok = middle;
        }else{
            ng = middle;
        }
    }
    return ok;
}



int main(){

    int m,n;
    while(cin >> m >> n,m|n){

        vector<int> w(n);
        for(int i = 0;i < n;i++){
            cin >> w[i];
        }
        int ans = solve(m,w);
        cout << ans << endl;
        w.shrink_to_fit();
    }

    return 0;
}


Measured memory_bytes: 2988
import sys
# from collections import defaultdict, deque
import math

# import copy
# from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 998244353

def solve():
    s = getS()
    if s.lower() == s:
        print("a")
    else:
        print("A")
def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()

Measured memory_bytes: 61992
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const long long INFL = 2e18;
const int MOD = 1000000007;
int main(){
	int n;
	ll m;
	cin >> n >> m;
	vector<ll> a(n);
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}

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

	ll ok = 0,ng = 1e18;
	while(ng - ok > 1){
		ll mid = (ng + ok) / 2;
		ll cnt = 0;
		for(int i = 0;i < n;i++){
			cnt += a.end() - lower_bound(a.begin(),a.end(),mid-a[i]);
		}

		if(cnt >= m)ok = mid;
		else ng = mid;
	}

	vector<ll> accum(n);
	accum[n-1] = a[n-1];
	for(int i = n-2;i >= 0;i--)accum[i] = a[i] + accum[i+1];

	ll cnt = 0;
	ll ans = 0;
	for(int i = 0;i < n;i++){
		auto p = lower_bound(a.begin(),a.end(),ok - a[i] + 1);
		if(p != a.end()){
			int idx = n - (a.end() - p);
			cnt += (a.end() - p);
			ans += accum[idx] + (a.end() - p) * a[i];
		}
	}

	if(cnt < m)ans += (m - cnt) * ok;

	cout << ans << endl;
}



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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans1 = a[n-1];
    int ans2;
    if(ans1 % 2 == 0){
        int best = ans1 / 2;
        int x = lower_bound(a.begin(), a.end(), best) - a.begin();
        int right = a[x];
        int left = a[x-1];
        if(right - best < best - left){
            ans2 = right;
        } else {
            ans2 = left;
        }
    } else {
        int best1 = ans1/2;
        int best2 = best1+1;
        int x1 = lower_bound(a.begin(), a.end(), best1) - a.begin();
        int x2 = lower_bound(a.begin(), a.end(), best2) - a.begin();
        int right1 = a[x1];
        int right2 = a[x2];
        int left1 = a[x1-1];
        int left2 = a[x2-1];
        int ansn1;
        if(right1 - best1 < best1 - left1){
            ansn1 = right1;
        } else {
            ansn1 = left1;
        }
        int ansn2;
        if(right2 - best2 < best2 - left2){
            ansn2 = right2;
        } else {
            ansn2 = left2;
        }
        if(abs(ansn1 - best1) < abs(ansn2 - best2)){
            ans2 = ansn1;
        } else {
            ans2 = ansn2;
        }

    }

    cout << ans1 << " " << ans2 << endl;

    return 0;
}

Measured memory_bytes: 3740
n = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
t = int('1'+'0'*18)
ans = 1
if min(A)==0:
    print(0)
else:
    for a in A:
        ans *= a
        if ans > t:
            print(-1)
            exit()
    print(ans)

Measured memory_bytes: 84820
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,i,j;
    cin>>a>>b;
    if(a<b)
    {
        for(i=1;i<=b;i++)
        {
            cout<<a;
        }
    }
    else
    {
        for(i=1;i<=a;i++)
        {
            cout<<b;
        }
    }
    cout<<endl;
    return 0;
}


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

#define For(i, j, k) for (int i = j; i <= k; i++)

using namespace std;

const int N = 110;
const int Mod = 1e9 + 7;

int h[N], fa[N], n;
int dp[N][2];

int find(int x) {
	return x == fa[x] ? x : fa[x] = find(fa[x]);
}

int Pow(int x, int e) {
	int ret = 1;
	while (e) {
		if (e & 1) ret = 1ll * ret * x % Mod;
		x = 1ll * x * x % Mod;
		e >>= 1;
	}
	return ret;
}

int rk[N];

bool cmp(int x, int y) {
	return h[x] > h[y];
}

bool vis[N];

int main() {

	scanf("%d", &n);
	For(i, 1, n) scanf("%d", &h[i]), fa[i] = i, rk[i] = i;
	sort(rk + 1, rk + n + 1, cmp);

	For(i, 1, n) {
		int x = rk[i], u = 0, v = 0;
		vis[x] = true;
		if (vis[x - 1]) u = find(x - 1), dp[u][0] = 1ll * dp[u][0] * Pow(2, h[u] - h[x]) % Mod, fa[u] = x;
		if (vis[x + 1]) v = find(x + 1), dp[v][0] = 1ll * dp[v][0] * Pow(2, h[v] - h[x]) % Mod, fa[v] = x;
		if (!u) u = v, v = 0;

		if (!u) {
			dp[x][0] = 1, dp[x][1] = 0;
		} else if (!v) {
			dp[x][0] = dp[u][0];
			dp[x][1] = (dp[u][1] * 2ll + dp[u][0] * 2ll) % Mod;
		} else {
			dp[x][0] = 1ll * dp[u][0] * dp[v][0] % Mod;
			dp[x][1] = 2ll * dp[u][1] * dp[v][1] % Mod;
			dp[x][1] = (dp[x][1] + 4ll * dp[u][0] * dp[v][1] + 4ll * dp[v][0] * dp[u][1]) % Mod;
			dp[x][1] = (dp[x][1] + 6ll * dp[u][0] * dp[v][0]) % Mod;
		}
	}

	int x = find(1);
	int ans = (dp[x][1] + 1ll * dp[x][0] * Pow(2, h[x])) % Mod;
	printf("%d\n", ans);

	return 0;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n, m;
  cin >> n >> m;
  int ans = pow(2, m) - 1;
  for (int i = 0; i < n; ++i) {
    int k;
    cin >> k;
    int bt = 0;
    for (int i = 0; i < k; ++i) {
      int a;
      cin >> a;
      a--;
      bt |= (1 << a);
    }

    ans &= bt;
  }

  cout << bitset<32>(ans).count() << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef vector<int> VI;
typedef vector<ll> VLL;

int is_prime(int x){
    if(x == 2)return 0;
    for(int i=2; i<sqrt(x); ++i){
        if(x % i == 0)return 1; 
    }
    return 0;
}

int main(){
    int x;
    cin >> x;
    ll ans = x;
    while(1){
        if(is_prime(x) == 0){
            ans = x;
            break;
        }
        else ++x;
    }

    cout << ans << endl;
}

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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

ll gcd(ll x, ll y)
{
  if (x % y == 0)
  {
    return y;
  }
  return gcd(y, x % y);
}

int main()
{
  ll A, B, C;
  cin >> A >> B >> C;
  cout << min(A*B, C) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

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


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

int n, a, b, c;
int main()
{
	cin >> a >> b >> c >> n;
	if (a >= n) cout << n;
	else if (a + b >= n) cout << a;
	else cout << a - (n - a - b);
    return 0;
}


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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

ll N, T;

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

int main() {
    cin >> T;
    REP(loop, T) {
        LCIN(A, B, C, D);
        if(A < B || B > D) {
            cout << "No"
                 << "\n";
        } else {
            if(C >= B || C >= A) {
                cout << "Yes"
                     << "\n";
            } else {
                ll g = gcd(B, D);
                ll x = (A - C) / g;
                if((A - C) % g == 0) x--;
                if(x * g > A - B)
                    cout << "No"
                         << "\n";
                else
                    cout << "Yes"
                         << "\n";
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed _main(){
  int h; cin >> h;
  int cnt=0;
  while(h>0){
    h/=2;
    cnt++;
  }
  int ans=1;
  rep(i,cnt) ans*=2;
  cout << ans-1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
const int MOD=1e9+7;;
 
int main() {
    vector<string> s(3);
    vector<int> t(3,-1);
    rep(i,3) cin >> s[i];
    int nxt=0;
    while (1) {
        ++t[nxt];
        if (t[nxt]==s[nxt].size()) break;
        else nxt=s[nxt][t[nxt]]-'a';
    }
    cout << char('A'+nxt) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define Would
#define you
#define please

int main() {
	//おまじない
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a, b;
	cin >> a >> b;

	int kotae = a - 1;

	if (a <= b) kotae++;

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<numeric>
#include<list>
#include<limits>
#include<algorithm>
#include<cmath>
#include<unordered_map>
#include<unordered_set>

#define pi 3.141592653589793
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pb push_back
#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)

using namespace std;
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;

const long long MOD = 1e9 + 7;
const long long INF = 1e9 ;

template <typename T>
std::ostream& operator<<(ostream& os, 
                        const vector<T> &v)
{
    for (T const& i: v) {
        os << i << " ";
    }
    os<<endl;
    return os;
}


template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
vector<int> sieve(int n){
    vector<bool> s(n, true);
    for(int i =2 ; i*i <= n; i++ )
        if(s[i])
            for(int j=2*i; j< n; j +=i )
                s[j] = false;

    vector<int> primes;
    for(int i =0; i<n; i++)
        if( s[i] )
            primes.push_back(s[i]);

    return primes;
}


int main(){
    int h , w ;
    cin>>h>>w;
    vector<vector<long long >> table(h , vector<long long>(w, 0));
    for(int i =0; i<h;i++){
        string temp ;
        cin>>temp;
        for(int j = 0; j < w; j++)
            if(  temp[j] == '#')
                table[i][j] = -1;
    }
    for(int i = 0; i < h; i++)
        if( table[i][0] == -1 ) 
            break;
        else
            table[i][0] = 1;
    for(int i = 0; i < w; i++)
        if( table[0][i] == -1 ) 
            break;
        else
            table[0][i] = 1;
    for(int i =1; i<h; i++)
        for(int j = 1; j< w; j++) {
            if( table[i][j] == -1 )
                continue;
            if( table[i-1][j] != -1 )
                table[i][j] = ( table[i][j] +  table[i-1][j] ) % MOD ;
            if( table[i][j-1] != -1 )
                table[i][j] = ( table[i][j] +  table[i][j-1] ) % MOD ;

        }
        
        if( table[h-1][w-1] == -1)
            cout<< 0;
        else
            cout<<table[h-1][w-1] % MOD ;
   
  

    return 0;
}

Measured memory_bytes: 9984
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define REP(i, start, end) for (ll i = start, i##Len = (end); i < i##Len; ++i)
#define REPR(i, start, end) for (ll i = start, i##Len = (end); i > i##Len; --i)
using ll = long long;
using namespace std;

struct Combination
{
    std::vector<long long> fac, inv;
    int maxN;
    long long mod;

    Combination(int maxN, long long mod) : maxN(maxN), mod(mod)
    {
        fac = std::vector<long long>(maxN + 1, 1);
        inv = std::vector<long long>(maxN + 1, 1);

        for (int i = 2; i <= maxN; ++i)
            fac[i] = fac[i - 1] * i % mod;

        long long pow = mod - 2, x = fac[maxN];
        while (pow > 0)
        {
            if (pow & 1)
                inv[maxN] = (inv[maxN] * x) % mod;
            x = x * x % mod;
            pow >>= 1;
        }

        for (int i = maxN; i > 0; --i)
            inv[i - 1] = inv[i] * i % mod;
    }

    long long combination(int n, int r)
    {
        assert(n <= maxN);
        return n < r || r < 0 ? 0 : (fac[n] * inv[r] % mod) * inv[n - r] % mod;
    }

    long long permutation(int n, int r)
    {
        assert(n <= maxN);
        return n < r || r < 0 ? 0 : fac[n] * inv[n - r] % mod;
    }
};

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

    ll n, m, mod = 1e9 + 7;
    cin >> n >> m;

    auto comb = Combination(1e6, mod);
    ll ans = comb.permutation(m, n) * comb.permutation(m, n) % mod;
    REP(i, 1, n + 1)
    {
        ll x = comb.combination(n, i) * comb.permutation(m, i) % mod;
        ll p = comb.permutation(m - i, n - i) * comb.permutation(m - i, n - i) % mod;
        x = x * p % mod;
        ll sign = (i & 1) ? -1 : 1;
        ans = (ans + x * sign + mod) % mod;
    }

    cout << ans << endl;
}


Measured memory_bytes: 18764
import itertools
n, k = input().split()
d = list(map(int, input().split()))

number = list(range(10))
number = [str(x) for x in number if x not in d]

ans = []
for v in itertools.product(number, repeat=len(n)):
  if v[0] == "0": continue
  if int("".join(v)) >= int(n): ans.append(int("".join(v)))

if not ans:
  for v in itertools.product(number, repeat=len(n)+1):
    if v[0] == "0": continue
    if int("".join(v)) >= int(n): ans.append(int("".join(v)))

print(min(ans))

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


int main(){
	int A, B;
	cin >> A >> B;
	int ans = 0;
	int tmp = 1;
	while(tmp < B){
		tmp += A - 1;
		ans++;
	}
	cout << ans << endl;

}














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

def num_p(n):
  r = 0
  for i in range(1,n+1):
    if n % i == 0:
      r += 1
  return r

ans = 0
for i in range(1, N+1, 2):
  if num_p(i) == 8:
    ans += 1
print(ans)


Measured memory_bytes: 9128
using System;
using System.Text;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using static System.Array;

namespace AtcoderExpress
{


    class Program
    {

        static void Main(string[] args)
        {
            var W = long.Parse(Console.ReadLine());
            //var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var A = new long[] { 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 };
            //Array.Sort(A);
            Console.WriteLine(A[W-1]);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>

using namespace std;

int numbers[100005];

int main()
{ 
	int n;
	cin >> n;
	int *arr = new int[n];
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	
	int count = 0;
	for (int i = 0; i < n; i++)
		numbers[arr[i]]++;
	int sum = 0;
	for (int i = 0; i < 100005; i++)
	{
		if (numbers[i] + numbers[i + 1] + numbers[i + 2] > sum)
			sum = numbers[i] + numbers[i + 1] + numbers[i + 2];
	}
	cout << sum;
	string str;
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

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

template<typename T>
inline void chmax(T& a,const T& b)
{
	a=max(a,b);
}

int main()
{
	for(int c,d,w,x;scanf("%d%d%d%d",&c,&d,&w,&x),c|d|w|x;){
		static int e[30][15],f[30][15];
		rep(i,c) rep(j,d) scanf("%d",&e[j][i]);
		rep(i,c) rep(j,d) scanf("%d",&f[j][i]);
		
		static int dp[31][6][201]; // [日][2回以上ライブを行った回数][疲労]
		memset(dp,-1,sizeof dp);
		
		dp[0][0][0]=0;
		rep(i,d) rep(j,x+1) rep(k,w+1){
			if(dp[i][j][k]==-1) continue;
			rep(l,c){
				chmax(dp[i+1][j][k],dp[i][j][k]);
				chmax(dp[i+1][j][k+f[i][l]],dp[i][j][k]+e[i][l]);
			}
			if(j==x) continue;
			rep(l,c) if(e[i][l]){
				int esum=e[i][l],fsum=f[i][l];
				repi(r,l+1,c){
					if(e[i][r]==0) break;
					esum+=e[i][r];
					fsum+=f[i][r];
					chmax(dp[i+1][j+1][k+fsum],dp[i][j][k]+esum);
				}
			}
		}
		
		int res=0;
		rep(i,x+1) rep(j,w+1)
			chmax(res,dp[d][i][j]);
		printf("%d\n",res);
	}
	
	return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int n, k, q;
vector<int> a, p;
int f(int mn){
    vector<int> v;
    for(int i=0;i<n;i++){
        if(a[i] < mn) continue;
        int j = i+1;
        while(j < n && a[j] >= mn) j++;
        if(j-i >= k){
            vector<int> t(a.begin()+i, a.begin()+j);
            sort(t.begin(), t.end());
            for(int l=0;l<=j-i-k;l++) v.push_back(t[l]);
        }
        i = j;
    }
    int vs = v.size();
    if(vs < q) return 2e9;
    sort(v.begin(), v.end());
    return v[q-1]-mn;
}
int main(void){
    cin >> n >> k >> q;
    a.assign(n, 0);
    for(int i=0;i<n;i++) cin >> a[i];
    p.assign(n, 0);
    for(int i=0;i<n;i++) p[i] = i;
    sort(p.begin(), p.end(), [](int const& l, int const& r){ return a[l] < a[r]; } );
    int ans = 2e9;
    for(int i=0;i<n;i++){
        int tmp = f(a[p[i]]);
        if(tmp < ans) ans = tmp;
    }
    cout << ans << endl;
}


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

typedef long long int ll;

ll optimalStrategyOfGame(ll* arr, ll n) 
{ 
    // Create a table to store solutions of subproblems 
    ll table[n][n]; 
  
    // Fill table using above recursive formula. Note  
    // that the table is filled in diagonal fashion (similar 
    // to http:// goo.gl/PQqoS), from diagonal elements to 
    // table[0][n-1] which is the result. 
    for (ll gap = 0; gap < n; ++gap) { 
        for (ll i = 0, j = gap; j < n; ++i, ++j) { 
  
            // Here x is value of F(i+2, j), y is F(i+1, j-1) and 
            // z is F(i, j-2) in above recursive formula 
            ll x = ((i + 2) <= j) ? table[i + 2][j] : 0; 
            ll y = ((i + 1) <= (j - 1)) ? table[i + 1][j - 1] : 0; 
            ll z = (i <= (j - 2)) ? table[i][j - 2] : 0; 
  
            table[i][j] = max(arr[i] + min(x, y), arr[j] + min(y, z)); 
        } 
    } 
  
    return table[0][n - 1]; 
} 
  
// Driver program to test above function 
int main() 
{
	ll n;
	cin >> n;
	ll arr[n],s=0,i;
	for(i=0;i<n;i++)
	{
		cin >> arr[i]; 
		s+=arr[i];
	}
	ll ans = optimalStrategyOfGame(arr, n); 
		ll y = s-ans;
    cout << ans-y << "\n"; 
    return 0; 
}

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

int main() {
#ifndef ONLINE_JUDGE
   freopen("inp.txt", "r", stdin);      freopen("outp.txt", "w", stdout);
#endif
   ios::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);

   ll s, d, t;
   cin >> d >> t >> s;
   if (s * t >= d)
      cout << "Yes\n";
   else
      cout << "No\n";

   return 0;
}

Measured memory_bytes: 3636