akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    lli n,M=1000000007;
    cin>>n;
    lli i,j,dp[n+1][n+1],ans=0;
    memset(dp, 0LL, sizeof(dp));
    
    string s;
    cin>>s;
    
    dp[1][1]=1;
    for(i=2;i<=n;i++)
    {
        for(j=1;j<=i-1;j++) dp[i-1][j]=(dp[i-1][j]+dp[i-1][j-1])%M;
        
        for(j=1;j<=i;j++)
        {
            if(s[i-2]=='<')
            {
                dp[i][j]+=dp[i-1][j-1];
                dp[i][j]%=M;
            }
            else
            {
                dp[i][j]+=dp[i-1][i-1];
                dp[i][j]-=dp[i-1][j-1];
                dp[i][j]+=M;
                dp[i][j]%=M;
            }
        }
    }
    
    for(i=1;i<=n;i++) ans+=dp[n][i];
    cout<<ans%M;
    return 0;
}

Measured memory_bytes: 70656
X,Y = map(int,input().split())
if X < 4:
  X = (4-X)*100000
else:
  X = 0
if Y < 4:
  Y = (4-Y)*100000
else:
  Y = 0
if X == 300000 and Y == 300000:
  print(X+Y+400000)
else:
  print(X+Y)


Measured memory_bytes: 2940
k = 1000000007

ans m 0 = 1
ans m 1 = m

ans m n =
  let n' = n `div` 2
      x  = ans m n'
      y  = ans m (n-2*n')
  in
    (x * x * y) `mod` k

main = do
  l <- getLine
  let (m:n:_) = map read $ words l :: [Integer]
      o = ans m n
  print o



Measured memory_bytes: 3704
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
using ll = long long;

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

    vector<int> d(N);
    for (int i = 0; i < N; ++i) {
        cin >> d[i];
    }

    lli answer = 0;
    for (lli i = 0; i < N; ++i) {
        for (lli j = 0; j < N; ++j) {
            answer += d[i] * d[j];
        }
        answer -= d[i] * d[i];
    }
    
    cout << answer / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)

ans = 0

sub = 0
judge = False
for i in range(n-1, -1, -1):
  key = int(s[i])+sub
  if key <= 4:
    ans += key
    sub = 0
  elif key == 5:
    ans += 5
    if i == 0:
      sub = 0
    elif int(s[i-1]) <= 4:
      sub = 0
    else:
      sub = 1
  else:
    ans += 10-key
    sub = 1
ans += sub
print(ans)

Measured memory_bytes: 5492
#include<iostream>
int main(){
  long long int N,T;
  std::cin>>N>>T;
  long long int a,ans=0,a_next=0;
  for(long long int i=0;i<N;i++){
    std::cin>>a;
    if(a_next<=a)ans=ans+T;
    else ans=ans+T-(a_next-a);
    a_next=a+T;
  }
  std::cout<<ans<<std::endl;
  return 0;
}

Measured memory_bytes: 3580
#include <stdio.h>

#define BMI 25

int main(){
  int num;
  double weight, height;

  while(scanf("%d,%lf,%lf", &num, &weight, &height) != EOF){
    if(weight / (height * height) >= BMI){
      printf("%d\n", num);
    }
  }
  return 0;
}

Measured memory_bytes: 628
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+15+7;
ll n,m,l;
string s,t;
ll d[100],dp[100][100];
vll vec;
ll a,b;

bool bs(ll num){
  vll box = vec;
  ll ans = 0;
  rep(i,0,n)box[i] -= num * b;
  sort(all(box));
  rep(i,0,n){
    if(box[i] > 0){
      ans = box[i] / (a-b);
      if(box[i] % (a-b) != 0)ans++;
      num -= ans;
    }
  }
  if(num >= 0)return true;
  return false;
}

int main(){
  cin >> n >> a >> b;
  rep(i,0,n){
    cin >> m;
    vec.pb(m);
  }
  sort(all(vec));
  ll mx = vec[n-1];
  ll mn = 1;
  ll ans;
  while(mn < mx){
    ans = (mn + mx)/2;
    if(bs(ans))mx = ans;
    else mn = ans+1;
  }
  print(mn);
  return 0;
}

Measured memory_bytes: 1908
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int num = scanner.nextInt();
    int answer = 0;
    
    for (int i = 1; i < 11; i++) {
      int bill = 1000*i;
      if (num > bill) {
      	continue;  
      } else {
       	answer = bill-num;
        break;
      }
    }
    System.out.println(answer);
  }
}

Measured memory_bytes: 35692
class Dice:
    N = [0, 1, 5, 4]
    S = N[::-1]
    E = [0, 3, 5, 2]
    W = E[::-1]

    def __init__(self, numbers):
        self.numbers = numbers

    def toX(self, x):
        data = getattr(self, x)
        self.numbers.append(0)
        for k in range(5):
            i1 = data[k - 1] if k != 0 else 6
            i2 = data[k] if k != 4 else 6
            self.numbers[i1] = self.numbers[i2]
        del self.numbers[6]

dice = Dice([int(i) for i in input().split()])
[dice.toX(d) for d in input()]
print(dice.numbers[0])


Measured memory_bytes: 5604
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <string>
#include <sstream>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<ll> VL;

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

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

  string s;
  cin >> s;

  int pre = atoi(s.substr(0, 2).c_str());
  int su = atoi(s.substr(2, 2).c_str());
  if (pre > 12 || pre == 0) {
    if (su <= 12 && su > 0) {
      cout << "YYMM" << endl;
    } else {
      cout << "NA" << endl;
    }
  } else {
    if (su > 12 || su == 0) {
      cout << "MMYY" << endl;
    } else {
      cout << "AMBIGUOUS" << endl;
    }
  }
}


