akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
#define x first
#define y second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
 
const ll MOD = 1e9+7;
const ll INF = 1e9+5;
 
vector <int> v;

int main() {
	int a, b, c, d, n, m;
	string s, t, r;
	cin >> n >> m;
	for (int i=0 ; i<n ; i++) {
		int x;
		cin >>x;
		v.pb(x);
	}
	ll sum = 0;
	sort(v.begin(), v.end());
	for (int i=0 ; i<n-m ; i++) {
		sum += v[i];
	}
	cout <<sum<<endl;
	return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll a, b, c;
  cin >> a >> b >> c;
  cout << (a^b^c) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <map>
#include <ctime>
#include <cstdlib>
#include <random>
#include <unistd.h>
using namespace std;

#define int long long

signed main(){
	int n;
	cin >> n;
	n = n % 1000;
	if(n == 0)cout << 0 << endl;
	else cout << 1000 - n << endl;
	return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
const int INF = 1 << 20;

typedef long long ll;




int main(){
  int h,w,d;
  cin >> h >> w >> d;
  int a;
  P b[h*w+1];
  REP(i,h){
    REP(j,w){
      scanf("%d",&a);
      b[a].first = i;
      b[a].second = j;
    }
  }
  int q;
  cin >> q;
  int res[90001] = {};
  for(int i = d+1;i <= h*w;i++){
    res[i] = res[i-d]+abs(b[i].first-b[i-d].first)+abs(b[i].second-b[i-d].second);
  }
  REP(i,q){
    int l,r;
    scanf("%d %d",&l, &r);
    //cin >> l >> r;
    
    int sum = res[r]-res[l];
    
    printf("%d\n",sum);
  }
  return 0;
}


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

using namespace std;
using ll = long long;

signed main(){
	string s;
	cin >> s;
	int num;
	int ans = 1000;
	for(int i = 0; i < s.size()-2; i++){
		num = (s[i]-'0') * 100 + (s[i+1]-'0') * 10 + s[i+2] -'0'; 
		ans = min(ans,abs(num - 753));
	}	
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 256
# 5
# 1 2 1 1 3
_ = gets.split.map(&:to_i).first
hs = gets.split.map(&:to_i)

height = hs.first
result = true
hs.each do |h|
  if height > h
    result = false
    break
  end
  next if height == h
  height = h - 1
end

puts result ? 'Yes' : 'No'


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

int main(){
	int n, m, c, sum=0, s=0;
	cin >> n >> m >> c;
	int a[m+1], b[n+1][m+1];
	for(int i=1; i<=m; i++)cin >> a[i];
	for(int i=1; i<=n; i++){
		sum=0;
		for(int j=1; j<=m; j++){
			cin >> b[i][j];
			sum+=b[i][j]*a[j];
		}
		sum+=c;
		if(sum>0)s++;
	}
	cout<<s<<endl;
	return 0;
}

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

const int N=1e5+5;
int red[N],green[N],clrs[N];
int x,y,a,b,c;
long long cnt=0;
vector<int> temp;

signed main()
{
	scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);
	for(register int i=1;i<=a;i++)
		scanf("%d",red+i);
	for(register int i=1;i<=b;i++)
		scanf("%d",green+i);
	for(register int i=1;i<=c;i++)
		scanf("%d",clrs+i);
	
	sort(red+1,red+1+a,greater<int>());
	sort(green+1,green+1+b,greater<int>());
	sort(clrs+1,clrs+1+c,greater<int>());
	
	for(register int i=1;i<=x;i++)
		cnt+=red[i],temp.push_back(red[i]);
	for(register int i=1;i<=y;i++)
		cnt+=green[i],temp.push_back(green[i]);
	
	sort(temp.begin(),temp.end());
	
	int i=1;
	for(vector<int>::iterator it=temp.begin();it!=temp.end();it++)
	{
		if(i>c) break;
		if(clrs[i]<=*it) break;
		cnt+=clrs[i]-*it;
		++i;
	}
	
	printf("%lld\n",cnt);
	return 0;
}

Measured memory_bytes: 2552
import sys
import collections

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    C = collections.Counter(A)

    B = []
    for k in C.keys():
        if C[k] >= 2:
            B.append(k)

    if len(B) == 0:
        print("0")
        return
    elif len(B) == 1:
        B.sort(reverse=True)
        if C[B[0]] <= 3:
            print("0")
        else:
            print(B[0] * B[0])
        return
    else:
        B.sort(reverse=True)
        if C[B[0]] <= 3:
            print(B[0] * B[1])
        else:
            print(B[0] * B[0])

        return






    
    

if __name__ == '__main__':
    main()



Measured memory_bytes: 18728
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
using namespace std;

pii x[3001][3001];
int d[3001][3001];

int main(){
	string s;cin>>s;
	string t;cin>>t;
	int n=s.size();
	int m=t.size();
	char a[n+1],b[m+1];
	for(int i=0;i<n;i++)a[i+1]=s[i];
	for(int i=0;i<m;i++)b[i+1]=t[i];
	

	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(a[i]==b[j]){
				d[i][j]=d[i-1][j-1]+1;
				x[i][j]={i,j};
			}
			else{
				if(d[i][j-1]>d[i-1][j])x[i][j]=x[i][j-1],d[i][j]=d[i][j-1];
				else x[i][j]=x[i-1][j],d[i][j]=d[i-1][j];
			}
		}
	}
	
//   for(int i=0;i<=n;i++){
//   	for(int j=0;j<=m;j++){
//   		cout<<'('<<x[i][j].f<<';'<<x[i][j].s<<')'<<' ';
//	   }
//	   cout<<endl;
//   }
//	
	pii o=x[n][m];
	string ans="";
	while(o.f!=0){
		ans+=a[o.f];
		o=x[o.f-1][o.s-1];
	}
	reverse(ans.begin(),ans.end());
	cout<<ans;
}

