akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <utility>
#include <algorithm>
#include <math.h>
using namespace std;
#define ll long long
const long long mod = 1e9 + 7;
map<pair<ll, ll>, ll>ma;
//map<pair<ll, ll>, int>::iterator it;
long long gcd(long long a, long long b)
{
	return b ? gcd(b, a % b) : a;
}
long long qpow(ll a, ll b)
{
	ll res = 1;
	while (b)
	{
		if (b & 1)
		{
			res *= a;
			res %= mod;
		}
		a *= a;
		a %= mod;
		b /= 2;
	}
	return res;
}
int main()
{
	long long n, s = 0;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		long long a, b;
		cin >> a >> b;
		long long g = gcd(a, b);
		if (g == 0)
		{
			s++;
			continue;
		}
		a /= g, b /= g;
		if (a < 0)
			a = -a, b = -b;
		ma[{a, b}]++;
	}
	long long ans = 1;
	for(auto it : ma)
	{
		if (it.second == 0)
			continue;
		ll a = it.first.first;
		ll b = it.first.second;
		ll d = qpow(2 * 1LL, ma[{a, b}]);
		b = -b;
		if (b < 0)
			a = -a, b = -b;
		if (ma.count({ b,a }))
		{
			d += (qpow(2 * 1LL, ma[{b, a}]) - 1);
			d %= mod;
			ma[{b, a}] = 0;
		}
		ans *= d;
		ans %= mod;
	}
	ans = (ans - 1 + s + mod) % mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 16124
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<math.h>
#include<map>
#include<unordered_map> 
#include<vector>
#include<queue>
#include<set>
#include<bits/stdc++.h>
#include<deque> 
#include<bitset>
#include<string>
#define N 1e6
#define K 300005
#define MOD 1e9+7
#define int long long 
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
 
int max(int a, int b){
    if(a>b)
        return a;
    return b;
}
int min(int a, int b){
    if(a<b)
        return a;
    return b;
}
 
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 

int ones(int mask){
	int ct = 0;
	while(mask > 0){
		ct = ct + (mask %2 == 1);
		mask /= 2;
	}
	return ct;
}

int mod = 1e9 + 7;

int32_t main(){
	int n;
	cin>>n;
	int a[n][n];

	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>a[i][j];
		}
	}
	
	int lim = 1<<n;
	int dp[lim];
	dp[0] = 1;
	for(int i =1; i<lim;i++){
		dp[i] = 0;
	}
	for(int mask = 1; mask < lim; mask++){

		for(int lady = 0; lady < n; lady++){
			int last_man = ones(mask) - 1;
			if(a[last_man][lady] && ((1<<lady) & mask)){
				dp[mask] += dp[mask ^ (1<<lady)];
				if(dp[mask] >= mod)
					dp[mask] -= mod;
			}
		}
        //cout<<mask<<" "<<dp[mask]<<endl;
	}
	cout<<dp[lim-1]<<endl;

	
}












Measured memory_bytes: 16768
# 組み合わせの計算は下記サイトから引用
# https://qiita.com/derodero24/items/91b6468e66923a87f39f#%E7%95%AA%E5%A4%96%E7%B7%A8
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N,K=map(int, input().split())
R=N-K

for i in range(1,K+1):
    print(cmb(R+1,i,mod) * cmb(K-1,i-1,mod) % mod)


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

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

  vector<ll> ya;

  for (ll i = 1; i * i < N + 1; i++) {
    if (N % i == 0) {
      ya.push_back(i);
    }
  }

  ll res = 1e12 + 1;

  for (const ll &e : ya) {
    res = min(res, e + (N / e) - 2);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 384
import bisect

n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        ans += bisect.bisect_left(l, l[i] + l[j]) - j - 1
print(ans)

Measured memory_bytes: 9368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	int n;
	double a,m=1,sum=0;
	vector<double>v;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		v.push_back(a);
		m*=a;
	}
	for(int i=0;i<n;i++)
	{
		sum+=m/v[i];
	}
	cout<<setprecision(15)<<m/sum<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int n = 1;
        while (x > n * (n + 1) / 2) {
            n++;
        }
        System.out.println(n);
    }

}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define u8 unsigned char
#define u16 unsigned short
#define u32 unsigned int
#define u64 unsigned long
#define s8 char
#define s16 short
#define s32 int
#define s64 long
#define f32 float
#define f64 double
#define forin(_x,_y) for(auto& _x: _y)
#define iter(_i,_c) for(auto _i=0; _i<_c; ++_i)

using namespace std;

int ctoi(char a){return a-'0';}

template<class T> T max(const vector<T> &x){return *std::max_element(x.begin(), x.end());}
template<class T> T min(const vector<T> &x){return *std::min_element(x.begin(), x.end());}
template<class T> size_t argmax(const vector<T> &x){auto iter = std::max_element(x.begin(), x.end()); return std::distance(x.begin(), iter);}
template<class T> size_t argmin(const vector<T> &x){auto iter = std::min_element(x.begin(), x.end()); return std::distance(x.begin(), iter);}
template<class T> T sum(const vector<T> &x){ return std::accumulate(x.begin(), x.end());}
template <class T> void sort(vector<T> &x){sort(x.begin(), x.end());}
template <class T, class Compare> void sort(vector<T> &x, Compare comp){sort(x.begin(), x.end(),comp);}
template<class T> void len(const vector<T> &x){return x.size();}
template<class T> ostream& operator<<(ostream& os, const vector<T> &x){forin(y,x)os<<y<<" "; return os;}

