akhauriyash/Code-Regression huggingface dataset:
/*input
8 6
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	int n;
	cin>>n;
	cout<<n*2/__gcd(2,n);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define IN(a) int a;scanf("%d",&a);
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define STRS(i,str) for(int i=0;(str)[i];i++)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX3(a,b,c) ((a)>(b)?(a)>(c)?(a):(c):(b)>(c)?(b):(c))
#define MIN3(a,b,c) ((a)<(b)?(a)<(c)?(a):(c):(b)<(c)?(b):(c))
#define RANGE(a,b) ((a)>(b)?(a)-(b):(b)-(a))
#define RANGE3(a,b,c) ((a)>(b)?(b)>(c)?(a)-(c):(c)>(a)?(c)-(b):(a)-(b):(b)>(c)?(c)>(a)?(b)-(a):(b)-(c):(c)-(a))
#define MAXI(a,b) if(a<b)a=b;
#define MINI(a,b) if(a>b)a=b;

int main(void){
	int n, k;
	int l[60];
	int ans = 0;
	scanf("%d%d", &n, &k);
	REP(i, n + 1) l[i] = 0;

	scanf("%d", l);
	FOR(i, 1, n){
		scanf("%d", l + i);
		int j = i;
		while(l[j] > l[(j - 1)/2]){
			int tmp = l[j];
			l[j] = l[(j - 1)/2];
			l[(j - 1)/2] = tmp;
			j = (j - 1)/2;
		}
	}

#ifdef DEBUG
	REP(i, n) printf("%d ", l[i]);
	putchar('\n');
#endif

	int size = n;
	REP(i, k){
		size--;
		ans += l[0];
		l[0] = l[size];
		int j = 0, tmp = l[j];
		for(;;){
			if((j*2 + 1 < size && l[j*2 + 1] > l[j*2 + 2] || j*2 + 1 == size) && l[j] < l[j*2 + 1]){
				l[j] = l[j*2 + 1];
				l[j*2 + 1] = tmp;
				j = j*2 + 1;
			}else if(j*2 + 1 < size && l[j] < l[j*2 + 2]){
				l[j] = l[j*2 + 2];
				l[j*2 + 2] = tmp;
				j = j*2 + 2;
			}else break;
		}
		
		#ifdef DEBUG
		REP(m, size) printf("%d ", l[m]);
		putchar('\n');
		#endif
	}

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

	return 0;
}

Measured memory_bytes: 128
#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 INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int 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 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    int n,m;cin>>n>>m;
    cout<<(n==m?"Yes":"No")<<endl;
    return 0;
}


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

int main() {
    int N, K, X, Y,sum=0;
    cin >> N >> K >> X >> Y;
    if(N < K){
        cout << N*X << endl;
    }
    else {
        sum = K*X;
        sum = sum + (N-K)*Y;
        cout << sum << endl;
    }

}

Measured memory_bytes: 3588
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <functional>
#include <numeric>
#include <cassert>
#include <algorithm>
#include <functional>
//#include "bits/stdc++.h"
using namespace std;
//using namespace std::vector;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)

#define huge 1000000007
typedef long long int ll;
ll gcd(ll a, ll b);
ll bur(ll N, ll X);


int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll D = 0;
	ll X = 0;
	//ll T = 0;
	//ll M = 0;
	ll h[1000] = {};
	//ll b[100] = {};
	//ll c[100] = {};
	//ll d[100] = {};

	//ll v[3] = {};
	//ll *c, *s, *n;
	string S[50],T[50],U[52];
	ll count = 0;
	ll count2 = 0;
	float sum = 0;
	ll min = 1000000000000;
	ll max = 0;
	ll smax = 0;
	ll max2 = 0;
	ll smax2 = 0;
	int tmax = 0;
	int tmax2 = 0;
	//int flag = 0;
	char temp,head;
	//int is = 0;
	bool flag = false;
	
	//char p;

	ll all = 0;
	ll niku = 0;
	ll state = 2;
	bool down = true;
	

	//cin >> S;
	
	//vector<pair<int,int>> ch(50);
	
	

	cin >> A >> B;

	rep(i, 0, A)
		cin >> S[i];

	rep(i, 0, B)
		cin >> T[i];

	rep(j, 0, A - B + 1) {
		rep(i, 0, A - B + 1) {

			rep(y, 0, B) {
				rep(x, 0, B) {

					if (S[i+x][j+y] == T[x][y]) {
						count++;
					}
					//cout << i+x << j+y << endl;
				}
			}

			if (count == B*B) {
				cout << "Yes" << endl;
				return 0;
			}
			
			//cout << count << endl;
			//cout << "-------------" << endl;
			count = 0;

		}
	}

	cout << "No" << endl;

	//x = (ll *)malloc((N+1) * sizeof(ll));
	//c = (ll *)malloc((N) * sizeof(ll));
	//cin >> D >> G;
	//vector<pair<int,int>> tr(M);
	//vector<pair<int,int>> qes(Q);
	//sort(c.begin(), c.end());
	
	//cout << c[2] - c[1] << endl;

	
	/*A = N / 1000;
	N %= 1000;
	B = N / 100;
	N %= 100;
	C = N / 10;
	N %= 10;
	D = N;*/
	


	//cin >> N >> M;

	//vector<pair<int,int>> c(M);
	////vector<pair<int, int>> e(M);
	//vector<ll> d(M);

	//rep(i, 0, M) {
	//	cin >> c[i].first >> c[i].second;
	//	//e[i].first = c[i].first;
	//	//e[i].second = c[i].second;

	//}
	////sort(c.begin(), c.end());

	//

	//rep(i, 0, M) {

	//	
	//	
	//	rep(j, 0, M) {
	//		if (c[i].first == c[j].first && c[j].second < c[i].second) {
	//			d[i]++;
	//			//cout << j << endl;
	//		}
	//	}
	//	cout << std::setfill('0') << std::right << std::setw(6) << c[i].first;
	//	cout << std::setfill('0') << std::right << std::setw(6) << d[i]+1 << endl;
	//}

	return 0;

}

