akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define finput ifstream cin;cin.open("in.txt")
#define foutput ofstream cout;cout.open("out.txt")  
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define mod 1000000007

ll gcd(ll x, ll y){ 
	if(x<y) 
		swap(x,y); 
	if(x%y==0)
		return y;
	return gcd(y, x%y);
}

ll pwm(ll a, ll n){
	ll ans = 1;
	while(n>0){
		if(n%2==1){
			ans = (ans * a)%mod;
		}
		a = (a*a)%mod;
		n /= 2;
	}
	return ans%mod;
}

const int pwn = 100010;
ll pw[pwn];
void pwtwo(){
	pw[0] = 1;
	for(int i=1; i<pwn; i++){
		pw[i] = (pw[i-1]*2)%mod;
	}
}


ll gcdExtended(ll a, ll b, ll *x, ll *y); 
  
ll modInverse(ll a, ll m) 
{ 	
	if(a==1)
		return 1;
	//cout<<"mi "<<a<<" "<<m<<" ";
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
    if (g != 1){
        //cout << "Inverse doesn't exist"<<endl; 
        return -1;
    }
    else
    { 
        // m is added to handle negative x 
        ll res = (x%m + m) % m; 
        //cout<<res<<endl;
        return res;
        // cout << "modular multiplicative inverse is " << res; 
    } 
} 
  
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    ll x1, y1;
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
  
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
} 

ll fact[1010];
ll init(){
	fact[0] = 1;
	for(int i=1; i<1010; i++)
		fact[i] = (fact[i-1]*i)%mod;
}

ll ncr(ll n, ll r){
	ll ans = fact[n];
	if(r>n)
		return 0;
	//if(r!=0)
	ans = (ans*modInverse(fact[r], mod))%mod;
	// if(n-r!=0)
	ans = (ans*modInverse(fact[n-r], mod))%mod;

	return ans;
}

