akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout <<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr << #x << ":" << (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;

	VAR(int, n, k);
	VEC(int, a, n);

	sort(ALL(a));
	int ans = n, sm = 0;
	RREP(i, n) {
		if (sm + a[i] < k) {
			sm += a[i];
		} else {
			ans = min(ans, i);
		}
	}
	OUT(ans)BR;
  return 0;
}


Measured memory_bytes: 256
def E():
    N = int(input())
    pairs = []
    lefts = []
    rights = []
    for _ in range(N):
        pairs.append(list(map(int, input().split())))
        lefts.append(pairs[-1][0])
        rights.append(pairs[-1][1])
    lefts.sort()
    rights.sort()
    if N%2==0:
        print(int(((rights[N//2]+rights[N//2-1])/2+1 - (lefts[N//2]+lefts[N//2-1])/2)*2-1))
        return
    print(rights[(N+1)//2-1] - lefts[(N+1)//2-1] + 1)
E()

Measured memory_bytes: 49340
#include <stdio.h>
#define MAX 10000
#define NIL -1

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

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d)
{
  if( u == NIL ) return;
  D[u]=d;
  setDepth(T[u].left, d+1);
  setDepth(T[u].right, d+1);
}

int setHeight(int u)
{
  int h1=0,h2=0;
  if( T[u].left != NIL )
    h1=setHeight(T[u].left)+1;
  if(T[u].right!=NIL)
    h2=setHeight(T[u].right)+1;
  return H[u]=( h1 > h2 ? h1 : h2);
}

int getSibling(int u)
{
  if( T[u].parent == NIL) return NIL;
  if( T[T[u].parent].left != u && T[T[u].parent].left != NIL)
    return T[T[u].parent].left;
  if( T[T[u].parent].right != u && T[T[u].parent].right != NIL)
    return T[T[u].parent].right;
  return NIL;
}

void print(int u)
{
  printf("node %d: ",u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", getSibling(u));
  int deg = 0;
  if( T[u].left != NIL ) deg++;
  if( T[u].right != NIL ) deg++;
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if( T[u].parent == NIL )
    {
      printf("root\n");
    }
  else if( T[u].left == NIL && T[u].right == NIL )
    {
      printf("leaf\n");
    }
  else
    {
      printf("internal node\n");
    }
}

int main()
{
  int i,v, l, r, root = 0;
  scanf("%d", &n);

  for( i = 0; i < n; i++ ) T[i].parent = NIL;

  for( i = 0; i < n; i++ )
    {
      scanf("%d %d %d", &v, &l, &r );
      T[v].left = l;
      T[v].right = r;
      if( l != NIL ) T[l].parent = v;
      if( r != NIL ) T[r].parent = v;
    }

  for( i = 0; i < n; i++ ) if( T[i].parent == NIL ) root = i;

  setDepth(root, 0);
  setHeight(root);

  for( i = 0; i < n; i++ ) print(i);

  return 0;
}



Measured memory_bytes: 2108
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

const int MAXN = 100100;
int N, L, Q;
int X[MAXN];

int nxt[30][MAXN];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N; 
    for (int i = 0; i < N; i++)
        cin >> X[i];
    cin >> L;
    memset(nxt, -1, sizeof(nxt));
    for (int i = 0; i < N; i++) {
        if (i == N-1) {
            nxt[0][i] = N-1;
            continue;
        }
        int low = i+1, high = N;
        while (high-low > 1) {
            int med = (high+low)/2;
            if (X[med] - X[i] <= L) low = med;
            else high = med;
        }
        nxt[0][i] = low;
    }
    for (int i = 0; i < 30-1; i++) {
        for (int j = 0; j < N; j++) {
            if (nxt[i][j] == -1) nxt[i+1][j] = -1;
            else nxt[i+1][j] = nxt[i][nxt[i][j]];
            assert(nxt[i][j] != -1);
        }
    }
    cin >> Q;
    for (int t = 0; t < Q; t++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        if (a > b) swap(a, b);
        if (a < b) {
            // int low = 0, high = N;
            // while (high - low > 1) {
            //     int med = (low+high)/2;
            //     int now = a;
            //     for (int i = 30-1; i >= 0; i--) {
            //         if ((med)&(1<<i)) {
            //             now = nxt[i][now];
            //         }
            //     }
            //     if (now >= b) high = med;
            //     else low = med;
            // }
            // cout << high << endl;
            int ans = 0;
            for (int i = 30-1; i >= 0; i--) {
                if (nxt[i][a] < b) {
                    a = nxt[i][a];
                    ans |= 1<<i;
                }
            }
            cout << ans+1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 12928
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdio>
using namespace std;

int main(){
  int n, m, l;
  while (1) {
    cin >> n >> m >> l;
    if((n == -1) && (m == -1) && (l == -1)) {
      break;
    } else if ((n == -1) || (m == -1)) {
      cout << 'F' << endl;
    } else if (n + m >= 80) {
      cout << 'A' << endl;
    } else if (n + m >= 65) {
      cout << 'B' << endl;
    } else if (n + m >= 50) {
      cout << 'C' << endl;
    } else if (n + m >= 30) {
      if (l >= 50) {
        cout << 'C' << endl;
      } else {
        cout << 'D' << endl;
      }
    } else {
      cout << 'F' << endl;
    }
  }

}

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

// i => (i+1) or (i+2)
// cost = |hj - hi|

using ll = long long; 
const int INF = 1e9 + 5;

void solve(vector<int> &arr, int k) {
    vector<int> dp(arr.size(), INF);

    dp[0] = 0;
    for(int i=0; i<arr.size(); i++){
        for(int j=1; j<=k; j++){
            int l = j+i;
            if(l < arr.size()){
                dp[l] = min(dp[l], dp[i] + abs(arr[l] - arr[i]));
            }
        }
    }

    cout << dp[arr.size()-1] << endl;
}

int main(){

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

    vector<int> arr(n, 0);
    for(int i=0; i<arr.size(); i++)
        cin >> arr[i];

    solve(arr, k);

    return 0; 
}

Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main implements Runnable{

	public static void main(String[] args) {
		new Thread(null,new Main(), "" ,Runtime.getRuntime().maxMemory()).start();
	}
	
	public void run() {
		FastScanner sc=new FastScanner();
		ArrayDeque<Long> pend=new ArrayDeque<>();
		ArrayDeque<Long> fix=new ArrayDeque<>();
		for(long i=1;i<=9;++i) {
			pend.addLast(i);
		}
		int K=sc.nextInt();
		while(K>fix.size()) {
			ArrayDeque<Long> tmp=new ArrayDeque<>();
			for(long v:pend) {
				fix.add(v);
				if(v%10+1<=9)tmp.add(10*v+v%10+1);
				if(v%10+0<=9)tmp.add(10*v+v%10+0);
				if(v%10-1>=0)tmp.add(10*v+v%10-1);
			}
			pend=tmp;
		}
		long[] a=new long[fix.size()];
		int p=0;
		while(!fix.isEmpty())a[p++]=fix.poll();
		Arrays.sort(a);
		System.out.println(a[K-1]);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 51040
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include <assert.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
#include <climits>
using namespace std;
typedef unsigned long long ull;
#define ll long long int
static const double PI = 3.141592653589793;
const ll INF = 100000000000000;
ll mod = 1000000007;
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;

int main(){
	ll n;
	string s="";
	cin >> n;
	ll ind = 1;
	while (n != 0) {
		int a =abs((n % (ind*(-2)))/ind);
		n -= a * (ind);
		s = to_string(a) + s;
		ind *= -2;
	}
	if (s == "")s = "0";
	cout << s << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, k) = readLine()?.split(" ")?.map(String::toDouble) ?: return
    var r = 0.0
    1.until(n.toInt() + 1).forEach {
        var dc = 1 / n
        var kk = it
        while (kk < k) {
            kk *= 2
            dc /= 2
        }
        r += dc
    }
    println(r)
}

Measured memory_bytes: 36008
#include<stdio.h>
#include<string.h>
  
#define SIZE 3
#define LIM 32
#define HN 362897
  
struct dep {
    int depth, key;
};
  
int ans[SIZE][SIZE] = {
    {1, 2, 3},
    {4, 5, 6},
    {7, 8, 0}};
  
int min = LIM;
struct dep h[HN];
  
int hash1(int k) {
    return k % HN;
}

int hash2(int k) {
    return 1 + k % (HN - 1);
}

int hash(int k, int i) {
    return (hash1(k) + i * hash2(k)) % HN;
}
  
void dfs(int p[SIZE][SIZE], int n) {
    int i, j, i1, j1, a = 0, b = 1;
    int f = 0;
    int tmp[SIZE][SIZE];
    for (i = 0; i < SIZE; i++) {
        for (j = 0; j < SIZE; j++) {
            if (ans[i][j] != p[i][j]) f++;
            if(p[i][j] == 0) {
                i1 = i;
                j1 = j;
            }
            a += p[i][j] * b;
            b *= 10;
        }
    }

    if (f == 0) {
        if(min >= n) {
            min = n;
        }
        return;
    }
    if(n > min) return;
    i = 0;
    while(1) {
        b = hash(a, i);
        if (h[b].key == 0) {
            h[b].key = a;
            h[b].depth = n;
            break;
        }
        else if (h[b].key == a) {
            if (h[b].depth > n) {
                h[b].depth = n;
                break;
            }
            else return;
        }
        i++;
    }
      
    if(i1 > 0 && i1 < SIZE) {
        memcpy(tmp, p, sizeof(int) * SIZE * SIZE);
        f = tmp[i1][j1];
        tmp[i1][j1] = tmp[i1 - 1][j1];
        tmp[i1 - 1][j1] = f;
        dfs(tmp, n + 1);
    }
    if(j1 > 0 && j1 < SIZE) {
        memcpy(tmp, p, sizeof(int) * SIZE * SIZE);
        f = tmp[i1][j1];
        tmp[i1][j1] = tmp[i1][j1 - 1];
        tmp[i1][j1 - 1] = f;
        dfs(tmp, n + 1);
    }
      
    if(i1 >= 0 && i1 < SIZE - 1) {
        memcpy(tmp, p, sizeof(int) * SIZE * SIZE);
        f = tmp[i1][j1];
        tmp[i1][j1] = tmp[i1 + 1][j1];
        tmp[i1 + 1][j1] = f;
        dfs(tmp, n + 1);
    }
    if(j1 >= 0 && j1 < SIZE - 1) {
        memcpy(tmp, p, sizeof(int) * SIZE * SIZE);
        f = tmp[i1][j1];
        tmp[i1][j1] = tmp[i1][j1 + 1];
        tmp[i1][j1 + 1] = f;
        dfs(tmp, n + 1);
    }
}
  
int main(void)
{
    int i, j;
    int p[SIZE][SIZE];
      
    for (i = 0; i < SIZE; i++) {
        for (j = 0; j < SIZE; j++) {
            scanf("%d", &p[i][j]);
        }
    }
    dfs(p, 0);
      
    printf("%d\n", min);
      
    return 0;
}


Measured memory_bytes: 4684
import java.util.*;
import java.util.Map.Entry;
 
 
 class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
    public static void main(String[] args) {
    
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long M = sc.nextLong();
        
        long[] a = new long[(int)N];
        int cnt1=0;
        for (int i=0 ; i<N; i++) {
            int cnt=0;
            a[i] = sc.nextLong();
            long tmp=a[i];
            	while(tmp%2==0) {
            		tmp=tmp/2;
            		cnt++;
            	}
        		if(i==0) {
        			cnt1=cnt;
        		} else {
        			if(cnt1!=cnt) {
        				System.out.println(0);
        				return;
        			}
            }
        }
        
        long lcm=a[0];
        for(int i=1;i<N;i++) {
        	lcm=LCM(lcm,a[i]);
        	if(lcm>M*2) {
        		System.out.println(0);
        		return;
        	}
        }
        	
        long ans=1;
        if(M<lcm/2) {
    		System.out.println(0);
        	return;
        } else {
        	long tmp=M-lcm/2;
        	ans=ans+tmp/lcm;
        }
 
        System.out.println(ans);  	
               		
    }

    static long GCD(long a,long b) {
    	  long tmp;
    	  long r;
    	  if(a<b) {
    		  tmp = a;
    		  a = b;
    		  b = tmp;				  
    	  }
    	  
    	  r = a % b;
    	  while(r!=0) {
    		  a=b;
    		  b=r;
    		  r=a%b;
    	  }
    	  
    	  return b;
      }
      
      static long LCM(long a,long b) {
    	  return a*b/GCD(a,b);
      }
}


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

const int INF = 2e9;

int main(){
    int n;
    cin >> n;
    ll sum = 0;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        sum ^= a[i];
    }
    if(sum == 0){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=200005;

int N,A[MAXN],B[MAXN];
bool check(int x)
{
	for(int i=0;i<N-1;i++)
	{
		if(A[N+i]>=x&&A[N+i+1]>=x)
			return true;
		if(A[N-i]>=x&&A[N-i-1]>=x)
			return true;
		if(A[N+i]<x&&A[N+i+1]<x)
			return false;
		if(A[N-i]<x&&A[N-i-1]<x)
			return false;
	}
	if(A[1]>=x)
		return true;
	return false;
}

int main()
{
	scanf("%d",&N);
	for(int i=1;i<=2*N-1;i++)
		scanf("%d",&A[i]);

	int L=1,R=2*N-1;
	while(L<R)
	{
		int mid=(L+R+1)/2;
		if(check(mid))
			L=mid;
		else
			R=mid-1;
	}
	printf("%d\n",L);
	return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#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 repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll t=(c+b-1)/b;
  ll ao=(a+d-1)/d;
  if(t<=ao){
    COUT("Yes");
  }
  else COUT("No");
}

Measured memory_bytes: 3624
//Subhash Suman
//Date: 10/02/19 ; Day: Sunday ; Time: 18::40::41 
//Description : 

#include<bits/stdc++.h>
#define ll long long int
#define MAX INT_MAX
#define MIN INT_MIN
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>

using namespace std;
const int N = 1e5+5;
int arr[N][3],dp[N][3];

int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
    int n;
    cin>>n;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < 3; j++){
            cin>>arr[i][j];
        }
    }
    dp[1][0] = arr[1][0];
    dp[1][1] = arr[1][1];
    dp[1][2] = arr[1][2];
    for(int i = 2; i <= n; i++){
        for(int x = 0; x < 3; x++){
            for(int c = 0; c < 3; c++){
                if(c!=x){
                    dp[i][c] = max(dp[i][c],arr[i][c] + dp[i-1][x]);
                }
            }
            
        }
    }
    int ans = 0;
    for(int i = 0; i < 3; i++){
        ans = max(ans,dp[n][i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
int main(){
  int w,h,x,y,r;
  scanf("%d %d %d %d %d\n",&w,&h,&x,&y,&r);
  int i = x+r;
  int j = y+r;
  if(i>0 && i <= w && j <= h && j>0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 588
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;
type I = usize;

fn main() {
    input!{
      n: usize,
      m: usize,
      mut abs: [(usize, usize); n],
    }
    abs.sort_by_key(|v| v.0);

    let mut ans = 0;
    let mut r = m;
    for i in 0..n {
        let (a, b) = abs[i];
        let num = min(r, b);
        ans += a*num;
        r -= num;
        if r == 0 {
            break;
        }
    }
    println!("{}", ans);
}


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

#define int long long

using namespace std;

int d[100001][4];
int fi, se;

 main () {
    int n, p;
    cin >> n >> p;
    d[0][0] = 1;
    for (int i = 1;i <= n;i ++) {
    	int x;
    	cin >> x;
    	x %= 2;
    	d[i][0] = d[i - 1][0];
    	d[i][1] = d[i - 1][1];
    	if (x == 0) {
			d[i][0] += d[i - 1][0];
			d[i][1] += d[i - 1][1];
    	}
    	else {
    		d[i][0] += d[i - 1][1];
    		d[i][1] += d[i - 1][0];
    	}
    }                   
    cout << d[n][p];
    return 0;           		
}

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

#define pb            push_back
#define mp            make_pair
#define all(x)        x.begin(),x.end()
#define debug(X)      { cerr<<'\n'<<(#X)<<" = "<<(X)<<'\n'; }
//#define cerr if(0)cerr

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll x,i=0;
    long double dep = 100.0;
    cin>>x;

    while (dep<x) {
        dep += floor(dep*0.01);
        ++i;
    }

    cout<<i<<endl;
    
    

}


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

using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define all(vec) vec.begin(),vec.end()
#define ff first
#define ss second
#define pi 3.141592653589
#define inf 4e18
#define MOD 1000000007
#define pb push_back
#define for1(low,high,k) for(int i=low;i<high;i+=k)
#define for2(low,high,k) for(int j=low;j<high;j+=k)
#define rev(high,low,k) for(int i=high;i>=low;i-=k) 

int main(){
	fast;
	lli n,d,ans=0;
	cin>>n>>d;
	while (n--){
		lli x,y;
		cin>>x>>y;
		double a=sqrt(x*x+y*y);
		if (a<=d) ans++;
	}
	cout<<ans<<endl;
}

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

int main() {
    ll N,M;
    cin >>N >>M;
    priority_queue<P> pq;
    for(int i=0;i<N;i++){
        ll A;
        cin >> A;
        pq.push(P(A,1));
    }
    for(int i=0;i<M;i++){
        ll B,C;
        cin >> B >>C;
        pq.push(P(C,B));
    }
    ll ans =0;
    for(int i=0;i<N;i++){
        P p =pq.top();pq.pop();
        ans += p.first;
         p.second--;
        if(p.second>0){
            pq.push(p);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7460
#pragma GCC optimize("Ofast",3,"inline")
#include <bits/stdc++.h>
using namespace std;
int N;
vector<int> g[100000];
int dist[2][100000];
int id;
void dfs(int idx,int par=-1){
	if(~par) dist[id][idx]=dist[id][par]+1;
	for(auto &to : g[idx])if(to!=par)dfs(to,idx);
}
int main(){
	ios_base::sync_with_stdio(false);
	cin>>N;
	for(int i=0;i<N-1;i++){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}
	id=0;
	dfs(0);
	id=1;
	dfs(N-1);
	int ret=0;
	for(int i=0;i<N;i++){
		if(dist[0][i]<=dist[1][i]){
			ret++;
		}
	}
	if(ret>=(N+2)/2) cout<<"Fennec";
	else cout<<"Snuke";
	return 0;
}


Measured memory_bytes: 9472
#include<bits/stdc++.h>;
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	int i=1;
	while(i<2){if(a+b>=a-b&&a+b>=a*b) {cout<<a+b;break;
	}
	if(a-b>=a+b&&a-b>=a*b) {cout<<a-b;break;
	}
	if(a*b>=a-b&&a*b>=a+b) {cout<<a*b;break;
	}
	i++;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(a) (a).begin(), (a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x, 0, sizeof(x))
#define MINF(x) memset(x, 0x3f, sizeof(x))
#define MMINUS(a) memset(a, 0xff, sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double EPS = 1.0 / LINF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

using namespace std;

int a;
string s;

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


Measured memory_bytes: 256
N=int(input())
A,B=map(int,input().split())
P=list(map(int,input().split()))

PA=len([P[i] for i in range(N) if P[i]<=A])
PB=len([P[i] for i in range(N) if P[i]>B])
PC=N-PA-PB

print(min(PA,PB,PC))

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

int main(){
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<4;i++){
        if(s[i]=='+')ans++;
        else if(s[i]=='-')ans--;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
import heapq
from sys import stdin

def read_and_print_pqueue():
    A = []
    while True:
        cmd = stdin.readline().strip().split()
        if cmd[0][0] == 'i':
            heapq.heappush(A, -int(cmd[1]))
        elif cmd[0][0:2] == 'ex':
            print(-heapq.heappop(A))
        elif cmd[0][0:2] == 'en':
            break

read_and_print_pqueue()


Measured memory_bytes: 45564
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

ll a[100010];
ll dp[110][2];

int main(){
    ll n, k;
    cin >> n >> k;
    rep(i, n) cin >> a[i];

    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;

    rep(d, 100){
        ll mask = 1ll<<(50 - d - 1);
        ll cnt = 0;
        rep(i, n) if (mask & a[i]) cnt++;
        ll cost0 = cnt * mask;
        ll cost1 = (n - cnt) * mask;

        if (dp[d][1] != -1) {
            chmax(dp[d+1][1], dp[d][1] + max(cost0, cost1));
        }
        
        if (dp[d][0] != -1) {
            if (k & mask) {
                chmax(dp[d+1][1], dp[d][0] + cost0);
            }
        }
        
        if (dp[d][0] != -1) {
            if (k & mask) chmax(dp[d+1][0], dp[d][0] + cost1);
            else chmax(dp[d+1][0], dp[d][0] + cost0);
        }
    }

    cout << max(dp[50][0], dp[50][1]) << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>

using namespace std;

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

	if (abs(a - x) < abs(b - x)) {
		cout << "A" << endl;
		return 0;
	}
	cout << "B" << endl;
	return 0;
}

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

struct UnionFind {
  vector<int> data;
  UnionFind() {}
  UnionFind(int n) : data(n, -1) {}

  bool same(int x, int y) { return root(x) == root(y); }
  int root(int x) { return (data[x] < 0) ? x : data[x] = root(data[x]); }
  int rank(int x) { return -data[root(x)]; }
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
};
template<typename T> struct Graph {
  struct Edge { int s, t; T cost; };
  int sz;
  vector<Edge> es;
  Graph(int n = 0) : sz(n) {}

  void addEdge(int u, int v, T w) {
    sz = max(sz, max(u, v) + 1);
    es.push_back({u, v, w});
  }
  T kruskal() {
    UnionFind uf(sz);
    sort(begin(es), end(es), [](Edge e1, Edge e2) {
      return e1.cost < e2.cost;
    });
    T res = 0;
    for (auto&& e : es) {
      if (uf.unite(e.s, e.t)) res += e.cost;
    }
    return res;
  }
};

int main() {
  int n;
  while (cin >> n, n) {
    int m; cin >> m;
    Graph<int> g;
    for (int i = 0; i < m; ++i) {
      int a, b, d;
      char c;
      cin >> a >> c >> b >> c >> d;
      g.addEdge(a, b, d / 100);
    }
    cout << g.kruskal() - (n - 1) << endl;
  }
  return 0;
}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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(b<a){a=b;return true;}return false;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;
 
template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is,pair<T1,T2>&p){
    is>>p.first>>p.second;
    return is;
}

template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}


signed main(){
    ll n;cin>>n;
    vector<ll> c(n+1,0);
    for(ll a=1;a<=n;a++){
        for(ll b=1;a*b<=n;b++){
            c[a*b]++;
        }
    }

    ll res=0;
    for(ll i=1;i<n;i++)res+=c[i]; 
    cout<<res<<endl;

    return 0;
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int n,a[101];

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

  cin>>n;
  int sum=0;
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
  }

  int idx=0;
  rep(i,n){
    int pred=abs(sum-a[idx]*n);
    int crtd=abs(sum-a[i]*n);
    if(pred>crtd){
      idx=i;
    }
  }
  cout<<idx<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  string s;
  cin>>s;
  long long n = s.length();
  long long sum=0;
  for(int i=0;i<n;i++)
  {
    sum += (s[i]-'0');
  }
  if(sum%9==0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 3716
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//BELOW
//-----CODE------//

void solve(void)
{
  int N;cin>>N;
  vector<int> vec (N,0);
  for (int i = 0; i < N; i++)
  {
     cin>>vec[i];
  }
  for (int i = 0; i < N-1; i++)
  {
    vec[i+1] += vec[i];
  }
  map<int,int> mp;
  for (int i = 0; i < N; i++)
  {
    mp[vec[i]]++;
  }
  int res = 0;

  for (auto &&x : mp)
  {
    res += x.second * (x.second - 1)/2;
  }

  cout<<res + mp[0]<<endl;

  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


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

int main(){
	string s;
	cin >> s;
	int total = 700;
	if(s.at(0) == 'o') total += 100; 
	if(s.at(1) == 'o') total += 100; 
	if(s.at(2) == 'o') total += 100; 
	cout << total << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll MOD = (ll)1e9 + 7;
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}

const int N = 200200;
char s[N];
int n, m;
ll dp[N];

void solve1() {
	dp[0] = 0;
	dp[1] = 1;
	for (int i = 1; i <= n + 1; i++) {
		dp[i] = add(dp[i], dp[i - 1]);
		dp[i + 1] = dp[i - 1];
	}
	ll ans = 1;
	for (int i = 2; i <= n; i++)
		ans = add(ans, mult(i, sub(dp[n - i + 1], dp[n - i])));
	printf("%lld\n", ans);
	return;
}

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

	scanf("%d%d", &n, &m);
	scanf("%s", s);
	bool allEq = true;
	for (int i = 1; i < m; i++)
		allEq &= s[i] == s[0];
	if (allEq) {
		solve1();
		return 0;
	}
	if (n & 1) {
		printf("0\n");
		return 0;
	}
	int b = n;
	int lst = -1;
	for (int i = 0; i < m; i++) {
		if (s[i] == s[0]) continue;
		int x = i - lst - 1;
		if (x % 2 == 0) {
			if (lst == -1) b = min(b, x + 2);
		} else {
			b = min(b, x + 1);
		}
		lst = i;
	}
	b /= 2;
	n /= 2;

	dp[0] = 0;
	dp[1] = 1;
	for (int i = 1; i <= n + 1; i++) {
		dp[i] = add(dp[i], dp[i - 1]);
		dp[i + 1] = sub(dp[i], dp[max(0, i - b)]);
	}
	ll ans = 0;
	for (int i = 1; i <= b; i++)
		ans = add(ans, mult(2 * i, sub(dp[n - i + 1], dp[n - i])));
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


// 組み合わせを求める(グローバル汚さない版)
// 上の関数にまとめたバージョン
// nCk mod. p を出したくて、nが<1e7 かつ pが素数(1e9+7は素数)ならおk
// MAX 1e7で1400msぐらいかかるので注意(元版はそれの半分の時間で済む)
// 上と同じ2回目以降はキャッシュされるのでO(1)
// 第三引数は初回のみに使用する。 nCkのnの最大値を入れる(1e6+1推奨)。O(k)を使用する場合は不要
// else O(k) [nが固定されている必要はある]
// O(k)とO(n)の両方を選択することは出来ないのでそういったときはこの関数を命名分けて2個作る必要がある。
long long combination(int n, int k,int init_max_n = -1){
    static vector<ll> fac,finv,inv,big_n_tbl;
    static const int mod = 1e9+7;
    static bool big_n = false;
    if (big_n) cerr << "big_n: trueのため、nは初期時に使用した値(init_max_n)になります。" << endl;
    // 初めて使用したときにテーブルに値を入れていく。
    if (n < init_max_n) {
        // nが1e7+1未満ならO(n)でテーブルを作る
        if ( init_max_n < 1e7+1) {
            fac.resize(init_max_n,0);
            finv.resize(init_max_n,0);
            inv.resize(init_max_n,0);
            fac[0] = fac[1] = 1;
            finv[0] = finv[1] = 1;
            inv[1] = 1;
            for (int i = 2; i < init_max_n; i++){
                fac[i] = fac[i - 1] * i % mod;
                inv[i] = mod - inv[mod%i] * (mod / i) % mod;
                finv[i] = finv[i - 1] * inv[i] % mod;
            }
        } else {
            cerr << "O(n)解法ではTLEすると思うのでO(k)解法で設定します。" << endl;
        }
    }
    // nが大きい場合O(k)でテーブルを作る。
    if(!big_n && n >= 1e7 ) {
        chmin(k,n-k);
        big_n_tbl.resize(k+1,1);
        inv.resize(k+2,1);
        FOR(i,1,k+1){
            inv[i+1] = mod - inv[mod%(i+1)] * (mod/(i+1)) % mod;
            big_n_tbl[i] = (i == 1) ? n : ((n-i+1)*inv[i])%mod * big_n_tbl[i-1];
            if (i==1) cerr<< "i:1 " << big_n_tbl[i] << endl;
            big_n_tbl[i]%=mod;
        }
        big_n = true;
    }
    if (big_n) return big_n_tbl[k];
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
long long modpow(long long a, long long n) {
    long long res = 1;
    static const int mod = 1e9+7;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main() {
    ll n,a,b;
    const int mod = 1e9+7;
    cin >> n >> a >> b;
    ll ans = modpow(2,n)-1;
    ans%=mod; ans += ( ans < 0) ? mod : 0;

    auto cb = combination(n,b,1e6+1);
    auto ca = combination(n,a);
    cerr << "comb[a]: " << ca << endl;
    cerr << "comb[b]: " << cb << endl;

    ans-=ca;
    ans%=mod; ans += ( ans < 0) ? mod : 0;

    ans-=cb;
    ans%=mod; ans += ( ans < 0) ? mod : 0;

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 23680
N = int(input())
a = list(map(int,input().split()))

X = 0
for i in range(N):
    X ^= a[i]
#print(X)

answers = []
for i in range(N):
    #print(i+1,a[i])
    #print()
    answers.append(X^a[i])
    #X=20^a_1
    #X=11^a_2
    #X=9^a_3
    #X=24^a_4

    #0=20^11^9^24^X
print(*answers)

Measured memory_bytes: 31616
#include <iostream>
#include <bits/stdc++.h>
#define loop(N) for(int i=0;i<N;i++)
#define vi vector<int>
#define vs vector<string>
#define vl vector<long long int>
#define vpi vector<pair<int,int>>
#define msi map<string,int>
#define mil map<int,long long int>
#define lli long long int
#define ulli unsigned long long int
using namespace std ;
void ps(string i){
    cout << i << endl;
}

template <class T>
void pt(T s){
    cout << s << endl;
}

void pi(int i){
    cout << i << endl;
}

template <class T>
void pv(vector<T> v){
    loop(v.size()){
        pt<T>(v[i]);
    }
}



/*********************************asserting****************************/

template <class T>
void asserty(T in,T out){

    if(in != out){
        ps("Test not passed:");
        pt<T>(in);
        ps("expected :");
        pt<T>(out);
    }
}

void assertv(vi in,vi out){
    bool equals = true;
    if( in.size()!=out.size()){
        equals = false;
    }else{
        loop(in.size()){
            if(in[i]!=out[i]){
                equals = false;
                break;
            }

        }

    }

    if(!equals){
        ps("Test not passed:");
        pv<int>(in);
        ps("expected :");
        pv<int>(in);
    }
}

/*********************************reused****************************/
ulli l[100];

ulli lucas(int k){
    if(l[k]>0)
        return l[k];
    l[k]=lucas(k-1)+lucas(k-2);
    return l[k];
}
int main()
{
    int n;
    cin >>n;
    loop(n+1){
        l[i]=0;
    }
    l[0]=2;
    l[1]=1;
    cout<<lucas(n)<<endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

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

				if ((H == 0) && (W == 0)) break;

				boolean flag = true;

				for (int i=0; i< H; i++) {
					if (flag) {
						singleL(W);
						flag = false;
					} else {
						doubleL(W);
						flag = true;
					}
				}
				System.out.print('\n');
			}
		}
	}

	static void singleL(int times) {
		boolean flag = true;
		for (int i=0; i < times; i++) {
			if (flag) {
				System.out.print('#');
				flag = false;
			} else {
				System.out.print('.');
				flag = true;
			}
		}
		System.out.print('\n');
	}

	static void doubleL(int times) {
		boolean flag = true;
		for (int i=0; i < times; i++) {
			if (flag) {
				System.out.print('.');
				flag = false;
			} else {
				System.out.print('#');
				flag = true;
			}
		}
		System.out.print('\n');
	}
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  ll n; std::cin >> n;
  ll mi = 1e18;
  rep(i, 5) {
    ll t; std::cin >> t;
    chmin(mi, t);
  }
  std::cout << ((n+mi-1) / mi) + 5 - 1 << "\n";
}


Measured memory_bytes: 256
n, m, q = map(int, input().split())
check = [list(map(int, input().split())) for _ in range(q)]


def calc(r):
    res = 0
    for a, b, c, d in check:
        if r[b-1] - r[a-1] == c:
            res += d
    return res


def dfs(t):
    if len(t) == n:
        return calc(t)

    res = [dfs(t + [i]) for i in range(t[-1], m+1)]

    return max(res)


ans = [dfs([i]) for i in range(1, m+1)]

print(max(ans))



Measured memory_bytes: 9116
#!/usr/bin python3
# -*- coding: utf-8 -*-
# https://atcoder.jp/contests/atc001/tasks/unionfind_a

import sys
sys.setrecursionlimit(10001000)

class UnionFind:
    def __init__(self, n):                      #初期化
        self.n = n                              # 要素数
        self.parents = [i for i in range(n)]    # 親
        self.ranks = [0] * n                    # 木の深さ
        self.sizes = [1] * n                    # グループの要素数

    def find(self, x):              # 親を出力
        if self.parents[x] == x:
            return x
        else:
            p = self.find(self.parents[x])
            self.parents[x] = p
            return p

    def unite(self, x, y):          # ユニオン
        x = self.find(x)
        y = self.find(y)
        if x == y: return
        if self.ranks[x] > self.ranks[y]:
            x , y = y, x    #yを親にする
        if self.ranks[x] == self.ranks[y]:
                self.ranks[y] += 1
        self.parents[x] = y
        self.sizes[y] += self.sizes[x]

    def same(self, x, y):       #xとyが同じグループかどうか
        return self.find(x) == self.find(y)

    def members(self, x):       #xと同じグループの要素
        root = self.find(x)
        return {i for i in range(self.n) if self.find(i) == root}

    def size(self, x):          #グループの要素数
        return self.sizes[self.find(x)]

    def roots(self):            #親の要素一覧
        return {i for i, x in enumerate(self.parents) if i == x}

    def group_count(self):      #グループの個数
        return len(self.roots())

    def all_group_members(self):      #グループのメンバー一覧
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

################

n, m = map(int, input().split())
uf = UnionFind(n)
for _ in range(m):
    a,b = map(int,input().split())
    uf.unite(a-1, b-1)

print(uf.group_count()-1)


Measured memory_bytes: 22428