ll bur(ll N,ll X) {
	ll pan = 1;
	ll pat = 1;
	ll burg = 0;



	if (X > burg) {
		if (N == 0)
			return pat;


		burg += pan;
		burg += bur(N - 1, X);
		burg += pat;
		burg += bur(N - 1, X);
		burg += pan;


	}

	return burg;

}

ll gcd(ll a, ll b) {
	
	/* 自然数 a > b を確認・入替 */
	if (a<b) {
		ll tmp = a;
		a = b;
		b = tmp;
	}
	ll x = b;
	ll y = a;
	/* ユークリッドの互除法 */
	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}


	return y/b*x;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define N 100000

int Partition(int *A,int p,int r)
{
  int x,i,j,swp;

  x=A[r];
  i=p-1;

  for(j=p;j<=r-1;j++){
    if(A[j]<=x){
      i=i+1;
      swp=A[i];
      A[i]=A[j];
      A[j]=swp;
    }
  }
  swp=A[i+1];
  A[i+1]=A[r];
  A[r]=swp;

  return i+1;
}
int main(){

  int n,i,p=0;
  int A[N];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  p=Partition(&A[0],0,n-1);
  printf("%d",A[0]);
  
  for(i=1;i<n;i++){
    if(i==p){
      printf(" ");
      printf("[%d]",A[i]);
    }else{
      printf(" ");
      printf("%d",A[i]);
    }
  }
    printf("\n");
    return 0;
  }

Measured memory_bytes: 992
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define vec vector
#define fi first
#define se second
#define eb emplace_back
#define ef emplace_front
#define pof pop_front()
#define pob pop_back()
#define Rep(i,n) for(li i=0,nn=(li)(n);i!=nn;++i)
#define Rep1(i,n) for(li i=1,nn=(li)(n)+1;i!=nn;++i)
#define Size(v) (li)(v.size())
#define SortA(v) sort(v.begin(),v.end())
#define SortD(v) sort(v.rbegin(),v.rend())
#define All(a) (a).begin(),(a).end()
#define Input(a) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii);}
#define Input2(a,b) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii)>>(b).at(ii);}
#define mp make_pair
using li = int64_t;
using intl = int64_t;
using vi = vec<li>;
using vb = vec<bool>;
using vvi = vec<vi>;
using qi = deque<li>;
using pi = pair<li,li>;
using vpi = vec<pi>;
using si = set<li>;
using vsi = vec<si>;
using mii = map<li,li>;
using vmii = vec<mii>;
vec<li> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<li> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr li INF = 9223372036854775807;

void Yes(li b){
  if(b)cout<<"Yes";
  else cout<<"No";
}
void yes(li b){
  if(b)cout<<"yes";
  else cout<<"no";
}

int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cout.precision(16);

  li L,R,d;
  cin >>L>>R>>d;

  li ans =0;
  for(li i=L; i<=R; ++i){
  	if(i%d==0){++ans;}
  }

  cout<<ans;
}


