akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#define INFL 1000000000000000

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pl;

vector<ll> dijkstra(ll s, vector< vector<pl> > e) {
    ll n = e.size();
    vector<ll> minD(n, INFL);
    minD.at(s) = 0;
    priority_queue< pl, vector<pl>, greater<pl> > q;
    q.push(pl(0, s));
    while (!q.empty()) {
        pl now = q.top();
        q.pop();
        ll c = now.first, v = now.second;
        if (minD.at(v) < c) continue;
        for (ll i = 0; i < e.at(v).size(); ++i) {
            pl p = e.at(v).at(i);
            if (minD.at(p.first) > minD.at(v) + p.second) {
                minD.at(p.first) = minD.at(v) + p.second;
                q.push(pl(minD.at(p.first), p.first));
            }
        }
    }
    return minD;
}

int main() {
    ios::sync_with_stdio(false);
    int h, w, s = 0;
    scanf("%d%d\n", &h, &w);
    vector< vector<char> > a(h + 2, vector<char>(w + 2, '.'));
    vector< vector<pl> > e((h + 2) * (w + 2), vector<pl>(4));
    vector<pl> m4 = {{-1, 0}, {0, -1}, {0, 1}, {1, 0}};
    for (int i = 1; i <= h; ++i) {
        scanf("%s\n", a.at(i).begin() + 1);
        for (int j = 1; j <= w; ++j) {
            if (a.at(i).at(j) == '#') {
                if (s == 0) s = i * (w + 2) + j;
                else e.at(s).push_back({i * (w + 2) + j, 0});
            }
            for (int k = 0; k < 4; ++k) e.at(i * (w + 2) + j).at(k) = {(i + m4.at(k).first) * (w + 2) + j + m4.at(k).second, a.at(i + m4.at(k).first).at(j + m4.at(k).second) == '.'};
        }
    }
    vector<ll> res = dijkstra(s, e);
    ll ans = 0;
    for (int i = 1; i <= h; ++i) for (int j = 1; j <= w; ++j) ans = max(ans, res.at(i * (w + 2) + j));
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 269156
n , m , c = map(int,input().split())
b = list(map(int,input().split()))
a = []
count = 0
x = 0

for i in range(n):
    a.append(list(map(int,input().split())))
#print(a)


for i in range(n):
    x = 0
    for j in range(m):
        x += a[i][j]*b[j]
    if x+c > 0:
        count += 1
print(count)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		if(n==1){
			Console.WriteLine("Hello World");
		}
		else{
			int a=int.Parse(Console.ReadLine());
			int b=int.Parse(Console.ReadLine());
			Console.WriteLine("{0}",a+b);
		}
	}
}

Measured memory_bytes: 13268
#include <stdio.h>

int main()
{
    int i, n = 0, num;
    scanf("%d", &n);
    int array[n];
    for (i = n - 1; i >= 0; i--)
    {
        scanf("%d", &num);
        array[i] = num;
    }
    printf("%d", array[0]);
    for (i = 1; i < n; i++)
        printf(" %d", array[i]);
    printf("\n");

    return 0;
}


Measured memory_bytes: 2620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int count = 0;
    int ans = n-1;
    for(int i = 0; i < n-1; i++)
    {
        if(s[i+1] != s[i])
        {
            count++;
        }
    }
    count -= 2 * k;
    count = max(count, 0);
    cout << ans - count << endl;
}


Measured memory_bytes: 512
s=str(input())
t=str(input())
n=len(s)
m=len(t)
ans=m
for i in range(n-m+1):
  tmp=0
  for j in range(m):
    if t[j]!=s[i+j]:
      tmp+=1
  ans=min(ans,tmp)
print(ans)

Measured memory_bytes: 9056
#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef long double ld;

#define rc(s) return cout << s, 0
#define fi first
#define se second
#define L (nod << 1)
#define R (L | 1)
#define smax(X, Y) ((X) > (Y) ? (X) : (Y))
#define smin(X, Y) ((X) < (Y) ? (X) : (Y))

const ll inf = (1LL<<62);
const int iinf = (1<<30);
//CLOCKS_PER_SEC

