akhauriyash/Code-Regression huggingface dataset:
#include <set>
#include <cstdio>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))

using namespace std;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int w, h;
char g[1000][1012];
bool reach[1000][1000];

int bfs(int x, int y){
  queue<pair<int, int> > q;
  q.push(make_pair(x, y));

  while(q.size()){
    pair<int, int> data = q.front(); q.pop();
    int xx = data.first;
    int yy = data.second;

    REP(i,4){
      int xxx = xx + _dx[i];
      int yyy = yy + _dy[i];
      if(ISIN(xxx, yyy, w, h) &&
         g[yyy][xxx] == '.' &&
         !reach[yyy][xxx]){
        reach[yyy][xxx] = true;
        q.push(make_pair(xxx, yyy));
      }
    }
  }

  return 0;
}

int main(){
  const int inf = 100000;
  int gx, gy;
  int ans = inf;
  scanf("%d%d", &w, &h);

  REP(i,h) scanf("%s", g[i]);
  REP(i,h) REP(j,w){
    if(g[i][j] == 't'){
      g[i][j] = '.';
      gx = j; gy = i;
    }
  }

  reach[0][0] = true; bfs(0, 0);
  if(reach[gy][gx]) ans = 0;

  int n;
  scanf("%d", &n);
  REP(i,n) if(ans == inf){
    int x, y; scanf("%d%d", &x, &y);
    if(g[y][x] == '#'){
      g[y][x] = '.';
      REP(j,4){
        int xx = x + _dx[j];
        int yy = y + _dy[j];
        if(ISIN(xx, yy, w, h) && reach[yy][xx]){
          reach[y][x] = true;
          bfs(x, y);
          break;
        }
      }
      if(reach[gy][gx]){
        ans = i + 1;
      }
    }
    // REP(i,h){ REP(j,w) printf("%d", reach[i][j]); puts(""); }
  }
  if(ans == inf) ans = -1;
  printf("%d\n", ans);

  return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
    int undern[2];
    double under[2]={999999,999999};
    for(int a = 0; a < 3; a++){
        double place[4] = {999999,999999,999999,999999};
        int    placen[4] = {999999,999999,999999,999999};
        for(int b = 0; b < 8; b++){
            int n;double t;
            cin >> n >> t;
            if(t < place[0]){
                swap(placen[0],n);
                swap(place[0],t);
            }
            if(t < place[1]){
                swap(placen[1],n);
                swap(place[1],t);
            }
            if(t < place[2]){
                swap(placen[2],n);
                swap(place[2],t);
            }
            if(t < place[3]){
                place[3] = t;
                placen[3] = n;
            }
        }
        cout << fixed << setprecision(2) << placen[0] << ' ' << place[0] << endl;
        cout << fixed << setprecision(2) << placen[1] << ' ' << place[1] << endl;
        if(place[2] < under[0]){
            swap(place[2],under[0]);
            swap(placen[2],undern[0]);
        }
        if(place[2] < under[1]){
            swap(place[2],under[1]);
            swap(placen[2],undern[1]);
        }
        if(place[3] < under[0]){
            swap(place[3],under[0]);
            swap(placen[3],undern[0]);
        }
        if(place[3] < under[1]){
            swap(place[3],under[1]);
            swap(placen[3],undern[1]);
        }
    }
    cout << fixed << setprecision(2) << undern[0] << ' ' << under[0] << endl;
    cout << fixed << setprecision(2) << undern[1] << ' ' << under[1] << endl;
    return 0;
}


Measured memory_bytes: 3264
s = input()
b = "abcdefghijklmnopqrstuvwxyz"

if s[0] != "A":
	print ("WA")
	exit()
if s[1] not in list(b) or s[-1] not in list(b):
	print ("WA")
	exit()
flg = 0
for i in range(2,len(s)-1):
	if s[i] == "C":
		if flg == 1:
			print ("WA")
			exit()
		flg = 1
	else:
		if s[i] not in list(b):
			print ("WA")
			exit()
if flg == 0:
	print ("WA")
else:
	print ("AC")

Measured memory_bytes: 3064
#!/usr/bin/env python
# coding: utf-8
#


def main(input_str):
    n = int(input_str)
    for i in range(0, 100):
        h = 7*i
        if n < h:
            break

        if 0 == (n - h) % 4:
            print('Yes')
            return
    print('No')
        
if __name__ == '__main__':
    try:
        main(input().strip())
    except EOFError:
        pass


Measured memory_bytes: 2940
coins = []
for i in range(0, 4):
  coins.append(int(input()))

count = 0

for i in range(0, coins[0] + 1):
  for j in range(0, coins[1] + 1):
    for k in range(0, coins[2] + 1):
      ans = 500*i + 100*j + 50*k
      if ans == coins[3]:
        count += 1
print(count)




Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MOD = 1e9 + 7;

//MAIN 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;
    cin>>n;
    ll a[n][3];
    ll dp[n][3];
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<3;j++)
        {
            cin>>a[i][j];
            dp[i][j] = INT_MIN;
        }
    }
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<3;j++)
        {
            if(i == 0)
            {
                dp[i][j] = a[i][j]; 
            }
            else
            {
                if(j == 0)
                {
                    dp[i][j] = max(dp[i-1][1]+a[i][j] , dp[i-1][2]+a[i][j]);
                }
                else if(j == 1)
                {
                    dp[i][j] = max(dp[i-1][0]+a[i][j] , dp[i-1][2]+a[i][j]);
                }
                else
                {
                    dp[i][j] = max(dp[i-1][0]+a[i][j] , dp[i-1][1]+a[i][j]);
                }
            }
            
        }
    }
    ll ans = max(dp[n-1][0] , max(dp[n-1][1] , dp[n-1][2]));
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 8264
#include<iostream>
#include<map>
#include<algorithm>