Measured memory_bytes: 3576
#include <iostream>
using namespace std;
int main()
{
  long long int n,k,x,y,rem,coast;
    cin>>n>>k>>x>>y;
    if(n>k)
    {
        rem = n-k;
        coast = (k*x) + (rem*y);
    }
    else if(n==k)
        coast = k * x;
    else
        coast = n * x;
    cout<<coast<<endl;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
using namespace std;
 
int main ()
{
	int n;
  	int h = 0;
  	int max = 0;
  	int cnt = 0;
  
  	cin >> n;
  	
  	for  (int i = 0; i < n; i++)
  	{
      cin >> h;
      
      if (h >= max)
      {
  		cnt++;
        max = h;
      }    
  	}
  
  	cout << cnt << endl;
  
	return 0;
}

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

int a[100];
int main() {
	int n; cin >> n;
	rep(i, n) {
		scanf("%d", &a[i]);
	}
	int Min = INF;
	for (int i = -100; i <= 100; i++) {
		int cnt = 0;
		rep(j, n) {
			cnt += abs(a[j] - i)*abs(a[j] - i);
		}
		Min = min(Min, cnt);
	}
	printf("%d\n", Min);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _LIBCPP_DEBUG 0
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF = 1 << 30;

int main(void){

    ll takashi = 100;
    ll X; cin>>X;
    ll cnt=0;
    while(takashi < X){
        cnt++;
        takashi += takashi *0.01;
    }

    cout<<cnt<<endl;
}


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

int main() {
	//input
	string S;
	cin >> S;

	//calculation
	int len = S.length();
	if (S[len - 1] == 's') {
		S += "es";
	} else {
		S += "s";
	}

	//output
	cout << S << endl;


	return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
const int mod = 1e9 + 7, N = 20000;
ll fact[N], inv[N];
ll fp(ll base, ll exp){
    if (exp == 0) return 1;
    ll ans = fp(base, exp / 2);
    if (exp % 2 == 0) return (ans * ans) % mod;
    else return (((ans * ans)% mod) * base)% mod;
}
void calcFacAndInv(ll n){
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++){
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}
ll ncr(ll n, ll r){
    if(r > n) return 0;
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}
 
int main(){
    Hello
    calcFacAndInv(N - 5);
    ll n, k;
    cin >> n >> k;
    for(int i = 1; i <= k; i++){
        ll ans = ((ncr(n - k + 1, i) % mod) * (ncr(k - 1, i - 1) % mod))% mod;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3884
#include<bits/stdc++.h>
using namespace std;
#define T top()
#define E end()
#define PS push
#define Q queue
#define PP pop()
#define L0 (LL)0
#define V vector
#define ST stack
#define FI first
#define MAX 4e18
#define MIN -MAX
#define DQ deque
#define RE rend()
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define SE second
#define DL double
#define G getline
#define IN insert
#define endl "\n"
#define EM empty()
#define EE emplace
#define RB rbegin()
#define MD 1000000007
#define PSB push_back
#define PI acos(-1.00)
#define PPB pop_back()
#define PSF push_front
#define ub upper_bound
#define lb lower_bound
#define PPF pop_front()
#define EB emplace_back
#define LL long long int
#define PQ priority_queue
#define N cout<<"NO"<<endl
#define Y cout<<"YES"<<endl
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define UOSMOY v.C;w.C;ww.C;uu.C;uo.C;vo.C;vu.C;ab.C;bc.C;cc.C;uuu.C;a.C;b.C;c.C;u.C
V<LL>v;
V<LL>w,ab,bc;
set<LL>uo;
map<LL,LL>ww,cc,u;
V<pair<LL,LL> >uu,su;
map<LL,V<LL> >uuu;
map<pair<LL,LL>,LL> vo;
map<pair<LL,LL>,LL> vu;
map<LL,pair<LL,pair<LL,LL > > > vs;
LL dxx[]= {-1,0,1,0};
LL dyy[]= {0,1,0,-1};
LL dx[]= {2,1,-1,-2,-2,-1,1,2};
LL dy[]= {1,2,2,1,-1,-2,-2,-1};
int main()
{
//  BRR;
//  file;
    FAST;
    char ch;
    string a,b,c;
    DL x,y,d,e,f,g,h;
    LL n,m,i,j,k,p,q,o,l,s,tt=1,t,z,aa,r=0;
//    cin>>tt;
    for(LL mau=1;mau<=tt;mau++)
    {
        UOSMOY;
        cin>>n;
        k=0;
        l=0;
        for(i=0;i<n;i++)
        {
            cin>>p>>q;
            if(p==q)
            {
                k++;
            }
            else
            {
                k=0;
            }
            if(k==3)
            {
                l=1;
            }
        }
        if(l==1)
        {
            cout<<"Yes"<<endl;
        }
        else

        {
            cout<<"No"<<endl;
        }


    }
    return 0;
    //IN
    //AL
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <stack>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, a[3];
string s[100000];

int next(int n) { return (n + 1) % 3; }
int prev(int n) { return (n - 1 + 3) % 3; }

signed main() {
	int i, j;
	
	cin >> n >> a[0] >> a[1] >> a[2];
	rep(i, n) {
		cin >> s[i];
		if (s[i] == "AC") { s[i] = "CA"; }
	}
	
	stack<int> stk[6];	//"AB", "BC", "CA" | "BA", "CB", "AC"
	rep(i, n) {
		a[s[i][0] - 'A']++;
		a[s[i][1] - 'A']--;
		stk[s[i][0] - 'A'].push(i);
		
		int t = s[i][0] - 'A';
		rep(j, 3) {
			while (!stk[t].empty() && a[next(t)] < 0) {
				int id = stk[t].top(); stk[t].pop();
				a[t] -= 2;
				a[next(t)] += 2;
				stk[t + 3].push(id);
			}
			t = prev(t);
		}
		if (a[0] < 0 || a[1] < 0 || a[2] < 0) { cout << "No" << endl; return 0; }
	}
	
	string coms[6] = {"AB", "BC", "CA", "BA", "CB", "AC"};
	static string ans[100000];
	
	rep(i, 6) {
		while (!stk[i].empty()) {
			int id = stk[i].top();
			stk[i].pop();
			ans[id] = coms[i];
		}
	}
	
	cout << "Yes" << endl;
	rep(i, n) cout << ans[i][0] << endl;
	return 0;
}

//一般的なテクを活かした解き方
//「片側に選択肢を寄せ、後で調整する」方針
//自分にとっては、これが自然に見えた。
//また、対称性を保って考察をおこなうため、s[i] = "AB", "BC", "CA"のいずれかとしておく。
//
//t[i] = s[i] or reverse(s[i])とし、文字t[i][0]と対応する変数を+1, t[i][1]と対応する変数を-1とする。
//例えばt[i] = "BA"なら、Bに1を足し, Aから1を引く。
//t[i]を上手く決められるか？という問題。このままでは2^N通りの候補があって大変。
//
//i=0,1,2,…の順番でt[i]を決めていく。
//とりあえず、t[i] = s[i]と仮置きしておいて進める。
//このまま何事もなければYes.
//A,B,Cのいずれかが負になってしまった瞬間iを考える。
//
//例えばAが負になったとする。このとき、t[j] = "CA" (j < i)なるjについてt[j] = "AC"と変えていき、Aを非負にする。
//非負にする最低限の調整をする。
//そのようなことをするjの組み合わせは重要ではなく、好きに選んでも良くて、例えば直前のものから選んでいく。
//非負にできなければNo. 非負にできたとき、今度はCが負になっていることがある。これについても同様にやる。
//Aを非負に -> Cを非負に -> Bを非負に、としていったときに、再びAが負になれば、どうやっても調整できない。（要検証）
//したがって、"No".
//
//B,Cが負になったときも同様におこなう。
//これで、最後までNoにならなければYes.
//
//実装方針：
//3回同じコードを書きたくはない。問題文中の変数はA->a[0], B->a[1], C->a[2]と置きなおして、
//"AB"は0, "BC"は1, "CA"は2のように変換してから実装する。
//このようにすれば、対称性を活かして実装量を軽減できる。
//
//この解き方のメリット・デメリット
//メリット：明示的な場合分けをほとんどせずに解ける。
//デメリット：明示的な場合分けをしていないので、どんなケースでYes, Noなのかが分からないままACしてしまう。


Measured memory_bytes: 10308
<?php

fscanf(STDIN, "%d", $n);

$fibo = [];
$fibo[0] = 1;
$fibo[1] = 1;

for ($i = 2; $i < 50; ++$i) {
    $fibo[$i] = $fibo[$i - 1] + $fibo[$i - 2];
}

echo $fibo[$n], PHP_EOL;



Measured memory_bytes: 9228
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    a,b,c,d = MII()
    print(max(min(b,d)-max(a,c), 0))

if __name__ == '__main__':
    main()

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

using ll = long long;
const ll mod = 1000000007LL;

const int limit = 5000000;
ll F[limit+10],IF[limit+10];

ll inv(ll a){
	ll b = 1LL;
	ll n = mod -2;
	while(n){
		if(n&1) b = b * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return b;
}

inline ll C(int n,int k){
	if(n < 0 or k < 0 or n-k < 0) return 0LL;
	return F[n] * IF[k] % mod * IF[n-k] %mod;
}

inline ll H(int n,int k){
	if(n == 0 and k == 0) return 1;
	n += k - 1;
	return C(n,k);
}

int main(void){
	F[0] = 1LL;
	for(ll i=1LL;i<=limit;++i) F[i] = i * F[i-1] %mod;
	IF[limit] = inv(F[limit]);
	for(ll i=limit;i>=1;--i) IF[i-1] = i * IF[i] %mod;
		
	ll a,b,c,sx,sy;
	while(cin >> a >> b >> c >> sx >> sy){
		if(a+b+c+sx+sy==0) break;
		ll ans = 0LL;

		for(ll wa = a; wa <= sx; ++ wa){
			const ll draw = sx - wa;
			const ll wb = sy - draw; 
			if(draw < 0 or wb < b) continue;
			//cerr << wa << " " << wb << " " << draw << endl;
			ll cur = 1LL;
			cur = cur * H(a,wa-a) % mod;
			cur = cur * H(b,wb-b) % mod;
			cur = cur * H(a+b+c,draw) % mod;
			ans = (ans + cur) % mod;
		}

		ans = ans * C(a+b+c,a) % mod * C(b+c,b) % mod;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 81112
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;

void solve() {
    int n; cin >> n;

    LL ans = 1ll * n * (n + 1) * (2 * n + 1) / 6 + 1ll * n * (n + 1) / 2;
    ans /= 2;

    for (int i = 0; i < n - 1; i++) {
        int l, r; cin >> l >> r;
        if (l > r) swap(l, r);

        ans -= 1ll * l * (n - r + 1);
    }
    cout << ans << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // int t;cin >> t;while(t--)
    solve();
    return 0;
}


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

int     main() {
        string s, t;
        cin >>s >>t;
        int ss=s.size();
        int tt=t.size();
        vector<vector<int>> Step(26, vector<int> (ss+1, -1));
        for (int i=1; i<=ss; i++) {
                int c=s.at(i-1)-'a';
                if (-1==Step.at(c).at(1))
                        for (int j=0; j<=ss; j++)
                                Step.at(c).at(j)=i;
                else
                        for (int j=i-1; j>=Step.at(c).at(j); j--)
                                Step.at(c).at(j)=i;
        }
        long Loop=0;
        int cc=t.at(0)-'a';
        int Pos=Step.at(cc).at(0);
        for (int i=1; i<tt; i++) {
                if (-1==Pos) {
                        cout <<-1 <<endl;
                        return 0;
                }
                int cc=t.at(i)-'a';
                int Pos2=Step.at(cc).at(Pos);
                if (Pos2<=Pos)
                        Loop++;
                Pos=Pos2;
        }
        Loop *=ss;
        if (-1==Pos)
                cout <<-1 <<endl;
        else
                cout <<Loop+Pos <<endl;
        return 0;
};

Measured memory_bytes: 12032
N = int(input())
A = list(map(int, input().split()))

sA = sorted(A, reverse=True)

if N % 2 == 0:
    res = sum(sA[:N//2]) * 2 - sA[0]
else:
    res = sum(sA[:N//2]) * 2 - sA[0] + sA[N//2]

print(res)

Measured memory_bytes: 105204
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;

#define pf(n) cout << n << endl
#define ps() cout <<" ";
#define sf(n) cin >> n
#define in(i,n) for (int i = 0; i < n; i++)
#define vi vector<int>
#define vp vector<pair<int, int>>
#define graph vector< vector<int> >
#define vs vector<string>
#define mn -
#define pls +
#define mod %
#define E =
#define EE ==
#define le <=
#define ge >=
int mx=9999999;
/**  '' "\n" - ^ **/

    void yes()
    {
        cout<<"yes\n";
    }

    void no()
    {
        cout<<"no\n";
    }
    void YES()
    {
        cout<<"YES\n";
    }

    void NO()
    {
        cout<<"NO\n";
    }

    void Case(int i,int n)
    {
        cout<<"Case:"<<i<<" "<<n<<endl;
    }
    /**  '' "\n" x ^ **/
    /** printf("\n") */

    bool comp(pair<int,int> a,pair<int,int> b)
    {
        if(a.second != b.second)//return false;
        return a.first<b.first;
        return true;
    }
    int a,b,c,d;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a>0&&c>0)//
    {
    	pf(b*d);
	}
	else if(a<0&&c<0)///
	{
		if(b*d>a*c)
		pf(b*d);
		else
		pf(a*c);
	}
	else if(a<0&&c>0)///
	{
		if(b>0)pf(b*d);
		else pf(b*c);
	}
	else
	{
		if(d>0)
		{
			pf(b*d);
		}
		else
		{
			pf(a*d);
		}
	}
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main(){
    int n;
    cin >> n;
    bool flag=false;
    for(int i=0; i<3; i++){
        if(n%10==7)flag=true;
        n/=10;
    }
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
	int h1,m1,h2,m2,k;

	cin >> h1 >> m1 >> h2>>m2>>k;
	int start = h1*60+m1;
	int end = h2*60+m2;

	cout << end -start  - k << endl;

	return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <initializer_list>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, a, n) for (int i = (a); i < (int)(n); i++)
#define repc(i, a, n) for (int i = (a); i <= (int)(n); i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init)                                              \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
#define DBG(str) cerr << (str) << endl;
int main() {
  int a, b, x;
  cin >> a >> b >> x;
  if (a <= x && b >= x - a)
    cout << "YES";
  else
    cout << "NO";

  return 0;
}


Measured memory_bytes: 256
def main():
    n,k=map(int,input().split())
    a=list(map(int,input().split()))
    a=[i-1 for i in a]
    from itertools import accumulate
    import bisect
    a=[0]+list(accumulate(a))
    d=dict()
    a=[i%k for i in a]
    cnt=0
    for j,i in enumerate(a):
        if i not in d.keys():
            d[i]=[j]
        else:
            d[i].append(j)
    for l in d.values():
        for j,i in enumerate(l):
            cnt+=bisect.bisect_left(l,i+k)-j-1
    print(cnt)
main()

Measured memory_bytes: 51492
use proconio::{*, marker::Chars};

fn main() {
    input!{
        n: Chars,
    }

    let n: Vec<i32> = n.into_iter().collect::<Vec<char>>().iter().map(|x| *x as i32 - 48).collect::<Vec<i32>>();
    let mut sum = 0;
    for i in n {
        sum += i;
        sum %= 9;
    }

    println!("{}", if sum == 0 { "Yes" } else { "No" });
}


Measured memory_bytes: 3856
class UF():
  def __init__(self, N):
    self._parent=[n for n in range(0, N)]
    self._size=[1] * N

  def find_root(self, x):
    if self._parent[x]==x:return x
    self._parent[x]=self.find_root(self._parent[x])
    return self._parent[x]

  def unite(self, x, y):
    gx=self.find_root(x)
    gy=self.find_root(y)
    if gx==gy:return

    if self._size[gx]<self._size[gy]:
      self._parent[gx]=gy
      self._size[gy]+=self._size[gx]
    else:
      self._parent[gy]=gx
      self._size[gx]+=self._size[gy]

  def size(self, x):
    return self._size[self.find_root(x)]

  def samegroup(self, x, y):
    return self.find_root(x)==self.find_root(y)

  def groupnum(self):
    N=len(self._parent)
    ans=0
    for i in range(N):
      if self.find_root(i)==i:
        ans+=1
    return ans

n,m=map(int,input().split())
UFa=UF(n)
for i in range(m):
  x,y=map(int,input().split())
  UFa.unite(x-1,y-1)
print(UFa.groupnum()-1)

Measured memory_bytes: 75416
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    int x = 100 * n / 108;
    if (x * 108 / 100 == n) {
        cout << x << endl;
    } else if ((x + 1) * 108 / 100 == n) {
        cout << x + 1 << endl;
    } else {
        cout << ":(" << endl;
    }
    return 0;
}

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

using namespace std;

int main() {
	int N;
	string S;
	cin >> N;
	cin >> S;
	vector<string> comb;
	for (int i = 0; i < 1000; i++) {
		string tmp;
		if (i >= 0 && i < 10) {
			tmp = string("00") + to_string(i);
		}
		else if (i >= 10 && i < 100) {
			tmp = string("0") + to_string(i);
		}
		else {
			tmp = to_string(i);
		}
		comb.push_back(tmp);
	}
	int ans = 0;
	for (int j = 0; j < comb.size(); j++) {
		if (S.find(comb[j][0]) != string::npos) {
			int n = S.find(comb[j][0]) + 1;
			string S1 = S.substr(n);
			if (S1.find(comb[j][1]) != string::npos) {
				int m = S1.find(comb[j][1]) + 1;
				string S2 = S1.substr(m);
				if (S2.find((comb[j][2])) != string::npos) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#define MAX 100000


struct node{
  int key;
  struct node *right;
  struct node *left;
  struct node *parent;
};
typedef struct node * Node;
#define NIL NULL
int n;
Node root;
Node treeSearch(Node ,int);
void print(Node );
void preorder(Node );
void inorder(Node );
void insert(int);
int main(){
  int  i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
  
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      
       Node t = treeSearch(root, x);      
       if ( t != NIL ) printf("yes\n");
       else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      //     scanf("%d", &x);
      //     treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}


void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  z->parent = y;   
  if(y == NIL) {
    root = z; //Tが空
  }
  else if(z->key < y->key ){
    y->left = z;
  }
  else y->right = z;
}

void print(Node root){
  inorder(root);
  preorder(root);
}

void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

void inorder(Node u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

Node treeSearch(Node u,int k){
  int i;
  while(u != NIL){
    if(u->key == k) return u;
    if(k< u->key ) u = u->left;
    else u = u->right; 
  }
  return NIL;
}




Measured memory_bytes: 20516
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define n_max int(1e5)
#define MOD llong(1e9+7)


int main(){
    int n,m;
    cin >> n >> m;
    llong x[n_max+5],y[n_max+5];
    REP(i,n){
        scanf("%lld",&x[i]);
    }
    REP(i,m) scanf("%lld",&y[i]);
    
    sort(x,x+n);
    sort(y,y+m);

    llong ruiseki[2][n_max+5];
    ruiseki[1][0]=0;
    ruiseki[0][0]=0;

    REP(i,n){
        ruiseki[0][i+1]= ruiseki[0][i] + x[i];
    }
    REP(i,m){
        ruiseki[1][i+1]= ruiseki[1][i] + y[i];
    }

    llong yoko=0,tate=0;
    REP(i,n){
        yoko += ( (ruiseki[0][n] - ruiseki[0][i+1] ) + MOD - (n-1-i)*x[i] % MOD )%MOD;
        yoko%=MOD;
    }
    REP(i,m){
        tate += ( (ruiseki[1][m] - ruiseki[1][i+1] ) + MOD - (m-1-i)*y[i] % MOD )%MOD;
        tate%=MOD;
    }

    cout << yoko * tate % MOD << endl;

}

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

int ans = INF;
char s[100010];

int main() {
    scanf("%s", s);
    for (int i = 1; i < strlen(s); ++i) {
    	if (s[i] != s[i - 1]) ans = min(ans, max(i, (int)(strlen(s) - i))); 
    }
    printf("%d\n", min(ans, (int)(strlen(s))));
    return 0;
}

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


int main(){
    ll K, A, B; cin >> K >> A >> B;
    for(int i = A; i <= B; i++){
        if(i % K == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;

}


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

#define EPS (1e-10)

int p, q, a, n;
double lhs;

int dfs(int n, int cdnm, int sdnm, double sum) {
  int res = 0;
  for (int i = cdnm; i * sdnm <= a; i += 1) {
    double rhs = sum + 1.0 / i;
    if (abs(lhs-rhs) < EPS) {res++; continue;}
    if (lhs < rhs) continue;
    if (n == 1) continue;
    
    res += dfs(n-1, i, sdnm * i, rhs);
  }
  return res;
}

void solve() {
  int res;
  lhs = (double)p / (double)q;
  res = dfs(n, 1, 1, 0);
  
  cout<<res<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>p>>q>>a>>n, n) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 868
#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 l, r, d;
	int ans = 0;
	cin >> l >> r >> d;
	for(int i=l; i<=r; i++){
		if(i%d == 0){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3532
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>

using namespace std;

int a, b;

int main() {
    while(2 == scanf("%d%d", &a, &b)) {
        if(a == 1) {
            a = 14;
        }
        if(b == 1) {
            b = 14;
        }
        if(a > b) {
            printf("Alice\n");
        }
        else if(a < b) {
            printf("Bob\n");
        }
        else {
            printf("Draw\n");
        }
    }
    return 0;
}


Measured memory_bytes: 128
n, k = map(int, input().split())
sortedList = sorted(list(map(int, input().split())))
mod = 10 ** 9 + 7

factorial = [1]
for i in range(1, n + 1):
  factorial.append((factorial[i - 1] * i) % mod)

def cmb(n, k):
  return factorial[n] * pow(factorial[n - k], mod - 2, mod) * pow(factorial[k], mod - 2, mod)

result = 0
for i in range(1, n - k + 2):
  val = cmb(n - i, k - 1) * (sortedList[n - i] - sortedList[i - 1])
  result += val
print(result % mod)


Measured memory_bytes: 14416
<?php

$input = explode( ' ', trim( fgets(STDIN) ) );

foreach ( $input as $key => $value ) {
  $input[$key] = intval( $value );
}

rsort( $input );

if ( $input[0] === $input[1] + $input[2] ) {
  echo 'Yes';
  return;
}

echo 'No';

?>

Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sort stable_sort
#define all(x) (x).begin(),(x).end()
#define rep(i,x) for (int (i)=(1);(i)<=(x);(i)++)
#define rep2(i,x) for (int (i)=(x);(i)>=(1);(i)--)
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
using namespace std;
int n,m,i,j,s;
string st;
int main()
{
	cin>>n>>st;
	for (i=0;i<n;i++) if (st[i]=='R') s++; else s--;
	if (s>0) puts("Yes"); else puts("No"); 
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M,C;
  cin>>N>>M>>C;
  vector<int>B(M);
  vector<vector<int>>A(N,vector<int>(M));
  for(int i=0;i<M;i++){
    cin>>B.at(i);
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cin>>A.at(i).at(j);
    }
  }
  int count=0;
  for(int i=0;i<N;i++){
    int sum=C;
    for(int j=0;j<M;j++){
      sum=sum+A.at(i).at(j)*B.at(j);
    }
    if(sum>0){
      count=count+1;
    }
    else{
    }
  }
  cout<<count<<endl;
}


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

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; }}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; }}

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

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int K, N; cin >> K >> N;
    vector<int> A(N), B(N); rep(i, N) cin >> A[i];
    rep(i, N) {
        if (i == N-1) {
            B[i] = K - A[i] + A[0];
        } else {
            B[i] = A[i+1] - A[i];
        }
    }

    int mx = 0;
    rep(i, N) chmax(mx, B[i]);
    cout << K - mx << endl;
}


Measured memory_bytes: 1792
import sys
import numpy as np
from scipy.sparse.csgraph import floyd_warshall
sys.setrecursionlimit(10**7)


def main():
    input = sys.stdin.readline
    N = int(input())
    G = []
    for _ in range(N):
        S = [int(c) for c in str(input().strip())]
        T = []
        for i, e in enumerate(S):
            if e == 1:
                T.append(i)
        G.append(T)
    
    colors = [-1] * N
    visited = [False] * N
    def is_binarygraph(v, color):
        visited[v] = True
        for n in G[v]:
            if colors[n] == color:
                return False
            if visited[n]:
                continue
            colors[n] = (color + 1) % 2
            if not is_binarygraph(n, colors[n]):
                return False
        return True
    
    colors[0] = 0
    if not is_binarygraph(0, 0):
        return -1

    inf = 10**3
    d = [[inf]*N for _ in range(N)]
    for i in range(N):
        for j in G[i]:
            d[i][j] = 1
    for i in range(N):
        d[i][i] = 0
    
    fw = floyd_warshall(d)
    return np.max(fw) + 1

if __name__ == '__main__':
    print(int(main()))

Measured memory_bytes: 18544
#include <bits/stdc++.h>
#define ll long long
#define mk make_pair
using namespace std;
const int N = 2e2 + 5;
const int mod = 998244353;
bool bo[N][N];
int n, x[N], y[N];
vector<int> V;
ll ans, p[N];
bool line(int i, int j, int k) {
	return (x[j] - x[i]) * (y[k] - y[i]) - (x[k] - x[i]) * (y[j] - y[i]) == 0; 
}
int main() {
	p[0] = 1;
	for (int i = 1; i < N; i++) p[i] = p[i - 1] * 2 % mod;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> x[i] >> y[i];
	}
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			if (bo[i][j]) continue;
			V.clear();
			V.push_back(i);
			V.push_back(j);
			for (int k = j + 1; k <= n; k++) {
				if (line(i, j, k)) V.push_back(k);
			}
			for (int k = 0; k < V.size(); k++)
				for (int l = 0; l < V.size(); l++)
					bo[V[k]][V[l]] = 1;
			ans += p[V.size()] - V.size() - 1;
			ans %= mod;
		}
	}
	ans = p[n] - ans - n - 1;
	ans %= mod;
	ans += mod;
	ans %= mod;
	cout << ans;
}



Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    let mut v2 = Vec::new();
    for _ in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        let v = s.trim().split_whitespace()
            .map(|e| e.parse().ok().unwrap()).collect();
        v2.push(v);
    }
    v2
}

fn main() {
    let input = read::<i32>();
    let mut done = false;
    let mut seven = 0;
    while seven * 7 < input {
    	if (input - seven * 7) % 4 == 0 {
    		done = true;
    		break;
    	} else if (input - seven * 7) % 7 == 0 {
    		done = true;
    		break;
    	}
    	seven += 1;
    }
    if done {
    	println!("Yes");
    } else {
    	println!("No");
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define F(i, l, r) for(int i = (l), _end_ = (int)(r); i <= _end_; ++i)
#define f(i, r, l) for(int i = (r), _end_ = (int)(l); i >= _end_; --i)
#define Set(a, v) memset(a, v, sizeof(a))
using namespace std;

bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
 int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar() ) x = (x<<1) + (x<<3) + (ch ^ '0');
    return x * fh;
}
int n,m;
int main () {
    n=read();
	m=read();
	long long ans=0;
	F(i,m+1,n){
	  int x=n/i,y=n%i;
      ans+=(long long)x*(i-m);
	  if(y>=m){
	     ans+=y-m;
		 if(m)ans++;
	  }
	}
	printf("%lld\n",ans);
	return 0;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve() {
  int a, b;
  cin >> a >> b;
  if (abs(a - b) > 1) {
    cout << 0 << '\n';
    return;
  }
  int ans = 1;
  for (int i = 1; i <= a; i++) {
    (ans *= i) %= MOD;
  }
  for (int i = 1; i <= b; i++) {
    (ans *= i) %= MOD;
  }
  if (a == b) (ans *= 2) %= MOD;
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <climits>

using namespace std;

int case1(int h, int w){
  if(h<3) return INT_MAX;
  int i=h/3, j=(h-i)/2, k=h-i-j;
  return (k-i)*w;
}

int case2(int h, int w){
  int i=w/3, j=h/2;
  int a=(h-j)*(w-i)-min(i*h, j*(w-i));
  i+=1;
  int s1=i*h, s2=j*(w-i), s3=(h-j)*(w-i);
  int b;
  if(s1<s2) b=s3-s1;
  else if(s1>s3) b=s1-s2;
  else b=s3-s2;
  return min(a,b);
}

int main(){
  int h,w;
  cin >> h >> w;
  int minS=INT_MAX;
  minS=min(minS,case1(h,w));
  minS=min(minS,case2(h,w));
  minS=min(minS,case1(w,h));
  minS=min(minS,case2(w,h));

  cout << minS << endl;
}


Measured memory_bytes: 384
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
txt = 'No'
suma = sum(a)


def fil(n):
    if suma / (4 * m) <= n:
        return True
    else:
        return False


a = list(filter(fil, a))

if len(a) >= m:
    txt = 'Yes'

print(txt)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n, fa[100007], dep[100007], d[100007], tot, cnt[100007], res1[100007], res2[100007];
vector<int>e[100007];
bool is[100007];
int read()
{
	int num = 0;
	char c = getchar();
	while (c < '0' || c>'9')c = getchar();
	while (c >= '0' && c <= '9')num = num * 10 + c - '0', c = getchar();
	return num;
}
int dfs(int w, int f)
{
	fa[w] = f;
	dep[w] = dep[f] + 1;
	int res = w;
	for (int i = 0, lim = e[w].size(); i < lim; i++)
		if (e[w][i] != f)
		{
			int ret = dfs(e[w][i], w);
			if (dep[ret] > dep[res])res = ret;
		}
	return res;
}
int print(int* p)
{
	for (int i = 1; i <= n; i++)
		printf("%d ", p[i]);
	putchar('\n');
	return 0;
}
int main()
{
	n = read();
	for (int i = 2; i <= n; i++)
	{
		int a = read(), b = read();
		e[a].push_back(b);
		e[b].push_back(a);
	}
	int mx = dfs(1, 0);
	mx = dfs(mx, 0);
	while (mx)d[++tot] = mx, is[mx] = 1, mx = fa[mx];
	for (int i = 1; i <= n; i++)
		if (!is[i])
		{
			bool ok = 0;
			for (int j = 0, lim = e[i].size(); j < lim && !ok; j++)
				if (is[e[i][j]])cnt[e[i][j]]++, ok = 1;
			if (!ok) { cout << -1 << endl; return 0; }
		}
	int pos = 0;
	for (int i = 1; i <= tot; i++)
	{
		for (int j = 1; j <= cnt[d[i]]; j++)
			res1[pos + j] = pos + j + 1;
		res1[pos + cnt[d[i]] + 1] = pos + 1;
		pos += cnt[d[i]] + 1;
	}
	pos = 0;
	for (int i = tot; i >= 1; i--)
	{
		for (int j = 1; j <= cnt[d[i]]; j++)
			res2[pos + j] = pos + j + 1;
		res2[pos + cnt[d[i]] + 1] = pos + 1;
		pos += cnt[d[i]] + 1;
	}
	for (int i = 1; i <= n; i++)
		if (res1[i] > res2[i]) { print(res2); return 0; }
		else if (res1[i] < res2[i]) { print(res1); return 0; }
	print(res1);
	return 0;
}

Measured memory_bytes: 14976
# -*- coding: utf-8 -*-
INF = 2**62-1

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

def slv(N, M):
    if N % 2 != 0:
        ans = [ (i+1, N-i) for i in range(M)]
    else:
        ans = []
        for i in range(M):
            l = i+1
            r = N-i
            if l > N //4:
                l += 1

            ans.append((l, r))

    for a in ans:
        print(*a)


def main():
    N, M = read_int_n()
    (slv(N, M))



if __name__ == '__main__':
    main()


Measured memory_bytes: 73400
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
int N;
int a[maxn], b[maxn], c[maxn];
int dp[maxn][3];
int main()
{
    scanf("%d", &N);
    for(int i = 1; i <= N; i++)
    {
        scanf("%d%d%d", &a[i], &b[i], &c[i]);
    }
    memset(dp, 0, sizeof(dp));
    dp[1][0] = a[1];
    dp[1][1] = b[1];
    dp[1][2] = c[1];
    for(int i = 2; i <= N; i++)
    {
        dp[i][0] = max(dp[i][0], dp[i - 1][1] + a[i]);
        dp[i][0] = max(dp[i][0], dp[i - 1][2] + a[i]);
        dp[i][1] = max(dp[i][1], dp[i - 1][0] + b[i]);
        dp[i][1] = max(dp[i][1], dp[i - 1][2] + b[i]);
        dp[i][2] = max(dp[i][2], dp[i - 1][0] + c[i]);
        dp[i][2] = max(dp[i][2], dp[i - 1][1] + c[i]);

    }
    int ans = max(dp[N][0], dp[N][1]);
    ans = max(ans, dp[N][2]);
    printf("%d\n", ans);
    return 0;
}


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


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    S = readstr()
    T = readstr()
    print('Yes' if S == T[:-1] else 'No')


if __name__ == "__main__":
    main()


Measured memory_bytes: 9108
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

H,W = I()
maze = [list(s()) for _ in range(H)]
L1 = []
for i in range(H-1,-1,-1):
    if '#' not in maze[i]:
        maze.pop(i)
H = len(maze)
L2 = []
for i in range(W-1,-1,-1):
    Flag = 1
    for j in range(H):
        if maze[j][i] == '#':
            Flag = 0
            break
    if Flag:
        for j in range(H):
            maze[j].pop(i)
for i in range(H):
    print(''.join(maze[i]))

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

int main() {
    string s;
    cin >> s;
    if(s == "ABC"){
     cout << "ARC" << endl;
    }else{
     cout << "ABC" << endl;
    } 
return 0;
}


Measured memory_bytes: 3620