const int N = 100100;
int n, m, a[N], ans;
vector <int> v[N];

int main(){
    //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //ifstream cin ("test.in");
    //ofstream cout ("test.out");
	cin >> n >> m;
	for (int i=1; i<=n; i++) cin >> a[i];
	for (int i=1; i<=m; i++){
		int x, y;
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	for (int i=1; i<=n; i++){
		bool flag = 1;
		for (int it: v[i]){
			if (a[it] >= a[i]) flag = 0;
		}
		ans += flag;
	}
	cout << ans;
    return 0;
}


Measured memory_bytes: 9100
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=2e4+10,oo=0x3f3f3f3f,MOD=998244353;
const double PI = acos(-1);

void solve(){
    string s;
    cin>>s;
    int cnt=0;
    loop(3,i,0)
        cnt+=(s[i]=='R');
    if(cnt!=2)
        cout<<cnt<<endl;
    else{
        if(s[0]==s[1]||s[1]==s[2])
            cout<<2<<Endl;
        else
            cout<<1<<endl;
    }
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();
}

Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
#include<stack>
#include<queue>
#include<map>
#include<set>

using namespace std;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(c-1 >  a + b) cout << a+b+1+b << endl;
    else cout << b+c << endl;
}



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

using namespace std;
using ll = int64_t;

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

  vector<ll> A(N);
  for (size_t i = 0; i < N; i++) {
    cin >> A[i];
  }

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

  const ll last = *(A.end() - 1);
  const double half = last / 2.0;

  double mx = 1e9;
  int ans = 0;

  for (auto &&e : A) {
    if (mx > abs(half - e)) {
      mx = abs(half - e);
      ans = e;
    }
  }
  cout << last << " " << ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>

#define Find_short(a,b) ((a>>b)&1)
#define minimum(a,b) ((a<b)?a:b)

long long int distance[50][50];
long long int dp[1<<16][16];
int Vtx,Edge;

void set()
{
	for(int i=0;i<Vtx;i++)
	{
		for(int j=0;j<Vtx;j++)
		{
			distance[i][j]=1e6;
		}
    }	
	
}

void calculate_short_distance()
{
	
	for(int i=1;i<1<<Vtx;i++)
	{
	   for(int k=0;k<Vtx;k++)
		  if(Find_short(i,k))
		  {
			for(int j=0;j<Vtx;j++)
			if(!Find_short(i,j))
			{
				dp[i|1<<j][j]=minimum(dp[i|1<<j][j],dp[i][k] + distance[k][j]);
			}
		  }
	}
}

int main ()
{
	long long int answer =1e6;
	
	long int source,target,c;
	
	scanf("%d %d",&Vtx,&Edge); getchar();
	set();
	
	for(int i=0;i<Edge;i++)
	{	
		scanf("%ld %ld %ld",&source,&target,&c); getchar();
		distance[source][target]= c;
	}
	
	for(int i=1;i<1<<Vtx;i++)
	{
	    for(int k=0;k <Vtx;k++)
	    {
		     dp[i][k]=1e6;
			 dp[1][0]=0;
		}
    }
    
    // Calculate the shortest path in graph
	calculate_short_distance();	
	
	for(int j=0;j<Vtx;j++)
		answer = minimum(answer,dp[(1<<Vtx)-1][j] + distance[j][0]);
		printf("%lld\n",answer==1e6?-1:answer);
    
	return 0;
}


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

int main(){
    long a,b;
    cin>>a>>b;
    long ans1=a/b;
    long ans2=a%b;
    double aa=a;
    double ans3=aa/b;
    cout<<fixed;
    cout<<ans1<<" "<<ans2<<" "<<setprecision(500)<<ans3<<endl;
}


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

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

  vector<int> v[200005];
  int ans[n+1] = {0};
  

  for(int i=1;i<=m;i++){
      int a,b;
      cin >> a >> b;
      v[a].push_back(b);
      v[b].push_back(a);
  }
queue<int> q;

q.push(1);

while(!q.empty()){
    int j = q.front();
    q.pop();

    for(int i:v[j]){
        if(ans[i]==0 ){
            q.push(i);
            ans[i] =j;
            
        }
    }

}
cout << "Yes" << endl;
for(int i=2;i<=n;i++){
   cout << ans[i] << endl;
}




}