Measured memory_bytes: 256
x,y = map(int,input().split())

a = list()
a.append("#"*(y+2))
for i in range(x):
    a.append(input())

for i in range(1,x+1):
    a[i] = "#"+a[i]+"#"

a.append("#"*(y+2))


for i in range(x+2):
    print(a[i])

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;

class UF{
  vi p,r;

public:
  UF(int n):p(n,-1),r(n,0){ }

  int find(int x){ return (p[x]<0)?x:(p[x] = find(p[x])); }

  void unite(int x,int y){
    x = find(x); y = find(y);
    if(x==y)return;

    if(r[x] < r[y])p[x] = y;
    else p[y] = x;
    if(r[x] == r[y])r[x]++;
  }

  bool same(int x,int y){return find(x)==find(y);}
};

const int INF= 1e9;

struct edge{
  int from, to, cost;
  edge(int x,int y, int z):from(x),to(y),cost(z){}
  bool operator<(const edge &x)const{ return cost<x.cost; }
};

class Kruskal{
  int n;
  vector< vector<edge> > g;
public:
  Kruskal(int a=0):n(a){ g.resize(n); }
  
  void AddEdge(int a, int b, int cost){
    g[a].push_back(edge(a,b,cost));
    g[b].push_back(edge(b,a,cost));
  }

  vector<edge> MinSpanningTree(){
    UF connect(n);
    vector<edge> edges;
    for(int v=0;v<n;v++){
      for(edge e : g[v])edges.push_back(e);
    }
    sort(edges.begin(), edges.end());
    
    vector<edge> res;
    for(edge e : edges){
      if(!connect.same(e.from,e.to)){
	res.push_back(e);
	connect.unite(e.from,e.to);
      }
    }
    return res;
  }
};

int main(){
  int n,m;
  while(cin >> n >> m, n){
    Kruskal mst(n);

    for(int i=0;i<m;i++){
      int s,t,c;
      cin >> s >> t >> c; s--; t--;
      mst.AddEdge(s,t,c);
    }
    vector<edge> res = mst.MinSpanningTree();
    cout << res[(n-1)/2].cost << endl;
  }
}

Measured memory_bytes: 4036
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;

int main()
{
  string S;
  cin >> S;
  int s_len = count(S.begin(), S.end(), 'A');
  if (s_len == S.size() || s_len == 0)
  {
    cout << "No" << endl;
  }
  else
  {
    cout << "Yes" << endl;
  }
}


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

int main(){
  long long L, R;
  cin >> L >> R;
  long long ans=2019;
  if(R-L>=2018) ans=0;
  else{
    long long l=L%2019;
    long long r=R%2019;
    for(long long i=l; i<r; i++){
      for(long long j=i+1; j<=r; j++){
        ans=min(ans, i*j%2019);
      }
    }
  }
  cout << ans << endl;
}

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

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    cout << max(((n-1)*b+a) - (b+(n-1)*a) + 1, ll(0)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  vector<long> A(N);
  rep (i, N) cin >> A[i];

  long result = abs(A[0] - A[1]);

  rep(i, N) rep (j, N) {
    if (i == j) continue;
    result = max(result, abs(A[i] - A[j]));
  }

  cout << result << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

int main() {
    int a,b,x;
    cin >> a >> b >> x;
    if(a <= x && x <= a+b) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define REV(s) (s).rbegin(), (s).rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define X first
#define Y second

using namespace std;

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

ll pay[2][1000];
ll lost[2][1000];
int main(){
	ll m, r[2], c[2];
	cin >> m >> r[0] >> r[1] >> c[0] >> c[1];


	rep(j, 2) rep(i, 1000) pay[j][i] = lost[j][i] = 1ll<<60;

	rep(i, 2){
		ll Min = 100*c[i]/r[i];
		for(ll x = Min; x < Min + 1000; x++){
			ll D = x*r[i]/100;
			D -= c[i];
			if(D < 0) continue;
			ll rest = D*100/r[i];
			pay[i][x-Min] = x;
			lost[i][x-Min] = x-rest;
		}
	}

	ll ans = 1ll<<60;
	rep(i, 1000) rep(j, 1000){
		if(pay[0][i]+pay[1][j] > m) continue;
		ans = min(ans, lost[0][i]+lost[1][j]);
	}
	if(m < ans) cout << -1 << endl;
	else cout << m-ans << endl;

	return 0;
}

Measured memory_bytes: 1196
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define N	    100001
#define rep(i,a,b)  for(int i=a;i<b;i++)
typedef long long ll;

int main() {
	int n, k;
	cin>>n>>k;
	vector<int> dp(n, hell), a(n);
	for(int &i : a) {
		cin>>i;
	}
	dp[0] = 0;
	for(int i = 0; i < n; i++) {
		for(int j = 1; j <= k; j++) {
			if(i + j < n)
				dp[i + j] = min(dp[i + j], dp[i] + abs(a[i] - a[i + j]));
		}
	}
	cout<<dp[n  - 1];
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  ll N, T;
  cin >> N >> T;
  vector<ll> Tn(N, 0);
  rep(i, 0, N) {
    cin >> Tn[i];
  }
  ll ans = 0;
  rep(i, 0, N - 1) {
    if (Tn[i+1] - Tn[i] < T) {
      ans += Tn[i+1] - Tn[i];
    } else {
      ans += T;
    }
  }
  cout << ans + T << endl;
  return 0;
}


Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())

p = 10**9+7


if n==1:
    print(0)
    exit()

_09 = pow(10,n,p)
_19 = _08 = pow(9,n,p)
_18 =  pow(8,n,p)

print((_09-_19*2+_18)%p)

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

using namespace std;

int x, y;

void check(int a, int b){
    if(a == b){
        cout << 0;
    }
    else if(a == 0 && b > 0){
        cout << b;
    }
    else if(a == 0 && b < 0){
        cout << abs(b) + 1;
    }
    else if (b == 0 && a > 0){
        cout << a + 1;
    }
    else if (b == 0 && a < 0){
        cout << abs(a);
    }
    else if(a > 0){
        if(b > a) {cout << b - a;}
        else if(b > 0) cout << a - b + 2;
        else if(b < 0) {
            if(a * -1 >= b) cout << b * -1 - a + 1;
            else cout << b - a * -1 + 1;
        }
    }
    else{
        if(b < 0){
            if(a < b) cout << b - a;
            else cout << 2 + a - b;
        }
        else{
            if(a * -1 < b) cout << b + a + 1;
            else cout << a * -1 - b + 1;
        }
    }
    return;
}

int main (){

    cin >> x >> y;
    check(x, y);

    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();

    int count = 0;
    int s_research = 0;

    if(s.charAt(0) == 'A'){

    }else{
        count++;
    }

    //System.out.println(count);
    for(int i = 2 ; i < s.length()-1;i++){
        if(s.charAt(i) == 'C'){
            if(s_research==0){
                s_research++;
            }else{
                count++;
            }
        }
    }

    //System.out.println(count);

    for(int i = 1; i < s.length() ; i++){
        if( Character.isUpperCase( s.charAt( i ) ) ) {
            if(s.charAt(i) == 'C'){
                
            }else{
                count++;
            }
        }else {

         }
    }

    

    //System.out.println(s_research);
    //System.out.println(count);
    if(s_research == 0){
        System.out.println("WA");
    }else if(count == 0){
        System.out.println("AC");
    }else{
        System.out.println("WA");
    }

    

    
  

    
    
    


    


    
    


    
	}
}