using namespace std;

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

	map<string, int> s;
	string S;
	for (int i = 0; i < n; i++) {
		cin >> S;
		s[S]++;
	}

	int m;
	cin >> m;
	string T;

	for (int i = 0; i < m; i++) {
		cin >> T;
		s[T]--;
	}

	int mx = 0;
	for (auto p : s) {
		mx = max(p.second, mx);
	}
	
	cout << mx << endl;

	return 0;
}

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

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

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

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 
int n;
vector <ll> v;
map <pair<int,int>,ll> m2;
ll cal(int m,int x);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    n=nxt();
    v.resize(n);
    generate(all(v),nxtl);
    ll ret=cal(n,n/2);
    cout<<ret<<endl;
    
    
    return 0;   
}


ll cal(int m,int x)
{
    if(x==0)
        return 0;
    ll ret=-1e18;
    ll max2=-1e10;
    for(int i=m-1;i>=2*(x-1);i--)
    {
        max2=max(max2,v[i]);
        ll temp;
        if(m2.find({i-1,x-1})!=m2.end())
            temp=m2[{i-1,x-1}];
        else
        {
            temp=cal(i-1,x-1);
            m2[{i-1,x-1}]=temp;
        }
        temp+=max2;
        ret=max(ret,temp);
    }
    return ret;
}






 
 


Measured memory_bytes: 34328
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'a') {
			continue;
		}

		int t = 26 - (s[i] - 'a');
		if (t <= n) {
			s[i] = 'a';
			n -= t;
		}
	}

	if (n) {
		int t = n % 26;
		s[s.length() - 1] += t;

		if (s[s.length() - 1] > 'z') {
			s[s.length() - 1] -= 'z' - 'a';
		}
	}
	cout << s << endl;

	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
main(){
  int i, j, m, N;
  int r[100];
  scanf("%d",&N);
  for(i=0;i< N;i++)
    scanf("%d",&r[i]);
  for(i=1;i<=N;i++){
    for(j=0;j<N-1;j++)
      printf("%d ",r[j]);
    printf("%d\n",r[j]);
    m=r[i];
    j=i-1;
    while(j>=0&&r[j]>m){
      r[j+1]=r[j];
      j--;
    }
    r[j+1]=m;
  }
  return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<cmath>
#include<cstdio>

using namespace std;

int main(int argc, char const *argv[])
{
    double a,b,c,s,l,h,PI;
    cin >> a >> b >> c;
    PI = acos(-1);
    c = PI*c/180;
    s = a * b * sin(c) * 0.5;
    l = a + b + sqrt( (a*a + b*b - 2*a*b*cos(c)) );
    h = b * sin(c);
    printf("%lf\n%lf\n%lf\n", s,l,h);
    return 0;
}

Measured memory_bytes: 1260
#include<iostream>
#include<stack>
#include<vector>
#include <map>
#include <queue>
#include<string.h>
using namespace std;
typedef pair<int,int> P;
vector<int> node[200];

int que(int s,int d,int v)
{
  queue<P> qu;
  int c[200];
  memset(c,-1,sizeof(c));
  for(int i=0;i<node[s].size();i++)
    {
      if(v-1>0)
	qu.push(P(node[s][i],v-1));      
    }
  while(!qu.empty())
    {
      P a = qu.front();
      qu.pop();
      //      cout<<a.first<<" "<<a.second<<endl;
      if(a.first==d)
	return v-a.second+1;
      for(int i=0;i<node[a.first].size();i++)
	{
	  if(a.second-1>0)
	    {
	      if(c[node[a.first][i]]==-1)
		{
		  c[node[a.first][i]]=a.second-1;
		  qu.push(P(node[a.first][i],a.second-1));	    
		}
	    }
	} 
    }
      return -1;
}
int main()
{
  int n;
  cin>>n;
  for(;n--;)
    {
      int k,t;
      cin>>k>>t;
      for(int i=0;i<t;i++)
	{
	  int tmp;
	  cin>>tmp;
	  node[k].push_back(tmp);
	}
    }
  int p;
  cin>>p;
  for(;p--;)
    {
      int s,d,v;
      cin>>s>>d>>v;
      int ans=que(s,d,v);
      if(ans==-1)
	cout<<"NA"<<endl;
      else
	cout<<ans<<endl;
      
    }
  
}

Measured memory_bytes: 1228
//============================================================================
// Name        : JOI.cpp
// Author      :2015 ho3
// Version     :???11:08
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <queue>
#include <vector>

using namespace std;
int N,M,Q;
typedef pair<int,int> P;
int U[200001];
int V[200001];
int UV[200001]={};

vector<int> C[100001];
vector<int> C2[100001];
int R[200001];
int dp[100001]={};
int man[100001]={};
const int INF=10000000;

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

	for(int i=1;i<M+1;++i){
		cin>>U[i]>>V[i];
		C[U[i]].push_back(i);
		C[V[i]].push_back(i);
	}
	for(int i=0;i<Q;++i)cin>>R[i];
	for(int i=2;i<N+1;++i)dp[i]=INF;

	priority_queue<P,vector<P>,greater<P>> que;
	que.push(P(0,1));
	P p1;
	int cost,to,to2;
	while(que.size()){
		p1=que.top();que.pop();
		cost=p1.first;
		to=p1.second;
		if(cost>dp[to])continue;
		dp[to]=cost;
		for(auto it=C[to].begin();it<C[to].end();++it){
			to2=U[*it];
			if(to2==to)to2=V[*it];
			if(cost+1<dp[to2]){
				que.push(P(cost+1,to2));
				dp[to2]=cost+1;
			}else if(cost+1>dp[to2]){
				C2[to].push_back(*it);
				C[to].erase(it);
				it-=1;
			}
		}
	}

	int total=0;
	int sum,flg;
	man[1]=1;
	queue<int> que2;
	for(int i=0;i<Q;++i){
		sum=0;
		UV[R[i]]=1;
		to=V[R[i]];
		to2=U[R[i]];
		que2.push(to);
		que2.push(to2);

		while(que2.size()){
			to=que2.front();que2.pop();
			flg=0;

			if(man[to]>0)continue;
//			cout<<to<<endl;

			for(auto it=C2[to].begin();it!=C2[to].end();++it){
				//if(*it==R[i]){
				//	C2[to].erase(it);
				//	it-=1;
				//	continue;
				//}
				to2=U[*it];
				if(to2==to)to2=V[*it];
				if(dp[to2]+1+UV[*it]<=dp[to]){
					flg=1;
					break;
				}
			}

			if(flg==0&&to>1){
				if(man[to]==0){
					man[to]=1;
					sum+=1;
				}
				for(auto it:C[to]){
					to2=U[it];
					if(to2==to)to2=V[it];
					que2.push(to2);
				}
				dp[to]+=1;
			}
		}
		total+=sum;
//		cout<<dp[2]<<":"<<dp[3]<<":"<<dp[4]<<":"<<dp[5]<<endl;
		cout<<total<<endl;
	}
	return 0;
}