Measured memory_bytes: 105856
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
    ll x;
    cin >> x;
    if(x == 0)cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int f(int x, int y, int r, int c){
	if (y == 0) return x;
	if (x == r) return r + y;
	if (y == c) return r + c + (r - x);
	if (x == 0) return r + c + r + (c - y);
	return -1;
}

int main() {
	int r, c, n;
	cin >> r >> c >> n;
	VI x1, y1, x2, y2;
	REP(i,n){
		int xa, ya, xb, yb;
		scanf("%d %d %d %d", &xa, &ya, &xb, &yb);
		if ((xa == 0 || xa == r || ya == 0 || ya == c) && (xb == 0 || xb == r || yb == 0 || yb == c)){
			if (xa > xb){
				swap(xa,xb);
				swap(ya,yb);
				if (xa == xb && ya > yb) swap(ya, yb);
			}
			x1.push_back(xa);
			y1.push_back(ya);
			x2.push_back(xb);
			y2.push_back(yb);
		}
	}

	n = x1.size();
	if (n == 0){
		cout << "YES" << endl;
		return 0;
	}

	vector<P> e;
	REP(i,n){
		e.push_back(P(f(x1[i], y1[i], r, c), i));
		e.push_back(P(f(x2[i], y2[i], r, c), i));
	}

	sort(ALL(e));

	VI st;
	for (auto p : e){
		if (!st.empty() && st.back() == p.second) st.pop_back();
		else st.push_back(p.second);
	}

	cout << (st.empty() ? "YES" : "NO") << endl;


    return 0;
}

Measured memory_bytes: 4316
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 3; i++) {
            int t = -sc.nextInt() * 3600 - sc.nextInt() * 60 - sc.nextInt() + sc.nextInt() * 3600 + sc.nextInt() * 60 + sc.nextInt();
            System.out.println(t / 3600 + " " + t % 3600 / 60 + " " + t % 3600 % 60);
        }
    }
}


Measured memory_bytes: 26160
N, Y = [int(elem) for elem in input().split(' ')]

if Y > 10000 * N:
    print(-1, -1, -1)
    exit(0)

for num_yukichi in range(N+1):
    for num_ichiyou in range(N - num_yukichi + 1):
        num_souseki = N - num_yukichi - num_ichiyou
        sum = 10000 * num_yukichi + 5000 * num_ichiyou + 1000 * num_souseki
        if sum == Y:
            print(num_yukichi, num_ichiyou, num_souseki)
            exit(0)
else:
    print(-1, -1, -1)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <climits>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
	int x, n;
	cin >> x >> n;
	int p[n + 1];
	for (int i = 1; i <= n; ++i) cin >> p[i];
	sort(p + 1, p + n + 1);
	int minx = INT_MAX;
	for (int i = -200; i <= 200; ++i) {
		if (!binary_search(p + 1, p + n + 1, i)) {
			minx = min(minx, abs(x - i));
		};
	} 
	int res1 = x - minx;
	int res2 = x + minx;
	if (!binary_search(p + 1, p + n + 1, res1)) cout << res1 << '\n';
	else cout << res2 << '\n';
	
	return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<climits>
#include<map>
#define ll long long
using namespace std;
int main() {
	string s;
	cin >> s;
	ll count = 0;
	for (ll i = s.size()-3; i >= 0; i-=2) {
		count = 0;
		for (ll j = 0; j <= i/2; j++) {
				if (s[j] == s[i/2+1+j]) {
					count++;
					if (count == i / 2 + 1) {
						cout << i + 1 << endl;
						exit(0);
					}
					
				}
				
			}

		}
	}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N, a, b, c, A[2], B[2], C[2];