Measured memory_bytes: 20948
#include <bits/stdc++.h>
using namespace std;
int N;
vector<string> w(110);
int main() {
    cin >> N;
    for(int i = 0; i < N; ++i) {
        cin >> w.at(i);
    }

    int flag = 0;

    if(flag == 0) {
        for(int i = 0; i < N-1; ++i) {
            if(w.at(i+1).at(0) != w.at(i).at(w.at(i).length() - 1)) {
                flag = 1;
                break;
            }
        }
    }

    if(flag == 0) {
        int flag2 = 0;
        for(int i = 0; i < N-1; ++i) {
            for(int j = i+1; j < N; ++j) {
                if(w.at(i) == w.at(j)) {
                    flag = 1;
                    flag2 = 1;
                    break;
                }
            }
            if(flag2 != 0) break;
        }
    }

    if(flag == 0) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}

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

int main(){
  int n;
  int imx = -1;
  int mx = -1;
  int L[100];
  while ((cin >> n)) {
  for (int i = 0; i < n; i++) {
  	cin >> L[i];
    if (L[i] > mx){
    	mx=L[i];
        imx=i;
    }
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
  	if (i != imx){
    	sum += L[i];
    }
  }
  if (mx<sum){
    cout << "Yes\n";
  }else{
    cout << "No\n";
  }
  }
  return 0;
}

Measured memory_bytes: 256
def main
  n = gets.chomp.to_i

  base = -2
  cur = 1
  div = base
  rest = n

  ans = []
  while true
    if rest % div != 0
      ans << 1
      rest -= cur
    else
      ans << 0
    end
    break if 0 == rest
    
    cur *= base
    div *= base
  end

  puts ans.reverse.join
end

if __FILE__ == $0
  main
end


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

