akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef pair<int, int> P;
typedef long long ll;

const int INF = 1 << 30;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

bool leap(int y)
{
	return ((y%4==0&&y%100!=0)||y%400==0);
}

#define debug(a, b, c) for(int i = 0; i < b; i++){for(int j = 0; j < c; j++){printf("%3d", a[i][j]);}puts("");}puts("-----------------------------------------");

int main()
{
	string sent;
	int JOI, IOI;

	while(cin >> sent)
	{
		JOI = 0;
		IOI = 0;
		for(int i = 0; i < sent.size(); i++)
		{
			if(sent.substr(i,3) == "JOI")
			{
				JOI++;
			}
			else if(sent.substr(i,3) == "IOI")
			{
				IOI++;
			}
		}
		cout << JOI << endl;
		cout << IOI << endl;
	}
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  int a, b, c;
  cin >> a >> b;
  c = a + b;

  if(c >= 10){
    cout << "error" << endl;
    return 0;
  }

  cout << c << endl;

  return 0;
}


Measured memory_bytes: 256
function main (input) {
  const S = input;
  var a = S.indexOf('a');
  var b = S.indexOf('b');
  var c = S.indexOf('c');

  if (a >= 0 && b >= 0 && c >= 0){
    console.log('Yes');
  } else {
    console.log('No');
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define EXIT(...) printf(__VA_ARGS__), exit(0)

template<typename T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int maxn = 280000;

int n, L;
int a[maxn + 5];

int ans[maxn + 5];

int pos[maxn + 5];
bool vis[maxn + 5];

int bitrev[maxn + 5];

int pre[maxn + 5];

int get_pre(int x) { return pre[x] == x ? x : pre[x] = get_pre(pre[x]); }

void dfs(int x)
{
	if (vis[x]) return;
	vis[x] = 1;
	int tmp = n - 1;
	REP(i, 0, L) if (!(x >> i & 1))
	{
		dfs(x | (1 << i));
		chkmin(tmp, a[x | (1 << i)]);
	}
	if (!~a[x]) 
	{
		tmp = get_pre(tmp);
		if (tmp == n) EXIT("NO\n");
		a[x] = tmp;
		if (!tmp) pre[tmp] = n;
		else pre[tmp] = get_pre(tmp - 1);
	}
	else if (tmp < a[x]) EXIT("NO\n");
}

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d", &L), n = 1 << L;
	REP(i, 0, n) scanf("%d", a + i), --a[i], pos[i] = i;
	sort(pos, pos + n, [&](int x, int y) { return a[x] > a[y]; });
	REP(i, 0, n + 1) pre[i] = i;
	REP(i, 0, n) if (~a[i])
	{
		if (!a[i]) pre[a[i]] = n;
		else pre[a[i]] = get_pre(a[i] - 1);
	}
	memset(vis, 0, sizeof vis);
	REP(i, 0, n) if (!vis[pos[i]])
	{
		dfs(pos[i]);
	}
	REP(i, 0, n) bitrev[i] = bitrev[i >> 1] >> 1 | ((i & 1) << (L - 1));
	REP(i, 0, n) 
	{
		ans[bitrev[i]] = a[i];
	}
	puts("YES");
	REP(i, 0, n) printf("%d ", ans[i] + 1);
	printf("\n");
	return 0;
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;
const long long INFL = 1LL<<60;

void dfs(vector<vector<int>>& edges, map<pair<int, int>, int>& colors, int s, int c = 0, int p=-1) {
  if (p != -1) colors[{min(s, p), max(s, p)}] = c;
  int color = 1;
  for (int& f : edges[s]) {
    if (f == p) continue;
    if (color == c) color++;
    dfs(edges, colors, f, color, s);
    color++;
  }
}

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

  int n;
  cin >> n;
  map<pair<int, int>, int> colors;
  vector<pair<int, int>> inputs;
  vector<vector<int>> edges(n, vector<int>());
  rep(i, n-1) {
    int a, b; cin >> a >> b; a--; b--;
    if (a > b) swap(a, b);
    edges[a].push_back(b);
    edges[b].push_back(a);
    colors[{a, b}] = -1;
    inputs.emplace_back(a, b);
  }

  int k = 0;
  rep(i, n) chmax(k, int(edges[i].size()));

  dfs(edges, colors, 0);

  cout << k << endl;
  for (auto& p : inputs) {
    cout << colors[p] << endl;
  }

  return 0;
}


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

int a[100001];


int main(){
    int n,q;
    
    ll b,c;
    ll sum=0;
    cin>>n;
    int temp;
    for(int i=0;i<n;++i){
        cin>>temp;
        sum=sum+temp;
        a[temp]++;
    }
    cin>>q;
    while(q--){
        cin>>b>>c;
        int count=a[b];
        sum = sum-(count*b);
        a[b]=0;
        a[c]=a[c]+count;
        sum = sum+(count*c);
        cout<<sum<<endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 3908
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep2(i, begin_i, end_i) for (int i = (int)begin_i; i < (int)end_i; i++)

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];
int x,y,z;
int main(){
    x=y=z=-1;
    int N,Y;
    cin>>N>>Y;
    for(int i=0;i<=N;i++){
        for(int j=0;i+j<=N;j++){
           int k=N-(i+j);
                if(10000*i+5000*j+1000*k==Y){
                    x=i;y=j;z=k;
            }
        }
    }
    cout<<x<<" "<<y<<" "<<z<<endl;
    return 0;
}




Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    private static int gcd(int a, int b) {
        return (b != 0) ? gcd(b, a % b) : a;
    }

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);

        int n = s.nextInt();
        int m = s.nextInt();
        int k = s.nextInt();

        ArrayList<Integer> divisors = new ArrayList<>();
        int g = gcd(n, m);
        for (int i = g + 1; i >= 1; i--) {
            if ((g % i) == 0) {
                k--;
                if (k == 0) {
                    System.out.println(i);
                    System.exit(0);
                }
            }
        }
    }
}