int main() {
	cin >> N;
	for (int i = 0; i != N; ++i) {
		cin >> a >> b >> c;
		A[i & 1] = max(B[(i - 1) & 1], C[(i - 1) & 1]) + a;
		B[i & 1] = max(C[(i - 1) & 1], A[(i - 1) & 1]) + b;
		C[i & 1] = max(A[(i - 1) & 1], B[(i - 1) & 1]) + c;
	}
	cout << max({ A[(N - 1) & 1],B[(N - 1) & 1],C[(N - 1) & 1] }) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#define ll long long
using namespace std;
int main()
{
     int i,j,k,n,m;
     int s=0;
     scanf("%d%d",&n,&m);
     for(i=0;i<n;i++)
     {
          scanf("%d",&k);
          int x=abs(0-k);
          int y=abs(m-k);
          if(x<y)
               s+=x*2;
          else
               s+=y*2;
     }
     printf("%d\n",s);
	return 0;
}


Measured memory_bytes: 256
n=int(input())
import math
a=[0]*3
sum=0
for i in range(n):
  for j in range(n):
    for k in range(n):
      a[0]=i+1
      a[1]=j+1
      a[2]=k+1
      ans=a[2]
      for l in range(2):
        ans = math.gcd(ans, a[l])
      sum+=ans
print(int(sum))
  


Measured memory_bytes: 68328
n = int(input())
x_l = []
for i in range(n):
    x,l = map(int,input().split())
    x_l.append([x-l,x+l])
x_l = sorted(x_l, key=lambda x:x[0])
x_r = sorted(x_l, key=lambda x:x[1])
ans_l = n
ans_r = n
for i in range(n-1):
    if x_l[i][1] > x_l[i+1][0]:
        ans_l -= 1
        x_l[i+1] = x_l[i]
    if x_r[i][1] > x_r[i+1][0]:
        ans_r -= 1
        x_r[i+1] = x_r[i]
print(max(ans_l, ans_r))


Measured memory_bytes: 22156
import sys
input = sys.stdin.readline

N,K=map(int,input().split())
S=input().strip()
cnt1=0
for i in range(1,N):
    if S[i]!=S[i-1]:
        cnt1+=1
num=[]
cnt=0
for i in range(1,N):
    if S[i]==S[i-1]:
        cnt+=1
    else:
        num.append(cnt)
        cnt=0
#print(num,cnt)
num.append(cnt)
if cnt1>=2*K:
    ans=sum(num)+2*K
    print(ans)
else:
    print(N-1)

"""

print(num)
if len(num)<=2*K+1:
    ans=sum(num)
else:
    cost=sum(num[:2*K+1])
    ans=cost
    for i in range(len(num)-(2*K+1)):
        cost+=num[2*K+1+i]-num[i]
        ans=max(ans,cost)
print(ans-1)"""


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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  int p = -a + b;
  if (p <= 0) cout << "delicious" << endl;
  else if (p <= x) cout << "safe" << endl;
  else cout << "dangerous" << endl;
  return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,x;
  cin>>n>>x;
  if(x==1 || x==2*n-1) cout<<"No"<<endl;
  else{
    int a[200000]={0};
    rep(i,200000){
      a[i]=i+1;
    }
    if(n>2){
      if(x==2){
	swap(a[n-1],a[1]);
	swap(a[n],a[0]);
      }else{
	bool flag[200001]={false};
	a[n-2]=x-2;
	a[n-1]=x;
	a[n]=x+1;
	a[n+1]=x-1;
	flag[n-2]=flag[n-1]=flag[n]=flag[n+1]=true;
	int now=0,nex=1;
	while(now<n*2-1){
	  if(nex>=x-2 && nex<=x+1) nex++;
	  else if(flag[now]) now++;
	  else if(!flag[now]){
	    a[now]=nex;
	    now++;
	    nex++;
	  }
	}
      }
    }
    cout<<"Yes"<<endl;
    rep(i,n*2-1){
      cout<<a[i]<<endl;
    }
  }
  return 0;
}


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

int main() {
	double N,T,A;
  cin>>N>>T>>A;
  vector<double> vec(N);
  
  
  for(int i=0;i<N;i++){
  	cin >> vec.at(i);
  }
  
  double ans=10000;
  int B=0;
  for(int i=0;i<N;i++){
  	if(ans>abs(A-T+vec.at(i)*0.006)){
    	ans = abs(A-T+vec.at(i)*0.006);
       
      B =i+1;
    }
  }
  
  cout<<B<<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++)
#define all(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;