int main(){
	// finput;
	// foutput;
	fast;

	int n, k, i, j, x, m,a,b;
	// ll ans;
	// string s;
	cin>>n>>a>>b;

	a = abs(a-b-1);

	if(a%2==0){
		cout<<"Borys";
	}
	else
		cout<<"Alice";


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main (){
    string n;
    cin >> n;
    int x = 0;
    for (int i = 0; i < n.size(); i++){
        x += n[i]-'0';
    }
    int a = stoi(n);
    if (a%x==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 673
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

//配列のSIZEは問題ごとに定義する必要がある。
const int SIZE = 700;
long long inv[SIZE+1];//各iの逆元を格納する配列。
long long kai[SIZE+1];//i!のmodを格納する配列。
long long invkai[SIZE+1];//各i!の逆元を格納する配列。
const int MOD=i_7;
void invinit(){//上の配列を初期化する関数。
    inv[1]=1;
    for(int i=2;i<=SIZE;i++){
        inv[i] = MOD - ((MOD/i)*inv[MOD%i])%MOD;
    }
    
    kai[0]=invkai[0]=1;
    for(int i=1;i<=SIZE;i++){
        kai[i]=(kai[i-1]*i)%MOD;
        invkai[i]=(invkai[i-1]*inv[i])%MOD;
    }
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  string s;
  cin>>s;
  int n = s.size();
  //2019 = 3 * 673
  invinit();
  vector<long long> dsumt(n, 0);
  vector<long long> dsum(n, 0);
  REP(i, n){
    if(i == 0){
      dsumt[i] = s[i] - '0';
      dsum[i] = s[i] - '0';
    }else{
      dsumt[i] = 10 * dsumt[i - 1] + (long long)(s[i] - '0');
      dsumt[i] = mod(dsumt[i]);
      dsum[i] = dsum[i-1] + (long long)(s[i] - '0');
    }
  }
  long long now = 1;
  REP(i, n){
    dsumt[i] = now * dsumt[i];
    dsumt[i] = mod(dsumt[i]);
    now *= inv[10];
    now = mod(now);
  }
  long long ans = 0;
  vector<vector<long long>> cnt(3, vector<long long>(673, 0));
  REP(i, n) if(dsum[i] % 3 == 0 && dsumt[i] == 0) ans++;
  REP(i, n){
    int m = dsum[i] % 3;
    ans += cnt[m][dsumt[i]];
    cnt[m][dsumt[i]]++;
  }
  cout << ans <<endl;
  return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
// typedef tuple<int, int, int> T;
#define FOR(i, s, x) for (int i = s; i < (int)(x); i++)
#define REP(i, x) FOR(i, 0, x)
#define ALL(c) c.begin(), c.end()
#define DUMP(x) cerr << #x << " = " << (x) << endl
#define UNIQUE(c) sort(ALL(c)), c.erase(unique(ALL(c)), c.end())

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int N;
ll dp[1 << 16], A[16][16];

int main() {
  scanf("%d", &N);
  REP(i, N) REP(j, N) scanf("%lld", &A[i][j]);
  REP(state, 1 << N) {
    REP(i, N) FOR(j, i + 1, N) {
      if ((state >> i & 1) and (state >> j & 1)) dp[state] += A[i][j];
      // dp[state] += A[i][j] * (state >> i & 1) * (state >> j & 1);
    }

    for (int sub = state & (state - 1); sub > 0; sub = state & (sub - 1)) {
      int not_sub = state & ~sub;
      if (sub < not_sub) break;
      dp[state] = max(dp[state], dp[sub] + dp[not_sub]);
    }
  }
  printf("%lld\n", dp[(1 << N) - 1]);
  return 0;
}


Measured memory_bytes: 768
[N,M,C] = list(map(int,input().split()))
B = list(map(int,input().split()))
A = [list(map(int,input().split())) for i in range(N)]
ans = 0
for i in range(N):
  tmp = C
  for j in range(M):
    tmp += A[i][j]*B[j]
  if tmp > 0:
    ans += 1
print(ans)


Measured memory_bytes: 3060
#include<cstdio>
const int maxn=100005;
int a[maxn];
int main(){
  int n,l;scanf("%d%d",&n,&l);
  for(int i=1;i<=n;++i)scanf("%d",a+i);
  int pos=0;
  for(int i=1;i<n;++i){
    if(a[i]+a[i+1]>=l){
      pos=i;break;
    }
  }
  if(pos==0)printf("Impossible\n");
  else{
    printf("Possible\n");
    for(int i=1;i<pos;++i)printf("%d\n",i);
    for(int i=n-1;i>pos;--i)printf("%d\n",i);
    printf("%d\n",pos);
  }
  return 0;
}


Measured memory_bytes: 1152
N,K=map(int,input().split())
m=10**9+7
d=[0]*K
for k in range(K,0,-1):
    d[k-1]=pow(K//k,N,m)
    for l in range(2*k,K+1,k):
        d[k-1]=(d[k-1]-d[l-1])%m
print(sum([(k+1)*d[k]%m for k in range(K)])%m)

Measured memory_bytes: 15444
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define MP make_pair
#define PB push_back
using namespace std;

int main() {
	ll n,k;
	cin>>n>>k;
    ll a[n],ans[k+1]={0};
    for(ll i=0;i<n;i++){cin>>a[i];}
	for(ll j=1;j<=k;j++){
		for(ll i=0;i<n;i++){
			if(j-a[i]<0)ans[j]++;
			else if(ans[j-a[i]]==1)ans[j]++;
		}
		if(ans[j]==n)ans[j]=0;
		else ans[j]=1;
	}
//	for(ll i=0;i<k;i++){cout<<ans[i]<<" "; }
	if(ans[k]==1)cout<<"First";
	else cout<<"Second";
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
int p[1000][4],q[4];
int main() {
	int n;
	while(scanf("%d",&n),n) {
		for(int i=0;i<n;i++) {
			for(int j=0;j<4;j++) {
				scanf("%d",&p[i][j]);
			}
		}
		for(int i=0;i<4;i++) {
			scanf("%d",&q[i]);
		}
		bool NA=1;
		for(int i=0;i<n;i++) {
			int calorie=(p[i][1]+p[i][3])*4+p[i][2]*9;
			if(p[i][1]<=q[0]&&p[i][2]<=q[1]&&p[i][3]<=q[2]&&calorie<=q[3]) {
				printf("%d\n",p[i][0]);
				NA=0;
			}
		}
		if(NA) printf("NA\n");
	}
}

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

int main(){
  int L;
  cin >> L;
  double l = L / 3.0;
  cout << fixed << setprecision(10);
  cout << l * l * l << endl;
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define join(a, d) accumulate(a.begin() + 1, a.end(), a[0], [](string s, string t) {return s + d + t;})
#define all(a) a.begin(), a.end()
// #define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

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

  int N, Y;
  cin >> N >> Y;
  rep(x, 0, N + 1) {
    rep(y, 0, N + 1) {
      int yen = x * 10000 + y * 5000;
      if (Y < yen) continue;
      int z = (Y - yen) / 1000;
      if (x + y + z == N) {
        printf("%d %d %d\n", x, y, z);
        return 0;
      }
    }
  }
  printf("%d %d %d\n", -1, -1, -1);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>

// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;



int32_t main()
{



    IOS



    int n,x;
    cin >> x >> n;

    set<int> s;

    for(int i = 1; i <= n; i++)
    {
    	int y;
    	cin >> y;
    	s.insert(y);
    }


    int i = x;
    int j = x;

    while(true)
    {
    	if(!s.count(i))
    	{
    		cout << i;
    		return 0;
    	}

    	 if(!s.count(j))
    	{
    		cout << j;
    		return 0;
    	}
    	s.insert(i);
    	s.insert(j);
    	i--;
    	j++;
    }




    return 0;
}


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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int count_abc=0;


    for(int i=0;i<n-2;){
        string d = s.substr(i,3);
        if(d=="ABC"){
            count_abc++;
            i+=3; 
        }else{
             i++;
        }
    }

    cout << count_abc << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    string s; cin >> s >> s;
    string ans = {'A',s[0],'C'};
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')

def factorize(n):
    """
    nの値を素因数分解し、素因数とその指数をtupleにまとめたリストを返す
    e.g.
    factorize(20)
    [(2, 2), (5, 1)]
    """
    b = 2
    fct = []
    while b * b <= n:
        cnt = 0
        while n % b == 0:
            cnt += 1
            n //= b
        if cnt > 0:
            fct.append((b, cnt))
        b += 1
    if n > 1:
        fct.append((n, 1))
    return fct


N = I()
ans = 0
for p, e in factorize(N):
    if p == 1:
        continue
    i = 1
    cnt = 0
    while e - i >= 0:
        e = e - i
        i = i + 1
        cnt += 1
    ans += cnt
print(ans)

Measured memory_bytes: 63040
def check_money(a, b, c, total, results):
    if a * 500 + b * 100 + c * 50 == total:
        check = str(a) + ',' + str(b) + ',' + str(c)
        for result in results:
            if check in result:
                break
        else:
            results.append(check)
        return results
    else:
        return results


def main():
    coin_a = int(input())
    coin_b = int(input())
    coin_c = int(input())
    total_money = int(input())
    result = list()

    for coin_a_count in range(coin_a+1):
        if coin_a_count <= coin_a:
            for coin_b_count in range(coin_b+1):
                if coin_b_count <= coin_b:
                    for coin_c_count in range(coin_c+1):
                        if coin_c_count <= coin_c:
                            result = check_money(coin_a_count, coin_b_count, coin_c_count, total_money, result)

    print(result.__len__())


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pii pair <ll,ll>
#define vl vector <ll>
#define vp vector <pair<ll,ll>>
#define sort(x) sort(x.begin(), x.end())
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,i,j,x,k,c,y,cnt;
    cin>>n;
    ll a[n],b[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n;i++)
        cin>>b[i];
    ll dp[1<<n][n];
    for(i=0;i<(1<<n);i++)
        for(j=0;j<n;j++)
            dp[i][j] = 10000;
    for(i=0;i<n;i++)
        dp[1<<i][i] = i;
    for(i=1;i<(1<<n);i++)
    {
        for(j=0;j<n;j++)
        {
            if(!(i&(1<<j)))
                continue;
            c = 0;
            k = i;
            while(k)
            {
                c++;
                k -= k&(-k);
            }
            if(c%2 == j%2)
                x = b[j];
            else
                x = a[j];

            cnt = -1;
            for(k=0;k<n;k++)
            {
                if(i&(1<<k))
                    continue;
                cnt++;
                if(c%2 == k%2)
                    y = a[k];
                else
                    y = b[k];
                //if(i == 1 and j == 0 and k == 1)
                    //cout<<x<<" "<<y<<" "<<c<<" "<<b[k]<<" "<<a[k]<<" ";
                if(x > y)
                    continue;
                dp[i+(1<<k)][k] = min(dp[i+(1<<k)][k], dp[i][j]+cnt);
            }
        }
    }
    ll ans = 10000;
    for(i=0;i<n;i++)
    {
        ans = min(ans, dp[(1<<n)-1][i]);
    }
    if(ans == 10000)
        ans = -1;
    cout<<ans;
    return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> p(N, 0);
  for (int i = 0; i < N; i++) {
  	cin >> p.at(i);
  }
  sort(p.begin(), p.end());
  int ans = 0;
  for (int i = 0; i < K; i++) {
  	ans += p.at(i);
  }
  cout << ans << endl;
}



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

#define cnd(c, a, b) (c ? a : b);
#define fl(x,y,z) for(int x=y;x<z;x++)
#define fe(x,y,z) for(int x=y;x<=z;x++)
#define fge(x,y,z) for(int x=y;x>=z;x--)

#define debug(x) std::cerr << #x << " --> " << x << "\n";
#define fastIO std::ios_base::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
#define pb push_back
#define pob pop_back
 
#define ln '\n'
typedef long long int ll;

ll mod=1e9+7;

void decrypt() {
	ll a, b,c ,d;
	cin>>a>>b>>c>>d;
	ll ans = b*d;
	ans = max(ans, a*c);
	ans = max(ans, b*c);
	ans = max(ans, a*d);
	cout<<ans<<ln;
	return;
}

int main() {
    fastIO
    int t = 1;
    // cin >> t;
    fl(i,0,t) {
    	// cout << "Case #"<< i+1 <<": ";
    	decrypt();
    }
    return 0;
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n;
    cin >> n;
    if(n == 2){
        cout << -1 << endl;
        return 0;
    }

    vector<vector<int> > v(n, vector<int>(n-1));
    for(int a=0; a<n; ++a){
        for(int t=0; t<n-1; ++t){
            v[a][t] = (a + t + 1) % n;
        }
    }
    if(n % 2 == 0){
        for(int a=0; a<n/2; ++a){
            for(int t=0; t<n-2; t+=2){
                swap(v[a][t], v[a][t+1]);
            }
        }
    }

    for(int i=0; i<n; ++i){
        cout << (v[i][0] + 1);
        for(int j=1; j<n-1; ++j)
            cout << ' ' << (v[i][j] + 1);
        cout << endl;
    }

    return 0;
}


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

int main()
{
	int n, w;	//top, south, east
	char o[6];

	while (cin >> n && n)
	{
		int r = 1, t = 1, s = 2, e = 3;
		for (; n > 0; --n)
		{
			cin >> o;
			switch (o[0])
			{
			case 'N':
				w = t;
				t = s;
				s = 7-w;
				break;
			case 'E':
				w = t;
				t = 7-e;
				e = w;
				break;
			case 'W':
				w = t;
				t = e;
				e = 7-w;
				break;
			case 'S':
				w = t;
				t = 7-s;
				s = w;
				break;
			case 'R':
				w = s;
				s = e;
				e = 7-w;
				break;
			case 'L':
				w = s;
				s = 7-e;
				e = w;
				break;
			}
			r += t;
		}
		cout << r << endl;
	}

	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
	int a[5][4][11];
	int i,j,k,n;
	int b,f,r,v;

	for( i=1; i<=4; i++ )
		for( j=1; j<=3; j++ )
			for( k=1; k<=10; k++ ) a[i][j][k] = 0;
	
	cin >> n;
	for( i=0; i<n; i++ ){
		cin >> b >> f >> r >> v;
		a[b][f][r] += v;
	}
	
	for( f=1; f<=4; f++ ){
		if( f>1 ) cout << "####################\n";
		for( b=1; b<=3; b++ ){
			for( r=1; r<=10; r++ ){
				cout << " " << a[f][b][r];
			}
			cout << endl;
		}
	}		
	return 0;
}

Measured memory_bytes: 3052
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

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<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }



main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x;
    cin >> x;
    int cur = 100;
    for (int i = 0; ; i++) {
        if (cur >= x) {
            cout << i << '\n';
            rr;
        }
        cur += cur / 100;
    }
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<climits>
#define pii pair<int,int>
#define ll long long
#define IMAX 1000000007
#define in2d(i,j,H,W)(0<=i&&i<H&&0<=j&&j<W)

using namespace std;
#define LLMAX LLONG_MAX
int N;
vector<int>a;
vector<vector<ll> >dp;
vector<ll>acc;
ll dfs(int l,int r){
	if(dp[l][r]!=LLMAX)return dp[l][r];
	ll ret=LLMAX;
	for(int i=l;i<r;i++){
		ll lmin=dfs(l,i);
		ll rmin=dfs(i+1,r);
		ret=min(ret,lmin+rmin);
	}
	return dp[l][r]=(ret+acc[r+1]-acc[l]);
}
int main(){
	//cout<<fixed<<setprecision(11);
	
	int N;cin>>N;
	a=vector<int>(N);
	for(int i=0;i<N;i++)cin>>a[i];
	acc=vector<ll>(N+1,0);
	for(int i=0;i<N;i++)acc[i+1]=acc[i]+a[i];
	dp=vector<vector<ll> >(N,vector<ll>(N,LLMAX));
	for(int i=0;i<N;i++)dp[i][i]=0;
	cout<<dfs(0,N-1)<<endl;

	return 0;
}



Measured memory_bytes: 1536
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Collections;

import java.util.Comparator;

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

		int d[]={9,5,4,3,2,1,0,1,2,3,4,5,6,7,8,9};

		int n = in.nextInt();
		for(int i = 0; i < n; i++){
			int s =in.nextInt(), e = in.nextInt();
			ArrayList<String> al = new ArrayList<String>();
			for(int j = 0; j < d.length; j++){
				StringBuilder sb = new StringBuilder();
				if(d[j] == s){
					for(int k = j; k < d.length; k++){
						if(k != j) sb.append(" ");
						sb.append((char)('0' + d[k]));
						if(d[k] == e){
							al.add(sb.toString());
							break;
						}
					}
				}
			}
			Collections.sort(al, new Comp());
			System.out.println(al.get(0));
		}
	}
}

class Comp implements Comparator<String>{
	public int compare(String a, String b){
		int l1 = a.length(), l2 = b.length();
		if(l1 > l2) return 1;
		else if (l1 == l2) return 0;
		else return -1;
	}
}

Measured memory_bytes: 26192
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  ll N, A, B;
  string S;
  cin >> N >> A>> B;
  cin >>S;
  ll a = 0, b = 0;
  for (ll i = 0; i < N; i++)
    {
      if (S[i] == 'a'&&a+b<A+B)
	{
	  a++;
	  cout << "Yes"<<endl;
	}
      else if (S[i] == 'b' && a+b<A+B && b < B)
	{
	  b++;
	  cout << "Yes"<<endl;
	}
      else
	{
	  cout << "No"<<endl;
	}
    }
}


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

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

   int a[n],b[n],c[n];
   for(int i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];

   int dp[n][3];
   dp[0][0] = a[0];
   dp[0][1] = b[0];
   dp[0][2] = c[0];

   for(int i=1;i<n;i++){
   	   dp[i][0] = a[i] + max(dp[i-1][1],dp[i-1][2]);
   	   dp[i][1] = b[i] + max(dp[i-1][0],dp[i-1][2]);
   	   dp[i][2] = c[i] + max(dp[i-1][1],dp[i-1][0]);
   }

   cout<<max(dp[n-1][0],max(dp[n-1][2],dp[n-1][1]));


return 0;	
}

Measured memory_bytes: 2560
/// Containers Start
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Extra Start
#define nn '\n'
/// Extra End



#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl
/// Debug End

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template



int main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cini(n);
    if(n==25){
        cout << "Christmas" << nn;
    }else if(n==24){
        cout << "Christmas Eve" << nn;
    }else if(n==23){
        cout << "Christmas Eve Eve" << nn;
    }else if(n==22){
        cout << "Christmas Eve Eve Eve" << nn;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

using namespace std;

constexpr int64_t mod = 998244353;

template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

using modint = ModInt< mod >;

template< typename T >
struct BinaryIndexedTree {
    vector< T > data;

    BinaryIndexedTree(int sz) {
        data.assign(++sz, 0);
    }

    T sum(int k) {
        T ret = 0;
        for(++k; k > 0; k -= k & -k) ret += data[k];
        return (ret);
    }

    void add(int k, T x) {
        for(++k; k < data.size(); k += k & -k) data[k] += x;
    }
};

int main(void) {
    int N, K;
    cin >> N >> K;
    vector<int> L(K), R(K);
    for(int i=0; i<K; i++) {
        cin >> L[i] >> R[i];
    }

    BinaryIndexedTree<modint> bit(N+1);
    bit.add(1, 1);
    for(int i=2; i<=N; i++) {
        modint tmp = 0;
        for(int j=0; j<K; j++) {
            tmp += bit.sum(i-L[j]);
            tmp -= bit.sum(max(0, i-R[j]-1));
        }
        bit.add(i, tmp);
    }

    cout << bit.sum(N) - bit.sum(N-1) << endl;
    return 0;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;

int main() {
  string s;
  cin>>s;
  int n=s.size();
  ///////
  int ans=0;
  int one=0;
  int zero=0;
  
  rep(i,n){
    if(s[i]=='0') zero++;
    else one++;
  }
  ans=min(zero,one);
  cout<<ans*2<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
long long x, p;
int main() {
    DAU
    cin >> x;
    p = log2(x) + 1;
    cout << (1LL << p) - 1;
    PLEC
}


Measured memory_bytes: 640
n = int(input())
l = [list(input().split()) for i in range(n)]
s = 0
for val in l:
    if val[1] == 'JPY':
        s += float(val[0])
    elif val[1] == 'BTC':
        s += float(val[0]) * 380000.0
print(s)

Measured memory_bytes: 3060
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;

int main() {
	
	int a, b, c;
	int sum;

	cin >> a;
	cin >> b;
	cin >> c;

	sum = a + b + c;

	if (sum <= 21) cout << "win" << endl;
	else cout << "bust" << endl;



	return 0;
}

Measured memory_bytes: 256
//In the Name of ̲A̲l̲l̲a̲h̲

#define pb push_back
#define F first
#define S second
#define sz size()
#define ll long long

#include <bits/stdc++.h>

using namespace std;

ll n, k, a[101];
bool dp[100001];
int main()
{
	ios_base::sync_with_stdio(0);
	cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        dp[a[i]] = 1;
    }
    for (int i = 1; i <= k; i++)
    {
        if (!dp[i])
        {
            for (int j = 0; j < n and a[j] <= i; j++)
            {
                if (!dp[i-a[j]])
                {
                    dp[i] = 1;
                    break;
                }
                else
                {
                    dp[i] = 0;
                }
            }
        }
    }
    if (dp[k])
    {
        cout << "First";
    }
    else
    {
        cout << "Second";
    }
}
/*𝐻𝒶𝒹𝒾*/


Measured memory_bytes: 384
#!/usr/bin/env python3

# N = int(input())
# S = input()
A, B, C, K = map(int, input().split())
# A = list(map(int, input().split()))

if A >= K:
    print(K)
else:
    if B >= K - A:
        print(A)
    else:
        if C >= K - A - B:
            print(A - 1 * (K - A - B))
        else:
            print(A- C)


Measured memory_bytes: 9164
#include <algorithm>
    #include <bits/stdc++.h>
    #include <cctype>
    #include <cmath>
    #include <cstdio>
    #include <iomanip>
    #include <iostream>
    #include <list>

    #include <stack>
    #include <string>
    #include <vector>
    #include <bits/stdc++.h>
    #define INFINI (1000 * 1000 * 1000)

    using namespace std;
    //#define s(T) scanf("%d", &T)
    #define sl(T) scanf("%lld", &T)
    #define fill(a, val) memset(a, val, sizeof(a))
    #define mp make_pair
    #define pb push_back
    #define all(x) x.begin(), x.end()
    #define DREP(x) sort(all(x)); x.erase(unique(all(x)), x.end())
    #define INDEX(a, val) (lower_bound(all(a), val) - a.begin())
    #define mod ll(1e9+7)
    typedef long long ll;


    bool compare_first(pair<ll,ll >a,pair<ll,ll >b)
    {
        return a.first<b.first;
    }

     bool compare_second(pair<int,pair<int , int> > a,pair<int,pair<int , int> > b)
    {
        return a.second.first<b.second.first;
    }


    ll min(ll a,ll b)
    {
        if(a>b)return b;
        return a;
    }

    ll toINT(string s)
    {
        ll a=0;
        for(ll index=0;index<s.size();index++)
            a=a*10+(s[index]-'0');
        return a;
    }

    int main() {
      ios::sync_with_stdio(false);
string s;
cin>>s;

ll ans=toINT(s);
ll last=(ll)pow(2,s.size()-1);

ll lenght=log(last)/log(2)+1;
for(ll index=1;index<last;index++)
{
    string curr="";
    ll idx=index;
    for(ll pos=0;pos<s.size();pos++)
    {


        curr+=s[pos];

        if(idx&1)
        {

            ans+=toINT(curr);
            curr="";
        }
        idx>>=1;

    }

    ans+=toINT(curr);

}

cout<<ans<<endl;





return 0;
    }


/*

 }
 */


Measured memory_bytes: 512
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#include <bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
bool a[705][705];
vector<int>g[705];
void dfs(int s, int &a,int &b,vector<int>&dist){
    if(dist[s]%2)a++;
    else b++;
    for(int x:g[s]){
        if(dist[x] == -1){
            dist[x] = dist[s] + 1;
            dfs(x,a,b,dist);
        }else{
            if(dist[x]%2==dist[s]%2){
                cout << -1 << endl;
                exit(0);
            }
        }
    }
}
int main(){
    int n,m;
    cin >> n >> m;
    rep(i,m){
        int c,d;
        cin >> c >> d;
        c--,d--;
        a[c][d] = true;
        a[d][c] = true;
    }
    rep(i,n)a[i][i] = true;
    rep(i,n)rep(j,n)if(!a[i][j])g[i].push_back(j);
    vector<pii>vec;
    vector<int>dist(n,-1);
    rep(i,n){
        if(dist[i] == -1){
            dist[i] = 0;
            int a,b;
            a = b = 0;
            dfs(i,a,b,dist);
            vec.emplace_back(a,b);
        }
    }
    set<int>st;
    set<int>st2;
    st.insert(0);
    rep(i,vec.size()){
        auto x = vec[i];
        st2.clear();{
            for(int y:st){
                st2.insert(y + x.first);
                st2.insert(y + x.second);
            }
        }
        st = st2;
    }
    int ans = INT_MAX;
    for(int x:st){
        ans = min(ans, x*(x-1)/2 + (n-x)*(n-x-1)/2);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <vector>
#include <bitset>
#include <cmath>
#include <utility>
#include <ctime>
#define Maxn 100005
#define Maxm 1000005
#define lowbit(x) x&(-x)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define PI acos(-1.0)
#define random(x) (rand()%x)+1
#define LL long long
#define Inf (1LL<<62)
#define inf 0x3f3f3f3f
#define eps 1e-12
#define input freopen("input.txt","r",stdin)
#define output freopen("output.txt","w",stdout)
using namespace std;
const int mod=1e9+7;
int main()
{
    //input;output;
    int m,n,k;
    bool flag;
    while(~scanf("%d%d%d",&m,&n,&k))
    {
        flag=false;
        for(int i=0;i<=m;i++)
        {
            if(flag)
                break;
            for(int j=0;j<=n;j++)
            {
                int now=(i*n)+(j*m)-2*i*j;
                if(now==k)
                {
                    flag=true;
                    break;
                }
            }
        }
        printf("%s\n",flag?"Yes":"No");
    }
    return 0;
}


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

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < n; i ++) cin >> a[i];
  
  int ans = 1;
  int d = 0;
  for (int i = 0; i < n; i ++) {
    d = d + a[i];
    if (d <= x) ans ++;
  }
  cout << ans << endl;
}

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


ans = 0

for i in range(N):
    if x >= A[i] and i != N - 1:
        x -= A[i]
        ans += 1
    elif x == A[i]:
        ans += 1
    else:
        break
print(ans)


Measured memory_bytes: 3060
N = int(input())
guidebook = []
for i in range(N):
    S, P = input().split()
    P = int(P)
    guidebook.append([S,P])

new_guidebook = sorted(guidebook, key=lambda x: (x[0],-x[1]))

for i in new_guidebook:
    print(guidebook.index(i)+1)


Measured memory_bytes: 9112
n, m = map(int, input().split())

if n % 2 == 1:
    for i in range(m):
        print(i+1,n-i)
else:
    bd = m // 2
    if m % 2 == 1:
        bd += 1
    for i in range(bd):
        print(i+1, n-i)
    for i in range(bd, m):
        print(i+2, n-i)


Measured memory_bytes: 80504
from collections import defaultdict
def C():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = defaultdict(int)
    for i in A:
        ans[i] += 1
    for i in range(N):
        if i+1 in ans:
            print(ans[i+1])
        else:
            print(0)
C()

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

int main() {
  int h,n;
  cin >> h >>n;
  vector<int> att(n);
  long long tatt=0;
 for(int i=0; i<n;i++){
  cin >> att.at(i);
   }
  for(int i=0; i<n ;i++){
    tatt+=att.at(i);
  }
  if(tatt>=h) cout <<"Yes" <<endl;
  else if(tatt <h) cout << "No" << endl;
 
}


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

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs =
                Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            var X = inputs[0];
            var Y = inputs[1];
            var f = false;
            for(var i = 0; i <= X; i++)
            {
                var sum = 2 * i + 4 * (X - i);
                f |= sum == Y;
            }

            Console.WriteLine(
                f ? "Yes" : "No"
            );
        }
    }
}