template<class T, size_t SIZE> T max(const array<T,SIZE> &x){return *std::max_element(x.begin(), x.end());}
template<class T, size_t SIZE> T min(const array<T,SIZE> &x){return *std::min_element(x.begin(), x.end());}
template<class T, size_t SIZE> size_t argmax(const array<T,SIZE> &x){auto iter = std::max_element(x.begin(), x.end()); return std::distance(x.begin(), iter);}
template<class T, size_t SIZE> size_t argmin(const array<T,SIZE> &x){auto iter = std::min_element(x.begin(), x.end()); return std::distance(x.begin(), iter);}
template<class T, size_t SIZE> T sum(const array<T,SIZE> &x){ return std::accumulate(x.begin(), x.end());}
template<class T, size_t SIZE> void sort(array<T,SIZE> &x){sort(x.begin(), x.end());}
template<class T, size_t SIZE, class Compare> void sort(array<T,SIZE> &x, Compare comp){sort(x.begin(), x.end(),comp);}
template<class T, size_t SIZE> ostream& operator<<(ostream& os, const array<T,SIZE> &x){forin(y,x)os<<y<<" "; return os;}

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

    char a, b;
    cin>>a>>b;
    string A="";
    string B="";
    iter(i, ctoi(b)) A.push_back(a);
    iter(i, ctoi(a)) B.push_back(b);

    iter(i, min(A.size(), B.size())){
        if (ctoi(A[i])<ctoi(B[i])){cout<<A;return 0;}
        else if (ctoi(A[i])>ctoi(B[i])){cout<<B;return 0;}
    }

    if (A.size()<B.size()) cout<<A;
    else cout<<B;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
X = list(map(int, input().split()))

time = 100000000000007
for i in range(0, N-K+1):
  if X[i] < 0 and X[i+K-1] > 0:
    if abs(X[i]) >= abs(X[i+K-1]):
      time = min(abs(X[i+K-1]-X[i]) + abs(X[i+K-1]),time)
    else:
      time = min(abs(X[i+K-1]-X[i]) + abs(X[i]),time)
  if X[i] >= 0:
      time = min(abs(X[i+K-1]-X[i]) + abs(X[i]),time)
  if X[i+K-1] <= 0:
      time = min(abs(X[i+K-1]-X[i]) + abs(X[i+K-1]),time)

print(time)

Measured memory_bytes: 62576
#include <stdio.h>