int main(){
    int N, Y;
    cin >> N >> Y;
    for (int x = 0; x <= N; x++) {
        for (int y = 0; y <= N-x; y++) {
            int z = N - x - y;
            int sum = 10000*x + 5000*y + 1000*z;
            if (sum == Y) {
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

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

int main() {
	string str;
	cin >> str;
	for (unsigned int i = 0; i+1 < str.length(); i++) {
		if (str[i] == str[i + 1]) {
			cout << i+1 << " " << i+2 << endl;
			return 0;
		}
		if (i + 2 < str.length()) {
			if (str[i] == str[i + 2]) {
				cout << i+1 << " " << i+3 << endl;
				return 0;
			} else if (str[i + 1] == str[i + 2]) {
				cout << i+2 << " " << i+3 << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1" << endl;
	return 0;
}

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

int main(){
    int c, n;
    cin >> n;
    long double b = 0;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    b = a[0];
    rep(i,n-1){
        b = (long double)((a[i+1]+b)/2);
    }
    cout <<setprecision(10) << b << endl;
    return 0;
}

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

using namespace std;

int main(){

    int n, k;
    cin >> n >> k;

    vector<int> nums(n);

    for (int i = 0; i < n; i++){
        cin >> nums[i];
    }

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

    int mn = 1e9;

    for (int i = 0; i < n - k + 1; i++){
        mn = min(mn, nums[i + k - 1] - nums[i]);
    }

    cout << mn << endl;
    
    return 0;
}


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

using namespace std;

int main()
{
    int N, count = 0, tmp, max = 0;
    cin >> N;
    while(N--)
    {
        cin >> tmp;
        if(tmp >= max)
        {
            max = tmp;
            count++;
        }
    }
    cout << count;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

int main()
{
	ll n;
	cin>>n;
	vector<string> s(n,"");

	ll sum = 0;
	ll a = 0;
	ll b = 0;
	bool same = true;

	REP(i,n)
	{
		cin>>s[i];
		REP( j, s[i].size() - 1 )
		{
			if( s[i][j] == 'A' )
			if( s[i][j+1] == 'B' ) ++sum;
		}
		if( s[i][0] == 'B' ) ++b;
		if( s[i][s[i].size()-1] == 'A' ) ++a;
		if( same && ( s[i][0] == 'B' ^ s[i][s[i].size()-1] == 'A' ) )
			same = false;
	}
	
	if( a != 0 && a == b && same ) --sum;
	sum += min( a, b );
	
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 768
// ------------------------------------
// Date:2018/ 3/31
// Problem:1 d reversi g.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  SCIN(s);
  int ans = 0;
  REP(i, s.size() - 1)
    if (s[i] != s[i + 1]) ans++;

  cout << ans << endl;
  

  return 0;
}



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

// a^n mod を計算する
ll powmod(ll a, ll n, ll mod) {
	ll ret = 1;
	while (n > 0) {
		if (n % 2 == 1) { ret = ret * a % mod; }
		a = a * a % mod;
		n /= 2;
	}
	return ret;
}

ll combination(ll n, ll r)
{
	// n < 1e9 より、オーバーフローはしない

	ll x = 1, y = 1;

	// 分子
	for(ll i = 0; i < r; ++i)
	{
		x = x * (n - i) % MOD;
	}

	// 分母
	for(ll i = 1; i <= r; ++i)
	{
		y = y * i % MOD;
	}

	return x * powmod(y, MOD-2, MOD) % MOD;
}

void solve()
{
	ll n, a , b;
	cin >> n >> a >> b;

	a = min(a, n - a);
	b = min(b, n - b);

	// 2^n - nCa ^- nCb
	cout << (powmod(2, n, MOD) + MOD - combination(n, a) + MOD - combination(n, b) + MOD - 1) % MOD;

}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
ll n;
ll a[1000005];
bool y[1000005];
bool x=false;
bool X=false;
ll gcd(ll a,ll b){
    if(b%a==0) return a;
    else return gcd(b%a,a);
}
ll p[100000];
ll pp=0;
map<ll,ll> prime_factor(ll n){
    map<ll,ll> res;
    for(ll i=2;i*i<=n;i++){
        bool w=true;
        while(n%i==0){
            res[i]++;
            n=n/i;
            if(w){
                w=false;
                p[pp]=i;
                pp++;
            }
        }
    }
    if(n!=1){
        res[n]=1;
        p[pp]=n;
        pp++;
    }
    return res;
}
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    int I=0;
    while(a[I]==1){
        I++;
    }
    if(I==n){
        cout<<"pairwise coprime"<<endl;
        return 0;
    }
    if((n-I)<80000){
        for(int i=I;i<n;i++){
            pp=0;
            map<ll,ll> k=prime_factor(a[i]);
            for(int j=0;j<pp;j++){
                if(y[p[j]]){
                    X=true;
                    break;
                }else{
                    y[p[j]]=true;
                }
            }
            if(X){
                break;
            }
        }
        if(X){
            
        }else{
            cout<<"pairwise coprime"<<endl;
            return 0;
        }
    }
    ll g=a[0];
    for(int i=1;i<n;i++){
        g=gcd(g,a[i]);
    }
    if(g==1){
        cout<<"setwise coprime"<<endl;
    }else{
        cout<<"not coprime"<<endl;
    }
    
}


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

int main(){
	int j,n,v,a[105];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(j=0;j<n-1;j++)
		cout<<a[j]<<" ";
	cout<<a[n-1]<<endl;
	for(int i=1;i<n;i++){
		v=a[i];
		j=i-1;
		while(j>=0&&a[j]>v){
			a[j+1]=a[j];
			j--;	
		}
		a[j+1]=v;
		for(j=0;j<n-1;j++)
			cout<<a[j]<<" ";
		cout<<a[n-1]<<endl;
	}
	return 0;
}



Measured memory_bytes: 3096
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	int n, k;
	cin >> n;
	string s;
	cin >> s;
	cin >> k;
	REP(i, s.length()) {
		if (s[i] != s[k - 1]) {
			cout << "*";
		}
		else {
			cout << s[i];
		}
	}
	cout << endl;
}


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

robo = []
for _ in range(N):
    X, L = map(int, input().split())
    robo.append([X-L, X+L])

robo = sorted(robo, key=lambda x:x[1])

last = robo[0][1]
cnt = 1
for r in robo[1:]:
    if r[0] >= last:
        cnt += 1
        last = r[1]

print(cnt)

Measured memory_bytes: 26308
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		String S = sc.get();
		var chars = S.toCharArray();
		int leftmostW = 0;
		int rightmostR = chars.length - 1;
		int count = 0;
		outer:
		for (; leftmostW < chars.length; leftmostW++) {
			if (chars[leftmostW] != 'W') continue;
			while (chars[rightmostR] != 'R') {
				if (rightmostR-- <= leftmostW) break outer;
			}
			if (rightmostR <= leftmostW) break;
			chars[leftmostW] = 'R';
			chars[rightmostR] = 'W';
			count++;
		}
		System.out.println(count);
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		new Solver().solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

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

#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define NP next_permutation
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;

const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;

template<class T> bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T> void decimal(T a){cout<<fixed<<setprecision(a);}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

void YesNo(bool a){if(a) out("Yes"); else out("No");}
void yesno(bool a){if(a) out("yes"); else out("no");}
void YESNO(bool a){if(a) out("YES"); else out("NO");}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){ll c=1; while(b>0){if(b&1){c=a*c %mod;}a=a*a %mod;b>>=1;}return c;}
vi calc(ll x){vi res; while(x>0){res.eb(x%10);x/=10;}reverse(all(res)); return res;}

void solve() {
  ll n,k;
  cin>>n>>k;
  if(n==k) out(0);
  else if(n<k) out(min(n,k-n));
  else out(min(n%k,k-n%k));
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define REP(k, n) for (ll k = 0; k < (ll)(n); ++k)
#define REPREV(k, n) for (ll k = (ll)(n)-1; k >= 0; --k)
#define FOR(k, a, b) for (ll k = (ll)(a); k < (ll)(b); ++k)
#define FORREV(k, a, b) for (ll k = (ll)(b)-1; k >= (ll)(a); --k)
#define FOREACH(e, v) for (auto& e : v)

#define TGET(t, i) get<i>(t)
#define TSET(t, i, a) get<i>(t) = a
// MinHeap - priority_queue<ll, vll, greater<ll>> pq;

#define EVEN(n) ((n)&1) == 0
#define ODD(n) ((n)&1) == 1

#define SORT(v) sort(v.begin(), v.end())
#define SORTREV(v) sort(v.rbegin(), v.rend())
#define SHUFFLE(v) random_shuffle(v.begin(), v.end())
//srand(unsigned(time(0)));

#define REMOVEAT(v, i) v.erase(v.begin() + i)
#define REVERSE(v) reverse(v.begin(), v.end())

ostream& operator<<(ostream& str, const pll& p) {
    str << p.first << " " << p.second;
    return str;
}

template <typename T>
void join(T& arr, string sep) {
    bool first = true;
    for (auto t : arr) {
        if (first) {
            first = false;
            cout << t;
        } else {
            cout << sep << t;
        }
    }
    cout << "\n";
}

const ll md = 1e9 + 7;
ll MOD(ll x) {
    ll r = x % md;
    if (r < 0) {
        r += md;
    }
    return r;
}

#define POS "POSSIBLE"
#define IMPOS "IMPOSSIBLE"

// #define INF LLONG_MAX
// #define MINF LLONG_MIN
#define INF 1e18
#define MINF -INF

void solve() {
    ll n;
    cin >> n;
    if (n == 1 || n == 7){ 
        cout << "1\n";
        return;
    }
    if (n % 2 == 0 || n % 5 == 0) {
        cout << "-1\n";
        return;
    }
    if (n % 7 == 0) {
        n /= 7;
    }
    ll res = 1;
    ll cur = 10;
    n = 9*n;
    while (cur != 1) {
        cur = (cur * 10) % n;
        res++;
    }


    // cout << fixed << setprecision(6);
    cout << res << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt = 1;
    // cin >> tt;
    for (int t = 1; t <= tt; t++) {
        // cout << "Case #" << t << ": ";
        solve();
    }
    //cin.rdbuf()->in_avail()
    return 0;
}


Measured memory_bytes: 3644
h,w=map(int,input().split())
s=[]
for i in range(h):
	ss=input()
	s.append(ss)
inf=10**4
dp=[[inf]*w for _ in range(h)]
if s[0][0]=="#":
	dp[0][0]=1
else:
	dp[0][0]=0
for i in range(w-1):
	if s[0][i+1]==".":
		dp[0][i+1]=dp[0][i]
	else:
		dp[0][i+1]=dp[0][i]+1
		if s[0][i]=="#":
			dp[0][i+1]-=1
for i in range(1,h):
	if s[i][0]==".":
		dp[i][0]=dp[i-1][0]
	else:
		dp[i][0]=dp[i-1][0]+1
		if s[i-1][0]=="#":
			dp[i][0]-=1
	for j in range(1,w):
		if s[i][j]==".":
			dp[i][j]=min(dp[i][j-1],dp[i-1][j])
		else:
			p=dp[i][j-1]
			q=dp[i-1][j]
			if s[i][j-1]=="#":
				p-=1
			if s[i-1][j]=="#":
				q-=1
			dp[i][j]=min(p,q)+1
print(dp[-1][-1])




Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
 
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int N;
    int SUM=0;
 
    cin >> N;
 
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N);
 
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];
    rep(i,N-1) cin >> C[i];
 
    rep(i,N-1)
    {
        if (A[i]+1 == A[i+1])
        SUM+=C[A[i]-1];
    }
 
    cout << accumulate(B.begin(), B.end(), 0)+SUM;
 
    return 0;
}

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

class C
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var p = new int[n].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToList();
		p.Insert(0, new[] { 0, 0, 0 });

		Console.WriteLine(Enumerable.Range(0, n).All(i =>
		{
			int[] q = p[i], r = p[i + 1];
			var m = r[0] - q[0] - Math.Abs(r[1] - q[1]) - Math.Abs(r[2] - q[2]);
			return m >= 0 && m % 2 == 0;
		}) ? "Yes" : "No");
	}
}


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

using namespace std;

int main() {
  long long n;
  cin >> n;
  long long ans = (n+10)/11;
  if (ans * 11 - 5 >= n)
    ans = ans * 2 - 1;
  else
    ans = 2 * ans;
  printf("%lld\n", ans);

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>
 
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long int;
 
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;
 
template<typename T>
void print(vector<T> a){
	for (auto x:a){
		cout << x << " ";
	}
	cout << endl;
}
 
template<typename T>
void print2d(vector<vector<T>> a){
	for (auto v:a){
		for (auto x:v){
			cout << x << " ";
		}
		cout << endl;
	}
}
 
 //nの約数を返す関数.sortされてない.
vector<long long int> divisors(long long int n){
	vector<long long int> res;
	for (long long int i = 1; i * i <= n;i++){
		if (n % i == 0){
			res.push_back(i);
			if(i * i != n){
				res.push_back(n / i);
			}
		}
	}
	return res;
}

//素因数分解をする関数.
map<long long int, int> prime_factorization(long long int a)
{
	map<long long int, int>ans;
	for (long long i = 2; i*i <= a; ++i) {
		while (a%i == 0) {
			ans[i]++;
			a /= i;
		}
	}
	if (a != 1)ans[a]++;
	return ans;
}

int main()
{
	int n;
	cin >> n;
	ll ans = 0;

	rep2(c,1,n){
		ll t = n - c;
		map<long long int, int> m = prime_factorization(t);
		ll temp = 1;
		for (auto x : m)
		{
			temp *= x.second + 1;
		}
		ans += temp;
		// vector<ll> a = divisors(t);
		// ans += a.size();
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;

int main() {
  int n;
  cin >> n;
  int v[50];

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

  sort(v, v + n);

  double ans = v[0];
  for (int i = 1; i < n; i++) {
    ans = (ans + v[i]) / 2;
  }

  cout << fixed;
  cout << setprecision(5) << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<60);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  a=abs(a);
  b=abs(b);
  if(a==0)return b;
  if(b==0)return a;
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

void solve(long long N, std::vector<long long> A){
  sort(A.begin(),A.end());
  multiset<ll> s(A.begin(),A.end());
  ll ans=0;
  for (auto &&i : A)
  {
    s.erase(s.lower_bound(i));
    auto f=[](ll x)->vector<ll>{
      vector<ll> ret;
      for (ll i = 1; i*i <= x; i++)
      {
        if(x%i==0){
          ret.push_back(i);
          if(i*i!=x){
            ret.push_back(x/i);
          }
        }
      }
      return ret;
    };
    vll y(f(i));
    bool fl=true;
    for (auto &&j : y)
    {
      if(s.count(j)){
        fl=false;
        break;
      }
    }
    if(fl)++ans;
    s.insert(i);
  }
  cout<<ans<<endl;
}

int main(){
  cout<<setprecision(1000);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 14352
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int N, M;
ll ans;

int main() {
    cin >> N >> M;
    vector<bool> ok(N+1, true);
    rep(i, M) {
        int a; cin >> a;
        ok[a] = false;
    }

    vector<ll> dp(N+1);
    dp[0] = 1;
    for (int i=0; i<N; i++) {
        for (int j=i+1; j<=min(N, i+2); j++) {
            if (ok[j]) {
                dp[j] += dp[i];
                dp[j] %= MOD;
            }
        }
    }
    cout << dp[N] << endl;
}


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

constexpr int MOD = 1000000007;

class mint {
  int n;
public:
  mint(int n_ = 0) : n(n_) {}
  explicit operator int() { return n; }
  friend mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
  friend mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
  friend mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
  friend mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
  friend mint &operator+=(mint &a, mint b) { return a = a + b; }
  friend mint &operator-=(mint &a, mint b) { return a = a - b; }
  friend mint &operator*=(mint &a, mint b) { return a = a * b; }
  friend bool operator==(mint a, mint b) { return a.n == b.n; }
  friend bool operator!=(mint a, mint b) { return a.n != b.n; }
  friend istream &operator>>(istream &i, mint &a) { return i >> a.n; }
  friend ostream &operator<<(ostream &o, mint a) { return o << a.n; }
};

mint modpow(mint a, long long b) {
  mint res = 1;
  while (b > 0) {
    if (b & 1) res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}


mint modinv(mint n) {
  int a = (int)n, b = MOD;
  int s = 1, t = 0;
  while (b != 0) {
    int q = a / b;
    a -= q * b;
    s -= q * t;
    swap(a, b);
    swap(s, t);
  }
  return s >= 0 ? s : s + MOD;
}


int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int N; cin >> N;
  vector<int> X(N); rep(i, N) cin >> X[i];
  vector<mint> sum(N + 1);
  rep(i, N) sum[i + 1] = sum[i] + X[i];
  mint ans;
  /*
  for (int i = 0; i < N; i++) {
    for (int j = 1; j + i < N - 1; j++) {
      ans += (X[i + j] - X[i]) * modinv(j + 1) * modinv(j);
    }
  }
  */
  for (int i = 1; i <= N - 2; i++) {
    ans += modinv(i + 1) * modinv(i) * (sum[N - 1] - sum[i]);
    ans -= modinv(i + 1) * modinv(i) * (sum[N - 1 - i] - sum[0]);
  }
  for (int i = 0; i < N - 1; i++) {
    ans += (X[N - 1] - X[i]) * modinv(N - i - 1);
  }
  for (int i = 1; i <= N - 1; i++) ans *= i;
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
/*********ANISH***********ANISH*************ANISH***********ANISH******/
#define pb push_back
#define ll long long
#define ff first
#define ss second
ll max(ll a,ll b)
{
    if(a>b) return a;
    return b;
}
ll min(ll a,ll b)
{
    if(a<b) return a;
    return b;
}
/********ANISH************ANISH*************ANISH**********ANISH*********/
int n;
int a[100010],b[100010],c[100010],dp[100010][3];
int fun(int pos,char prev)
{
    if(pos>=n) return 0;
    if(prev!='z'&&dp[pos][prev-'a']!=-1) return dp[pos][prev-'a'];
    int cost=0;
    if(prev=='z')
    {
        cost=max(cost,a[pos]+fun(pos+1,'a'));
        cost=max(cost,b[pos]+fun(pos+1,'b'));
        cost=max(cost,c[pos]+fun(pos+1,'c'));
    }
    if(prev=='a')
    {
        cost=max(cost,b[pos]+fun(pos+1,'b'));
        cost=max(cost,c[pos]+fun(pos+1,'c'));
    }
    else if(prev=='b')
    {
        cost=max(cost,a[pos]+fun(pos+1,'a'));
        cost=max(cost,c[pos]+fun(pos+1,'c'));
    }
    else
    {
        cost=max(cost,a[pos]+fun(pos+1,'a'));
        cost=max(cost,b[pos]+fun(pos+1,'b'));
    }
    if(prev!='z') dp[pos][prev-'a']=cost;
    return cost;
}
int main()
{
    int t;
    t=1;
    while(t--)
    {
        cin>>n;
        for(int i=0;i<n;++i) cin>>a[i]>>b[i]>>c[i];
        memset(dp,-1,sizeof(dp));
        cout<<fun(0,'z');
    }
}


Measured memory_bytes: 7296
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>

using namespace std;
typedef long long ll;
typedef pair<ll,ll>P;
int main(){
  int n,min_val=0,color[8],free_num=0;
  scanf("%d",&n);
  fill(color,color+8,0);
  for(int i=0;i<n;i++){
    int a;
    scanf("%d",&a);
    if(a>=3200) free_num++;
    else if(color[a/400]==0) color[a/400]=1;
  }
  for(int i=0;i<8;i++){
    min_val=min_val+color[i];
  }

  printf("%d %d\n",max(1,min_val),min_val+free_num);
    
  return 0;
}


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

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

typedef long long ll;

ll INF = 1001001001;
ll MOD = 1e9+7;

using Graph = vector<vector<ll>>;

Graph G(100010);
ll table[100010];

int main(){
    ll N,M;cin >> N >> M;
    vector<pair<int,int>> key;
    for(int i = 0;i < M;i++){
        int a,b;cin >> a >> b;
        int s = 0;
        for(int j = 0;j < b;j++){
            int c;cin >> c;
            c--;
            s |= 1<<c;
        }
        key.emplace_back(s,a);
    }
    vector<int> dp(1 << N,INF);
    dp[0] = 0;
    for(int i = 0;i < (1 << N);i++){
        for(int j = 0;j < M;j++){
            int t = i | key[j].first;
            int cost = dp[i] + key[j].second;
            dp[t] = min(dp[t],cost);
        }
    }
    if(dp.back() == INF){
        cout << -1 << endl;
        return 0;
    }
    cout << dp.back() << endl;
}


Measured memory_bytes: 2688
N = gets.chomp.to_i
SP = Array.new
for i in 1..N
    sp = gets.chomp.split(" ")
    sp[1] = sp[1].to_i
    sp << i
    SP << sp
end
SP.sort!{|a, b| (a[0] <=> b[0]).nonzero? || b[1] <=> a[1]}
SP.each do |sp|
    puts sp[2]
end

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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll a,b,c;
	cin>>a>>b>>c;
	ll l,r;
    l = 4*a*b;
    r = (c-a-b)*(c-a-b);
    string ans;
    if(l<r){
        ans = "Yes";
    }else{
        ans = "No";
    }
    if(c<=(a+b)) ans = "No";
    cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
a,b,k = map(int,input().split())
"""for i in range(k):
    if a > 0: a-=1
    elif b > 0: b-= 1"""
if a>k: a,b = a-k,b
elif k <= a+b: a,b = 0,b+a-k
else: a,b = 0,0
print(a,b)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int h;
    cin >> h;

    long long int counter = 0,ans = 2;
    while (h != 1)
    {
        // counter++;
        h = (long long int)floor(h/2);
        ans *= 2;
    }
    ans--;
    // cout << pow(2,counter + 1) - 1 << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll a, ll b) { //gcdを返す
	if(a == 0){
		return b;
	} else if (b == 0){
		return a;
	} else {
	  if(a < b) return gcd(b, a);
	  ll r;
	  while ((r=a%b)) {
	    a = b;
	    b = r;
	  }
	  return b;
	}
}
ll ketasum(ll n) { //桁の数字全ての和を返す 例: 112 -> 4
	ll sum=0;
	if (n<0) return 0;
	while (n>0) {
		sum += n%10;
		n /= 10;
	}
	return sum;
}

typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{ // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
        ll n = av.size();
        vector<pair_t> p(n);
        vector<ll> av2(n), bv2(n);
        for (ll i = 0; i < n; i++)
                p[i] = make_pair(av[i], bv[i]);
        sort(p.begin(), p.end(), comp);
        for (ll i = 0; i < n; i++) {
                av2[i] = p[i].first;
                bv2[i] = p[i].second;
        }
        av = av2;
        bv = bv2;
}
ll facctorialMethod(ll k){ //階乗
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int main(){
	ll a;
	string s;
	cin >> a >> s;
	if(a >= 3200){
		cout << s << endl;
	} else {
		cout << "red" << endl;
	}
}

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

int main()
{
	string ordor;
	int countnum = 0;

	cin >> ordor;

	if (ordor[0] == 'o') countnum++;
	if (ordor[1] == 'o') countnum++;
	if (ordor[2] == 'o') countnum++;

	cout << 100 * countnum + 700;

	return 0;
}

Measured memory_bytes: 256
fn main() {
    let v = read_vec::<i32>();
    let x = v[0];
    let a = v[1];
    let b = v[2];
    yn((x - a).abs() < (x - b).abs());
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("A");
    } else {
        println!("B");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

/*typedef struct PP{
    int px, py, lx, ly;
} PP;*/
typedef pair<ll, ll> P;
int h, w;
int sx;
int sy;
vector<vector<char>> s;
//unordered_map<PP, int> ump;
vector<vector<bool>> v;
vector<P> c;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
ll bc, wc;

void dfs(int y, int x, int prev){
    // black = 1, white = 2;
    if (y >= h || y < 0 || x >= w || x < 0) return;
    if(v[y][x]) return;
    int now = 0;
    v[y][x] = true;
    
    if (s[y][x] == '#') now = 1;
    else now = 2;
    if (prev == 0) bc++;
    else if (prev == 1 && now == 2) wc++;
    else if (prev == 2 && now == 1) bc++;
    else {
        v[y][x] = false;
        return;
    }
    
    for (int i = 0; i < 4; ++i) dfs(y+dy[i], x+dx[i], now);
    return;
}

ll count(int y, int x) {
    wc = 0;
    bc = 0;
    dfs(y, x, 0);
    return wc*bc;
}

int main(int argc, char const *argv[]) {
    cin >> h >> w;
    s.resize(h);
    v.resize(h);
    REP(i,h) {
        s[i].resize(w);
        v[i].resize(w);
    }
    vector<P> PPP;
    REP(i,h) REP(j,w) {
        cin >> s[i][j];
        v[i][j] = false;
        if(s[i][j] == '#') PPP.push_back({i, j});
    }
    ll ans = 0;
    for(auto q : PPP) ans += count(q.first, q.second);
    cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 9328
# E - Payment

S = input()
N = len(S)

# 先頭からi桁目までの金額のやり取りに必要な紙幣の枚数
dp = [0]
dp_plus1 = [1]

for i in range(N):
    x = int(S[i])
    dp.append(min(dp[i] + x, dp_plus1[i] + (10 - x)))
    dp_plus1.append(min(dp[i] +  (x + 1), dp_plus1[i] + (10 -  (x + 1))))

print(dp[-1])

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

int main(){
    int N,K;
    cin >> N >> K;
    int total;
    int max,min;
    max = N-K+1;
    

    if(K==1){
        cout << "0";
        return 0;
    }
    cout << max - 1;

}

Measured memory_bytes: 256