Measured memory_bytes: 23124
def list_count(my_list):
    dic={} #辞書型の宣言
    for num in my_list:
        if num in dic: #もしnumがkeyとして辞書にあれば
            dic[num]+=1 #valueに+1
        else: #なければ
            dic[num]=1 #dicにnumというkeyを追加し、対応するvalueを1とする
    return dic
n=int(input())
a=[input() for i in range(n)]
b=list_count(a)
m=max(b.values())
c=[]
#print(b)
for i in range(n):
    #print(a[i],b[a[i]],m)
    if b[a[i]]==m:
        c.append(a[i])
c=sorted(list(set(c)))
for s in c:
    print(s)

Measured memory_bytes: 45456
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#include <iomanip>
#include <tuple>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;

ll dp[200005] = {};

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	ll n,k;
	cin >> n >> k;
	ll ans = 0;
	ans += (ll)(n/k)*(ll)(n/k)*(ll)(n/k);
	
		ll t=0;
	if(k%2 == 0){
		for(int i=k/2;i<=n;i+=k){
			t++;
		}
		ans += t*t*t;
	}
	cout << ans << endl;

}


Measured memory_bytes: 256
#include "bits/stdc++.h" // {{{
using namespace std; typedef long long ll; typedef pair<int,int> pii;
#define val         const auto
#define eb          emplace_back
#define emp         emplace
#define fi          first
#define se          second
#define outl(x)     cout << (x) << '\n'
#define rep(i,n)    for(int i=0; i < (int)(n); ++i)
#define repr(i,h,l) for(int i=(h); i >= (int)(l); --i)
#define reps(i,s,t) for(int i=(s); i <= (int)(t); ++i)
#define ALL(x)      begin(x), end(x)
#define TMPLT(T,U)  template<class T, class U>
#define ten(p)      ((long long)(1e##p))
#define FILL(a,v)   memset((a), (v), sizeof(a))
#ifdef  DEBUG
#define debug(...)  fprintf(stderr, __VA_ARGS__)
#define show(x)     clog << #x << " \t\t= " << (x) << '\n'
#define show2(x,y)  clog << '(' << #x << ',' << #y << ")\t\t= " << '(' << (x) << "\t, " << (y) << ")\n"
#define LN()        fputs("\n--------------------------------\n", stderr)
#else
#define debug(...)
#define show(x)
#define show2(x,y)
#define LN()
#endif
#define def(op) inline bool operator op (const T &that) const { return comp(that) op 0; }
template<class T> struct Ordered
{ virtual int comp(const T &that) const = 0; def(==); def(!=); def(<); def(<=); def(>); def(>=); };
#undef def
namespace {
  constexpr int INF = 0x3f3f3f3f; constexpr ll LINF = 0x3f3f3f3f3f3f3f3fLL; ostringstream _oss;
  TMPLT(T,U) inline constexpr common_type_t<T,U> gcd(T x, U y)
  { return (x<y)? gcd(y,x) : (y <= 0)? x : gcd(y, x % y); }
  TMPLT(T,U) inline bool chmax(T &a, const U &b){return b>a ? a=b,1 : 0;}
  TMPLT(T,U) inline bool chmin(T &a, const U &b){return b<a ? a=b,1 : 0;}
  TMPLT(T,U) inline constexpr ll lcm(T x, U y) { return (ll)x/gcd(x,y) * y; }
  template<class T>   string toString(const T &x){ _oss.str(""); _oss << x; return _oss.str(); }
  template<class Itr> string mkString(Itr begin, Itr end, const char *sp = " ") {
    _oss.str(""); for(Itr i=begin; i != end; ++i) { if(i != begin)_oss << sp; _oss << *i; }
    return _oss.str();
  }
  // }}}

constexpr int MX = ten(5) + 10;

void Xx_main_xX(const vector<char*> &args)
{
  int N;
  cin >> N;
  ll p[MX];

  ll sum = 0;
  ll maxv= 0;
  rep(i, N) {
    cin >> p[i];
    chmax(maxv, p[i]);
    sum += p[i];
  }

  sum -= maxv;
  sum += maxv / 2;

  outl(sum);
}

} // {{{
signed main(signed argc, char *argv[]) {
#ifndef DEBUG
  ios::sync_with_stdio(false); cin.tie(nullptr);
#endif
  cout << fixed << setprecision(9); Xx_main_xX(vector<char*>(argv, argv+argc)); return 0;
} // }}}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.nextLine();
		String T = sc.nextLine();
		for(int i=0;i<=S.length();i++) {
			if(T.equals(S)) {
				System.out.println("Yes");
				return;
			}
			S = rotate(S);
		}
		System.out.println("No");
	}
	static String rotate(String str) {
		StringBuilder ans = new StringBuilder(str);
		ans.insert(0,ans.charAt(ans.length()-1));
		ans.deleteCharAt(ans.length()-1);
		return ans.toString();
	}
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){ 
    int N;
  int o = 0;
  o = 1;
    cin >>N;
    vector<int> A(N+1);
    vector<int>  B(N+1);
    vector<int>  C(N);
    for(int i = 1 ;i < N+1;i++){
        cin >> A[i];
    }
    for(int i = 1 ;i < N+1;i++){
        cin >> B[i];
    }
    for(int i = 1 ;i < N;i++){
        cin >> C[i];
    }
    int ans = 0;
    for(int i = 1;i < N+1;i++){
        ans += B[A[i]];
        if(i >= 2){
            if(A[i] - A[i-1] == 1){
                ans += C[A[i-1]];
            }
        }
    }
    cout << ans << endl;
}   


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