Measured memory_bytes: 18916
fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map{it.toInt()}
    val A = readLine()!!.split(" ").map{it.toLong()}.sorted()

    val MOD = 1e9.toLong() + 7L
    val comb = ModCombination(100010, MOD)

    var res = ModInt(0L, MOD)

    for (i in A.indices) {
        if (i <= A.size - K) {
            res -= comb[A.size - i - 1L, K - 1L] * A[i]
        }

        if (i >= K - 1) {
            res += comb[i.toLong(), K - 1L] * A[i]
        }
    }

    println(res.value)
}

class ModInt (value: Long, val mod: Long) {
    init {
        if (mod <= 0) {
            throw IllegalArgumentException("ModInt cannot be created for non-positive modulus: $mod")
        }
    }

    val value = (value % mod + mod) % mod

    private fun assertSameMod(other: ModInt) {
        if (mod != other.mod) {
            throw IllegalArgumentException(
                "You cannot operate summation, subtraction and multiplication for ModInts with different moduli: $mod, ${other.mod}"
            )
        }
    }

    operator fun unaryMinus() = ModInt(mod - value, mod)

    operator fun plus(other: ModInt): ModInt {
        assertSameMod(other)

        return ModInt((value + other.value) % mod, mod)
    }

    operator fun plus(other: Long) = plus(ModInt(other, mod))

    operator fun minus(other: ModInt): ModInt {
        assertSameMod(other)

        return plus(-other)
    }

    operator fun minus(other: Long) = minus(ModInt(other, mod))

    operator fun times(other: ModInt): ModInt {
        assertSameMod(other)

        return ModInt((value * other.value) % mod, mod)
    }

    operator fun times(other: Long) = times(ModInt(other, mod))

    fun pow(k: Long): ModInt {
        var res = 1L
        var a = value
        var l = k

        while (l > 0) {
            if ((l and 1L) == 1L) {
                res = (res * a) % mod
            }

            a = a * a % mod
            l /= 2L
        }

        return ModInt(res, mod)
    }

    /**
     * Returns an inverse element of the value.
     * To ensure `m * m.inv() = 1`, the modulus should be prime, since it uses Fermat's little theorem.
     */
    fun inv() = pow(mod - 2)

    operator fun div(other: ModInt): ModInt {
        assertSameMod(other)
        if (other.value == 0L) {
            throw ArithmeticException()
        }

        return times(other.inv())
    }

    operator fun div(other: Long) = div(ModInt(other, mod))
}

class ModCombination(val n: Long, val mod: Long) {
    private val fact = Array(n.toInt() + 1) { ModInt(1, mod) }
    private val invfact = Array(n.toInt() + 1) { ModInt(1, mod) }

    init {
        for (i in 2..n.toInt()) {
            fact[i] = fact[i - 1] * i.toLong()
            invfact[i] = fact[i].inv()
        }
    }

    operator fun get(n: Long, m: Long): ModInt {
        if (m > n) {
            return ModInt(0, mod)
        }

        return fact[n.toInt()] * invfact[m.toInt()] * invfact[(n - m).toInt()]
    }
}


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

using namespace std;

map<string, int> s;

int main() {
    string tmp;
    int n;

    cin >> n;
    s["WA"] = 0;
    s["AC"] = 0;
    s["TLE"] = 0;
    s["RE"] = 0;

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

    cout << "AC x " << s["AC"] << "\n";
    cout << "WA x " << s["WA"] << "\n";
    cout << "TLE x " << s["TLE"] << "\n";
    cout << "RE x " << s["RE"] << "\n";
}


Measured memory_bytes: 3628
#include<iostream>
using namespace std;
 