int main()
{
	int P, Q, R;

	scanf("%d %d %d", &P, &Q, &R);

	int a, b, c;

	a = P + Q;
	b = Q + R;
	c = R + P;

	if (a <= b && a <= c) {
		printf("%d", a);
		return 0;
	}
	if (b <= a && b <= c) {
		printf("%d", b);
		return 0;
	}
	if (c <= a && c <= b) {
	       printf("%d", c);
	       return 0;
	}
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

// #define int ll
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << '\n'
#define hyphen() cerr << "--\n"

#define ALL(vec) (vec).begin(), (vec).end()
#define REVALL(vec) (vec).rbegin(), (vec).rend()

#define fst first
#define pb push_back

const int MOD = (int)1e9 + 7;

int head(int n) {
    if (0 <= n && n <= 9) {
        return n;
    }

    return head(n / 10);
}

int tail(int n) {
    return n % 10;
}


int c(int N, int i, int j) {
    int ans = 0;

    FORE(k, 1, N) {
        int hd = head(k);
        int tl = tail(k);

        if (hd == i && tl == j) {
            ans += 1;
        }
    }

    return ans;
}

signed main() {
    int N;

    cin >> N;

    int ans = 0;
    FORE(i, 1, 9) {
        FORE(j, 1, 9) {
            ans += c(N, i, j) * c(N, j, i);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <string>
#include <cstdlib> //絶対値利用のため
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)

//const int INF = INT_MAX / 2;




int main() {
	int a, b, c;
	cin >> a >> b >> c;
	

	cout << a*b/2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int n, x, y, b, p, ans[400], an, a,bb;
	cin >> n;
	an = 0;
	for (int i = 1; i <= n; i++) {
		an = an + 1;
		cin >> x >> y >> b >> p;
		if (b >= 5 && p >= 2) {
			ans[an] = x * b + y * p;
			ans[an] = ans[an] * 0.8;
		}
		else {
			a = x * b + y * p;
			if (b < 5) {
				while (b != 5) {
					b++;
				}
			}
			if (p < 2) {
				while (p != 2) {
					p++;
				}
			}
			bb = x * b + y * p;
			bb = bb * 0.8;
			if (a < bb) {
				ans[an] = a;
			}
			else {
				ans[an] = bb;
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 3060
fn count2(x: usize) -> i32 {
    let mut i = x;
    let mut ret = 0;
    while i % 2 == 0 && i > 0 {
        i /= 2;
        ret += 1;
    }
    ret
}

fn main() {
    let mut fac = vec![0; 1000002];
    for i in 0..(fac.len() - 1) {
        fac[i + 1] = fac[i] + count2(i + 1);
    }
    fn comb_mod2(fac: &Vec<i32>, i: usize, j: usize) -> u8 {
        if fac[i] - fac[j] - fac[i - j] > 0 {
            0
        } else {
            1
        }
    }
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    let mut b = line.trim().as_bytes();
    let mut a = vec![0; b.len()];
    for i in 0..a.len() {
        a[i] = b[i] - 0x31;
    }
    let mut coeff = 1;
    if a.iter().all(|&x| x != 1) {
        for num in &mut a {
            *num /= 2;
        }
        coeff = 2;
    } else {
        for num in &mut a {
            *num %= 2;
        }
    }
    let mut ret = 0;
    for i in 0..a.len() {
        ret = (ret + comb_mod2(&fac, a.len() - 1, i) * a[i]) % 2;
    }
    println!("{}", ret * coeff);
}


Measured memory_bytes: 10492
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val a = sc.nextInt()
  val b = sc.nextInt()

  val x = 1 to 1000
  val y = x.find(i => (i * 0.08).toInt == a && (i * 0.1).toInt == b)

  println(y.getOrElse(-1))
}


Measured memory_bytes: 25680
import sys
sys.setrecursionlimit(10**9)

N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))

stack = [1]
s = {1}

def dfs(a, k):
  global stack
  global s
  if k == 0:
    return a
  next_a = A[a]
  if next_a in s:
    idx = stack.index(next_a)
    n = len(stack)
    k = (k - 1)%(n - idx)
    return stack[idx + k]
  else:
    stack.append(next_a)
    s.add(next_a)
    res = dfs(next_a, k-1)
  return res

print(dfs(1, K))

Measured memory_bytes: 168372
//
//  main.cpp
//  temp
//
//  Created by tolemy on 2019/08/04.
//  Copyright © 2019 tolemy. All rights reserved.
//

#include <iostream>

int main(int argc, const char * argv[]) {
    
    int n = 0;
    std::cin >> n;
    
    int count = 0;
    
    if(n < 10)
    {
        count = n;
    }
    else if(n < 100)
    {
        count = 9;
    }
    else if(n < 1000)
    {
        count = n - 90;
    }
    else if(n < 10000)
    {
        count = 900 + 9;
    }
    else if(n < 100000)
    {
        count = n - 9000 - 90;
    }else
    {
        count = 90909;
    }
    
    std::cout << count;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();

		PriorityQueue<int[]> pq = new PriorityQueue<>(
				(a, b) -> Integer.compare(a[1], b[1]));

		SegmentTree st = new SegmentTree(n);
		int[][] xs = new int[m][3];
		for (int i = 0; i < m; i++) {
			xs[i][0] = sc.nextInt();
			xs[i][1] = sc.nextInt();
			xs[i][2] = sc.nextInt();
		}
		Arrays.sort(xs, (a, b) -> Integer.compare(a[0], b[0]));

		long answer = 0;
		for (int i = 1, p = 0; i <= n; i++) {
			while (p < m && i >= xs[p][0]) {
				st.add(0, xs[p][0], xs[p][2]);
				pq.offer(xs[p++]);
			}

			long v = st.query(0, i);
			st.add(i, i + 1, v);
			answer = Math.max(answer, v);

			while (!pq.isEmpty() && pq.peek()[1] <= i) {
				int[] u = pq.poll();
				st.add(0, u[0], -u[2]);
			}
		}

		System.out.println(answer);
	}

	static class SegmentTree {
		private static final long MIN = -1_000_000_000_000_000L;
		private final int n;
		private long[] data;
		private long[] add;

		public SegmentTree(int n) {
			int t = 1;
			while (t < n) t <<= 1;
			this.n = t;
			this.data = new long[t * 2 - 1];
			this.add = new long[t * 2 - 1];
		}

		// [l, r) の最大値
		public long query(int a, int b) {
			return query(a, b, 0, 0, n);
		}

		private long query(int a, int b, int k, int l, int r) {
			if (b <= l || r <= a) return MIN;
			if (a <= l && r <= b) return data[k];
			long vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
			long vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
			return Math.max(vl, vr) + add[k];
		}

		// [a, b) に v を追加する
		public void add(int a, int b, long v) {
			add(a, b, v, 0, 0, n);
		}

		private void add(int a, int b, long v, int k, int l, int r) {
			if (b <= l || r <= a) return;
			if (a <= l && r <= b) {
				add[k] += v;
				data[k] += v;
				return;
			}

			add(a, b, v, k * 2 + 1, l, (l + r) / 2);
			add(a, b, v, k * 2 + 2, (l + r) / 2, r);
			data[k] = Math.max(data[k * 2 + 1], data[k * 2 + 2]) + add[k];
		}
	}
}


Measured memory_bytes: 172312
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int N;cin>>N;
	cout<<N/3<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  int a[N+1];
  a[0] = -1;
  int boal[N+1];
  vector<int> ans; 
  for (int i = 1; i < N+1; i++) {
    cin >> a[i];
    boal[i] = -1;
  }
  for (int i = N; i >= 1; i--) {
    int cnt = 0;
    for (int j = i * 2; j <= N; j+=i) {
      if (boal[j] == 1) {
        cnt++;
      }
    }
    if (cnt % 2 == a[i]) {
      boal[i] = 0;
    } else {
      boal[i] = 1;
      ans.push_back(i);
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

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

typedef long long ll;
const ll INF = (ll)2e+10;
vector<ll> vs;

ll type1(ll h, ll w) {
	ll x;
	ll ret, val1, val2;

	ret = 0LL;
	if (h % 3 == 0 || w % 3 == 0)
		return ret;

	x = w / 3;
	vs[0] = x * h; vs[1] = ((w - x) / 2 * h);	vs[2] = w * h - vs[0] - vs[1];
	if (vs[0] == 0 || vs[1] == 0 || vs[2] == 0)
		val1 = INF;
	else {
		sort(vs.begin(), vs.end());
		val1 = vs[2] - vs[0];
	}
	x += 1;
	vs[0] = x * h; vs[1] = ((w - x) / 2 * h);	vs[2] = w * h - vs[0] - vs[1];
	if (vs[0] == 0 || vs[1] == 0 || vs[2] == 0)
		val2 = INF;
	else {
		sort(vs.begin(), vs.end());
		val2 = vs[2] - vs[0];
	}
	ret = min(val1, val2);
	return ret;
}

ll calcu(ll h, ll w, ll x) {
	ll ret;

	vs[0] = x * h;	vs[1] = (w - x) * (h / 2);	vs[2] = h * w - vs[0] - vs[1];
	if (vs[0] == 0 || vs[1] == 0 || vs[2] == 0)
		ret = INF;
	else {
		sort(vs.begin(), vs.end());
		ret = vs[2] - vs[0];
	}
	return ret;
}

ll type2(ll h, ll w) {
	ll x, dx, xx;
	ll val, ret;

	x = w / 3;
	dx = (w - x) / h;
	dx += 1;
	ret = INF;
	for (ll i = x - dx; i <= x + dx; ++i) {
		xx = max(0LL, i);
		xx = min(xx, w);
		val = calcu(h, w, xx);
		if (val < ret)
			ret = val;
	}
	return ret;
}

int main(void) {
	ll H, W;
	ll ans, ans1, ans2, val1, val2;

	cin >> H >> W;
	vs.resize(3);

	val1 = type1(H, W);
	val2 = type2(H, W);
	ans1 = min(val1, val2);

	val1 = type1(W, H);
	val2 = type2(W, H);
	ans2 = min(val1, val2);

	ans = min(ans1, ans2);
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]
x_, y_, h_ = sorted(xyh, key=lambda x: x[2], reverse=True)[1]

for cx in range(101):
    for cy in range(101):
        H = h_+abs(x_ - cx) + abs(y_ - cy)
        for x, y, h in xyh:
            if max(H - abs(x-cx)-abs(y-cy), 0) != h:
                break
        else:
            print(cx, cy, H)
            exit()

Measured memory_bytes: 3064
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
N, K = map(int, input().split())
c = 0
ans = 0
for k in range(K, N+2):
    a = k*(k-1)/2
    b = (2*N-k+1)*k/2
    c += (b-a)+1
    # print(c)
print(int(c % 1000000007))


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

inline int gi()
{
	char c = getchar();
	while(c < '0' || c > '9') c = getchar();
	int sum = 0;
	while('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

const int maxn = 405, maxm = 100005;

int n, m;
int x[maxm], y[maxm];
bitset<maxn> dlt[maxn];
bool use[maxn], vis[maxn];

int main()
{
	n = gi(); m = gi();
	for (int i = 1; i <= m; ++i) x[i] = gi(), y[i] = gi();

	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= n; ++j) vis[j] = 0;
		dlt[i][i] = 1;
		for (int j = m; j >= 1; --j) {
			int a = dlt[i][x[j]], b = dlt[i][y[j]];
			if (a && b) {use[i] = 1; break;}
			else if (a) dlt[i][y[j]] = 1;
			else if (b) dlt[i][x[j]] = 1;
		}
	}
		
	int ans = 0;
	for (int i = 1; i <= n; ++i)
		for (int j = i + 1; j <= n; ++j)
			if (!use[i] && !use[j] && !(dlt[i] & dlt[j]).count() && !dlt[i][j]) ++ans;
	printf("%d\n", ans);
	
	return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

ll a, b, c, d;
ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	while (b) {
		ll r = a % b;
		a = b;
		b = r;
	}
	return a;
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll f(ll x) {
	return x / c + x / d - x / lcm(c, d);
}
int main() {
	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
	printf("%lld\n", b - a + 1 - f(b) + f(a - 1));
}

Measured memory_bytes: 128
import java.io.*;

public class Main {
    public static void main(String... args) throws IOException {
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final StringBuilder sb = new StringBuilder();
        final String space = " ";
        while (true) {
            final String[] lines = br.readLine().split(space);
            final int x = Integer.parseInt(lines[0]);
            final int y = Integer.parseInt(lines[1]);
            if (x == 0 && y == 0) break;
            sb.append(x < y ? x + space + y : y + space + x).append("\n");
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 25024
#include <iostream>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i,n){
    cin >> d[i];
  }
  
  sort(d.begin(),d.end());
  int ans = d[n/2]-d[n/2-1];
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

const int N = 2005 * 2005;
const int mod = 1e9 + 7;

int Pow(int x , int y) {
	if(y == 0) return 1;
	if(y == 1) return x;
	int it = Pow(x , y >> 1);
	it = it * 1ll * it % mod;
	if(y & 1) it = it * 1ll * x % mod;
	return it;
}

int inv[N] , fac[N] , n , k , dp[2005][2005];

void predance(int x) {
	fac[0] = inv[0] = 1;
	for(int i = 1;i <= x;i ++) {
		fac[i] = fac[i - 1] * 1ll * i % mod;
		inv[i] = Pow(fac[i] , mod - 2);
	}
}

int C(int x , int y) {
	return fac[x] * 1ll * inv[y] % mod * 1ll * inv[x - y] % mod;
}

int main(void) {
	scanf("%d%d" , &n , &k);
	if(k == 1) {
		puts("1");
		return 0;
	}
	dp[0][0] = 1;
	predance(n * k);
	for(int i = 1;i <= n;i ++) {
		for(int j = 0;j <= i;j ++) {
			dp[i][j] = dp[i - 1][j];
			if(j) {
				dp[i][j] += dp[i][j - 1] * 1ll * C(n * k - (j - 1)* (k - 1) - i - 1 , k - 2) % mod;
				if(dp[i][j] >= mod) dp[i][j] %= mod;
			}
		}
	}
	printf("%d\n" , (int)((dp[n][n] * 1ll * fac[n]) % mod));
	return 0;
}

Measured memory_bytes: 46464
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K, N;
    cin >> K >> N;
    int A[400010];
    rep(i, N) cin >> A[i];
    rep(i, N) A[N + i] = A[0 + i] + K;
    int ans = INF;
    rep(i, N) {
        ans = min(ans, A[N - 1 + i] - A[i]);
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 6744
n = int(input())
a = list(map(int, input().split()))
a2 = []
mi = 0
for i in range(n):
    a2.append(a[i]-i-1)
a3 = sorted(a2)
if n % 2 == 0:
    b = (a3[n//2-1]+a3[n//2])//2
else:
    b = a3[n//2]
s = 0
for i in a3:
    s += abs(i-b)
print(s)

Measured memory_bytes: 25200
#include<iostream>
#include<set>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)

int main() {
  int N;
  int d[110];
  cin >> N;
  REP(i,N) cin >> d[i];
  
  set<int> values;
  REP(i,N) values.insert(d[i]);
  
  cout << values.size() << endl;
}

Measured memory_bytes: 256
li = [0,0,0,0]
for i in range(0,3):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    li[a] += 1
    li[b] += 1
kisuu = 0
for i in li:
    if i % 2 == 1:
        kisuu += 1
if kisuu == 2:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if(c=='a' || c=='i' || c=='e' || c=='o' || c=='u'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
 
using namespace std;
 
#define MAX 100000
 
int main(){
    int n;
    char str[MAX+1];
 
    scanf("%d" ,&n);
    while(n--){
	bool ok = true;
	scanf("%s" ,str);
	int len = (int)strlen(str);
	for(int i = 1 ; i < len ; i++){
	    if(str[i] == str[i-1]){
		ok = false;
		break;
	    }
	}
	printf("%s\n" , ok ? "Yes" : "No");
    }
 
    return 0;
}

Measured memory_bytes: 2644
#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
    #include <atcoder/all>
#endif
using namespace std;
using namespace atcoder;
namespace defines{
    typedef long long ll;
    typedef pair<ll,ll> P;
    #define FOR(i,a,b) for(ll i = a ; i < b ; i++) // for i in range(a,b)
    #define REP(i,n) for(ll i = 0 ; i < n ; i++) // for i in range(b)
    #define FORD(i,a,b) for(ll i = a ; i > b ; i--) // for i in range(a,b,-1)
    #define ALL(x) x.begin(),x.end()
    template<class T> vector<T> make_vec(size_t a){return vector<T>(a);}
    template<class T, class... Ts> auto make_vec(size_t a, Ts... ts){ return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));}

    /* for debug print */
    #define DEBUG(x) cerr << #x << ": " << x << '\n'
    #define DEBUGP(x) cerr << #x << ": (" << x.first << ", " << x.second << ")" << '\n' 
    #define DEBUGL(xl) dbgl_f(#xl,xl)
    #define DEBUGLP(xl) dbglp_f(#xl,xl)
    #define DEBUGLL(xll) dbgll_f(#xll,xll)
    #define DEBUGM(xl) dbgm_f(#xl,xl)
    template<class T> void dbgl_f(string name, vector<T> xl){cerr<<name<<": "; for(T x: xl) cerr<<x<<" "; cerr << '\n';}
    template<class T, class U> void dbgm_f(string name, map<T,U> xl){cerr<<name<<": ";for(auto x: xl)cerr<<"("<<x.first<<": "<<x.second<<") ";cerr<<'\n';}
    template<class T> void dbglp_f(string name, vector<T> xl){cerr<<name<<": ";for(T x: xl)cerr<<"("<<x.first<<", "<< x.second<<") ";cerr<<'\n';}
    template<class T> void dbgll_f(string name, vector<vector<T>> xll){
        cerr<< name << ": " << '\n'; 
        for(vector<T> xl: xll){
            for(T x : xl) cerr << x << " ";
            cerr << '\n';
        }
    }
}
using namespace defines;

const int IINF = 1'001'001'001;
const ll INF = 1'001'001'001'001'001'001ll;
const int MOD = 1'000'000'007;


void solve(){
    int n,q; cin >> n >> q;
    dsu d(n);
    REP(i,q){
        int t,u,v; cin >> t >> u >> v;
        if(t==0){
            d.merge(u,v);
        }
        else{
            if(d.same(u,v)){
                cout << 1 << endl;
            }
            else{
                cout << 0 << endl;
            }
        }
    }
}

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

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

int main(){
  int a[9],n,b[10];
  for(int i=0; i<9; i++){
    cin >> a[i];
  }
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> b[i];
  }

  bool f[9];
  for(int i=0; i<9; i++){
    f[i] = false;
    for(int j=0; j<n; j++){
      if (a[i] == b[j]){
        f[i] = true;
        break;
      }
    }
  }
  if((f[0] && f[4] && f[8]) || (f[2] && f[4] && f[6]) || (f[0] && f[1] && f[2]) || (f[3] && f[4] && f[5]) || (f[6] && f[7] && f[8]) || (f[0] && f[3] && f[6]) || (f[1] && f[4] && f[7]) || (f[2] && f[5] && f[8])){
    cout << "Yes";
  } else {
    cout << "No";
  }

  return 0;
}

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

const int N = 1e6 + 100;

int main() {
    // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    string s;
    cin >> s;
    int n = s.size() + 1;
    vector<int> L(n), R(n);
    for(int i = 1; i < n; i++) {
        if(s[i-1] == '<') L[i] = 1 + L[i-1];
        else L[i] = 0;
    }
    for(int i = n-2; i >= 0; i--) {
        if(s[i] == '>') R[i] = 1 + R[i+1];
        else R[i] = 0;
    }
    long long ans = 0;
    for(int i = 0; i < n; i++) {
        ans += max(L[i], R[i]);
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 4764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string S;cin >> S;
  char pre = ' ';
  bool check = false;
  rep(i,4){
    if(pre == S[i])check =  true;
    pre = S[i];
  }
  if(check) cout << "Bad" << endl;
  else cout << "Good" << endl;
  return 0;
}


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

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

    int n;
    cin >> n;
    
    int lim = 55556;

    vector<bool> A(lim, true);
    A[0] = false;
    A[1] = false;
    
    for(int i = 2; i <= (int)(sqrt(lim)); i++){
        if(A[i]){
            for(int j = i * 2; j < lim; j += i){
                A[j] = false;
            }
        }
    }

    vector<int> B(n);
    int n_i = 0;
    for(int i = 2; i < lim; i++){
        if(A[i]){
            if(i % 5 == 1){
                B[n_i] = i;
                n_i++;
                if(n_i > n) break;
            }
        }
    }

    for(int i = 0; i < n; i++){
        if(i > 0) cout << " " << B[i]; 
        else cout << B[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<algorithm>
#include<iostream>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
int main(){
    int N,M,ans=0,A=1,B=0,C=0,D,j;
    cin>>N>>M;
    rep(i,N-1){
        A*=10;
    }
    D=A;
    if(M==0&&N!=1){
        ans=A;
        }
    else if(M==0&&N==1){
        ans=0;
    }
    else{
        int s[M],c[M];
        rep(i,M){
            j=i;
            cin>>s[i]>>c[i];
            if(s[i]==1&&c[i]==0&&N!=1){
                ans=-1;
                break;
            }
            while(j>0){
                j--;
                if(s[i]==s[j]&&c[i]!=c[j]){
                    ans=-1;
                    break;
                }
            }
            if(s[i]==1){
                D=c[i]*A;
            }
            if(s[i]==2){
                B=c[i]*(A/10);
            }
            if(s[i]==3){
                C=c[i]*(A/100);
            }
         }
        if(ans!=-1){
            ans=D+B+C;
        }
     }
    cout<<ans<<endl;
    }

    


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace AtCoder.ABC
{
    class QuestionA
    {
        public static void Main(string[] args)
        {
            var abx = Console.ReadLine().Split(" ").Select(x => long.Parse(x)).ToArray();
            var a = abx[0];
            var b = abx[1];
            var x = abx[2];

            var aa = Math.Max((a - 1), 0) / x;
            var bb = b / x;

            if(a == 0) {
                bb++;
            }

            Console.WriteLine(bb - aa);
        }
    }
}



Measured memory_bytes: 28072
#include<bits/stdc++.h>
using namespace std;
#define    for0(i,n) for(int i=0;i<n;i++)
#define    fors(i,s) for(int i=0;i<s.size();i++)
#define    nl     "\n"
#define    End    return 0
#define    gt     greater<int>()
#define    ll     long long int

int main()
{
    ll n,p=100,c=0;
    cin>>n;
    while(p<n)
    {
        p+=(p/100);
        c++;
    }
    cout<<c;
}


Measured memory_bytes: 3540
package main

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

func exec(stdin *Stdin, stdout *Stdout) {
	n := stdin.ReadInt()
	p := stdin.ReadInt()
	s := stdin.Read()

	if p == 2 || p == 5 {
		sum := 0
		for i := 0; i < n; i++ {
			if int(s[i]-'0')%p == 0 {
				sum += i + 1
			}
		}
		stdout.Println(sum)
		return
	}

	t := make([]int, n)
	for i := 0; i < n; i++ {
		t[n-i-1] = int(s[i] - '0')
	}

	d := make([]int, p)
	d[0] = 1
	mod := 0
	fct := 1
	sum := 0
	for i := 0; i < n; i++ {
		mod = (mod + t[i]*fct) % p
		sum += d[mod]
		d[mod]++
		fct = (fct * 10) % p
	}

	stdout.Println(sum)
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), int(math.MaxInt32))
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
typedef long long ll;
using namespace std;
int main()
{
    ll n, x, a[101], ans = 0;
    cin >> n >> x;
    REP(i, n) cin >> a[i];
    sort(a, a + n);
    REP(i, n)
    {
        x -= a[i];
        if (x >= 0) ans++;
        else break;
    }
    if (x > 0)
        ans--;
    cout << ans << endl;
}

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

void draw(int H, int W) {
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cout << "#";
        }
        cout << endl;
    }
    cout << endl;
}

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

    int H, W;
    while (true) {
        cin >> H >> W;
        if (H == 0 && W == 0) {
            break;
        } else {
            draw(H, W);
        }
    }
}


Measured memory_bytes: 3136
/**
 *  author: nayakashutosh9
 *	[2020-09-19 17:25]
**/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define endl '\n'
#define mod 1000000007
#define modd 998244353
#define inf 1e18
#define ff first
#define ss second
#define pb push_back
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update> pbds;
const int N = 300005;
/*******************************************************/


void solve() {
	string s; cin >> s;
	if (s[s.length() - 1] == 's') s += "es";
	else s += 's';
	cout << s << endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int T = 1;
	// cin >> T; cin.ignore();
	for (int i = 1; i <= T; i++) {
		// cout << "Case #" << i << ": ";
		// clock_t start = clock();
		solve();
		// clock_t end = clock();
		// cout << (end-start) << endl;
		//print execution time in ms
	}

	return 0;
}

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

int main() {
  int n,w;
  while(cin >> n >> w && n) {
    int m=100/w+1;
    int a[m];
    memset(a,0,sizeof(a));
    int ma=0;
    for(int i=0; i<n; i++) {
      int x;
      cin >> x;
      a[x/w]++;
      ma=max(ma,a[x/w]);
    }

    int k;
    for(k=m-1; k>=0; k--) {
      if(a[k]) break;
    }
    k++;

    double ans=0;
    for(int i=0; i<k; i++) {
      ans+=((double)a[i]/ma)*((double)(k-1-i)/(double)(k-1));
    }
    printf("%.10f\n",ans+0.01);
  }
  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e9

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

string s;
int n, cur, ans1;


int main()
{
    cin >> n >> s;
    for(int i = 0; i<n; i++){
		if(s[i]=='('){
			cur++;
		}
		else{
			cur--;
		}
		if(cur<0){
			cur=0;
			ans1++;
		}
	}
	while(ans1){
		s="("+s;
		ans1--;
	}
	while(cur){
		s+=")";
		cur--;
	}
	cout << s;
	
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <tuple>
#define INF 1000000009
#define LINF 1000000000000000009
#define double long double
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
//ll mod = 1000000007;
//ll mod = 998244353;

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


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include<limits.h>
#include<algorithm>
#include<queue>
#include<set>


#define MOD 1000000007

using namespace std;

long long int modpow(long long int a, long long int n) {
	if (n == 0)return 1;
	if (n == 1)return (a % MOD);

	long long int hanbun = n / 2;
	long long int amari = n % 2;

	long long int ans = (a * a) % MOD;
	ans = modpow(ans, hanbun);

	if (amari == 1)ans *= a;

	ans %= MOD;

	return ans;

}

long long int gcd(long long int a, long long int b) {
	if (a < b) {
		long long int tmp = a;
		a = b;
		b = tmp;
	}

	long long int amari = a % b;

	if (amari == 0)return b;

	return gcd(b, amari);
}

long long int lcm(long long int a, long long int b) {
	long long int ans = (a * b) % MOD;
	long long int wari = modpow(gcd(a, b), MOD - 2);
	ans = (ans * wari) % MOD;
	return ans;
}

long long int factElement[10000] = { 0 };

long long int factrial(int n) {

	if (factElement[n] != 0)return factElement[n];

	if (n == 0) {
		factElement[0] = 1;
		return factElement[n];
	}

	long long int ans = n * factrial(n - 1);
	factElement[n] = ans;
	return factElement[n];

}


int main()
{

	int n, a, b;
 	cin >> n >> a >> b;



	
	
	long long int ans = 0;

	ans = modpow(2, n);
	ans -= 1;



	long long int wk,invwk;
	wk = 1;
	invwk = 1;
	for (int i = 0; i < a; i++) {
		wk *= (n - i);
		wk %= MOD;

		invwk *= i + 1;
		invwk %= MOD;
	}
	wk *= modpow(invwk, MOD - 2);
	wk %= MOD;



	ans -= wk;
	ans %= MOD;


	wk = 1;
	invwk = 1;
	for (int i = 0; i < b; i++) {
		wk *= (n - i);
		wk %= MOD;

		invwk *= i + 1;
		invwk %= MOD;
	}
	wk *= modpow(invwk, MOD - 2);
	wk %= MOD;



	ans -= wk;
	ans %= MOD;



	while (ans < 0)ans += MOD;

	

	
	cout << ans << endl;

	

	return 0;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pb push_back
const double PI = acos(-1.0);
using namespace std;

int main()
{
    faster
    int r,g,b,k;

    cin>>r>>g>>b>>k;

    while(g<=r)
    {
        if(k==0)
        {
            cout<<"No"<<endl;
            return 0;
        }

        g=g*2;
        k--;
    }

    while(b<=g)
    {
        if(k==0)
        {
            cout<<"No"<<endl;
            return 0;
        }

        b=b*2;
        k--;
    }

    cout<<"Yes"<<endl;




    return 0;
}


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

int n, a, b;
vector<int> e[100004];
int coloring[100004];
int main() {
	cin>>n;
	for(int i = 0 ; i<n-1;i++){
		cin>>a>>b;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	memset(coloring,-1,sizeof(coloring));
	queue<int> q;
	int b = 1, w = 1;
	coloring[1] = 0;
	coloring[n] = 1;
	q.push(1);
	q.push(n);
	while(!q.empty()){
		int here = q.front();
		q.pop();
		for(int there : e[here]){
			if(coloring[there] == -1){
				q.push(there);
				coloring[there] = coloring[here];
				if(coloring[here] == 0)	b++;
				else w++;
			}
		}
	}
	if(b>w)	cout<<"Fennec";
	else	cout<<"Snuke";
	return 0;
}

Measured memory_bytes: 6400
fun main(args: Array<String>) = IO().exec {
    val m = int()
    val d = int()
    var cnt = 0
    for (i in 1..m) {
        for (j in 1..d) {
            val d1 = j % 10
            val d10 = j / 10 % 10
            if (d1 >= 2 && d10 >= 2 && d1 * d10 == i) cnt++
        }
    }
    println(cnt)
}

// region template
operator fun Int.iterator() = 0.until(this).iterator()

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = java.io.PrintWriter(System.out)
    fun hasNextByte(): Boolean = if (ptr < buflen) true else {
        ptr = 0
        buflen = System.`in`.read(buffer)
        buflen > 0
    }

    fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }

    fun string(): String {
        if (!hasNext()) throw java.util.NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun long(): Long {
        if (!hasNext()) throw java.util.NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }

    fun double(): Double = string().toDouble()
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}
// endregion

Measured memory_bytes: 31256
S = input()
key = 'keyence'
for i in range(len(key) + 1):
  pre = key[:i]
  post = key[i:]
  p = len(S) - len(key) + i
  if S[:i] == pre and S[p:] == post:
    print('YES')
    break
else:
  print('NO')

Measured memory_bytes: 3060
#include <stdio.h>
#include <algorithm>

int main() {
	int a[100];
	int n, s, i, j, sum;

	scanf("%d",&n);

	while(true) {
		sum = 0;
		if(n == 0)break;
		for(i = 0; i < 100; i++) {
			a[i] = 1000;
		}	
		for(i = 0; i < n; i++) {
			scanf("%d",&s);
			a[i] = s;
		}
		std::sort(a,a+100);
		for(j = 1; j < n-1; j++) {
			sum = sum + a[j];
		}
		printf("%d\n",sum/(n-2));
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 1044
#include <stdio.h>

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

int main(){
    int a,b,c,d,ans;

    scanf("%d %d %d %d",&a,&b,&c,&d);

    if(a<c){
        if(b<d){
            ans=MAX(b-c,0);
        }else{
            ans=d-c;
        }
    }else{
        if(b<d){
            ans=b-a;
        }else{
            ans=MAX(d-a,0);
        }
    }
    printf("%d\n",ans);
    return 0;
}


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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#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 DCIN(...)                                                              \
    double __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"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = atan(1.0) * 4.0;
// const int MOD = 998244353;
const ll LINF = 9e18;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};

vector<PL> ab;

signed main() {
    LCIN(N, M);
    REP(i, N) {
        LCIN(A, B);
        ab.emplace_back(A, B);
    }
    sort(All(ab));
    PQ<ll> pq;
    ll ans = 0, cnt = 1, idx = 0;
    while(cnt <= M) {
        while(ab[idx].fi == cnt) {
            pq.emplace(ab[idx++].se);
        }
        if(!pq.empty()) {
            ans += pq.top();
            pq.pop();
        }
        cnt++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3568
X = int(input())
lst = [1]
for i in range(2, 32):
    for j in range(2, 10):
        x = i ** j
        if x <= 1000:
            lst.append(x)
if X in lst:
    print(X)
else:
    lst.append(X)
    lst2 = sorted(lst)
    n = lst2.index(X)
    print(lst2[n-1])

Measured memory_bytes: 9088