Measured memory_bytes: 28176
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
	vector<int> result(0);
	int n;
	cin >> n;
	while (n > 0) {
		vector<int> array(0);
		int sum = 0;
		for (int i = 0; i < n; i++) {
			int tmp;
			cin >> tmp;
			sum += tmp;
			array.push_back(tmp);
		}
		double avg = sum / n;
		int count = 0;
		for (int i = 0; i < n; i++) {
			if (array[i] <= avg) {
				++count;
			}
		}
		result.push_back(count);
		cin >> n;
	}
	
	for (int &num:result) {
		cout << num << endl;
	}
	
	return 0;
}



Measured memory_bytes: 3256
/// awoooooo

# include <bits/stdc++.h>
# define sz(x) (int)((x).size())

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;

const int N = (int)2e5 + 5;
const int inf = (int)1e9 + 7;
const int mod = 998244353;

int n;
int d[N], f[N];
int cnt[N];

int main(){
  cin >> n;
  for(int i = 1; i <= n; ++i){
    cin >> d[i];
  }

  if(d[1] != 0){
    cout << 0;
    return 0;
  }
  sort(d + 1, d + 1 + n);
  if(d[2] == 0 && n > 1){
    cout << 0;
    return 0;
  }
  for(int i = 1; i + 1 <= n; ++i){
    if(d[i + 1] - d[i] > 1){
      cout << 0;
      return 0;
    }
  }
  for(int i = 1; i <= n; ++i) cnt[d[i]]++;
  int ans = 1;
  for(int i = 1; i <= n; ++i){
    if(!cnt[i]) break;
    for(int j = 1; j <= cnt[i]; ++j){
      ans = ans * 1ll * cnt[i - 1] % mod;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

ll dp[2010][2010];
ll sum[2010][2010];

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> S(N), T(M);
    rep(i, N) cin >> S[i];
    rep(i, M) cin >> T[i];

    // dp[i][j]:=Sが[0,i)、Tが[0,j)まで見て、最後にS[i-1]==T[j-1]をとる場合の数
    dp[0][0] = 1;
    sum[1][1] = 1;
    for(int i = 0; i <= N; i++) {
        for(int j = 0; j <= M; j++) {
            if(i == 0 && j == 0)
                continue;
            if(i != 0 && j != 0 && S[i - 1] == T[j - 1]) {
                dp[i][j] = sum[i][j];
            }
            sum[i + 1][j + 1] =
                (sum[i][j + 1] + sum[i + 1][j] - sum[i][j] + dp[i][j] + MOD) %
                MOD;
        }
    }

    cout << sum[N + 1][M + 1] << endl;
    return 0;
}

Measured memory_bytes: 63104
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; i++) {
    if(to_string(i).size() % 2 == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"def s(n):\n"
"    return[m(t)for t in d(f(n))]\n"
"def f(n):\n"
"    l=[]\n"
"    b,e=2,0\n"
"    while b*b<=n:\n"
"        while not n%b:\n"
"            n//=b\n"
"            e+=1\n"
"        if e:\n"
"            l.append((b,e))\n"
"        b,e=b+1,0\n"
"    if n>1:\n"
"        l.append((n,1))\n"
"    return l\n"
"def d(l):\n"
"    b,e=l.pop()\n"
"    p=d(l)if l else[[]]\n"
"    v=[[(b,k)]for k in range(e+1)]\n"
"    return[s+t for s in p for t in v]\n"
"def m(l):\n"
"    a=1\n"
"    for b,e in l:\n"
"        a*=b**e\n"
"    return a\n"
"N,M=map(int,input().split())\n"
"if M<2:print(1);exit()\n"
"a=0\n"
"for i in sorted(s(M))[::-1]:\n"
"    if M//i>=N:\n"
"        a=i\n"
"        break\n"
"print(a)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 3408
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

// int rec(int s, bool f, string n) {
//   if(s==n.size()) {
//     return 1;
//   }
//   int d = n[s]-'0';
//   if(f)
// }

int dc(int n) {
  int c=0;
  while(n!=0) {
    n/=10;
    c++;
  }
  return c;
}

bool check(ll n){
  vector<int> freq(10);
  while(n!=0) {
    freq[n%10]++;
    n/=10;
  }
  rep(i,10) {
    if(i==3||i==5||i==7) {
      if(freq[i]==0)
        return false;
    } else {
      if(freq[i]>0)
        return false;
    }
  }
  return true;
}

int rec(ll k,ll n) {
  if(k>n) {
    return 0;
  }
  //cout << k << endl;
  int ret=0;
  if(check(k))
    ret+=1;
  ret+=rec(10*k+3,n);
  ret+=rec(10*k+7,n);
  ret+=rec(10*k+5,n);
  return ret;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  ll n;
  cin>>n;
  cout << rec(0,n) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
	ll i,j,k,n,t;
	cin>>n;
	t=0;
	for(i=0;i<n;i++)
	{
		cin>>k;
		while(k%2==0)
		{
			k/=2;
			t++;
		}
	}
	cout<<t<<endl;
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    if (s[1] == s[2] && (s[0] == s[1] || s[3] == s[2])) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


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

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

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << " " << y << " " << z << '\n';
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int h, w;
	cin >> h >> w;
	char tab[2*h][w], tmp;
	for(int i = 0; i < h; i++)
		for(int j = 0; j < w; j++)
		{
			cin >> tmp;
			tab[2*i][j] = tmp;
			tab[2*i+1][j] = tmp;
		}
	for(int i = 0; i < 2*h; i++)
	{
		for(int j = 0; j < w; j++)
			cout << tab[i][j];
		cout << "\n";
	}
}

Measured memory_bytes: 256
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
map<string,int>mp;
int n,mx;
vector<string>v;
string s;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		mp[s]++;
	}
	for(map<string,int>::iterator it=mp.begin();it!=mp.end();it++)
	{
		if(it->second>mx)
		{
			v.clear();
			mx=it->second;
			v.push_back(it->first);
		}
		else if(it->second==mx)
		{
			v.push_back(it->first);
		}
	}
	sort(v.begin(),v.end());
	for(int i=0;i<v.size();i++)
	{
		cout<<v[i]<<endl;
	}
	return 0;
}

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

#define LL long long
struct Q{char x; int a, b, c, d;} a[2001][2001];
int n, m;

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++) cin >> a[i][j].x;

    for(int i = 1; i <= n; i++) {
        int cur = 1;
        for(int j = 1; j <= m; j++) {
            a[i][j].a = cur;
            if(a[i][j].x == '#') cur = j + 1;
        }
    }

    for(int i = 1; i <= n; i++) {
        int cur = m;
        for(int j = m; j >= 1; j--) {
            a[i][j].b = cur;
            if(a[i][j].x == '#') cur = j - 1;
        }
    }

    for(int j = 1; j <= m; j++) {
        int cur = 1;
        for(int i = 1; i <= n; i++) {
            a[i][j].c = cur;
            if(a[i][j].x == '#') cur = i + 1;
        }
    }

    for(int j = 1; j <= m; j++) {
        int cur = n;
        for(int i = n; i >= 1; i--) {
            a[i][j].d = cur;
            if(a[i][j].x == '#') cur = i - 1;
        }
    }

    int ans = 0;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++) {
            if(a[i][j].x == '.') ans = max(ans, a[i][j].b - a[i][j].a + 1 + a[i][j].d - a[i][j].c + 1 - 1); //if(i == 2 && j == 3) cout << a[i][j].a << a[i][j].b << a[i][j].c << a[i][j].d;
        }
    cout << ans;    
}

Measured memory_bytes: 81812
#include <bits/stdc++.h>
#define ll long long

#define INF 999999999

using namespace std;

// input

bool alpha[26];


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

    while(cin >> c){
        alpha[c - int('a')] = true;
    }

    int ans_index = -1;

    for(int i = 0;i < 26;i++){
        if(!alpha[i]){
            ans_index = i;
            break;
        }
    }

    if(ans_index == -1){
        cout << "None" << "\n";
    }
    else{
        cout << char(ans_index + 'a') << "\n";
    }
    
}

Measured memory_bytes: 256