akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>
 
#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second
 
const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;
ll n,k,w[100005];
 


bool func(ll P)
{
	ll cnt = 0;
	ll sum = 0;
	rep(i, n)
	{
		if (w[i]>P)
		{
			return false;
		}
		if (sum+w[i] > P)
		{
			sum = 0;
			cnt++;
		}
		sum += w[i];
	}
	return cnt < k;
}
int main()
{
	cin >> n >> k;
	rep(i, n) cin >> w[i];

	ll l = 0, r = 10e9;
	while (r-l>1)
	{
		ll mid = (l + r) / 2;
		if (func(mid))
		{
			r = mid;
		}
		else
		{
			l = mid;
		}
	}
	cout << r << endl;
	return 0;
}

Measured memory_bytes: 3860
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
bool is_prime(lli x) {
  for(lli i = 2; i * i <= x; i++) {
    if(x % i == 0) return false;
  }
  return true;
}
int main() {
  lli A,B,C=INF,D=0,E=0,F=0,G=0,H=0,N,M;
  string S,K,L;
  cin >> N >> M;
  rep(i,0,N)cin >> A;
  N--;M--;
  if(N%M==0)Out(N/M);
  else Out(N/M+1);
}

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

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

const ll MOD = 1e9 + 7;

int findLongestPath(int currentVertex, unordered_map<int, vector<int>>& edges, vector<int>& memo) {
    if (memo[currentVertex] != -1) return memo[currentVertex];

    int longestPath = 0;
    for (const int destination : edges[currentVertex]) {
        longestPath = max(longestPath, findLongestPath(destination, edges, memo) + 1);
    }
    memo[currentVertex] = longestPath;
    return longestPath;
}

// LCS Longest common subsequence
void solve(int N, int M, unordered_map<int, vector<int>>& edges) {
    vector<int> memo(N+1, -1); // longest path from i vertex

    int answer = 0;
    REP(i,1,N+1) {
        answer = max(answer, findLongestPath(i, edges, memo));
    }

	stringstream ss;
    ss << answer;
	cout << ss.str() << '\n';

    return;
}

signed main() {
    int N, M;
    cin >> N >> M;

    unordered_map<int, vector<int>> edges;
    REP(i,0,M) {
        int s, t;
        cin >> s >> t;
        edges[s].emplace_back(t);
    }

    solve(N, M, edges);
    
    return 0;
}