vecl dividers(ll N) {
    vecl res;
    for(ll i = 1; i * i <= N; i++) {
        if(N%i == 0) {
            res.push_back(i);
            if(i != N/i) res.push_back(N/i);
        }
    }
    return res;
}

int main() {
    ll N;
    cin >> N;
    vecl res = dividers(N);
    ll ans = 0;
    for(ll p : res) {
        if(1 <= p && p <= N-1) {
            ll m = N/p-1;
            if(N/m == N%m) ans += m;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 (ll)1 << 60
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll a, b, c;
int main() {
	cin >> a >> b >> c;
	if (a == b and b == c)cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


using vvll = vector< vector<ll> >;
using vll = vector<ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

ll fast(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        y >>= 1;
    }
    return res;
}

ll inv(ll n){
    return fast(n,mod-2);
}

const ll N = 2e6+5;
ll fact[N];
ll ifact[N];
ll p25[N];

void pre(){

    fact[0] = 1;
    ifact[0] = 1;
    p25[0] = 1;
    for(ll i=1;i<N;i++){
        fact[i] = fact[i-1]*i%mod;
        ifact[i] = inv(fact[i]);
        p25[i] = p25[i-1]*25%mod; 
    }

}

ll ncr(ll n,ll r){
    ll tmp = fact[n]*ifact[r]%mod;
    tmp = tmp*ifact[n-r]%mod;
    return tmp;
}

void solve(){

    ll k;
    cin >> k;
    string s;
    cin >> s;
    ll n = s.size();
    ll sz = n+k;
    ll ans = 0;
    for(ll i=n;i<=sz;i++){
        ans += ncr(sz,i)*p25[sz-i]%mod;
        ans %= mod;
    }
    cout << ans << endl;

}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 51152
from sys import stdin, stdout
input = stdin.readline
#print = stdout.write
n = int(input())
a = list(map(int,input().split()))
yen = 1000
stocks = 0
for i in range(n - 1):
    if a[i]<a[i+1]:
        stocks += yen//a[i]
        yen -= (yen//a[i])*a[i]
    elif a[i]>a[i+1]:
        yen += stocks * a[i]
        stocks = 0
    #print(yen, stocks)
yen += stocks * a[n-1]
print(yen)

Measured memory_bytes: 61808
x, n = map(int, input().split())
p = list(map(int, input().split()))

p_all = set(range(0, 102)) - set(p)
# print(p_all)

mi = float('inf')
ans = 0
for i in p_all:
    if abs(x - i) < mi:
        mi = abs(x - i)
        ans = i

print(ans)


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

using namespace std;

typedef long long ll;

int a[200005],b[200005];
queue <int> q;

int main() {
  int n;
  scanf("%d",&n);
  for(int i=1;i<=n;i++) scanf("%d",&b[i]);
  for(int i=1;i<=n;i++) scanf("%d",&a[i]);
  for(int i=1;i<=n;i++) {
  	if (a[i]<b[i]) {
  		puts("-1");
  		return 0;
	  }
    if (a[i]!=b[i]) q.push(i);
  }
  ll ans=0;
  while (!q.empty()) {
  	int x=q.front();q.pop();
  	int l=((x>1)?x-1:n),r=((x<n)?x+1:1);
  	if (a[x]<a[l]+a[r]||a[x]==b[x]) continue;
  	if (b[x]>=a[l]+a[r]&&a[x]%(a[l]+a[r])!=b[x]%(a[l]+a[r])) {
  		puts("-1");
  		return 0;
	  }
	if (b[x]>=a[l]+a[r]) {
		ans+=(a[x]-b[x])/(a[l]+a[r]);
		a[x]=b[x];
	}
	else {
		ans+=a[x]/(a[l]+a[r]);
		a[x]%=(a[l]+a[r]);
		if (a[x]<b[x]) {
			puts("-1");
			return 0;
		}
	}
	q.push(l);q.push(r);
  }
  for(int i=1;i<=n;i++)
    if (a[i]!=b[i]) {
    	puts("-1");
    	return 0;
	}
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
double arr[3000];
double dp[3000][3000];
int n;

double solve(int i, int x){   //From a subset of n elements atleast n heads.

	//cout<<"Caled"<<i<<" "<<x<<endl;

	//Base Cses
	if(x==0)
		dp[i][x]=1.0;
	else if(i==0)
		dp[i][x]=0.0;


	if(dp[i][x]>-0.9)
		return dp[i][x];

	double pi = arr[i-1];
	double ans  = pi*solve(i-1,x-1) + (1-pi)*solve(i-1,x);
	dp[i][x] = ans;


	return dp[i][x];
}




int main() {

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n;

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

	for(int i=0;i<=n;i++)
		for(int j=0;j<=n;j++)
			dp[i][j]=-1.0;
	
	cout<<fixed<<setprecision(9)<<solve(n,(n+1)/2)<<endl;

}

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

int main(){
    ll a, b, k;
    cin >> a >> b >> k;
    if(a-k < 0){
        k = k - a;
        b = max(0ll, b-k);
        cout << 0 << " " << b << endl;
    }else{
        a = a - k;
        cout << a << " " << b << endl;
    }
}

Measured memory_bytes: 256
def ilog2(n):
    return 0 if n <= 0 else n.bit_length() - 1
def pack(pack, shamt):
    size = len(pack)
    while size > 1:
        npack = []
        for i in range(0, size - 1, 2):
            npack += [pack[i] | (pack[i+1] << shamt)]
        if size & 1:
            npack += [pack[-1]]
        pack, size, shamt = npack, (size + 1) >> 1, shamt << 1
    return pack[0]
def unpack(M, size, shamt):
    s, sizes = size, []
    while s > 1:
        sizes += [s]
        s = (s + 1) >> 1
    ret = [M]
    for size in sizes[::-1]:
        mask, nret = (1 << shamt) - 1, []
        for c in ret:
            nret += [c & mask, c >> shamt]
        ret, shamt = nret[:size], shamt >> 1
    return ret
def poly_mul_mod(f, g, mod):
    size = min(len(f), len(g))
    shift = ((mod - 1) ** 2 * size).bit_length()
    rsize = len(f) + len(g) - 1
    h = unpack(pack(f, shift) * pack(g, shift), rsize, shift * (1 << ilog2(rsize - 1)))
    return [int(x % mod) for x in h]
mod, N = 998244353, 10 ** 4 + 10
def inv(n): return pow(n, mod - 2, mod)
def poly_power_mod(f, n, mx):
	ret = [1]
	while n:
		if n & 1 : ret = poly_mul_mod(ret, f, mod)[:mx]
		f = poly_mul_mod(f, f, mod)[:mx]
		n >>= 1
	return ret	

fact, ifact, sm, poly = [1] * N, [1] * N, 1, [1] * N
for i in range(1, N): 
	fact[i], ifact[i] = (fact[i - 1] * i) % mod, (ifact[i - 1] * inv(i)) % mod
	poly[i - 1] = ifact[i]

A, B, n, m = raw_input(), raw_input(), 0, 0
for i in range(len(A)):
	if(A[i] == '1'):
		n += 1
		if(B[i] != '1'): m += 1		

ans, poly = 0, poly_power_mod(poly, m, n + 1)
for k in range(n - m + 1):
	term = fact[n - m - k] * fact[n - m - k] % mod
	if k < len(poly):
		term *= poly[k] * fact[m]
	else : term = 0	
	term *= fact[n - m] * fact[n] * ifact[n - m - k] * ifact[n - m - k]
	ans += term

print ans % mod	


Measured memory_bytes: 7716
#include <iostream>
#include <cstring>
#include <fstream>
#include <string>
#include <cmath>
using namespace std;
int main()
{
    unsigned long long a,b;
    long long max=-9999999;
    unsigned long long n;
    int h;
    cin>>a>>b>>n;
    for(int i=0;i<=n/b;i++)
    {
        h=i;
    }
  if(h>0)
  {
    for(int i=0;i<1;i++)
    {
        if(max<floor(a*((b-1)+i*b)/b)-a*i)
            max = floor(a*((b-1)+i*b)/b)-a*i;
    }
  }
    if(max<floor(a*n/b)-floor(n/b)*a)
        max = floor(a*n/b)-floor(n/b)*a;
    cout<<max;
}


Measured memory_bytes: 3592
D = int(input())
c = list(map(int, input().split()))
sdi = [list(map(int, input().split())) for i in range(D)]

import numpy as np

lastdi = [0 for i in range(26)]
ans_c = []

d = 0
while True:
  if d == D:
    break
  if d < D - 3:
    day_s = sdi[d]
    
    sloss = [day_s[i] + c[i]*(d - lastdi[i]) for i in range(26) ]
    ans = sloss.index(max(sloss))
    ans_c.append( ans+1 )
    
    for i in range(26):
      if i != ans:
        lastdi[i] += 1
    lastdi[ans] = d
    d += 1
    
  else:
    
    a = [sdi[d][i] + sdi[d+1][i2] + sdi[d+2][i3] - 3 * sum([c[k]*( d - lastdi[k] + 1) for k in range(26) if k not in [i,i2,i3]] )- 3*c[i] - c[i2]*(d+1+lastdi[i2]) - c[i3]*(2*d-2*lastdi[i3]) for i in range(26) for i2 in range(26) for i3 in range(26)]
    idx = a.index(max(a))
    best_i3 = idx % 26 + 1
    best_i2 = (idx // 26) % 26 + 1
    best_i1 = idx // 676 + 1
    
    ans_c.append(best_i1)
    ans_c.append(best_i2)
    ans_c.append(best_i3)
    lastdi[best_i1-1] = d
    lastdi[best_i2-1] = d+1
    lastdi[best_i3-1] = d+2
    
    d += 3

for i in range(D):
  print(ans_c[i])

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

int main(){
  
  int a; cin >> a;
  int cur = 1;
  vector<int> v(a+1);
  for(int i = 1; i <= a; ++i) cin >> v[i];
  
  for(int i = 0; i < 100009; ++i){
    cur = v[cur];
    if(cur == 2){
      cout << i+1;
      return 0;
    }
  }
  
  
  cout << -1;
  return 0;
}


Measured memory_bytes: 768
import java.util.*;

public class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        char c1[] = sc.next().toCharArray();
        char c2[] = sc.next().toCharArray();
        char c3[] = sc.next().toCharArray();

        System.out.println(c1[0]+""+c2[1]+""+c3[2]);
    }
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int x, y;
  cin >> x >> y;
  bool flg = false;

  if ((x == 4 || x == 6 || x == 9 || x == 11) &&
      (y == 4 || y == 6 || y == 9 || y == 11))
    flg = true;
  else if ((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 ||
            x == 12) &&
           (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 ||
            y == 12))
    flg = true;

  cout << (flg ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
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 FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
int a[100];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  bool check[8];
  fill(check, check + 8, false);
  int ans = 0;
  int sum = 0;
  REP(i, n) {
    cin >> a[i];
    if(1 <= a[i] && a[i] <= 399) {
      if(check[0]) continue;
      ans++;
      check[0] = true;
    } else if(400 <= a[i] && a[i] <= 799) {
      if(check[1]) continue;
      ans++;
      check[1] = true;
    } else if(800 <= a[i] && a[i] <= 1199) {
      if(check[2]) continue;
      ans++;
      check[2] = true;
    } else if(1200 <= a[i] && a[i] <= 1599) {
      if(check[3]) continue;
      ans++;
      check[3] = true;
    } else if(1600 <= a[i] && a[i] <= 1999) {
      if(check[4]) continue;
      ans++;
      check[4] = true;
    } else if(2000 <= a[i] && a[i] <= 2399) {
      if(check[5]) continue;
      ans++;
      check[5] = true;
    } else if(2400 <= a[i] && a[i] <= 2799) {
      if(check[6]) continue;
      ans++;
      check[6] = true;
    } else if(2800 <= a[i] && a[i] <=3199) {
      if(check[7]) continue;
      ans++;
      check[7] = true;
    } else {
      sum++;
    }
  }

  cout << ((sum >= 1 && ans == 0) ? 1 : ans) << " ";
  cout << ans + sum << endl;
}


Measured memory_bytes: 256
#include <cmath>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;

ld r;

void input() {
  cin >> r;
}

void solve() {
  cout << 2 * M_PI * r << '\n';
}

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

  cout.precision(16);
  cout << fixed;

  int _times = 1;

#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);

  _times = 2;
#endif

  // cin >> _times;

  while (_times--) {
    input();
    solve();
  }
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	int ans = c - (a - b);
	if(ans > 0) printf("%d\n", ans);
	else printf("0\n");
	return 0;
}

Measured memory_bytes: 3724
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int a[20][2],f[300010][20];
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n=read();
	for(int i=0;i<n;i++)a[i][0]=read();
	for(int i=0;i<n;i++)a[i][1]=read();
	memset(f,-1,sizeof(f));
	for(int i=0;i<n;i++)f[1<<i][i]=i;
	for(int i=1;i<(1<<n);i++)
	{
		int tot=0,sum=0;
		for(int j=0;j<n;j++)if(i>>j&1)tot++;
		for(int j=0;j<n;j++)
		{
			if(i>>j&1)
			{
				if(f[i][j]==-1)continue;
				int wy=(tot+2*sum-j-1)&1,cnt=0;
				for(int k=0;k<n;k++)
				{
					if(i>>k&1)continue;
					cnt++;int ul=(tot+2*cnt-k-2)&1;
					if(a[j][wy]>a[k][ul])continue;
					int uf=f[i][j]+cnt-1;
					if(f[i+(1<<k)][k]==-1)f[i+(1<<k)][k]=uf;
					else f[i+(1<<k)][k]=min(f[i+(1<<k)][k],uf);
				}
			}
			else sum++;
		}
	}
	int ans=-1;
	for(int i=0;i<n;i++)
	{
		if(f[(1<<n)-1][i]!=-1)
		{
			if(ans==-1)ans=f[(1<<n)-1][i];
			else ans=min(ans,f[(1<<n)-1][i]);
		}
	}pr2(ans);
	return 0;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define LL long long
using namespace std;
string N; int l,K; LL ans;
LL dp[105][5][2];
int main(){
	int i,j,k,t;
	cin >> N >> K; l = N.size();
	for (i = 0; i < l; ++i){
		for (j = 0; j <= 9; ++j){
			if (j){
				if (i==0){
					if (j < N[0]-'0') ++dp[i][1][1];
					else if (j==N[0]-'0')++dp[i][1][0];
				}
				else ++dp[i][1][1];
			}
			if (i>0){
				for (k = 1; k <= K; ++k)
				for (t = 0; t <= 1; ++t){
					//dp[i-1][k][t];
					if (t==1){
						if (j) dp[i][k+1][t] += dp[i-1][k][t];
						else dp[i][k][t] += dp[i-1][k][t];
					}
					if (t==0){
						if (j>N[i]-'0') continue;
						if (j==N[i]-'0'){
							if (j) dp[i][k+1][t] += dp[i-1][k][t];
							else dp[i][k][t] += dp[i-1][k][t];
						}
						if (j<N[i]-'0'){
							if (j) dp[i][k+1][1] += dp[i-1][k][t];
							else dp[i][k][1] += dp[i-1][k][t];
						}
					}
				}
			}
		}
		if (i==l-1){
			for (k = K; k <= K; ++k)
			for (t = 0; t <= 1; ++t) ans += dp[i][k][t];
		}
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int64, int64> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int64 n;
  cin >> n;
  set<int64> ret;
  for (int64 i = 1; i * i <= n - 1; ++i) {
    if ((n - 1) % i == 0) {
      if (i != 1) ret.insert(i);
      if ((n - 1) / i != 1) ret.insert((n - 1) / i);
    }
  }
  // trace(ret);
  vector<int64> f;
  for (int64 i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      if (i != 1) f.push_back(i);
      if (i * i != n) f.push_back(n / i);
    }
  }
  for (auto& p : f) {
    for (int64 q = p; ; q *= p) {
      if (n / q % p == 1) ret.insert(p);
      if (n / q % p) break;
    }
  }
  // trace(ret);
  cout << (int)ret.size() << endl;
  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int main(){
  int n,i,j,k;
  char s[4006];
  int cnt = 0;
  int g = 0;
  int b = 0;
  int r = 0;

  scanf("%d", &n);
  scanf("%s", s);

  for(i = 0;i < n;i++){
    if(s[i] == 'R') r++;
    if(s[i] == 'B') b++;
    if(s[i] == 'G') g++;
  }

  for(i = 0;i < n - 1;i++){
    for(j = i + 1;j < n;j++){
      k = 2*j - i;
      if(k < n && s[i] != s[j] && s[j] != s[k] && s[i] != s[k]) cnt++;
    }
  }

  printf("%lld\n", r*b*g - cnt);

  return 0;
}


Measured memory_bytes: 1736
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def main():
    n = int(input().strip())
    v = input().strip()
    if n % 2 == 1:
        print('No')
        return
    if v[:n//2] == v[n//2:]:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll mod =1e9 + 7;
ll size;

int main(){
	int a , b;
	int k;
	cin >> k;
	cin >> a >> b;
	for(int i = a ; i <= b ; i++){
		if(i % k == 0)
		{
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int X, Y, Z, K;
	cin >> X >> Y >> Z >> K;
	VI A(X), B(Y), C(Z);
	REP(i, X)cin >> A[i];
	REP(i, Y)cin >> B[i];
	REP(i, Z)cin >> C[i];
	rSORT(A);
	rSORT(B);
	rSORT(C);

	VI AB,ABC;
	REP(i, min(3000LL, X)) {
		REP(j, min(3000LL, Y)) {
			AB.push_back(A[i] + B[j]);
		}
	}
	rSORT(AB);
	REP(i, min(3000LL, (int)AB.size())) {
		REP(j, min(3000LL, Z)) {
			ABC.push_back(AB[i] + C[j]);
		}
	}
	rSORT(ABC);
	REP(i, K)cout << ABC[i] << endl;
	return 0;
}



Measured memory_bytes: 42600
#include<bits/stdc++.h>
using namespace std;
vector<int> v[100100];
bool visited[100100];
int dp[100100];
void dfs(int a)
{
    visited[a]=1;
    for(int i=0;i<v[a].size();i++)
    {
        int j= v[a][i];
        if(visited[j]==0)
        {
            // dp[j]=1;
            dfs(j);
        }
        dp[a] = max(dp[a],dp[j]+1);

    }
}
int main()
{
    int n,m;
    cin >> n >> m;
    int x,y;
    for(int i=0;i<m;i++)
    {
        cin >>  x >> y;
        v[x].push_back(y);
    }
    for(int i=1;i<=n;i++)
    {
        if(visited[i]==0)
        {
            // dp[i]=1;
            dfs(i);
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        ans = max(ans,dp[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  cout<<98<<" "<<99<<endl;
  a--;
  b--;
  for(int i=0;i<=48;i++){
    for(int j=0;j<=98;j++){
      if(i%2==0||j%2==0||a==0)
        cout<<'#';
      else{
        cout<<'.';
        a--;
      }
    }
    cout<<endl;
  }
  for(int i=0;i<=48;i++){
    for(int j=0;j<=98;j++){
      if(i%2==0||j%2==0||b==0)
        cout<<'.';
      else{
        cout<<'#';
        b--;
      }
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)			(x).begin(),(x).end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF				(int)2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))	
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)	
#define FloorN(x, n)	((x)-(x)%(n))			
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define M_PI			3.14159265358979323846
typedef long long			ll;
typedef unsigned long long	ull;
typedef pair<ll, ll>		P;
typedef vector<ll>			VLL;
typedef vector<VLL>			VVLL;
typedef vector<VVLL>		VVVLL;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> s(M), c(M);
	REP(i, M) {
		cin >> s[i] >> c[i];
		s[i]--;
	}

	int minCnt;
	int maxCnt;
	if (N == 1) {
		minCnt = 0;
		maxCnt = 9;
	} else if (N == 2)	{
		minCnt = 10;
		maxCnt = 99;
	} else {
		minCnt = 100;
		maxCnt = 999;
	}

	int ans = -1;
	for (int i = minCnt; i <= maxCnt; i++) {
		bool isOk = true;
		string valStr = to_string(i);
		REP(j, M) {
			if (valStr.size() <= s[j]) {
				isOk = false;
				break;
			} else {
				if (c[j] + '0' != valStr[s[j]]) {
					isOk = false;
					break;
				}
			}
		}

		if (isOk) {
			ans = i;
			break;
		}
	}
		
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;

int main()
{
    ll x,y;
    cin >> x >> y;
    ll ans = inf * 1000;
    if(y >= x){
        ans = min(ans,y-x);
    }
    if(-x <= y){
        ans = min(ans,y+x+1);
    }
    if(x <= -y){
        ans = min(ans,-y-x+1);
    }
    if(-x <= -y){
        ans = min(ans,-y+x+2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define For(i,a,b) for(int i=a;i<b;i++)
#define reset(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define pi acos(-1)
#define eps 0.00000001
#define pb push_back
#define off 250555

long long h,w,a,b,fac[200005],inv[200005];


long long f(long long x, long long y)
{
    long long ret = fac[x+y] * inv[x];
    ret%=mod;
    ret*=inv[y];
    //cout<<x<<' '<<y<<' '<<ret<<endl;
    return ret%mod;
}

long long invv(long long x)
{
    long long ret=1;
    for(int i=30;i>=0;i--)
    {
        ret*=ret;
        ret%=mod;
        if((1ll<<i)&(mod-2))
        {
            ret*=x;
            ret%=mod;
        }
    }
    return ret;
}

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios::sync_with_stdio(0);
    fac[0]=inv[0]=1;
    For(i,1,200005)
    {
        fac[i]=fac[i-1]*i;
        fac[i]%=mod;
        inv[i]=invv(fac[i]);
    }
    cin>>h>>w>>a>>b;
    long long ans=0;
    For(i,0,h-a)
    {
        ans+=(f(i,b-1)*f(h-i-1,w-b-1))%mod;
        ans%=mod;
    }
    cout<<ans;
}


Measured memory_bytes: 3328
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		boolean odd[] = new boolean[num];
		for(int i = 0; i < num; i ++) {
			odd[i] = sc.nextLong() == 1;
		}
		boolean ans[] = new boolean[num];
		for(int i = num; i >= 1; i --) {
			ans[i - 1] = odd[i - 1];
			for(int j = 2; i * j <= num; j ++) {
				ans[i - 1] ^= ans[i * j - 1];
			}
		}
		int count = 0;
		for(int i = 0; i < num; i ++) {
			if(ans[i]) { count ++; }
		}
		System.out.println(count);
		StringBuilder str = new StringBuilder();
		for(int i = 0; i < num; i ++) {
			if(ans[i]) { str.append((i + 1)+" "); }
		}
		System.out.println(str);
	}
}

Measured memory_bytes: 66096
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
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; }

signed main() {
	string s; cin >> s;
	string ans = s;
	if (s.size() < 8) { cout << s << endl; return 0; }
	int c[200] = {};
	string t = "AIZUNYAN";
	rep(i, 0, s.size()) {
		c[s[i]]++;
		if (c['A'] == 2 && c['I'] == 1 && c['D'] == 1 && c['U'] == 1 && c['N'] == 2 && c['Y'] == 1) {
			rep(j, 0, 8)ans[i - 7 + j] = t[j];
		}
		if (i - 7 >= 0)c[s[i - 7]]--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define int long long
#define ff first
#define dd second
#define mp make_pair
#define pb push_back
#define pp pair<int,int>
#define N 200007 // check
#define K 13
using namespace std;

int n;

int tab[N];

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> tab[i];
        tab[i] -= i+1;
    }

    int best = 1e17;

    sort(tab, tab+n);

    int val = 0;
    int cur = tab[0];
    for(int i = 0; i < n; ++i) {
        val += tab[i]-cur;
    }

    best = val;

    int last = cur;

    for(int i = 0; i < n; ) {
        while(i < n and tab[i] == last)++i;
        if(i == n) break;
        val += (tab[i]-last)*i;
        val -= (n-i)*(tab[i]-last);
        last = tab[i];
        best = min(best, val);
    }
    cout << best << endl;

}

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

int main(){
  int h, w;
  int black = 1, white = 0;
  int dx[] = {-1, 0, 1, 0};
  int dy[] = {0, 1, 0, -1};
  cin >> h >> w;
  char grid[h][w] = {};
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> grid[i][j];
    }
  }
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(grid[i][j] == '#'){
        bool flag = false;
        for(int k = 0; k < 4; k++){
          int ni = i + dy[k];
          int nj = j + dx[k];
          if(ni >= 0 && ni < h && nj >= 0 && nj < w){
            if(grid[ni][nj] == '#') flag = true; 
          }
        }
        if(!flag){
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

typedef struct{
  char pics;
  int num;
}Card;

void BubbleSort(Card *, int);
void SelectionSort(Card *, int);
void Print(Card *, int);
int Compare(Card *, Card *, int);


void change(Card *a, Card *b){
  Card c;

  c = *a;
  *a = *b;
  *b = c;
}


int main(){
  int n,i,c;
  Card T1[100];
  Card T2[100];

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    scanf(" %c%d",&T1[i].pics,&T1[i].num);
    T2[i] = T1[i];
  }

  BubbleSort(T1,n);
  SelectionSort(T2,n);

  c = Compare(T1,T2,n);

  Print(T1,n);
  printf("Stable\n");
  Print(T2,n);
  if(c == 1) printf("Stable\n");
  else printf("Not stable\n");

 return 0;
}


void BubbleSort(Card A[], int x){
  int i,j;
  Card a;
  for(i = 0 ; i < x ; i++){
    for(j = x - 1 ; j >= i + 1 ; j--){
      if(A[j].num < A[j-1].num) change(&A[j],&A[j-1]);
    }
  }
}

void SelectionSort(Card A[], int x){
  int i,j,minj;
  Card a;

  for(i = 0 ; i < x ; i++){
    minj = i;
    for(j = i ; j < x ; j++){
      if(A[j].num < A[minj].num) minj = j;
    }
    change(&A[i],&A[minj]);
  }
}

void Print(Card A[], int x){
  int i;

  for(i = 0 ; i < x ; i++){
    if(i > 0) printf(" ");
    printf("%c%d",A[i].pics, A[i].num);
  }
  printf("\n");
}

int Compare(Card A1[], Card A2[], int x){
  int i;

  for(i = 0 ; i < x ; i++){
    if(A1[i].pics != A2[i].pics) return 0;
  }
  return 1;
}



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

  int N; cin >> N;
  vector<int> vec(N+1);
  for(int i=0;i<N;i++){
    cin >> vec.at(i);}
  vec.at(N)=9999;
  
  sort(vec.begin(),vec.end());
  vec.at(N)=vec.at(N-1);
    
  int sum=0;
  for(int j=0;j<N;j++){
    if(vec.at(j) < vec.at(j+1)){sum++;}
  }

  cout << sum+1 << endl;
}

Measured memory_bytes: 256
W,H,x,y,r = map(int, input().split())
dx1,dy1 = (x + r),(y + r)
dx2,dy2 = (x - r),(y - r)
if 0 <= dx1 <= W and 0 <= dx2 <= W and 0 <= dy1 <= H and 0 <= dy2 <= H:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5600
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
#include<numeric>
#include<complex>
#include<ctype.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void pV(vector<ll> A){
    cout << "[vector]" << endl;
    for(int i=0; i<A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    // input
    int N, T;
    cin >> N >> T;

    int c[N];
    int t[N];

    FOR(i, 0, N){
        cin >> c[i] >> t[i];
    }

    bool found = false;
    int minCost = 10000;
    FOR(i, 0, N){
        if(T >= t[i]){
            if(minCost > c[i]){
                minCost = c[i];
                found = true;
            }
        }
    }

    if(found){
        p(minCost);
    }else{
        p("TLE");
    }
    
    return 0;
}

Measured memory_bytes: 256
/*ID:PROG:LANG:*/
#include<bits/stdc++.h>
#define LL long long
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define MAXN 16
#define MAXM (1<<15)
using namespace std;
LL n,m,dp[MAXM],cnt[MAXN][MAXM];
bool mp[MAXN][MAXM],ok[MAXM];
LL rd(){
	LL x=0,tp=1;char c=getchar();
	while(c<'0' || c>'9'){if(c=='-')tp=-1;c=getchar();}
	while(c>='0' && c<='9'){x=(x*10+c-'0');c=getchar();}
	return x*tp;
}
LL quick_mod(LL a,LL x){LL res=1;while(x){if(x&1)(res*=a)%=MOD;(a*=a)%=MOD,x>>=1;}return res;}
int main(){
	// freopen("testdata.in","r",stdin);
	// freopen("1.out","w",stdout);
	int x,y;
	n=rd(),m=rd();
	int S=1<<n;dp[0]=1;
	for(int i=1;i<=m;i++){
		x=rd(),y=rd();
		mp[x][1<<(y-1)]=1;
	}
	for(int i=1;i<=n;i++){
		for(int sta=1;sta<S;sta++){
			int j=sta&-sta;
			cnt[i][sta]=cnt[i][sta^j]+mp[i][j];
		}
	}
	for(int sta=0;sta<S;sta++)ok[sta]=(((1&sta)>0)==((2&sta)>0));
	for(int sta=1;sta<S;sta++){
		if(ok[sta]){
			dp[sta]=1;
			for(int i=(sta-1)&sta;i;i=(i-1)&sta){//枚举子集
				if(ok[i]){
					LL j=sta^i,tmp=dp[j];
					for(int k=0;k<n;k++){
						if((j>>k)&1)(tmp*=(1<<cnt[k+1][i])-1)%=MOD;
						else if((i>>k)&1)(tmp*=(1<<cnt[k+1][j]))%=MOD;
					}
					(dp[sta]+=tmp)%=MOD;
				}
			}
		}
	}
	printf("%d\n",(quick_mod(2,m)-dp[S-1]+MOD)%MOD);
	// printf("%.2lf\n",(double)clock()/CLOCKS_PER_SEC);
	return 0;
}

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

int sum(int n){
	int a,b,c,d,ans = 0;
	rep(a,0,10)
	  rep(b,0,10)
	    rep(c,0,10)
	      rep(d,0,10)
	        if(n==a+b+c+d) ans++;
	return ans;
}

int main() {
	int n;
	while(cin >> n)
		cout << sum(n) << endl;	
	return 0;
}


Measured memory_bytes: 3048