int main(){
    int n, m, l;
    cin >> n >> m >> l;
    int a[101][101], b[101][101];
    long int c[101][101] = {0};
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }
    for(int j = 0; j < m; j++){
        for(int k = 0; k < l; k++){
            cin >> b[j][k];
        }
    }
    for(int i = 0; i < n; i++){
        for(int k = 0; k < l; k++){
            for(int j = 0; j < m; j++) c[i][k] += a[i][j] * b[j][k];
        }
        for(int k = 0; k < l-1; k++) cout << c[i][k] << ' ';
        cout << c[i][l-1] << endl;
    }
    return 0;
}

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

using namespace std;

int main()
{int ts, th, as, ah, flow(1);
cin>>th>>ts>>ah>>as;
while (th>0 and ah>0)
{ if (flow%2!=0){
  ah-=ts;
flow++;
continue;
}
 else th-=as;
flow++;
}
if (ah<=0)cout<<"Yes";
else cout<<"No";

}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
long long a,b;
void solve()
{
    long long x;
    if (a>b) {x=a;a=b;b=x;}
    if ((a+b)%2==0) cout<<(a+b)/2;
    else cout<<"IMPOSSIBLE";
    cout<<endl;
}
int main()
{
    while(cin>>a>>b)
        solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 998244353
typedef long long ll;
using namespace std;

int main(){
  string s;
  cin>>s;
  int n=s.size();
  ll red[2*n+1]={};
  ll blue[2*n+1]={};
  for(int i=1;i<=n;i++){
    if(s[i-1]=='0') red[i]+=2;
    else if(s[i-1]=='2') blue[i]+=2;
    else{
      red[i]++;
      blue[i]++;
    }
    red[i]+=red[i-1];
    blue[i]+=blue[i-1];
  }
  for(int i=n+1;i<=2*n;i++){
    red[i]=red[i-1];
    blue[i]=blue[i-1];
  }

  int m=2*n;
  ll dp[m+1][m+1]={};
  dp[0][0]=1;
  for(int i=1;i<=m;i++){
    for(int j=0;j<=m;j++){
      if(red[i]<j||i<j) continue;
      if(red[i]>j&&j<m){
        dp[i][j+1]=dp[i][j+1]+dp[i-1][j];
        dp[i][j+1]%=MOD;
      }
      if(blue[i]<i-j) continue;
      dp[i][j]=dp[i][j]+dp[i-1][j];
      dp[i][j]%=MOD;
    }
  }

  ll ans=0;
  for(int i=0;i<=m;i++){
    ans=ans+dp[m][i];
    ans%=MOD;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 125312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
const ll INF = 1000000000000000000;
// const ll MOD = 1000000007;

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

	int n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	ll dp[n][n];
	for(int i=0;i<n;i++)
		dp[i][i] = 0;
	for(int k=1;k<n;k++){
		for(int i=0;i<n-k;i++){
			// dp[i][i+k] = min(dp[i][i+j-1]+dp[i+j][i+k]);
			dp[i][i+k] = INF;
			for(int j=1;j<=k;j++)
				dp[i][i+k] = min(dp[i][i+k],dp[i][i+j-1]+dp[i+j][i+k]);
			for(int j=i;j<=i+k;j++)
				dp[i][i+k] += a[j];
		}
	}
	
	cout<<dp[0][n-1]<<endl;
}


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

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

vector<pair<long long, int>> factor(long long a){
    vector<pair<long long, int>> v;
    for(long long i=2; i*i <=a; i++){
        if(a % i != 0) continue;
        int num = 0;
        while(a % i == 0){
            num++;
            a /= i;
        }
        v.push_back({i, num});
    }
    if(a != 1) v.push_back({a, 1});
    return v;
}

int main()
{
    long long a,b;
    cin >> a >> b;
    auto g = gcd(a, b);
    cout << factor(g).size() + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  for (int i = 0; i < a.size()+b.size(); i++) {
    if (i % 2 == 0) {
      cout << a[i/2];
    }
    else {
      cout << b[i/2];
    }
  }
}

Measured memory_bytes: 3588
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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)*}
    };
}

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)*}
    };
}

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:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

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

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(a: i32, b: i32, c: i32);
    puts!("{}\n", c - min(c, a - b));
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
while True:
    n, m = map(int, raw_input().split())

    if n == 0 and m == 0:
        break

    a = map(int, raw_input().split())

    ans = -1

    for i in range(n-1):
        for j in range(i+1, n):
            if a[i] + a[j] <= m:
                ans = max(ans, a[i] + a[j])

    print "NONE" if ans == -1 else ans



Measured memory_bytes: 4712
#include <bitset>
#include <iostream>

int main(void) {
    int q;
    std::cin >> q;

    std::bitset<64> bitset{};
    for (int time = 0; time < q; ++time) {
        int kind;
        std::cin >> kind;

        int i;
        switch (kind) {
            case 0:
                std::cin >> i;
                std::cout << bitset.test(i) << std::endl;
                break;
            case 1:
                std::cin >> i;
                bitset.set(i);
                break;
            case 2:
                std::cin >> i;
                bitset.reset(i);
                break;
            case 3:
                std::cin >> i;
                bitset.flip(i);
                break;
            case 4:
                std::cout << bitset.all() << std::endl;
                break;
            case 5:
                std::cout << bitset.any() << std::endl;
                break;
            case 6:
                std::cout << bitset.none() << std::endl;
                break;
            case 7:
                std::cout << bitset.count() << std::endl;
                break;
            case 8:
                std::cout << bitset.to_ullong() << std::endl;
        }
    }
}