Measured memory_bytes: 12196
#include<iostream>
using namespace std;
int main(){

  int N,n[100],a,b=0;
  
  cin >>N;

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

  for( int i=0 ; i < N ; i++ ){
    for( int j=N-1 ; j > i ; j-- ){
      if( n[j] < n[j-1] ){
	a=n[j];
	n[j]=n[j-1];
	n[j-1]=a;
	b++;
      }
    }
  }

  for( int i=0 ; i < N ; i++ ){
    if( i == N-1 ){
      cout <<n[i]<<endl;
    }else{
      cout <<n[i]<<" ";
    }
  }
  cout <<b<<endl;

  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main() {
    i64 N, K;
    cin >> N >> K;
    vector<pair<i64, i64>> X(N);
    for(auto &x : X) {
        cin >> x.first >> x.second;
    }
    auto f = [&](i64 k) -> i64 {
        i64 a = 0, b = 0;
        for(auto &x : X) {
            i64 A, B;
            tie(A, B) = x;
            if ((a | A) & (~k)) {
                continue;
            } else {
                a |= A;
                b += B;
            }
        }
        return b;
    };
    i64 ans = 0;
    for(int i = 32; i >= 0; i--) {
        // i ビット以上が K と一致するような場合
        if (K & (1ll << i)) {
            // iビット目が 1 または 完全一致
            i64 a = 0, b = 0;
            i64 k = K & ( ((1ll << 32) - 1) - ((1ll << (i + 1)) - 1));
            k |= (1ll << i) - 1;
            ans = max(ans, f(k));
        }
    }
    ans = max(ans, f(K));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
n,m=map(int,input().split())
A=[input() for _ in range(n)]
B=[input() for _ in range(m)]
ans="No"
for i in range(n-m+1):
  for j in range(n-m+1):
    if [A[k][i:i+m] for k in range(j,j+m)]==B:
      ans="Yes"
      break
print(ans)

Measured memory_bytes: 3060
n = int(input())
sn = []
for _ in range(n):
  s = input()
  s = sorted(s)
  sn.append(''.join(s))
sn.sort()

sa = sn[0]
cnt = 0
n = 1
for sb in sn[1:]:
  if sb == sa:
    n += 1
  else:
    cnt += (n * (n-1) // 2)
    n = 1
    sa = sb
cnt += (n * (n-1) // 2)
print(cnt)

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

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



Measured memory_bytes: 3076
#include <stdio.h>
int main (void){
   int a,b,i,aa=0,bb=0,cc=0,dd=0,ee=0,ff=0,gg=0;
   for(;;){
        scanf("%d",&a);
        if(a==0)break;
        aa=0,bb=0,cc=0,dd=0,ee=0,ff=0,gg=0;
        for(i=0;i<a;i++){
            scanf("%d",&b);
            if(b<10){
                aa++;
            }
            else if(b>=10&&b<20){
                bb++;
            }
            else if(b>=20&&b<30){
                cc++;
            }
            else if(b>=30&&b<40){
                dd++;
            }
            else if(b>=40&&b<50){
                ee++;
            }
            else if(b>=50&&b<60){
                ff++;
            }
            else{
                gg++;
            }
        }
        printf("%d\n%d\n%d\n%d\n%d\n%d\n%d\n",aa,bb,cc,dd,ee,ff,gg);
   }

return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
#define N 100

int main(void)
{
	int i,n,j,t,k,minj,A[N],fmin;
	int count=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&A[i]);
		
	for(i=0;i<n;i++){
		minj=i;
		fmin=minj;
		for(j=i;j<n;j++){
			if(A[j]<A[minj])
				minj=j;
		}
		t=A[i];
		A[i]=A[minj];
		A[minj]=t;
		if(fmin!=minj)//minj??????????????´???????????????
		count++;//???????????°???1?¢???????
		
	}

	for(k=0;k<n-1;k++)
	printf("%d ",A[k]);
	
	printf("%d\n",A[k]);	
	printf("%d\n",count);
	
	return 0;
}

Measured memory_bytes: 600
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    string s; cin>>s;
    if(s[0] == 'S') cout << "Cloudy" << endl;
    else if(s[0] == 'C') cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
    
    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;


int main()
{
	FAST;
	int k,s;
	cin >> k >> s;

	int count = 0;
	for(int i=0 ; i<=k ; i++)
	{
		for(int j=0 ; j<=k ; j++)
		{
			if(s-i-j <= k && s-i-j >= 0)
			    count++;
		}
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int k;
	cin>>k;
	int tmp=7%k;
	for(int i=1;i<=k;++i){
		if(tmp==0){
			cout<<i<<endl;
			return 0;
		}
		tmp=(tmp*10+7)%k;
	}
	cout<<-1<<endl;
}

Measured memory_bytes: 3604
A, B, C, D = map(int, input().split())


def gcm(c, d):
    """
    最大公約数を求める
    """
    while d > 0:
        c, d = d, c % d
    return c


def lcm(c, d):
    """
    最小公倍数を求める
    """
    return c*d//gcm(c, d)


def f(x, c, d):
    return x - x//c - x//d + x//lcm(c, d)


print(f(B, C, D) - f(A-1, C, D))


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rept(i,k,n) for(int i = (k); i < (int)(n); i++)
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define F first
#define S second

typedef long long ll;
typedef pair<double,double> Pdd;
typedef pair<int,int> Pii;

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
    }
    int k = 1;
    rep(i,n){
        if(k==a[i]){
            k++;
        }
    }
    if (k==1) cout<<-1<<endl;
    else cout<<n-(k-1)<<endl;
    return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>
int min(int a,int b){return a<b?a:b;}
int main(void){
    int n,ans=0,a[120]={};
    scanf("%d",&n);
    for (int i=1; i<=n; i++){
        int k=i;
        for (int j=2; j<=i; j++){
            while(k%j==0){
                a[j]++;
                k/=j;
            }
        }
    }

    int c75=0,c25=0,c15=0,c5=0,c3=0;
    for(int i=0; i<120; i++){
        if (a[i]>=74){
            c75++;
        }
        if (a[i]>=24){
            c25++;
        }
        if (a[i]>=14){
            c15++;
        }
        if (a[i]>=4){
            c5++;
        }
        if (a[i]>=2){
            c3++;
        }
    }
    ans=c75+c25*(c3-1)+c15*(c5-1)+c5*(c5-1)*(c3-2)/2;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
    int N, Y;
    cin >> N >> Y;

    int x, y, z;
    for(x=0; x<=N; x++){
        for(y=0; x+y<=N; y++){
            z = N - x - y;
            if( Y == 10000*x + 5000*y+ 1000*z ) goto LABEL;
        }
    }
    LABEL:

    if( Y != 10000*x + 5000*y+ 1000*z || x+y+z!=N) cout << "-1 -1 -1\n";
    else cout << x << ' ' << y << ' ' << z << endl;
    return 0;
}


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

#define int long long

#define pb          push_back
#define mp          make_pair
#define ll          long long
#define pii         pair<int, int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int, int>
#define mii         map<pii, int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rev(i,a,b)  for(int i=a;i>=b;i--)
#define lb          lower_bound
#define ub          upper_bound

#define bg(i)       i.begin()
#define fset(it,s)   for(auto it = s.begin(); it != s.end(); it++)
 
#define track(x)                 cerr<<#x<<": "<<x<<endl
#define track2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define track3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define track4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
 
#define ed(i)       i.end()
#define mem(a)	    memset(a, 0, sizeof(a))

#define MOD         1000000007
int mult(ll a,ll b, int p=MOD){return ((a%p)*(b%p))%p;}
int add(int a, int b, int p=MOD){return (a + b + p)%p;}
int fpow(int n, int k, int p = MOD) {int r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
void self_max(int &a, int b) {a = max(a, b); }
void self_min(int &a, int b) {a = min(a, b); }
void self_add(int &a, int b, int p = MOD) { a += b; if(a >= p) a -= p;}
void self_sub(int &a, int b, int p = MOD) { a -= b; if(a < 0) a += p;}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
const int INF = 1e9 + 5;
#define N	    	400001

void solve() {
    int n, m;
    cin>>m;
    int a[3][m+1];

    rep(i, 1, 3) 
        rep(j, 1, m+1) 
            cin>>a[i][j];

    int dp[3][m+1];
    mem(dp);
    rep(j, 1, m+1) {
        rep(i, 1, 3) {
            dp[i][j] += a[i][j] + max(dp[i-1][j], dp[i][j-1]);
        }
    }
    cout<<dp[2][m]<<endl;
}
signed main() {
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	cin.tie(0);  //for interactive problem comment this
	cout.tie(0);    // and this
	int t = 1;
	while(t--){
		solve();
	}
}



Measured memory_bytes: 3592
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int[][] card = new int[3][3];
        boolean[][] bingo = new boolean[3][3];
        for(int i = 0 ; i < 3; i++){
            for(int j = 0; j < 3; j++){
                card[i][j] = sc.nextInt();   
            }
        }
        int n = sc.nextInt();
        for(int i = 0; i < n; i++){
            int b = sc.nextInt();
            for(int j = 0; j < 3; j++){
                for(int k = 0; k < 3; k++){
                    if(b == card[j][k]){
                        bingo[j][k] = true;
                    }
                }
            }
        }
        boolean ans = false;
        for(int i = 0; i < 3; i++){
            if(bingo[0][i] && bingo[1][i] && bingo[2][i] || bingo[i][0] && bingo[i][1] && bingo[i][2]){
                ans = true;
                break;
            }
        }
        if(bingo[0][0] && bingo[1][1] && bingo[2][2] || bingo[2][0] && bingo[1][1] && bingo[0][2]){
            ans = true;
        }
        if(ans){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll int i,n,t,j=0,p,x,a=0,b,l=0,r=0,y,k,c,sum=0,m,d;
    cin>>n;
    int ara[n];
    for(i=0;i<n;i++){
        cin>>ara[i];
        if(ara[i]&1 && i%2==0){
            l++;
        }
    }
    cout<<l<<endl;

    return EXIT_SUCCESS;
}



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

int main() {


	int a;
	int b;
	cin>>a>>b;
	string S(b, '0'+a);
	string T(a, '0'+b);


if(a>b){
	cout<<T<<endl;
}
else{

	cout<<S<<endl;
}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 4005, MOD = 998244353;

int fac[N], inv[N];

int qp(ll a, ll b) {
    ll ans = 1;
    while(b) {
        if(b & 1) ans = ans * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return ans;
}

void pre() {
    fac[0] = 1;
    for(int i = 1; i < N; i++) fac[i] = 1ll * fac[i - 1] * i % MOD;
    inv[N - 1] = qp(fac[N - 1], MOD - 2);
    for(int i = N - 2; ~i; i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % MOD;
}

ll C(int n, int m) {
    if(n < m) return 0;
    return 1ll * fac[n] * inv[m] % MOD * inv[n - m] % MOD;
}

int n, k;
int tot[N];

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    pre();
    cin >> k >> n;
    for(int i = 1; i <= k; i++) {
        ++tot[i + 1]; --tot[i + k + 1];
    }
    for(int i = 1; i <= 2 * k; i++) tot[i] += tot[i - 1];
    for(int i = 2; i <= 2 * k; i++) {
        ll ans = 0;
        int cnt = (tot[i] + 1) / 2;
        for(int j = 0, d = 1; j <= cnt; j++, d = MOD - d) {
            ans += 1ll * d * C(cnt, j) % MOD * C(n - 2 * j + k - 1, k - 1) % MOD;
            ans %= MOD;
        }
        if(ans < 0) ans += MOD;
        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf 1000000000000000000
#define lli long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli n,k;
    cin>>n>>k;
    lli arr[n],dp[n];
    for(int i=0; i<n; i++)
        cin>>arr[i];
    dp[0]=0;
    for(int i=1; i<min(k,n); i++)
        dp[i]=abs(arr[i]-arr[0]);
    for(int i=k; i<n; i++)
    {
        dp[i]=dp[i-1]+abs(arr[i]-arr[i-1]);
        for(int j=1; j<=k; j++)
        dp[i]=min(dp[i], dp[i-j]+abs(arr[i-j]-arr[i]));
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 5168
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string s;
    cin >> s;
 
    int a_idx, z_idx;
 
    for(int i = 0; i < s.length(); ++i){
 
        if(s[i] == 'A'){
            a_idx = i;
            break;
        }
    }
 
    for(int i = 0; i < s.length(); ++i){
 
        if(s[i] == 'Z'){
            z_idx = i;
        }
    }
 
    cout << z_idx - a_idx + 1 << endl;
}

Measured memory_bytes: 640
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

/*
 * C[0][0] = A[0] + B[0];
 * C[0][1] = A[0] + B[1];
 * C[0][2] = A[0] + B[2];
 * C[1][0] = A[1] + B[0];
 * C[1][1] = A[1] + B[1];
 * C[1][2] = A[1] + B[2];
 * C[2][0] = A[2] + B[0];
 * C[2][1] = A[2] + B[1];
 * C[2][2] = A[2] + B[2];
 
 * C[0][0] + C[1][1] + C[2][2] == C[0][1] + C[1][2] + C[2][0] == C[0][2] + C[1][0] + C[2][1];
 */
const int n = 3;
int C[n][n];
int main() {
  loop(i,0,n) {
    loop(j,0,n) {
      cin >> C[i][j];
    }
  }
  
  int a = C[0][1] + C[1][2] + C[2][0];
  if (C[0][0] + C[1][1] + C[2][2] == a and a == C[0][2] + C[1][0] + C[2][1]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3596
N = int(input())
S = input()
l = 0
r = N - 1
ans = 0
while 1:
    while l < N and S[l] == "R":
        l += 1
    if l >= N: break
    
    while r >= 0 and S[r] == "W":
        r -= 1
    if r < 0: break
    if l > r:
        break
    ans += 1
    l += 1
    r -= 1
print(ans)

Measured memory_bytes: 67672
N = int(input())
S = input()

MOD = 1e9 + 7
L = {}
for i in S:
  if i in L:
    L[i] += 1
  else:
    L[i] = 1

Ans = 1
for i in L.values():
  Ans = Ans * (i + 1) % MOD

Ans -= 1
if Ans < 0:
  Ans += MOD

print(int(Ans))

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

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

  int digit_sum = 0, t = N;
  while (t > 0) {
    digit_sum += t % 10;
    t /= 10;
  }

  if (N % digit_sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

public class Main {

	static Scanner scanner;

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

        int N=gi();

        for (int i=0; i<N; i++) {
            String s=gs();
            if(s.equals("Y")) {
            	 System.out.println("Four");
            	 return;
            }
        }
        

	    System.out.println("Three");

//	    if (isNumber(s1) && isNumber(s2) && s.charAt(a) == '-') {
//	    	System.out.print("Yes");
//	    }else {
//	    	System.out.print("No");
//	    }



	}

	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35748
#include<cstdio>
#include<cmath>
const double eps=1e-9;
bool zero(double e)
{return fabs(e)<eps;}
int sgn(double e)
{return e<-eps?-1:e>eps;}
struct v3{
    double x,y,z;
    v3(){}
    v3(double x,double y,double z):x(x),y(y),z(z){}
    void s()
    {
        scanf("%lf%lf%lf",&x,&y,&z);
    }
    void p()
    {
      //  printf("%lf %lf %lf",x,y,z);
    }
    double len()
    {
        return sqrt(x*x+y*y+z*z);
    }
    v3 normalized()
    {
        double l=this->len();
        return v3(x/l,y/l,z/l);
    }
};
v3 operator +(v3 a,v3 b){return v3(a.x+b.x,a.y+b.y,a.z+b.z);}
v3 operator -(v3 a,v3 b){return v3(a.x-b.x,a.y-b.y,a.z-b.z);}
v3 operator *(v3 a,double b){return v3(a.x*b,a.y*b,a.z*b);}
v3 operator /(v3 a,double b){return v3(a.x/b,a.y/b,a.z/b);}
v3 operator *(double b,v3 a){return v3(a.x*b,a.y*b,a.z*b);}
v3 Det(v3 a,v3 b)
{
    return v3(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);
}
double Dot(v3 a,v3 b)
{
    return a.x*b.x+a.y*b.y+a.z*b.z;
}

struct l3
{
v3 a,b;
l3(){};
l3(v3 a,v3 b):a(a),b(b){};
};
struct p3
{
v3 a,b,c;
p3(){}
p3(v3 a,v3 b,v3 c):a(a),b(b),c(c){}
};
double vlen(v3 p){return sqrt(Dot(p,p));}
v3 pvec(v3 s1,v3 s2,v3 s3)
{
    return Det(s1-s2,s2-s3);
}
v3 pvec(p3 x)
{return pvec(x.a,x.b,x.c);}
int parallel(p3 u,p3 v)
{
    return vlen(Det(pvec(u),pvec(v)))<eps;

}
int parallel(v3 a,v3 b,p3 s)
{
    return zero(Dot(a-b,pvec(s)));
}
v3 intersection(v3 a,v3 b,p3 s)
{
    v3 ret=pvec(s);
    double t=(ret.x*(s.a.x-a.x)+ret.y*(s.a.y-a.y)+ret.z*(s.a.z-a.z))/
            (ret.x*(b.x-a.x)+ret.y*(b.y-a.y)+ret.z*(b.z-a.z));
    ret=a+(b-a)*t;
    return ret;

}
bool intersection(p3 pl1,p3 pl2,l3& li)
{
    if(parallel(pl1,pl2))return false;
    li.a=parallel(pl2.a,pl2.b,pl1)?intersection(pl2.b,pl2.c,p3(pl1.a,pl1.b,pl1.c)):
    intersection(pl2.a,pl2.b,p3(pl1.a,pl1.b,pl1.c));
    v3 fa;
    fa=Det(pvec(pl1),pvec(pl2));
    li.b=li.a+fa;
    return true;
}
double ptoplane(v3 p,p3 s)
{
    return fabs(Dot(pvec(s),p-s.a))/vlen(pvec(s));
}
double ptoline(v3 p,l3 l)
{
    return vlen(Det(p-l.a,l.b-l.a))/(l.a-l.b).len();
}
int main()
{
    v3 c1;
    c1.s();
    v3 d1,d2;
    d1.s();
    d2.s();
    p3 p1=p3(c1,c1+d1,c1+d2);


    v3 c2;
    c2.s();
    v3 d1p,d2p;
    d1p.s();
    d2p.s();
    p3 p2=p3(c2,c2+d1p,c2+d2p);

    l3 ins;
    //not parl//
    if(!intersection(p1,p2,ins)){puts("NO");return 0;}

    v3 l=(ins.b-ins.a).normalized();
    double r1=ptoline(c1,ins),r2=ptoline(c2,ins);
    if(r1>1+eps||r2>1+eps){puts("NO");return 0;}

    double le1=sqrt(1-r1*r1);

    //projection//
    v3 pt1;
    if(zero(ptoline(c1,ins)))
        pt1=c1;
    else{
        v3 p01=Det(c1-ins.a,c1-ins.b);
        v3 p02=Det(ins.b-ins.a,p01);
        p3 p0=p3(c1,c1+p01,c1+p02);
        pt1=intersection(ins.a,ins.b,p0);
    }


    v3 np1=pt1+l*le1,np2=pt1-l*le1;
    //ins.b.p();
    //np2.p();
    if(sgn(vlen(np1-c2)-1.0)*sgn(vlen(np2-c2)-1.0)!=-1){puts("NO");return 0;}
    puts("YES");
    return 0;




}

Measured memory_bytes: 1056
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    VI a(n); VIin(a);
    SORT(a);
    OUT(a[n-1] - a[0]);

    return 0;
}



Measured memory_bytes: 256
using System;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System.Collections.Generic;

class Myon

{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }
    static Scanner cin;


    void calc()
    {
        string L = cin.next();
        long mod = 1000000007;
        long ans = 0;
        long samePattern = 1;
        for (int i = 0; i < L.Length; i++)
        {
            if(L[i] == '1')
            {
                ans += samePattern % mod *  powmod(3, L.Length - i - 1);
                ans %= mod;

                samePattern *= 2;
                samePattern %= mod;
            }
        }
        ans += samePattern;
        ans %= mod;

        Console.WriteLine(ans);
    }

    long mod = 1000000007;
    long powmod(long a, long p)
    {
        long ans = 1;
        long mul = a;
        for (; p > 0; p >>= 1, mul = (mul * mul) % mod)
        {
            if ((p & 1) == 1) ans = (ans * mul) % mod;
        }
        return ans;
    }


    long f(long a)
    {
        if (a < 0) return 0;
        long ans = 0;
        if (a % 4 == 1 || a % 4 == 2) ans += 1;
        for (int i = 1; i < 50; i++)
        {
            long num = a % (1L << (1 + i)) + 1;
            num = Math.Max(0, num - (1L << i));
            ans += (1L << i) * (num % 2);
        }
        return ans;
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

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

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

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

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

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


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}




Measured memory_bytes: 14036
#include <stdio.h>

#define DATA_SET_MAX 50

int main()
{
    int H[DATA_SET_MAX];
    int W[DATA_SET_MAX];
    int cnt;

    for (int i = 0; i < DATA_SET_MAX; i++) {
        scanf("%d %d", &H[i], &W[i]);
        if ((H[i] == 0) && (W[i]== 0)) {
            cnt = i;
            break;
        }
        else {
            /* NOP */
        }

    }

    for (int i = 0; i < cnt; i++) {
        for (int h = 0; h < H[i]; h++) {
            for (int w = 0; w < W[i]; w++) {
                if ((h == 0) || (h == (H[i] - 1))) {
                    printf("#");
                }
                else {
                    if ((w == 0) || (w == (W[i] - 1))) {
                        printf("#");
                    }
                    else {
                        printf(".");
                    }
                }
            }
            printf("\n");
        }
        printf("\n");
    }

}


Measured memory_bytes: 2136
n=int(input())
b_list=list(map(int,input().split()))
ans=int()
b_list.append(10**5+1)
for i in range(0,n-1):
    if b_list[i]  <= b_list[i+1]:
        ans+=b_list[i]
    else:
        ans+=b_list[i+1]
print(ans+b_list[0])

Measured memory_bytes: 3060
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	while(cin>>s) {
		ll N = s.size();
		ll M = N-1;
		map<VI, ll> h;
		REP(bi, 1<<M) {
			VI es;
			ll v=s[0]-'0';
			RANGE(i, 1, N) {
				if(bi>>(i-1)&1) {
					es.PB(v);
					v=0;
				}
				v=v*10+(s[i]-'0');
			}
			es.PB(v);
//			DD(es);
			ll sum = accumulate(ALL(es), 0LL);
			h[es]=sum;
		}
		ll ans = 0;
		for(auto kv: h) ans+=kv.SE;
		cout<<ans<<endl;
	}
	
	return 0;
}


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

int main(){
    long long N, M;
    cin >> N >> M;
    vector<pair<long long, long long>> WB(N);
    priority_queue<long long> res;
    for(int i = 0; i < N; i++)cin >> WB[i].first >> WB[i].second;
    sort(WB.begin(), WB.end());
    
    long long see = 0;
    long long days = 1;
    long long income = 0;
    
    while(days <= M){
        if(see < N && WB[see].first <= days){
            res.push(WB[see].second);
            see++;
        }else{
            if(res.empty()){
                days++;
            }else{
                income += res.top();
                res.pop();
                days++;
            }
        }
    }
    
    cout << income << endl;
    return 0;
}

Measured memory_bytes: 2936
#include <stdio.h>

int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(-1000<=a&&b<=1000){
		printf("%s\n",(a<b)?"a < b":((a>b)?"a > b":"a == b"));
	}
	else
	{
		printf("??????????????¶????????¶?????n");
	}
}

Measured memory_bytes: 1808
import Control.Applicative ((<$>))
import Control.Monad (replicateM)
import Data.List (intercalate)
import Data.Vector (Vector, (!))
import qualified Data.Vector as V

main :: IO ()
main = do
  [h, w] <- map read <$> words <$> getLine
  solve h w <$> replicateM h getLine >>= putStrLn

solve :: Int -> Int -> [String] -> String
solve h w gs = if all f [(i, j) | i <- [0..h-1], j <- [0..w-1]] then "Yes" else "No"
  where cs = V.fromList $ replicate (w+1) '.' ++ intercalate "." gs ++ replicate (w+1) '.'
        f (x, y) | cs ! ix == '.' = True
                 | (cs ! (ix-1)== '#' ||
                    cs ! (ix+1) == '#' ||
                    cs ! (ix-w-1) == '#' ||
                    cs ! (ix+w+1) == '#') = True
                 | otherwise = False
          where ix = (x+1) * (w+1) + y


Measured memory_bytes: 1020
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll, ll>

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const int sz=1e5+100;
ll last[sz];
bool cmp(PII a,PII b)
{
    if(a.s==b.s)   return (a.f>b.f);
    else return (a.s>b.s);
}
ll Find(ll p)
{
    if(last[p]==p) return p;
    else return (last[p]=Find(last[p])) ;
}
int main()
{
    Khela
    ll a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    while(cin>>m>>n)
    {
        PII ara[m];
        for(i=0;i<m;i++) cin>>ara[i].f>>ara[i].s;
        sort(ara,ara+m,cmp);
        bool mark[n];
        memset(mark,false,sizeof mark);
        ll sum=0;
        for(i=0;i<=n;i++) last[i]=i;
        for(i=0;i<m;i++)
        {
                if(n-ara[i].f>=0 && !mark[(Find(n-ara[i].f))]){
                sum+=ara[i].s;
                p=(Find(n-ara[i].f));
                mark[p]=true;
                if(p-1>=0) last[p]=Find(last[p-1]);
            }
        }

        cout<<sum<<endl;
    }


}

Measured memory_bytes: 2688
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector <int> vi;
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
typedef pair< int ,int > pii;
#define endl "\n"
#define sd(val) scanf("%d",&val)
#define ss(val) scanf("%s",&val)
#define sl(val) scanf("%lld",&val)
#define pt(x) cout<<x<<endl
#define deb(x) cout << #x << "=" << x << endl
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long
typedef vector<ll> vl;
#define MOD 1000000007
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
 
int main()
{
// OJ;
 int t,n,m,a,b;
 cin >> n;
 vector<int> hts(n+1,0);
 for(int i=1;i<=n;i++){
     cin>>hts[i];
 }
 int dp[n+1];
 dp[0]=0;
 dp[1]=0;
 dp[2]=abs(hts[1]-hts[2]);
 for(int i=3;i<=n;i++){
    dp[i]=min(dp[i-1]+abs(hts[i]-hts[i-1]),dp[i-2]+abs(hts[i]-hts[i-2]));
 }
pt(dp[n]);
return 0;
   
}

Measured memory_bytes: 4028
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

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

    int ans = 0;

    for(int i = 1; i < n - 1; i++){
        vector<int> temp(3);
        temp[0] = p[i - 1];
        temp[1] = p[i];
        temp[2] = p[i + 1];
        sort(temp.begin(), temp.end());

        if(temp[1] == p[i]){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
r1,c1,r2,c2=map(int,input().split())
n=2*max(r1,r2,c1,c2)+2
mod=10**9+7

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

inv_factorial = [-1] * (n+1)
inv_factorial[-1] = pow(factorial[-1], mod-2, mod)
for i in reversed(range(n)):
    inv_factorial[i] = inv_factorial[i+1] * (i+1) % mod

def fact(n):
    return factorial[n]

def nck(n, k):
    if k>n or k<0:
        return 0
    else:
        return factorial[n] * inv_factorial[n-k] * inv_factorial[k]
      
def routes(r,c):
  return nck(r+c+2,c+1)-1

ans=routes(r2,c2)-routes(r2,c1-1)-routes(c2,r1-1)+routes(r1-1,c1-1)
ans%=mod
print(ans)
  

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(50 + 5);
const int MAX_X = (int)(50 + 5);

int n, a;
int x[MAX_N];

ll dp[MAX_N][MAX_N][MAX_N * MAX_X];

ll ans = 0;

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &a);

  for (int i = 1; i <= n; ++i) {
    scanf("%d", &(x[i]));
  }

  dp[0][0][0] = 1LL;

  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= i; ++j) {
      for (int k = 0; k < n * MAX_X; ++k) {
        if (k - x[i] < 0) {
          dp[i][j][k] = dp[i - 1][j][k];
        }
        else {
          if (j > 0) dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]];
        }
      }
    }
  }

  // printf("    ");
  // for (int k = 0; k < n * 9; ++k) {
  //   printf("%2d ", k);
  // }
  // printf("\n");
  //
  // for (int i = 1; i <= n; ++i) {
  //   int j = 1;
  //   printf("%2d: ", i);
  //   for (int k = 0; k < n * 9; ++k) {
  //
  //     printf("%2lld ", dp[i][j][k]);
  //   }
  //   printf("\n");
  // }


  for (int j = 1; j <= n; ++j) {
    ans += dp[n][j][j * a];
  }

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

  return 0;
}


Measured memory_bytes: 65792
S = input()
A = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"] 
B = [0]*26
flag = -1

for i in range(len(S)):
  
  for j in range(len(A)):
    if S[i] == A[j]:
      B[j] += 1
      break
  
  if i == len(S):
    break

for k in range(len(B)):
  if B[k] == 0:
    print(A[k])
    flag = 1
    break
    
if flag == -1:
  print("None")

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <climits>
#include <math.h>
#include <utility>
#include <ctime>
#include <cstdlib>
using namespace std;

typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) a.begin(),a.end()

int main() {
	string o, e;
	cin >> o >> e;
	rep(i, o.size() + e.size()) {
		if (i % 2 == 0) {
			cout << o.at(i / 2);
		}
		else {
			cout << e.at((i - 1) / 2);
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}
ll valid(ll w, ll h, ll x, ll y) {
  if (x * 2 == w && y * 2 == h)
    return 1;
  return 0;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll w, h, x, y;
  cin >> w >> h >> x >> y;

  ld res = w * h;
  res /= 2;

  cout << fixed << setprecision(10) << res << " " << valid(w, h, x, y) << en;

  return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, c;
    cin >> a >> b >> c;

    int k;
    cin >> k;

    for (int i = 0; i <= k; i++){
        for (int j = 0; j <= k; j++){
            for (int kk = 0; kk <= k; kk++){
                if (i + j + kk <= k){
                    int aa = (1 << i) * a;
                    int bb = (1 << j) * b;
                    int cc = (1 << kk) * c;

                    if (cc > bb && bb > aa){
                        cout << "Yes\n";
                        return 0;
                    }
                }
            }
        }
    }

    cout << "No\n";

    return 0;
}


Measured memory_bytes: 3664
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  private static final int mod = 1000000007;

  private static long[] fac;
  private static long[] finv;
  private static long[] inv;

  private static void comInit(int n) {
    fac = new long[n + 1];
    finv = new long[n + 1];
    inv = new long[n + 1];
    fac[0] = 1;
    fac[1] = 1;
    finv[0] = 1;
    finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i <= n; i++) {
      fac[i] = fac[i - 1] * i % mod;
      inv[i] = mod - inv[mod % i] * (mod / i) % mod;
      finv[i] = finv[i - 1] * inv[i] % mod;
    }
  }

  private static long com(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    comInit(n);
    StringBuilder sb = new StringBuilder();
    for (int i = 1; i <= k; i++) {
      if (sb.length() > 0) sb.append("\n");
      long blueballSeq = com(k - 1, i - 1);
      long count = com(n - k + 1, i) * blueballSeq;
      count %= mod;
      sb.append(count);
    }
    System.out.println(sb.toString());
  }
}

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

int main(){
    int n;
    cin>>n;
    int a=0,b=0,c=0;
    for(int i=0;i<n;i++){
        int s;
        cin>>s;
        if(s%4==0) a++;
        else if(s%2==0) b++;
        else c++;
    }
    bool flag=false;
    if(b==0&&c<=a+1) flag=true;
    if(b&&c<=a) flag=true;
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3664
n = int(input())

b = list(map(int, input().split( )))

a = [0 for i in range(n)]
a[0] = b[0]

for i in range(1,n-1):
    a[i] = min(b[i],b[i-1])
a[n-1] = b[n-2]

print(sum(a))

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

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

    if(n == 2){
        if(k == 0){
            cout << 1 << endl;
            cout << "1 2" << endl;
        }else{
            cout << -1 << endl;
        }
        return 0;
    }

    vector<vector<bool>> g(n, vector<bool>(n, false));
    for(int i = 0; i < n; i++){
        if(i == 1)  continue;
        g[i][1] = g[1][i] = true;
    }

    int res = n-2 + (n-2)*(n-2-1)/2;
    
    if(res < k){
        cout << -1 << endl;
        return 0;
    }

    int ind1 = 2, ind2 = 2;
    while(res != k){
        if(ind1 != n){
            g[0][ind1] = g[ind1][0] = true;
            res--;
            ind1++;
            continue;
        }else{
            bool path = false;
            for(int next = ind2+1; next < n; next++){
                if(!g[ind2][next]){
                    g[ind2][next] = g[next][ind2] = true;
                    res--;
                    path = true;
                    break;
                }
            }
            if(!path)   ind2++;
            continue;
        }
    }

    vector<pair<int,int>> vp;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            if(g[i][j]) vp.push_back({i+1,j+1});
        }
    }
    cout << vp.size() << endl;
    for(int i = 0; i < vp.size(); i++){
        cout << vp[i].first << " " << vp[i].second << endl;
    }

    return 0;
}

Measured memory_bytes: 384
from collections import defaultdict


def min_factor(n):
    sieve = list(range(n + 1))
    sieve[2::2] = [2] * (n // 2)
    for i in range(3, int(n ** 0.5) + 2, 2):
        if sieve[i] == i:
            sieve[i * i::2 * i] = [i] * ((n - i * i) // (2 * i) + 1)
    return sieve


def prime_factorize(n, table):
    a = {}
    while n != 1:
        b = table[n]
        if b in a:
            a[b] += 1
        else:
            a[b] = 1
        n //= b
    return a


def main():
    n = int(input())
    mod = 10 ** 9 + 7
    table = min_factor(10 ** 3)

    dic = defaultdict(int)
    for i in range(1, n + 1):
        for key, value in prime_factorize(i, table).items():
            dic[key] += value

    res = 1
    for value in dic.values():
        res *= value + 1
        res %= mod
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316