Measured memory_bytes: 12752
#include<bits/stdc++.h>
typedef long long ll;
#define F(i,L,R) for (ll i = L; i < R; i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define re(x) scanf("%lld",&x)
using namespace std;


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin>>s;
  ll sum = 0;
  for(auto i: s) sum += (int)((int)i-'0');
  cout<<((sum%9)?"No":"Yes");
  
  return 0;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
#define int long long


signed main(){
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
   
    if(a[0]==a[1]&&a[0]==a[2])cout<<"Yes";
    else cout <<"No";


    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=b[a[0]-1]
for i in range(1,n):
  ans=ans+b[(a[i]-1)]
  if a[i]==a[i-1]+1:
    ans+=c[a[i-1]-1]
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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; }

lli n, m;
vector<vector<lli>> v(100100);
vector<lli> dp(100100);
vector<bool> seen(100100);

lli f(lli x){
    if(seen[x]) return dp[x];
    seen[x] = true;
    lli mx = 0;
    for(auto to : v[x]){
        mx = max(mx, f(to)+1);
    }
    return dp[x] = mx;
}

int main(void){
    cin >> n >> m;
    rep(i, m){
        lli a, b;
        cin >> a >> b;
        a--;
        b--;
        v[a].push_back(b);
    }
    lli ans = 0;
    rep(i, n){
        ans = max(ans, f(i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11476
#include <stdio.h>

int main(void) {
	int num[3];
	int i, j;
	int diff;
	int answer;
	if (scanf("%d%d%d", &num[0], &num[1], &num[2]) != 3) return 1;
	for (i = 0; i < 3; i++) {
		for (j = 1; j < 3; j++) {
			if (num[j - 1] > num[j]) {
				int t = num[j - 1];
				num[j - 1] = num[j];
				num[j] = t;
			}
		}
	}

	diff = (num[2] - num[1]) + (num[2] - num[0]);
	if (diff % 2 == 0) {
		answer = diff / 2;
	} else {
		answer = (diff + 3) / 2;
	}

	printf("%d\n", answer);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl "\n"
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

template<typename T>   T max_self(T& a, T b) { if (a < b) a = b; return a; }
template<typename T>   T min_self(T& a, T b) { if (a > b) a = b; return a; }
template<typename T>   T add(T x, T y) { return ((x % MOD)  + (y % MOD)) % MOD;}
template<typename T>   T mul(T x, T y) { return ((x % MOD) * (long long)(y % MOD)) % MOD;}
template<typename T>   T sub(T x, T y) { return add(x, -y + MOD);}
template<typename T>   T gcd(T a, T b) { return b ? gcd(b, a % b) : a;}
template<typename T>   T lcm(T a, T b) { return a / gcd(a, b) * b;}
template<typename T>   vector<T> read(vector<T>& v, int n) {v.resize(n); for (auto &x : v)cin >> x;}
template<typename T>   void trav(vector<T> &v) {for (int i = 0 ; i < (int)v.size() ; ++i) {cout << v[i]; if (i != (int)v.size() - 1) cout << ' ';}}
int lg2(long long x)   {   return 64 - __builtin_clzll(x) - 1;	}
int lg2(int x)   {   return 32 - __builtin_clz(x) - 1;	}


//Variables Declaration


int main() {
	string A;
	cin>>A;
	if(A[2]==A[3] && A[4]==A[5]){
		cout<<"Yes"<<endl;
	}
	else cout<<"No";

	return 0;
}


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

using namespace std;

#define forn(a, e) for (int a = 0; a < (int)(e); a++)
#define forr(a, s, e) for (int a = s; a < (int)(e); a++)
#define fore(e, a) for (auto& e : a)

#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; fore(e, a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; fore(r, a) { fore(e, r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; fore(e, a) { cerr << e.field << " ";} cerr << "\n"; }
#define logvff(a, f1, f2) {cerr << #a".{"#f1 << ", "#f2 << "} = \n"; fore(e, a) { cerr << "(" << e.f1 <<", " << e.f2 << ") ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logvff(a, f1, f2)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif

using i64 = long long;
using iip = pair<i64, i64>;
using ivec = vector<int>;
using llvec = vector<i64>;
using svec = vector<string>;
template<typename T> using vec = vector<T>;

template<typename T, typename Dim>
auto make_vec(T value, Dim dim) { return vector<T>(dim, value); }
template<typename T, typename Dim1, typename... Dim>
auto make_vec(T value, Dim1 dim1, Dim... dims) { return make_vec(make_vec(value, dims...), dim1); }

template<typename T>
bool uax(T& v, const T& newv) { if (v < newv) { v = newv; return true; } else return false; }
template<typename T>
bool uin(T& v, const T& newv) { if (v > newv) { v = newv; return true; } else return false; }

template<typename T>
istream& operator>>(istream& is, vector<T>& c) { for (auto& e : c) is >> e; return is; }

template<typename ...T>
istream& read(T&... args) { return (cin >> ... >> args); }

static mt19937 rande(123123);
template<typename T>
T rand_int(T from, T to) { uniform_int_distribution<T> distr(from, to); return distr(rande); }

const i64 M = 1e9 + 7;

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

    i64 n, k;
    while (read(n, k)) {
        llvec a(n);
        read(a);

        llvec cc(n);
        forn(i, n) {
            forn(j, i) {
                if (a[i] < a[j]) {
                    cc[i]++;
                }
            }
        }

        i64 ans = 0;
        forn(i, n) {
            forn(j, n) {
                if (a[i] < a[j]) {
                    ans += (k - 1) * k / 2;                    
                    ans %= M;
                }
            }
            ans += k * cc[i];
            ans %= M;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n,k;
    cin >> n >> k;
    vector <int> h(n);
    REP(i,n)cin >> h[i];
    sort(h.begin(),h.end());
    int ans=1000000000;
    REP(i,n-k+1){
        int diff=max(h[i],h[i+k-1])-min(h[i],h[i+k-1]);
        ans = min(ans,diff);
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
using ll = long long;
int main(){
    ll n;
    
    cin >> n;
    ll array[n+1];
    for ( int i = 0;i< n;++i){
        cin >> array[i];
    }
    ll answer =-1;
    int rinp = 1;
    int flag =0;
    while(array[rinp-1] != 2){
        if(array[rinp-1]==-5){
            flag =1;
        }
        if(flag ==1){
            answer = -3;
            break;
        }
        int coo = rinp;
        rinp = array[rinp-1];
        array[coo-1]=-5;
        answer++;
        
    }   

  

    cout << answer + 2 << endl;



    


}

Measured memory_bytes: 1656
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

a,b=i2()
s=max(a+b,a-b,a*b)
print(s)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

const int mod = 1000000007;
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;}

mint f(int n, int r){
    mint nn = 1, rr = 1;
    rep(i, r){
        nn *= n-i;
        rr *= (i+1);
    }
    return nn / rr;
}

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    mint ans = 2;
    ans = ans.pow(n);
    ans -= 1;
    ans -= f(n, a) + f(n, b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
void solve() {
	while (true) {
		int n, m, k;
		cin >> n >> m >> k;
		if (n == 0) return;
		long double dp[30001] = {};
		dp[0] = 1;
		REP(i, n) {
			for (int q = 30000; q >= 0; --q) {
				if (dp[q] == 0.00000000000000L) {
					continue;
				}
				long double prob = dp[q] / (long double)m;
				for (int j = 1; j + q <= 30000 && j <= m; ++j) {
					dp[q + j] += prob;
				}
				dp[q] = 0;
			}
		}
		long double ans = 0;
		for (int i = 0; i <= 30000; ++i) {
			long double cnt = max(1LL, i - k);
			ans += dp[i] * cnt;
		}
		cout << ans << endl;
	}
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3632
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
            _
            int n; cin>>n;
            map<int,int> mp;
            vi vec(n);
            rep(i,n){
                int a; cin>>a;
                mp[a]++;
                vec[i]=a;
            }
            if(mp[1]==0){
                cout<<-1;
                return 0;
            }
            ll ans=0;
            int k=1;
            rep(i,n){
                if(vec[i]==k){
                    k++;
                }
                else ans++;
            }
            cout<<ans<<endl;

return 0;
}




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

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

    string s;
    cin >> s;

    bool flg1 = false;
    bool flg2 = false;
    bool flg3 = true;
    int cidx = 0;

    if(s[0] == 'A') flg1 = true;
    else flg1 = false;

    for (int i = 2; i < s.length()-1; ++i){
        if(s[i] == 'C') {
            flg2 = flg2 || true;
            cidx = i;
            }
        else flg2 = flg2 || false;
    }

    for (int i = 1; i < s.length(); ++i){
        if(('a'<=s[i] && s[i]<='z') || i==cidx) flg3 = flg3 && true;
        else flg3 = false;
        
    }

    if(flg1 && flg2 && flg3) puts("AC");
    else puts("WA");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
char s[N];
int main()
{
	scanf("%s",s+1);
	if (strlen(s+1)%2==1) { puts("No"); return 0; }
	for (int i=1;i<=strlen(s+1);i+=2)
		if (s[i]!='h'||s[i+1]!='i') { puts("No"); return 0; }
	puts("Yes");
}

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

int main() {
  ll N,K;
  cin >> N >> K;
  set<ll> set;
  for(int i=0;i<K;i++){
    ll a;
    cin >> a;
    for(ll b = 0; b < a; b++){
      ll c[b];
      cin >> c[b];  
      set.insert(c[b]);
    }
  }
  cout << N - set.size()<<endl;
}


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


int main() {

    int n;
    cin >> n;
    int high = 0;
    int ans = 0;
    rep(i,n) {
        int h; cin >> h;
        if (h >= high) ++ans;
        high = max(high, h);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

vector<int> PriceInfo;

void solve(int n) {
	int minR, maxProfit;

	minR = PriceInfo[0];
	maxProfit = -1000000000;
	for (int i = 1; i < n; ++i) {
		maxProfit = max(maxProfit, PriceInfo[i] - minR);
		minR = min(minR, PriceInfo[i]);
	}

	cout << maxProfit << endl;
}

int main() {
	int n, r;

	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> r;
		PriceInfo.push_back(r);
	}
	solve(n);
	
	return 0;
}


Measured memory_bytes: 3820
#include	<stdio.h>
int	main(void)
{
	int a,b,c,w;
	scanf("%d %d %d",&a,&b,&c);
	
	if(a>b){
		w=a;
		a=b;
		b=w;
	}if(a>c){
		w=c;
		c=a;
		a=w;
	}if(b>c){
		w=b;
		b=c;
		c=w;
	}
	printf("%d %d %d\n",a,b,c);
	return	0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
int main(){
    //write code  here
    const double pi = 3.141592652589793228462643383279;
    double A,B;
    double H,M;
    cin >> A >> B >> H >> M;

    double a = (30.000000000 * H) + (M/2.000000000);
    double b = 6.000000000 * M;
    double theta = a-b;
    if (theta < 0) theta *= -1.000000000;

    if (theta > 180.000000000) theta = 360.000000000 - theta;

    double rad = pi/180.000000000 * theta;
//    cout << theta << endl;
//    cout << rad << endl;
//    cout << cos(rad) << endl;

    cout << fixed << setprecision(15) <<  sqrt((A*A) + (B*B) - (2.000000000*A*B*cos(rad))) << endl;

    return 0;
}

Measured memory_bytes: 4220
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;



int main() {
    string s;
    cin >> s;
    int count = 0;
    for (int i = 0; i < 3; i++) if (s[i] == '1')count++;
    cout << count << endl;
    return 0;
}

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

int n, m;
vector<int> adjr[100001];
int dp[100001] = {};

int d(int v)
{
    if (dp[v] == 0)
    {
        int ma = 0;
        for (auto a : adjr[v])
            ma = max(d(a), ma);
        
        dp[v] = ma + (adjr[v].size() != 0);
    }
    
    return dp[v];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    cin >> n >> m;
    
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        adjr[b].push_back(a);
    }
    
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        if (dp[i] == 0)
            ans = max(ans, d(i));
    }
    
    cout << ans;

    return 0;
}


Measured memory_bytes: 15504
n=int(input())
a=list(map(int,input().split()))
s2=int(sum(a)*sum(a))
a2=[int(i*i) for i in a]
# ans1=int((s2-sum(a2))/2)
gyakugen=pow(2,10**9+5,10**9+7)
ans1=(s2-sum(a2))*gyakugen
print(int(ans1%(10**9+7)))

Measured memory_bytes: 31568
#include<bits/stdc++.h>
#define int long long

using namespace std;

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

    stack<int> ans;
    set<int> d;
    int n, k, t;
    cin >> n >> k;
    for (int i = 0; i < k; i++)
        cin >> t, d.insert(t);

    bool check = true;
    for (; check; n++)
    {
        check = false;
        int tmp = n;
        while (!check && tmp)
        {
            if (d.count(tmp % 10))
                check = true;
            tmp /= 10;
        }
    }
    cout << n - 1 << '\n';

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

int cou;
int main() {
	string h;
	cin >> h;
	for (int i = 0; i < h.length(); ++i) {
		if (h[i] == 'o') { ++cou; }
	}
	cout << 700 + 100 * cou << endl;
}

Measured memory_bytes: 256
def examA():
    N = SI()
    ans = 0
    for i in N:
        ans += int(i)
    if ans==1:
        ans = 10
    print(ans)
    return

class combination():
    # 素数のmod取るときのみ　速い
    def __init__(self, n, mod):
        self.n = n
        self.fac = [1] * (n + 1)
        self.inv = [1] * (n + 1)
        for j in range(1, n + 1):
            self.fac[j] = self.fac[j - 1] * j % mod

        self.inv[n] = pow(self.fac[n], mod - 2, mod)
        for j in range(n - 1, -1, -1):
            self.inv[j] = self.inv[j + 1] * (j + 1) % mod

    def comb(self, n, r, mod):
        if r > n or n < 0 or r < 0:
            return 0
        return self.fac[n] * self.inv[n - r] * self.inv[r] % mod
def examB():
    N, A, B, K = LI()
    C = combination(N, mod2)
    Da = []
    for i in range(N+1):
        if (K-A*i)%B!=0 or (K-A*i)//B>N:
            continue
        Da.append((i, (K-A*i)//B))
#    print(Da)
    ans = 0
    for a,b in Da:
        cur = C.comb(N,a,mod2)*C.comb(N,b,mod2)
        ans +=cur
        ans %=mod2
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examB()


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

I n,dp[1024][100001],v[323456],w[323456];

void dfs(I i){
    I j=i/2;
    if(i>1){
        for(I k=100000;k+1;k--){
            if(dp[j-1][k]or!k){
                I ne=k+w[i-1];
                if(ne<=100000)dp[i-1][ne]=max(dp[j-1][k]+v[i-1],dp[i-1][ne]);
            }
            dp[i-1][k]=dp[j-1][k];
        }
    }
    if(i*2<=min(1024,n))dfs(i*2);
    if(i*2+1<=min(1024,n))dfs(i*2+1);
}

signed main(){
    cin>>n;
    REP(i,n){I x,y;cin>>v[i]>>w[i];}
    dp[0][w[0]]=v[0];
    dfs(1);
    REP(i,1024)REP(j,100000)dp[i][j+1]=max(dp[i][j],dp[i][j+1]);
    I q;cin>>q;
    REP(i,q){
        I u,l;cin>>u>>l;
        vector<I> cand;
        while(u>1024){
            cand.push_back(u);
            u=u/2;
        }
        I r=cand.size();
        I ans=0;
        REP(j,1<<r){
            I v_sub=0;I w_sub=0;
            REP(k,r){
                if(j>>k&1){
                    v_sub+=v[cand[k]-1];
                    w_sub+=w[cand[k]-1];
                }
            }
            if(w_sub<=l)ans=max(ans,dp[u-1][l-w_sub]+v_sub);
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 405672
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using i64 = int64_t;

int H, W, h, w;

int main() {
    cin >> H >> W >> h >> w;

    int b[500][500], sm = 0;
    for (int j = 0; j < H; ++j) {
        for (int k = 0; k < W; ++k) {
            if ((j+1) % h == 0 && (k+1) % w == 0) {
                b[j][k] = -1000 * (h*w-1) - 1;
            } else {
                b[j][k] = 1000;
            }
            sm += b[j][k];
        }
    }
    if (sm <= 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
        for (int j = 0; j < H; ++j) {
            for (int k = 0; k < W; ++k) {
                if (k > 0) cout << ' ';
                cout << b[j][k];
            }
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(vector<int>::iterator itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair

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

using namespace std;

int t, max_num, f = 0;
vector<int> ans;

int get_nextnum(int x){
  char s[10];
  sprintf(s, "%d", x);
  return s[0] + '0';
}

int calc_digit(int x){
  int res = 0;
  while(x != 0){
    x /= 10;
    res++;
  }
  return res;
}

void solve(vector<int> v, int digit, int n, int num){
  if(n == digit){
    int sum = 0;
    v.pb(num);
    REPI(itr,v){
      sum += *itr;
    }
    if(t >= sum && sum == max_num){
      f = 1;
    }else if(t >= sum && sum > max_num){
      max_num = sum;
      f = 0;
      ans.clear();
      copy(v.begin(), v.end(), back_inserter(ans));
    }
    return;
  }
  
  solve(v, digit, n + 1, num);
  if(get_nextnum(num) != 0){
    int tmp = 1;
    REP(i,digit - n){
      tmp *= 10;
    }
    v.pb(num / tmp);
    solve(v, digit, n + 1, num % tmp);
  }
}

int main(){

  while(true){
    int num;
    scanf("%d %d", &t, &num);
    
    if(t == 0 && num == 0)  break;
    if(t == num){
      printf("%d %d\n", t, num);
      continue;
    }
    int digit = calc_digit(num);
    max_num = -1, f = 0;
    vector<int> v;
    solve(v, digit, 1, num);
    if(max_num == -1){
      printf("error\n");
    }else if(f == 1){
      printf("rejected\n");
    }else{
      printf("%d ", max_num);
      REPI(itr, ans){
        printf("%d", *itr);
        vector<int>::iterator itrt = itr;
        itrt++;
        if(itrt != ans.end()){
          printf(" ");
        }
      }
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 3212
#include<bits/stdc++.h>
#define ll long long int
#define Y printf("YES\n")
#define N printf("NO\n")
#define pb push_back
#define tp make_tuple
#define srt(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define pr(a) printf("%lld\n",a)
#define r0 return 0
#define pi acos(-1)
using namespace std;

int main()
{
    ll n,m,i,j,k,x,y,z,t;

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

    string s,str;

    cin>>s>>str;

    k=str.size();

    ll cnt,mx=k;

    for(i=0;i<=s.size()-k;i++)
    {
        string kk=s.substr(i,k);

         cnt=0;

        for(j=0;j<k;j++)
        {
            if(str[j]!=kk[j])cnt++;
        }

        mx=min(mx,cnt);
    }

    cout<<mx<<endl;
}


Measured memory_bytes: 3628
def insertionSort(A, N):
    for i in range(1, N):
        for j in range(N - 1):
            print(A[j], end=' ')
        print(A[-1])
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
    for j in range(N - 1):
        print(A[j], end=' ')
    print(A[-1])

n = int(input())
A = list(map(int, input().split()))
insertionSort(A, n)



Measured memory_bytes: 5976
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


// 累乗mod
ll pmod(ll n, ll m){
    if(m == 0) return 1;
    if(m == 1) return n % MOD;
    if(m % 2 == 0){
        return pmod(n * n % MOD, m / 2) % MOD;
    }
    return n * pmod(n * n % MOD, (m - 1) / 2) % MOD;
}

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

    ll ans = ((pmod(10, N) + pmod(8, N)) % MOD) - (pmod(9, N) * 2 % MOD);
    if(ans < 0){
        ans += MOD;
    }
    ans %= MOD;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int inf = 2e18;  
const int mod1 = 998244353;
const int mod = 1e9 + 7;

void solve()
 {
  int d,t,s;
  cin>>d>>t>>s;
  double ok = 1.0*d/s;
  if(ok <= (double)t)
     cout<<"Yes";
  else
     cout<<"No";
 }
signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
 /* int t;
  cin>>t;
  while(t--)*/
  solve();
  // cerr<<END<<1.0*clock()/CLOCKS_PER_SEC;
  return 0;
} 

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int n, a[323123];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	for (int i = 1, lst; i <= n; i = lst) {
		for (lst = i + 1; lst <= n && ((a[lst] == lst) ^ (a[lst - 1] == lst - 1)); ++lst);
		if (i + 1 == lst) {
			if (a[i] == i) continue;
			printf("No"); return 0;
		}
		if (a[i] == i) ++i;
		if (a[lst - 1] == lst - 1) --lst;
		int la = 0, lb = 0;
		for (int j = i; j < lst; j += 2) {
			if (a[j] < i || a[j] >= lst) {
				printf("No"); return 0;
			}
			if (j > a[j]) {
				if (la > a[j]) {
					printf("No"); return 0;
				}
				la = a[j];
			} else {
				if (lb > a[j]) {
					printf("No"); return 0;
				}
				lb = a[j];
			}
		}
	}
	printf("Yes");
}


Measured memory_bytes: 1536
///#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
///#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,popcnt,avx,avx2,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

/*
    zet:
        find_by_order(k): k-stat [k > 0]
        order_of_key(k) : {el < k}

    gp_hash_table<key, val, custom_hash>

    rope<T>:
        iterators: mutable_begin, ..
        methods  : erase, insert, substr, ..
*/

#define all(x) (x).begin(), (x).end()
#define size(x) (int)((x).size())
#define em_back emplace_back

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<typename T>
using zet = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

mt19937 eng(chrono::steady_clock::now().time_since_epoch().count());

const int mod = 1e9 + 7;
const int N = 2e5 + 4;

int sum(int x, int y) {
    return (x + y) % mod;
}

int mult(int x, int y) {
    return (ll)x * y % mod;
}

int binpow(int x, int y) {
    if (!y) {
        return 1;
    }
    if (y & 1) {
        return mult(x, binpow(x, y - 1));
    } else {
        return binpow(mult(x, x), y >> 1);
    }
}

int h, w, a, b;
int fact[N], ifact[N];

void prepare() {
    fact[0] = 1;
    for (int i = 1; i < N; ++i) {
        fact[i] = mult(fact[i - 1], i);
    }
    ifact[N - 1] = binpow(fact[N - 1], mod - 2);
    for (int i = N - 2; i >= 0; --i) {
        ifact[i] = mult(ifact[i + 1], i + 1);
    }
}

int c(int k, int n) {
    return mult(fact[n], mult(ifact[k], ifact[n - k]));
}

void calc() {
    int res = 0;
    for (int t = 1; t <= h - a; ++t) {
        res = sum(res, mult(c(b - 1, b + t - 2), c(h - t, h - t + w - b - 1)));
    }
    cout << res << "\n";
}

void solve() {
    cin >> h >> w >> a >> b;
    prepare();
    calc();
}

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

    int z = 1;
    /// cin >> z;

    while (z--) {
        solve();
    }

    return 0;
}


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

int main(void){
    int N , M, C, sum, count = 0;
    cin >> N >> M >> C;
    int *A, *B, *P;
	A = new int[M];
	B = new int[M];
	P = new int[M];
	for(int i = 0; i < M; i++){
		cin >> B[i];
	}
    for(int iN = 0; iN < N; iN++){
		sum = 0;
        for(int iM = 0; iM < M; iM++){
			cin >> A[iM];
			sum += A[iM] * B[iM];
		}
		if(sum + C > 0){
			count++;
		}
	}
	cout << count;
	return 0;
}

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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        long N = cin.nextLong();
        long K = cin.nextLong();

        double ans = 0;
        for (long i = 1; i <= N; i++)
        {
            double tmp = 1.0 / N;
            long now = i;
            while (true)
            {
                if (now >= K)
                {
                    break;
                }
                now *= 2;
                tmp /= 2;
            }
            ans += tmp;
        }
        Console.WriteLine(ans.ToString("F12"));
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }

    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}


Measured memory_bytes: 13140