Measured memory_bytes: 3084
#include <iostream>
using namespace std;
int main(void){
    int shotoku[10000];

    while(true){
        int sum=0;
        int s=0;
        int n;
        cin >> n;
        if(n==0)break;
        for(int i=0;i<n;i++){
            cin >> shotoku[i];
            sum += shotoku[i];
        }
        int x=sum/n;
        for(int j=0; j<n;j++){
            if(shotoku[j]<=x){
            s=s+1;
        }
        else{
        }
        }
    cout << s << endl;

    }
}



Measured memory_bytes: 3092
import itertools as it
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

all_num_list = list(it.permutations(range(1,N+1)))
all_num_list.sort()

P_num = all_num_list.index(P)
Q_num = all_num_list.index(Q)

print (abs(P_num-Q_num))

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

int main() {
	char b;
	cin >> b;
	if (b == 'A') {
		cout << 'T' << endl;
	}
	else if (b == 'T') {
		cout << 'A' << endl;
	}
	else if (b == 'C') {
		cout << 'G' << endl;
	}
	else {
		cout << 'C' << endl;
	}
	return 0;
}

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

#define _USE_MATH_DEFINES
#define reb(i,b,n)         for(int i=(int)(b); i<(int)(n); i++)
#define rep(i,n)           reb(i,0,n)
#define each(it,v)         for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define reach(it,v)        for(__typeof((v).rbegin()) it=(v).rbegin();it!=(v).rend();it++)
#define vsort(v)           sort((x).begin(), (x).end()
#define rvsort(v)          sort((x).rbegin(), (x).rend()
#define mp(a, b)           make_pair(a, b)
#define fi                 first
#define se                 second
#define pb                 push_back
#define dbg(x)             cerr<<__LINE__<<": "<<#x<<" = ["<<(x)<<"]"<<endl;
#define dbgArr(table, n)   rep(i,n){cout<<table[i]<<' ';}cout<<'\n';
#define dbg2Arr(table,W,H) rep(y,H){rep(x,W)cout<<table[y][x]<<' ';cout<<'\n';}

using namespace std; using std::stringstream;

typedef long long       ll; typedef unsigned long long ull; typedef long double     ld;
typedef pair <int, int> P;  typedef pair <int, P>      PP;
typedef vector<int>     vi; typedef vector<vi>         vvi; typedef vector<ll>      vl;
typedef vector<P >      vP; typedef vector<char>       vc;  typedef vector<string>  vs;

static const int    INF  = 0x3f3f3f3f;
static const ll     INFL = 0x3f3f3f3f3f3f3f3fLL;
static const double EPS  = 1e-9;
static const ll     MOD  = 1000000007LL;