int main()
{
  int N;
  int hashad=0;
  int N_tmp;
  
  cin >> N;
  N_tmp = N;
  
  while(N>0)
  {
    hashad += N%10;
    N /= 10;
  }
  
  if (N_tmp%hashad)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define max 200000
#define ll long long int
using namespace std;  
int main()
{
    int a,b,c,d,k;
    cin>>k>>a>>b;
    c=ceil((float)a/k);
    if(c*k<=b)
    cout<<"OK";
    else
    {
        cout<<"NG";
    }
    
}

Measured memory_bytes: 3592
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

typedef vector<int> VI;
const int MV=1005;
const int ME=2005;

int n,m;

VI g[MV];
int col[MV];
bool dfs(int u)
{
	if(col[u]) return col[u]==1;
	col[u]=1;
	for(int v:g[u])
		if(dfs(v)) return true;
	col[u]=2;
	return false;
}

VI ans,nans;
int vis[MV],pre[MV];

void bfs(int st)
{
	nans.clear();
	queue<int> qu;
	for(int i=1;i<=n;i++)
		vis[i]=0;
	qu.push(st);
	vis[st]=1;
	pre[st]=0;
	int ed=0;
	while(!qu.empty())
	{
		int u=qu.front(); qu.pop();
		for(int v:g[u])
		{
			if(v==st)
			{
				ed=u;
				break;
			}
			if(vis[v]) continue;
			pre[v]=u;
			vis[v]=1;
			qu.push(v);
		}
		if(ed) break;
	}
	//cout<<st<<" "<<ed<<endl;
	while(ed)
	{
		nans.push_back(ed);
		ed=pre[ed];
	}
}

void upd()
{
	if((int)nans.size()==0) return;
	if((int)ans.size()==0||nans.size()<ans.size())
		ans=nans;
}

int main()
{
	scanf("%d%d",&n,&m);
	int u,v;
	for(int i=0;i<m;i++)
	{
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
	}
	int f=0;
	for(int i=1;i<=n;i++)
		if(!col[i]&&dfs(i))
		{
			f=1;
			break;
		}
	if(!f)
	{
		printf("-1\n");
		return 0;
	}
	for(int i=1;i<=n;i++)
	{
		bfs(i);
		upd();
	}
	printf("%d\n",ans.size());
	for(int i:ans)
		printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define N (long long)(1e9 + 7)
#define MAX 500000
using namespace std;

long long factorial[MAX] = {0}, finverse[MAX] = {0},
          inverse[MAX] = {0};

void smodfact() {
  factorial[0] = factorial[1] = 1;
  finverse[0] = finverse[1] = 1;
  inverse[1] = 1;
  for(int i = 2; i < MAX; ++i) {
    factorial[i] = factorial[i - 1] * i % N;
    inverse[i] = N - (inverse[N % i] * (N / i)) % N;
    finverse[i] = finverse[i - 1] * inverse[i] % N;
  }
}

long long calccomb(long long n, long long k) {
  if(n == k && n == 0) return 1;
  if(n < 0 || k < 0 || n < k) return 0;
  return factorial[n] * finverse[k] % N * finverse[n - k] %
         N;
}

long long n, l, m, r;
long long ch[100005] = {0};

long long solve(long long x);

int main() {
  smodfact();
  cin >> n;
  for(int i = 1; i <= n + 1; ++i) {
    long long x;
    cin >> x;
    if(ch[x] != 0) {
      l = ch[x] - 1;
      m = i - ch[x] - 1;
      r = n - i + 1;
    }
    ch[x] = i;
  }
  for(int i = 0; i < n + 1; ++i)
    cout << solve(i + 1) << endl;
  return 0;
}

long long solve(long long x) {
  if(x == 1) return n;
  long long ans = 0;
  // nomal
  ans += calccomb(n, x);
  // double use
  ans += calccomb(n - 1, x - 2);
  ans %= N;
  ans -= calccomb(l + r, x - 1);
  while(ans < 0) ans += N;
  // use all
  ans += calccomb(l + r + m, x - 1);
  ans %= N;
  return ans;
}

Measured memory_bytes: 13696
#include<cstdio>
#include<cstring>

typedef long long int lli;

char prime[50000002];

int main(void) {
//    memset(prime, 0xFF, sizeof(prime));
    prime[0] = 1;
    for(lli i=3; i<100000002; i+=2)
        if(!prime[i/2])
            for(lli j=3; i*j<100000002; j+=2)
                prime[i*j/2] = 1;

    int n;
    scanf("%d",&n);
    int res=0;
    for(int i=0; i<n; i++) {
        int a;
        scanf("%d",&a);
        if(!(a%2) && a-2) continue;
        if(!prime[a/2]) res++;
    }
    printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 51524
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
const int MGN = 2;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vc = vector<char>;
using vvc = vector<vc>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using psl = pair<string, ll>;

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

  string S; cin >> S;
  int K; cin >> K;
  int L = S.size();

  auto dp = vector<vvl>(L+MGN, vvl(K + MGN, vl(2, 0)));
  // dp[i][j][k] := S[0,i] (上位から i ) 桁目までを決め、非 0 を j 個使い、
  // そこまでの桁が S と一致していたら k = 0, 一致していないで、既に S
  // の値以下となることが確定していたら k = 1 とするときの通り数
  dp[0][0][0] = 1;

  REP(i, L) {
    REP(j, K + 1) {
      REP(k, 2) {
        const int DMAX = S[i] - '0'; // i 桁目で選択できる最大値
        REP(nd, 10) {
          int ni = i + 1, nj = j, nk = k;
          if (nd > 0) nj++; // 非 0 を使った
          if (nj > K) continue; // 非 0 の使用個数を超えた

          if (k == 0) { // ここまでの桁が上限と一致していたら
            if (nd > DMAX) continue;
            else if (nd == DMAX) nk = 0;
            else {
              assert(nd < DMAX);
              nk = 1;
            }
          }

          dp[ni][nj][nk] += dp[i][j][k];
        }
      }
    }
  }

  ll ans = dp[L][K][0] + dp[L][K][1];
  cout << ans << endl;

  return 0;
}

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

int main() {
    int N, P, j;
    string A;
    cin >> N;
    map<string, int> S;
    for (int i = 0; i < N; i++){
        cin >> A;
        S[A]++;
    }
    cout << S.size() << endl;
}

Measured memory_bytes: 19112
#include <iostream>
using namespace std;
int C[10001]={0};
int n=0, a;
int main() 
{
	int maxa=0;
	cin>>n;
	for(int i=0;i<n;i++) {
		cin>>a; C[a]++; if (a>maxa) maxa=a;
	}
	bool first = true;
	for(int i=0;i<=maxa;i++){
		for(int j=0;j<C[i];j++){
			if (first) { first=false;} else {cout<<' ';}
			cout<<i;
		}
	}
	cout<<endl;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
int n,t;
int ans,anc;
int main() {
	ios::sync_with_stdio(false);
	cin>>n>>t;
	anc=0x3f3f3f;
	for(int i=0;i<n;i++) {
		int c,ti;
		cin>>c>>ti;
		if(ti<=t&&c<anc) anc=c;
	}
	if(anc!=0x3f3f3f) cout<<anc;
	else cout<<"TLE";
	return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n, a, b;
    cin >> n >> a >> b;
    vll x(n);
    rep(i, n) cin >> x[i];
    
    ll ans = 0;
    rep(i, n-1) {
        ll walk = (x[i+1] - x[i]) * a;
        ll telepo = b;
        if (walk <= telepo) ans += walk;
        else ans += telepo;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define reverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vc = vector<char>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
const ll MOD = 1e9+7;
vi alphabet = {'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'};

int main() {
	ll a,b,x;
  	cin>>a>>b>>x;
  	if(a%x==0){
    cout<<-(a/x)+(b/x)+1<<endl;
    }
  	else cout<<-(a/x)+(b/x)<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define mod 1000000007
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

using namespace std;

int main()
{
  ll A, B, C; cin >> A >> B >> C;
  if ((A + B < C) && (4 * A * B < (C - A - B) * (C - A - B))) {
  	cout << "Yes" << endl;
  } else {
  	cout << "No" << endl;
  }
}

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


int main()//本物解答（さっきのフルACは謎）
{
	int a1,a2,a3,maxNum,midNum,minNum;
	cin >> a1 >> a2 >> a3;
	maxNum = max(a1, max(a2, a3));
	minNum = min(a1, min(a2, a3));
	if (a2 >= a1) {
		if (a3 <= a1)midNum = a1;
		else if (a3 >= a2)midNum = a2;
		else midNum = a3;
	}
	else if (a2 < a1) {
		if (a3 <= a2)midNum = a2;
		else if (a3 >= a1)midNum = a1;
		else midNum = a3;
	}
	cout << abs(maxNum - midNum)+abs(midNum - minNum) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,s;
char b;
int main()
{
cin>>n;
for(int i=0;i<n;i++)
{
cin>>b;
if(b=='I')m++;
else m--;
s=max(s,m);
}
cout<<s<<endl;
}

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

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

    bool f = false;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        f += (a % 2);
    }
    cout << (f ? "first" : "second");

    return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
a = []
for i in range(H):
    s = input()
    if s != '.'*W:
        a.append(s)
ls = []
for i in range(W):
    b = ''
    for j in range(len(a)):
        b += a[j][i]
    if b == '.'*len(a):
        ls.append(i)
ans = []
for i in range(len(a)):
    s = ''
    for j in range(W):
        if j in ls:
            continue
        else:
            s += a[i][j]
    ans.append(s)
print(*ans, sep='\n')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define lli long long int
#define timesave ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

void solve()
{
    char ch;

    cin >> ch;

    if(ch >= 'A' && ch <= 'Z') cout << 'A' << "\n";
    else cout << 'a' << "\n";
}

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

    int tc = 1;
    //cin >> tc;
    while(tc--	) solve();
 
    return 0;
}

Measured memory_bytes: 3632
n = gets.to_i

h = Hash.new(0)

n.times do
  s = gets.strip
  h[s] += 1
end

sorted = h.sort_by{|k, v| -v}

max = nil
keys = []

sorted.each do |k, v|
  max = v if max.nil?
  if max == v
    keys << k
  else
    break
  end
end

puts keys.sort

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

int a[3][3];

int main() {
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a[i][j];
        }
    }
    int N;
    cin >> N;
    for (int k = 0; k < N; k++) {
        int b;
        cin >> b;
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (a[i][j] == b) a[i][j] = -1;
            }
        }
    }
    string ans = "No";
    for (int i = 0; i < 3; i++) {
        if (a[i][0] == -1 && a[i][1] == -1 && a[i][2] == -1) ans = "Yes";
        if (a[0][i] == -1 && a[1][i] == -1 && a[2][i] == -1) ans = "Yes";
    }
    if (a[0][0] == -1 && a[1][1] == -1 && a[2][2] == -1) ans = "Yes";
    if (a[0][2] == -1 && a[1][1] == -1 && a[2][0] == -1) ans = "Yes";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#define int long long
using namespace std;
char aa[123456];
signed main() {
	int n, d = 0; string s, t; cin >> n >> s >> t;
	for (int h = 0; h < n; h++) {
		aa[d] = s[h]; d++;
		aa[d] = t[h]; d++;
	}
	for (int h = 0; h < d; h++) {
		cout << aa[h];
	}
	cout << endl;
}

Measured memory_bytes: 256
using System;
using System.Numerics;
using System.Linq;

namespace AtCoder
{
    class Abc169B
    {
        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ').Select(i => ulong.Parse(i)).ToArray();

            if (a.Contains(0ul))
            {
                Console.WriteLine('0');
                return;
            }

            ulong ans = 1;
            for (int i = 0; i < n; i++)
            {
                if (ans > long.MaxValue / a[i] || (ans *= a[i]) > 1000000000000000000L)
                {
                    Console.WriteLine(-1);
                    return;
                }
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 41468
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
pair<string,int> d[101];
int ptop[101];
int p[101][101];
int main(){
	string a;
	int q,top;
	top=0;
	while(cin>>a>>q){
		bool news=true;
		for(int i=0;i<top;i++){
			if(d[i].first==a){
				p[i][ptop[i]]=q;
				ptop[i]++;
				news=false;
			}
		}
		if(news){
			d[top].first=a;
			d[top].second=top;
			ptop[top]=1;
			p[top][0]=q;
			top++;
		}
	}
	sort(d,d+top);
	for(int i=0;i<top;i++)sort(p[i],p[i]+ptop[i]);
	for(int i=0;i<top;i++){
		cout<<d[i].first<<endl;
		cout<<p[d[i].second][0];
		for(int j=1;j<ptop[d[i].second];j++){
			cout<<" "<<p[d[i].second][j];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1252
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        ArrayList<Integer>[] list = new ArrayList[N];
        for (int i=0; i<N; i++) {
            list[i] = new ArrayList<Integer>();
        }
        for (int i=0; i<N; i++) {
            int S = sc.nextInt();
            for (int j=0; j<S; j++) {
                list[i].add(sc.nextInt());
            }
        }
        int counter = 0;
        for (int i=0; i<=M; i++) {
            boolean flag = true;
            for (int j=0; j<N; j++) {
                if (list[j].contains(i)) {
                } else {
                    flag = false;
                }
            }
            if (flag) {
                counter++;
            }
        }
        System.out.println(counter);
    }
}


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

using namespace std;

int f=0, g[2001], D[2001][2001], P[2001], I, n;

void dfs(int d, int p, int be)
{
    if (f == 1)
    {
        return;
    }
    P[d] = p;
    for (int i = 1; i <= n; i++)
    {
        if (i != p && D[d][i] == 1 && g[i] == 1)
        {
            if (i == be)
            {
                f = 1;
                I = d;
            }
            g[i] = 0;
            dfs(i, d, be);
        }
        if (f == 1)
        {
            return;
        }
    }
}

int main()
{
    int m, a, b, c;
    cin >> n >> m;
    int G[n+1], A[m], B[m];
    deque <int> V;
    for (int i = 0; i <= n; i++)
    {
        for (int y = 0; y <= n; y++)
        {
            D[i][y] = 0;
        }
        G[i] = 1;
        g[i] = 1;
        P[i] = -1;
    }
    for (int i = 0; i < m; i++)
    {
        cin >> a >> b;
        A[i] = a;
        B[i] = b;
        D[a][b] = 1;
    }
    for (int i = 1; i <= n; i++)
    {
        for (int y = 1; y <= n; y++)
        {
            g[y] = 1;
            P[y] = -1;
        }
        dfs(i, -1, i);
        if (f == 1)
        {
            break;
        }
    }
    if (f == 0)
    {
        cout << -1;
        return 0;
    }
    while (I != -1)
    {
        V.push_front(I);
        I = P[I];
    }
    while (true)
    {
        for (int i = 1; i <= n; i++)
        {
            G[i] = 0;
        }
        for (int i = 0; i < m; i++)
        {
            D[A[i]][B[i]] = 0;
        }
        for (int i = 0; i < V.size(); i++)
        {
            G[V[i]] = 1;
            if (i != 0)
            {
                D[V[i-1]][V[i]] = 2;
            }
        }
        D[V[V.size()-1]][V[0]] = 2;
        a = -1;
        for (int i = 0; i < m; i++)
        {
            if (G[A[i]] == 1 && G[B[i]] == 1)
            {
                if (D[A[i]][B[i]] != 2)
                {
                    a = A[i];
                    b = B[i];
                    D[A[i]][B[i]] = 1;
                }
            }
        }
        if (a == -1)
        {
            break;
        }
        for (int i = 0; i < V.size(); i++)
        {
            if (a == -1)
            {
                if (V[i] == b)
                {
                    b = -1;
                    break;
                }
                else
                {
                    V.erase(V.begin()+i);
                    i--;
                }
            }
            else if (V[i] == a)
            {
                a = -1;
            }
        }
        for (int i = 0; i < V.size(); i++)
        {
            if (V[i] == b || b == -1)
            {
                break;
            }
            else
            {
                V.erase(V.begin()+i);
                i--;
            }
        }
    }
    cout << V.size() << "\n";
    for (int i = 0; i < V.size(); i++)
    {
        cout << V[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll, ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second

const int N = 5000 + 4;
const int NN = 5000*5000 + 4;

int dpA[N]; //max# acorns you can get at station B using i acorns
ll dpB[NN]; //max# acorns you get from B -> A starting with i acorns at station B

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // Emily <3
  int n;
  cin >> n;
  vector<pii> balls(3);
  forx(i,3) { cin >> balls[i].ff; }
  forx(i,3) { cin >> balls[i].ss; }
  forx(i, N) { dpA[i] = i; }
  forx(i, N) {
    forx(j, 3) {
      if (i >= balls[j].ff)
        dpA[i] = max(dpA[i], dpA[i - balls[j].ff] + balls[j].ss);
    }
  }

  forx(i, NN) { dpB[i] = i; }
  forx(i, NN) {
    forx(j, 3) {
      if (i >= balls[j].ss)
        dpB[i] = max(dpB[i], dpB[i - balls[j].ss] + balls[j].ff);
    }
  }
  ll ans = n;
  forx(i, n+1) {
    ans = max(ans, dpB[dpA[i]]);
  }
  cout << ans << nl;
  
  return 0;
}


Measured memory_bytes: 195584
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Diagnostics;
using static System.Console;
using static System.Math;


namespace FunProCon
{
    class FunProConSummer
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            int cnt = 0;
            while (n>1)
            {
                n /= 2;
                cnt++;
            }
            int ans = 1;
            for (int i = 0; i < cnt; i++)
            {
                ans *= 2;
            }
            WriteLine(ans);
        }

    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#define MAX 10000
#define NIL -1
using namespace std;

struct Node {
    int parent;
    int left;
    int right;
};

Node Tree[MAX];
int D[MAX];
int H[MAX];

void setDepth(int u,int d) {
    if (u==NIL) {
        return ;
    }
    D[u]=d;
    setDepth(Tree[u].left,d+1);
    setDepth(Tree[u].right,d+1);
}
int setHeight(int u) {
    int h1=0;
    int h2=0;
    if (Tree[u].left!=NIL) {
        h1=setHeight(Tree[u].left)+1;
    }
    if (Tree[u].right!=NIL) {
        h2=setHeight(Tree[u].right)+1;
    }
    return H[u]=(h1>h2?h1:h2);
}
int getSibling(int u) {
    if (Tree[u].parent==NIL) {
        return NIL;
    }
    if (Tree[Tree[u].parent].left!=u && Tree[Tree[u].parent].left!=NIL) {
        return Tree[Tree[u].parent].left;
    }
    if (Tree[Tree[u].parent].right!=u && Tree[Tree[u].parent].right!=NIL) {
        return Tree[Tree[u].parent].right;
    }
    return NIL;
}
void print(int u) {
    printf("node %d: ",u);
    printf("parent = %d, ",Tree[u].parent);
    printf("sibling = %d, ",getSibling(u));
    int deg=0;
    if (Tree[u].left!=NIL) {
        deg++;
    }
    if (Tree[u].right!=NIL) {
        deg++;
    }
    printf("degree = %d, ",deg);
    printf("depth = %d, ",D[u]);
    printf("height = %d, ",H[u]);
    if (Tree[u].parent==NIL) {
        printf("root\n");
    } else if (Tree[u].left==NIL && Tree[u].right==NIL) {
        printf("leaf\n");
    } else {
        printf("internal node\n");
    }
}
int main() {
    int n;
    cin >> n;
    for (int i=0; i<n; i++) {
        Tree[i].parent=NIL;
    }
    int v, l, r;
    for (int i=0; i<n; i++) {
        cin >> v >> l >> r;
        Tree[v].left=l;
        Tree[v].right=r;
        if (l!=NIL) {
            Tree[l].parent=v;
        }
        if (r!=NIL) {
            Tree[r].parent=v;
        }
    }
    int root=0;
    for (int i=0; i<n; i++) {
        if (Tree[i].parent==NIL) {
            root=i;
        }
    }
    setDepth(root,0);
    setHeight(root);
    for (int i=0; i<n; i++) {
        print(i);
    }
    return 0;
}

Measured memory_bytes: 3236
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
		String str = sc.next();
        if (num < str.length()){
          str = str.substring(0, num);
          System.out.printf(str + "...");
        }
		else
        {
          System.out.printf(str);
        }
    }
}

Measured memory_bytes: 38520
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

namespace math_helper
{
	template<typename value_type>
	value_type fast_power(const value_type a, const value_type n, const value_type& m)
	{
		if (n == 1) return a;

		value_type ret = fast_power(a, n / 2, m);
		ret = (ret * ret) % m;
		if (n % 2 != 0) ret = (a * ret) % m;
		return ret;
	}
};

//long long power_value = math_helper::fast_power<long long>(value, power);

template<typename value_type>
class fast_combination
{
public:
	value_type mod_value;

	vector<value_type> mod_inv;
	vector<value_type> fact;
	vector<value_type> fact_inv;

public:
	fast_combination(const value_type& limit, const value_type& m)
		: mod_value(m), mod_inv(), fact(), fact_inv()
	{
		mod_inv.assign(limit + 1, 0);
		fact.assign(limit + 1, 0);
		fact_inv.assign(limit + 1, 0);

		mod_inv[1] = 1;
		fact[0] = 1;
		fact[1] = 1;
		fact_inv[0] = 1;
		fact_inv[1] = 1;

		for (value_type i = 2; i <= limit; i++)
		{
			mod_inv[i] = mod_value - ((mod_value / i) * mod_inv[mod_value % i] % mod_value);
			fact[i] = (fact[i - 1] * i) % mod_value;
			fact_inv[i] = (fact_inv[i - 1] * mod_inv[i]) % mod_value;
		}
	}

public:
	value_type process(const value_type& n, const value_type& r)
	{
		if (n < 0 || r < 0) return 0;
		if (n < r) return 0;
		if (n == r) return 1;

		return (fact[n] * (fact_inv[r] * fact_inv[n - r] % mod_value)) % mod_value;
	}
};

//fast_combination<long long> fc(N, MOD);
//long long result = fc.process(n, r);

const long long MOD = 1e9 + 7;

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

    int N, a, b;
    cin >> N >> a >> b;

	fast_combination<long long> fc(max(a, b), MOD);

	long long nCa = 1;
	for (long long i = N - a + 1; i <= N; i++)
	{
		nCa = nCa * i % MOD;
	}
	nCa = nCa * fc.fact_inv[a] % MOD;

	long long nCb = 1;
	for (long long i = N - b + 1; i <= N; i++)
	{
		nCb = nCb * i % MOD;
	}
	nCb = nCb * fc.fact_inv[b] % MOD;

	long long power_value = math_helper::fast_power<long long>(2, N, MOD) - 1;

	cout << (power_value - nCa - nCb + MOD * 2) % MOD;

    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#define T 1001
#define M 1000000007
#define E e[x][i]
#define S e[x].size()
using namespace std;
typedef long long ll;
ll func(int);
int N,s,t;
string n[T];
vector<int> e[T];
 
main(){
  cin>>N;
  for(int i=0;i<N;i++) cin>>n[i];
  for(int i=0;i<N-1;i++) cin>>s>>t,e[s-1].push_back(t-1);
  cout<<func(0)%M<<endl;
}

ll func(int x){
  ll res=0;
  if(!e[x].size()){
    if(n[x]=="E") return 1;
    return 2;
  }
  if(n[x][0]=='E'){
    res++;
    for(int i=0;i<S;i++) res*=func(E);
    if(n[x]=="E?") res++;
  }
  if(n[x][0]=='A'){
    for(int i=0;i<S;i++) res+=func(E);
    if(n[x]=="A?") res++;
  }
  if(n[x][0]=='R'){
    res++;
    for(int i=0;i<S;i++) res*=(1+func(E));
    if(n[x]=="R") res--;
  }
  return res%M;
}

Measured memory_bytes: 1372
/*
[arc103] C - /\/\/\/
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 100000;
const int MAX_V = 100000;

int N;
int v[MAX_N];
pii cnt[2][MAX_V + 1];

ll solve() {
    for (int i = 0; i < N; i++) {
        cnt[i % 2][v[i]].first++;
    }
    for (int k = 0; k < 2; k++) {
        for (int i = 0; i <= MAX_V; i++) {
            cnt[k][i].second = i;
        }
        sort(cnt[k], cnt[k] + MAX_V + 1, greater<pii>());
    }

    int ans[2] = {N / 2 - cnt[0][0].first, N / 2 - cnt[1][0].first};
    if (cnt[0][0].second == cnt[1][0].second) {
        int k = (cnt[0][0].first - cnt[0][1].first <=
                 cnt[1][0].first - cnt[1][1].first)
                    ? 0
                    : 1;
        ans[k] += cnt[k][0].first - cnt[k][1].first;
    }

    return ans[0] + ans[1];
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> v[i];
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 2176
#include "bits/stdc++.h"
using namespace std;


int main()
{
	int64_t x;
	cin >> x;

	int64_t a = 0;
	int64_t b = 0;
	bool flag = false;

	for (int64_t i = -1000; i <= 1000; i++) {
		for (int64_t j = -1000; j <= 1000; j++) {
			if (pow(i, 5) - pow(j, 5) == x) {
				a = i;
				b = j;
				flag = true;
			}
		}
		if (flag == true) {
			break;
		}
	}

	cout << a << " " << b << endl;

}

Measured memory_bytes: 4024
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
signed main() {
  int N; cin >> N;
  for (int i = 1; i < 10; i++) {
    for (int j = 1; j < 10; j++) {
      if (i*j == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;  
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;

int main()
{
	ll A, B, K;
	cin >> A >> B >> K;
	if (A >= K) {
		A = A - K;
	}
	else if (A < K && K <= A + B){
		K = K - A;
		A = 0;
		B = B - K;

	}
	else {
		A = 0;
		B = 0;
	}
	cout << A << " " << B << endl;

	return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, M, Q;
int L, R;
int p, q;
int cnt[510][510];

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

    std::cin >> N >> M >> Q;

    for(int i=0;i<M;++i){
        std::cin >> L >> R;

        cnt[L][R] += 1;
    }

    for(int i=1;i<=N;++i){
        for(int j=i+1;j<=N;++j){
            cnt[i][j] += cnt[i][j-1];
        }
    }

    for(int i=0;i<Q;++i){
        std::cin >> p >> q;

        ll c = 0;

        for(int j=p;j<=q;++j){
            c += cnt[j][q] - cnt[j][j-1];
        }

        std::cout << c << std::endl;
    }
}


Measured memory_bytes: 1920
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
#include <complex>

using namespace std;

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

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

    int max = 0;
    for(int i = 0; i < n - 1; i++){
        for(int j = i + 1; j < n; j++){
            if(abs(a[i] - a[j]) > max) max = abs(a[i] - a[j]);
        }
    }

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

    return 0;
}


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

int main() {
  // 入力
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }

  // 貰うDPをする
  vector<int> dp(n);
  dp[0] = 0;
  for (int i = 1; i < n; i++) { // 0より左に行かないように、場合分け
    if (i - 2 >= 0) {  // 1つ前と2つ前を比較する
      dp[i] = min(dp[i - 1] + abs(v[i] - v[i - 1]), dp[i - 2] + abs(v[i] - v[i - 2]));
    } else {  // 1つ前から取ってくる
      dp[i] = dp[i - 1] + abs(v[i] - v[i - 1]);
    }
  }

  cout << dp[n - 1] << endl;
}


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

int n;
double a[105] = {0};
double ave = 0;
int ans = 0;

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    cin >> a[i];
    ave += a[i];
  }
  ave /= (double)n;
  ans = 0;
  for(int i = 0; i < n; ++i)
    if(fabs(ave - a[ans]) > fabs(ave - a[i])) ans = i;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 764
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
#define INF 1e18
signed main(){
  init_io();
  ll n,m,x,ans=INF;
  cin >> n >> m >> x;
  vector<ll> c(n);
  vector<vector<ll>> a(n,vector<ll>(m));
  for(int i=0;i<n;i++){
    cin >> c[i];
    for(int j=0;j<m;j++){
      cin >> a[i][j];
    }
  }
  for(ll i=0;i<(1ll<<n);i++){
    ll tmp=0;
    vector<ll> v(m,0);
    for(int j=0;j<n;j++){
      if(i&(1ll<<j)){
        tmp += c[j];
        for(int k=0;k<m;k++){
          v[k] += a[j][k];
        }
      }
    }
    bool can = true;
    for(int j=0;j<m;j++){
      if(v[j]<x){
        can = false;
        break;
      }
    }
    if(can){
      ans = min(ans,tmp);
    }
  }
  if(ans==INF){
    cout << -1 << endl;
  }else{
    cout << ans << endl;
  }
}


Measured memory_bytes: 3660
import numpy as np

mat = []

for i in range(3):
	(a,b,c)= input().split(' ')
	mat.append((int(a),int(b),int(c)))

mat = np.array(mat).reshape(3,3)


num = int(input())
ball=[]
for i in range(num):
  ball.append(int(input()))

ball = set(ball)

for h in range(3):
  x = set(mat[h,:])
  res = ball.intersection(x) == x
  if res:
    print('Yes')
    exit()

for w in range(3):
  x = set(mat[:, w])
  res = ball.intersection(x) == x
  if res:
    print('Yes')
    exit()

x = {mat[0,0],mat[1,1], mat[2,2]}
res = ball.intersection(x) == x
if res:
  print('Yes')
  exit()

x = {mat[2,0],mat[1,1], mat[0,2]}  
res = ball.intersection(x) == x
if res:
  print('Yes')
  exit()
  
print('No')

Measured memory_bytes: 12500