static const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main(int argc, char *argv[])
{
    ll N;
    cin >> N;

    map<int, int> m;
    ll ans=0;
    rep(i, N) {
        ll A;
        cin >> A;
        ans += m[i-A];
        m[i+A]++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 20436
N, Q = map(int, input().split())
S = input()
lr = [list(map(int, input().split())) for i in range(Q)]

count = [0]

for i in range(1, N):
    count.append(count[i - 1])
    if S[i] == "C" and S[i - 1] == "A":
        count[i] += 1


for i in range(Q):
    print(count[lr[i][1] - 1] - count[lr[i][0] - 1])


Measured memory_bytes: 30716
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<map>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1000000000 + 7, INF = 1e18;

map< int64_t, int > prime_factor(int64_t n) {
	map< int64_t, int > ret;
	for (int64_t i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}
lint N, A, cnt = 0;
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N;
	REP(i, N) {
		cin >> A;
		auto mp = prime_factor(A);
		cnt += mp[2];
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3624
#include<stdio.h>
#include<stdbool.h>
bool isPrime(int x){
  int i;
  if(x < 2) return false;
  else if (x == 2) return true;
  if(x%2 == 0) return false;
  for(i=3; i*i<=x; i+=2){
    if(x%i == 0) return false;
  }
  return true;
}

int main(){
  int n,x,i;
  int cnt = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&x);
    if(isPrime(x)) cnt++;
  }
  printf("%d\n",cnt);
  return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
using str=string;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

ll lcm(ll a,ll b){
    return (a*b/gcd(a,b));
}

int main(){
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >>k;
    double ans=0;
    for(int i=1;i<=n;i++){
        double count=0;
        int tmp=i;
        while(tmp<k){
            tmp*=2;
            count++;
        }
        ans+=pow(0.5,count);
    }
    printf("%.10lf", ans/n);
    return 0;
}

Measured memory_bytes: 256
from collections import deque
n=int(input())
a=list(map(int,input().split()))

a.sort(reverse=True)                    

comfort=0
q=deque()
q.append(a[0])
for i in range(1,n):
    comfort=comfort+q.popleft()
    q.append(a[i])
    q.append(a[i])

print(comfort)    

Measured memory_bytes: 32460
#include<bits/stdc++.h>
using namespace std;
#define V vector
#define L long
#define W V<L>
#define R(n)for(L i=0;i<n;i++)
L E=70;W S(V<W>p){if(!E){return{1,0};}V<V<W>>T(2);for(W x:p){T[x[1]&1].push_back({x[0]/2,x[1]/2});if(x[0]&1){T[(x[1]+1)&1].push_back({x[0]/2,(x[1]+1)/2});}}R(2){L c=0;for(W x:T[!i]){L Q=(2*x[0]+x[1])%3;c^=Q+1;}if(!c){E--;W A=S(T[i]);A[0]*=2;A[1]*=2;A[1]+=i;return A;}}for(W&v:p){v[0]++;}W A=S(p);A[0]--;return A;}int main(){L M=2e17,n,a,b;cin>>n;V<W>p(n);R(n){cin>>a>>b;p[i]={a+M,b+M};}W x=S(p);cout<<x[0]-M<<" "<<x[1]-M;}

Measured memory_bytes: 62908
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int a, b, c; cin >> a >> b >> c; std::pair<int, int> p = {b, c};
	int A, B, C; cin >> A >> B >> C; std::pair<int, int> P = {B, C};
	if(a > A) {
		std::swap(a, A);
		std::swap(p, P);
	} else if(a == A) {
		if(p.first > P.first) std::swap(p, P);
		else if(p.first == P.first and p.second > P.second) std::swap(p, P);
	}
	
	if(P > p) cout << A - a + 1 << endl;
	else cout << A - a << endl;
	return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
#include <array>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vsort(x) sort(x.begin(),x.end())

using int64 = uint64_t;

using namespace std;

int main() {
	int a[3], b[2];
	cin >> a[0] >> a[1] >> a[2] >> b[0] >> b[1];
	int mini[2] = { INF,INF };
	rep(i, 0, 3)
		mini[0] = min(mini[0], a[i]);
	mini[1] = min(b[0], b[1]);
	cout << mini[0] + mini[1] - 50 << endl;
	return 0;
}

Measured memory_bytes: 3080
N, K = map(int, input().split())
mod = 10**9+7

sum_left = list(range(N+1))
sum_right = list(range(N+1))[::-1]

for i in range(1, N+1):
    sum_left[i] += sum_left[i-1]

for i in range(1, N+1):
    sum_right[i] += sum_right[i-1]

ans = 0
for i in range(K-1, N+1):
    ans += sum_right[i] - sum_left[i] + 1
    ans %= mod

print(ans)

Measured memory_bytes: 30080
#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 n;
    cin >> n;
    int h, m, s;
    h = n / 3600;
    m = (n % 3600) / 60;
    s = (n % 3600) % 60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <stack>
#include <queue>
#include <map>
#include <vector>
#include <cstdio>
#include <string>
#include <climits>
#include <cmath>
#include <cstring>
#include <iomanip>
 
using namespace std;
 
long long int gcd(long long int n, long long int m){
    if(m == 0)return n;
    return gcd(m, n%m);
}
 
int main(){
    int n;
    cin>>n;
    long long int ans, x;
    for(int i = 1; i <= n; i++){
        cin>>x;
        if(i == 1){
            ans = x;
            continue;
        }
        long long int tmp = gcd(ans, x);
        ans /= tmp;
        ans *= x;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 400010
#define MOD 1000000007
using namespace std;
typedef long long ll;
ll h,w,a,b;
ll nq[MAXN],inv[MAXN];
ll fsp(ll x,int y){
	ll res=1;
	while(y){
		if(y&1)
			res=res*x%MOD;
		x=x*x%MOD;
		y>>=1;
	}
	return res;
}
ll C(int n,int m){
	return nq[n]*inv[m]%MOD*inv[n-m]%MOD;	
}
int main(){
	SF("%lld%lld%lld%lld",&h,&w,&a,&b);
	nq[0]=1;
	for(int i=1;i<=400000;i++)
		nq[i]=nq[i-1]*i%MOD;
	inv[400000]=fsp(nq[400000],MOD-2);
	for(int i=400000;i>0;i--)
		inv[i-1]=inv[i]*i%MOD;
	ll ans=0;
	for(int i=0;i<w-b;i++){
		ans+=C(a+i-1,i)*C(h-a+w-i-2,w-i-1)%MOD;
		ans%=MOD;
		//PF("{%d %lld %lld}",i,C(a+i-1,i),C(h-a+w-i-2,w-i-1));
	}
	PF("%lld",ans);
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define deb(x) cout << #x << " " << x << endl;
#define PI 3.14159265358979323846264338327950L
#define fi(i,a,b) for(int i = a; i<b; i++)
#define ull unsigned long long
#define all(x) x.begin(), x.end()
#define ll long long int
#define ld long double
#define pii pair<int, int>
#define F first
#define S second
#define vi vector<int>
#define N 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
using namespace std;

//*************************************************************************************

void solve()
{
	int n; cin >> n; unordered_map<int, int> arr; ll ans = 0;
	fi (i, 0, n) {

		int curr; cin >> curr;
		arr[curr]++;
	}
	for (auto it : arr) {

		int x = it.S, y = it.F;
		if (x >= y) {ans += x - y;}
		else {ans += x;}
	}
	cout << ans << endl;
}

int main() {

#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif

	IOS;

	int t = 1; //cin >> t;
	fi(i, 0, t) {solve();}
	return 0 ;
}


Measured memory_bytes: 7256
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> vec;
#define INF (1<<20)

int main(){
	int n;
	while( cin >> n, n ){
		vec data(n);
		for( int i = 0; i < n; i++ ){
			cin >> data[i];
		}
		int ans = -INF;
		vector<vec> dp(n, vec(n));
		for( int i = 0; i < n; i++ ){
			for( int j = i; j < n; j++ ){
				if( i == 0 ){
					if( j == 0 ) dp[0][0] = data[0];
					else dp[0][j] = dp[0][j-1] + data[j];
					ans = max(ans, dp[i][j]);
				}else{
					//if( i <= j ){
						dp[i][j] = dp[i-1][j] - data[i-1];
						ans = max(ans, dp[i][j]);
					//}
				}
			}
		}
		/*for( int i = 0; i < n; i++ ){
			for( int j = 0; j < n; j++ ){
				printf("%4d", dp[i][j]);
			}
			cout << endl;
		}
		*/
		cout << ans << endl;
	}
}

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

typedef long long ll;
using namespace std;

ll square(ll a){
    ll i = 1;
    while(a > i*i)
        i++;
    
    if(i*i > a)
        i--;

    return i*i;
}
int main(){
    ll n; scanf("%lld",&n);
    printf("%lld\n",square(n));
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;



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

    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int vx = x2-x1;
    int vy = y2-y1;

    int x = x2;
    int y = y2;

    rep(i, 2) {
        int nvx = -vy;
        int nvy = vx;
        x += nvx;
        y += nvy;
        cout << x << ' ' << y << ' ';
        vx = nvx;
        vy = nvy;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <numeric>
#include <math.h>

using namespace std;

int main() {
	long int N;
	long int T, A;
	long int temp;
	vector<long int> H;
	float ans;
	float t_ans;
	int ans_num;

	cin >> N;
	cin >> T >> A;

	H.push_back(-1);
	for (int i = 1; i <= N; i++) {
		cin >> temp;

		H.push_back(temp);
	}

	ans = T - H[1] * 0.006;
	ans_num = 1;
	for (int i = 2; i <= N; i++) {
		t_ans = T - H[i] * 0.006;
		if(fabs(ans-A) > fabs(t_ans - A)){
			ans = t_ans;
			ans_num = i;
		}
	}


	cout << ans_num << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{	
	int n,x,y,a,b,c,d;
	scanf("%d",&n);
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	x=n/a*b;
	y=n/c*d;
	if(n%a>0){
		x=x+b;
	}
	if(n%c>0){
		y=y+d;
	}
	if(x<y){
		printf("%d\n",x);
	}
	else{
		printf("%d\n",y);
	}
	
	return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
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; }
//get the biggest element.
template<typename KeyType, typename ValueType>
std::pair<KeyType,ValueType> get_max( const std::map<KeyType,ValueType>& x ) {
  using pairtype=std::pair<KeyType,ValueType>;
  return *std::max_element(x.begin(), x.end(), [] (const pairtype & p1, const pairtype & p2) {
        return p1.second < p2.second;
  });
}
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;

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

  string s = "";
  while (n) {
    --n;
    s += ('a' + n % 26);
    n /= 26;
  }

  reverse(s.begin(), s.end());
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3588
package main

import (
	"fmt"
)

func div(t int) int {
	count := 0
	for i := 1; i <= t; i++ {
		if t%i == 0 {
			count++
		}
	}
	return count
}

func main() {
	var n int
	fmt.Scan(&n)
	c := 0
	for i := 1; i <= n; i += 2 {
		if div(i) == 8 {
			c++
		}
	}
	fmt.Println(c)
}


Measured memory_bytes: 512
/*_BELIEVE_*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int          long long int
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     __gcd((a),(b))
#define     lcm(a,b)     ((a)*(b))/gcd((a),(b))
#define     pb           push_back
#define     ins          insert
#define     F            first
#define     S            second

const int inf=1e18,M=1e9+7;
const int N=1e6;

void solve()
{
    int k,x;

    cin>>k>>x;

    for(int i=max(-N,x-k+1);i<=min(N,x+k-1);++i)
        cout<<i<<" ";

}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }

    return 0;
}



Measured memory_bytes: 256
n, a, b = map(int, input().split())
MOD = 10**9 + 7

# a//b (MOD p)
def div_mod(a, b, p = MOD):
    return (a * pow(b, p-2, p)) % p

def cmb(n, r, p = MOD):
    tmp = 1
    i = n
    while i > n - r:
        tmp *= i
        tmp %= p
        i -= 1
    for i in range(1, r+1):
        tmp = div_mod(tmp, i, p)
    return tmp

ans = pow(2, n, MOD) - cmb(n, a) - cmb(n, b) - 1
print(ans % MOD)

Measured memory_bytes: 38976
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

	if(1<=a && a<=9 && 1<=b && b<=9) cout<<(a*b)<<endl;
	else cout<<(-1)<<endl;

	return 0;
}


Measured memory_bytes: 3632
from collections import defaultdict
import heapq
n,m=map(int,input().split())
dic=defaultdict(list)
for i in range(n):
    a,b=map(int,input().split())
    dic[a].append(-b)
    
li=[]
ans=0

for i in range(1,m+1):
    if dic[i]:
        for j in dic[i]:
            heapq.heappush(li,j)
    if li:
        ans+=heapq.heappop(li)
print(-ans)

Measured memory_bytes: 27676
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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 ll = long long;

ll N, W;
ll w[110], v[110];
ll dp[110][110][330];
ll ans, sum;

int main()
{
  std::cin >> N >> W;

  rep( i, N )
    std::cin >> w[i] >> v[i], sum += w[i]-w[0];

  rep( i, N ) rep( j, i+1 ) rep( k, std::min(W-j*w[0],sum)+1 )
  {
    chmax( dp[i+1][j][k], dp[i][j][k] );

    if( k+w[i]-w[0]+w[0]*(j+1) <= W )
      chmax( dp[i+1][j+1][k+w[i]-w[0]], dp[i][j][k]+v[i] );
  }

  rep( j, N+1 ) rep( k, std::min(W-j*w[0],sum)+1 )
    chmax( ans, dp[N][j][k] );

  std::cout << ans << std::endl;

  return 0;
}

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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  int n;
  const int max_n = 2 * 1e5;
  char c[max_n + 1];
  cin >> n;
  for(int i = 0; i < n; i++) cin >> c[i];

  int Rcnt = 0;
  for(int i = 0; i < n; i++){
    if(c[i] == 'R') Rcnt ++;
  }
  int cnt = 0;
  // Rcnt --;
  for(int i = Rcnt; i < n; i++){
    if(c[i] == 'R') cnt ++;
  }
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 3792
function Main(input) {
	input = input.trim().split("\n").map(function(x) { return x.split(" ")});
	let N = parseInt(input[0][0], 10);
	let A = input[1].map(e => parseInt(e, 10));
	let Amap = Array.from({length: 1e6 + 1}, () => false);
	let ansFlag0 = false;
	let N2 = N;
	let variation = 0;
	for (let i = 0; i < N; i++){
		if (Amap[A[i]]){
			if (A[i] !==1) ansFlag0 = true;
			N2 --;
			continue;
		}
		Amap[A[i]] = true;
		variation ++;
	}

	let bitmap = Array.from({length: 1e6 + 1}, () => false);
	bitmap[0] = true;
	bitmap[1] = true;

	
	// let ansFlag1 = false;
	let countList = [];
	for (let i = 2; i < bitmap.length; i++){
		if (bitmap[i]) continue;
		let count = 0;
		let j = 1;
		if (Amap[i * j]){
			count ++;
		}
		for (j = 2; j <= (1e6 / i); j++){
			bitmap[i * j] = true;
			if (Amap[i * j]){
				count ++;
			}

		}
		countList.push(count);
	}
	countList.sort((a,b) => a - b);
	let ans = "pairwise coprime";
	if (ansFlag0) ans = "setwise coprime";
	for (let i = 0; i < countList.length; i++){
		if (countList[i] <= 1) continue;
		if(countList[countList.length - 1] < N2){
			ans = "setwise coprime";
		} else {
			ans = "not coprime";
		}
	}
	if (variation === 1){
		if (A[0] === 1) ans = "pairwise coprime";
		else ans = "not coprime";
	}
	console.log(ans);
	
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 112864
local function str2tbl(s)
    local t = {string.byte(s, 1, #s)}
    for i=1, #t do
        t[i] = string.char(t[i])
    end
    return t
end
--
local N,_,S = io.read("n", "l", "l")
local B = '#'
local W = '.'
S = str2tbl(S)
local tbl = {}
for i=1,N+1 do
    table.insert(tbl, {})
end
local bs = 0
for i=1,N do
    local t = tbl[i]
    t.bs = bs
    if S[i] == B then
        bs = bs + 1
    end
end
tbl[N+1].bs = bs
local ws = 0
tbl[N+1].ws = 0
for i=N,1,-1 do
    local t = tbl[i]
    if S[i] == W then
        ws = ws + 1
    end
    t.ws = ws
end
local ans = N+1
for i=1,N+1 do
    local t = tbl[i]
    ans = math.min(ans, t.bs + t.ws)
end
print(ans)

Measured memory_bytes: 36472
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MAXSIZE 10000000;

bool comp(const pair<string,int> a, const pair<string,int> b) {
  if (a.first != b.first)
    return a.first < b.first; // 高い順に並べたいので演算子を逆に
  else{
      return a.second > b.second;
  }
}

int Dx[6] = { 0, 0, 1, 1,-1,-1};
int Dy[6] = { 1,-1, 1, 0, 0,-1};

//priority_queue<long long int,vector<long long int>, greater<long long int>> PQ;
//priority_queue<long long int> PQ1;
int main(){
    int N,X;
    int L[101] = {0};

    cin >>N>>X;

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

    int D = 0,num = 1;

    for(int i = 0;i<N;i++){
      D+=L[i];
      if(D > X){
        break;
      }
      num++;
    }

    cout <<num<<endl;




    return 0;
}

/*Syakutori
while(cin >>b && b)){
      ll t = 1;
      long long int ansS = 1,ansT=0;
      long long int sum = 0;

      for(ll s = 1;s < 50000000;s++){

        while(t <  50000000 && sum+Rsum[t] < b){
          sum += Rsum[t];
          t++;
        }
        if(b == sum+Rsum[t]){
          if(ansT - ansS < t-s){
            ansS = s;
            ansT = t;
          }
          cout <<ansS<<" "<<ansT-ansS + 1<<endl;
          break;
        }
        if(t == s)++t;
        else sum -= Rsum[s];
        }
    }

*/

Measured memory_bytes: 256
import numpy as np

n = int(input())
a = np.array([int(x) for x in input().split()])
inf = 10**9+7

ans = 0
p = 1
for i in range(61):
    a, b = a//2, a%2
    key = int(b.sum())
    ans += p*(n-key)*key
    ans = ans%inf
    p *= 2
    p %= inf
print(ans)

Measured memory_bytes: 48836
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>


using ll = long long;
typedef std::pair<int, int>p;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);

}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
bool flag = true;
struct edge { int to, cost; };
std::vector<edge>v[100];
bool u[100];



int main() {
	int n, k, a[11];
	std::cin >> n >> k;
	for (int i = 0;i < k;i++) {
		std::cin >> a[i];
	}
	for (int i = n;i <= 10 * n;i++) {
		for (int j = i;j > 0;j /= 10) {
			for (int l = 0;l < k;l++) {
				if (j % 10 == a[l]) {
					flag = false;
				}
			}
		}
		if (flag) {
			std::cout << i << std::endl;
			break;
		}
		flag = true;
	}
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long

int main(void)
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    bool t=false;
    while(true){
        c-=b;
        if(c<=0){
            t=true;
            break;
        }
        a-=d;
        if(a<=0) break;
    }
    if(t) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
} 

Measured memory_bytes: 3592