akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
      
      	if(a%2==0||b%2==0){
          System.out.println("Even");
        }else{
          System.out.println("Odd");
        }
	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#include <cstdlib>
using namespace std;
#define ll long long
typedef vector<vector<ll> > matrix;
#define pb push_back
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const double PI  =3.141592653589793238463;
long long MOD = 1000000007;

int stringToInteger(string x){
    int gg=0;
    stringstream geek(x);
    geek >> gg;
    return gg;
}

ll powmod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b>0){ if(b%2)
        {ans*=a; ans%=m;}
         b/=2; a=a*a; a=a%m;
        }
        return ans%m;
}
ll gcd(ll a,ll b)
{

    return __gcd(a,b);
}
ll mulmod(ll a,ll b,ll m)
{  ll ans=0;
    a %=m;
    while (b>0)
    {       if(b&1) ans = (ans + a) % m;
        a = (a * 2)%m;
        b /= 2;
    }
    return ans % m;
}

ll f[2000001];



ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a;
 while(b > 0)
 	{
 		if(b%2 == 1)
 	{
 		x=(x*y);
 		if(x>MOD) x%=MOD;
 	}
 	y = (y*y);
 	if(y>MOD) y%=MOD;
 	b /= 2;
 	}
 return x;
}

/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}

bool prime[100005];
void seive()
{  memset(prime,true,sizeof(prime));
    for(int i=2;i*i<=100005;i++)
    {
         if(prime[i]==true) {
        for(int j=2*i;j<=(100005);j+=i)
           { prime[j]=false;}
           }

    }
}
bool in(float x1,float y1,float x,float y,float r )
{
    if(abs(x1-x)*abs(x1-x)+abs(y1-y)*abs(y1-y)<=r*r) return true;
    return false;
}
bool cmp(pair<int,int> &a,pair<int,int> &b)
{

        return (a.second<b.second);
}
//
//vector<vector<int> >matrix;
matrix mul(matrix A,matrix B)
{
    matrix C(3, vector<ll>(3));
    for(int i=1;i<=2;i++)
    for(int j=1;j<=2;j++)
     for(int k=1;k<=2;k++)
         C[i][j] = (C[i][j] + A[i][k] * B[k][j]);
    return C;

}
matrix pow(matrix A, int p)
{
    if (p == 1)
        return A;
    if (p % 2)
        return mul(A, pow(A, p-1));
    matrix X = pow(A, p/2);
    return mul(X, X);
}
ll fib(int N,int a,int b)
{
    vector<ll> F1(3);
    F1[1] = a;
    F1[2] = b;
    matrix T(3, vector<ll>(3));
    T[1][1] = 0, T[1][2] = 1;
    T[2][1] = -1, T[2][2] = 1;
    if (N == 1)
        return a;
    if(N==2) return b;
    T = pow(T, N-1);
    ll res = 0;
    for(int i=1;i<=2;i++)
        res = (res + T[1][i] * F1[i]+ MOD)%MOD ;
    return res;
}

//1 2 3 4 5
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

 int t =1;
 while(t--)
  {
      string s;
      cin>>s;
      cout<<s[0]<<s.length()-2<<s[s.length()-1];
  }
}


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

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 100005

int main(){

    int a,b,c;
    cin >> a >> b >> c;
    if(a+b>c && a <= c){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
   
    return 0;
}

Measured memory_bytes: 256
#darker　and darker
from collections import deque
d=deque()
e=deque()
h,w=map(int,input().split())
field=[0 for i in range(h+2)]
field[0]=[True for i in range(w+2)]
distance=0
for i in range(h):
    s=input()
    a=[False for i in range(w+2)]
    a[0]=True
    for j in range(w):
        if s[j]=="#":
            a[j+1]=True
            d.append((i+1,j+1))
    a[w+1]=True
    field[i+1]=a
field[h+1]=[True for i in range(w+2)]
while d:
    while d:
        some=d.popleft()
        index1,index2=some[0],some[1]
        if field[index1-1][index2]==False:
                field[index1-1][index2]=True
                e.append((index1-1,index2))
        if field[index1+1][index2]==False:
                field[index1+1][index2]=True
                e.append((index1+1,index2))
        if field[index1][index2+1]==False:
                field[index1][index2+1]=True
                e.append((index1,index2+1))
        if  field[index1][index2-1]==False:
                field[index1][index2-1]=True
                e.append((index1,index2-1))
    distance+=1
    d=e
    e=deque()
print(distance-1)
    


Measured memory_bytes: 99036
#include <bits/stdc++.h>
#define s second
#define f first
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

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

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

int N, A, B;
vector<ll> V;

// Three choices:
// 1. Walk to nxt
// 2. Teleport to nxt
// 3. Teleport to other, and walk/teleport to nxt

ll move(ll from, ll to){
	assert(from >= 0 && to >= 0);
	return min((ll)B,(ll)A*abs(V[to] - V[from]));
}

ll solve(int pos, int nxt){
	if(nxt == N) return move(pos,nxt);
	if(nxt > N) return 0;

	ll op1 = move(pos,nxt) + move(nxt,nxt + 1);
	ll op2 = move(pos,nxt+1) + move(nxt,nxt + 1);

	if(op1 <= op2) return move(pos,nxt) + solve(nxt,nxt+1);
	else return op2 + solve(nxt,nxt+2);
}

int main(){ //_

	cin >> N >> A >> B;

	V.resize(N+100,0);
	V[0] = 1;
	for(int i = 1; i <= N; i++){
		cin >> V[i];
	}

	cout <<	solve(1,2) << endl;

	return 0;
}


Measured memory_bytes: 3944
n = int(input())
num_of_anagram = dict()
ans = 0

for _ in range(n):
    s = input()
    s = ''.join(sorted(list(s)))
    if s in num_of_anagram:
        num_of_anagram[s] += 1
        ans += num_of_anagram[s]
    else:
        num_of_anagram[s] = 0

print(ans)

Measured memory_bytes: 17892
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

struct murmur_hash {
    const unsigned int random = random_device{}();
    unsigned int operator()(const string& s) const {
        const unsigned int m = 0x5bd1e995;
        const int r = 24;
        unsigned int len = s.size(), h = (random ^ len);
        const unsigned int *z = (const unsigned int*)s.c_str();
        while(len >= 4){
            unsigned int k = *z;
            k *= m, k = (k^(k>>r))*m, h = (h*m)^k;
            z += 1, len -= 4;
        }
        const char *c = (const char *)z;
        switch(len)
        {
        case 3u: h ^= (c[2] << 16);
        case 2u: h ^= (c[1] << 8);
        case 1u: h ^= c[0];
                 h *= m;
        }
        h = (h^(h>>13))*m;
        return (h^(h>>15));
    }
};

unordered_map<string, unordered_map<string, int, murmur_hash>, murmur_hash> mp[2];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    n *= 2;
    string s;
    cin >> s;
    rep(i,(1 << (n-n/2))){
        string red,blue;
        rep(j,n-n/2){
            if((i >> j) & 1){
                red.pb(s[j+n/2]);
            }else{
                blue.pb(s[j+n/2]);
            }
        }
        reverse(all(blue));
        if(len(red) <= len(blue)){
            mp[0][blue][red]++;
        }else{
            mp[1][red][blue]++;
        }
    }
    ll ans = 0;
    rep(i,(1 << n/2)){
        string red, blue;
        rep(j,n/2){
            if((i >> j) & 1){
                red.pb(s[j]);
            }else{
                blue.pb(s[j]);
            }
        }
        reverse(all(blue));
        if(len(red) >= len(blue)){
            ans += mp[0][red][blue];
        }else{
            ans += mp[1][blue][red];
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 138392
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

const int MAX_SIZE = 10000;

int k,r,l;
double p,e,t;

double dfs(int k,double r,double l){
    if(k==0){
        double h=(r+l)/2;
        if(abs(h-t)<e||EQ(abs(h-t),e))
            return 1.0;
        else
            return 0.0;
    }
    if((r<t-e&&l<t-e)||(r>t+e&&l>t+e))
        return 0.0;
    if(t-e<=r&&t+e>=r&&t-e<=l&&t+e>=l)
        return 1.0;
    double h=(r+l)/2;
    double per=0;
    if(h>t||EQ(h,t))
        per+=(1-p)*dfs(k-1,r,h);
    else
        per+=(1-p)*dfs(k-1,h,l);
    if(h>t||EQ(h,t))
        per+=(p)*dfs(k-1,h,l);
    else
        per+=(p)*dfs(k-1,r,h);
    return per;
}

void solve(){
    cin>>k>>r>>l;
    cin>>p>>e>>t;
    double res=dfs(k,r,l);
    printf("%.7f\n",res);
}
int main(){
    solve();
    return 0;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

bool search(int x, int y, vector<vector<char>> a, vector<vector<char>> b) {
    for (int i = x; i <= x + m - 1; ++i) {
        for (int j = y; j <= y + m - 1; ++j) {
            if (a.at(i).at(j) != b.at(i - x).at(j - y)) return false;
        }
    }

    return true;
}

int main() {
    cin >> n >> m;
    vector<vector<char>> a(n, vector<char>(n));
    vector<vector<char>> b(m, vector<char>(m));

    NREP() {
        string t;
        cin >> t;
        REP(j, n) {
            a.at(i).at(j) = t.at(j);
        }
    }

    REP(i, m) {
        string t;
        cin >> t;
        REP(j, m) {
            b.at(i).at(j) = t.at(j);
        }
    }

    for (int x = 0; x <= n - m; ++x) {
        for (int y = 0; y <= n - m; ++y) {
            if (search(x, y, a, b)) {
                MSG("Yes")
                exit(0);
            }
        }
    }

    MSG("No")
}


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

using namespace std;

#define ll long long int
#define get(a) ll a; cin >> a;
#define show(a) cout << a << endl;
#define full(p) p.begin(), p.end()
#define sz(a) (ll)(a.size())
#define pb push_back

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout<<fixed;
	////////////////////////////////
	get(a);
	get(b);
	get(c);

	cout << max( a*10 + b + c , max(a + b*10+c , a + b + c*10))  << endl;	

	return 0;
}

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

int main(){
  int n;
  cin >> n;
  long long sum = 1;
  for(int i=1; i<=n; i++){
    
    sum = (i*sum) % 1000000007;
  }
  
  cout << sum % 1000000007 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#ifndef M_E
#define M_E 2.71828182845904523536
#endif
#ifdef DEBUG
#include <boost/core/demangle.hpp>
#define dump(x) cerr << "L" << __LINE__ << ": in " << __PRETTY_FUNCTION__ << " \e[32;1m" << boost::core::demangle(typeid(x).name()) << "\e[37m" << " " << (#x) << " = " << (x) << "\e[m" << endl;
#else
#define dump(x)
#endif
#define pln(x) cout << (x) << endl
#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename Iter> ostream& out_container(ostream &os, Iter first, Iter last){
  os << "{"; auto itr = first; while(itr != last){if(itr != first) os << ","; os << *itr; ++itr;} os << "}"; return os;
}

template <typename T> ostream& operator<<(ostream &os, const vector<T> &c){return out_container(os,ALL(c));}
template <typename T> ostream& operator<<(ostream &os, const deque<T> &c){return out_container(os,ALL(c));}
template <typename T> ostream& operator<<(ostream &os, const set<T> &c){return out_container(os,ALL(c));}
template <typename T> ostream& operator<<(ostream &os, const unordered_set<T> &c){return out_container(os,ALL(c));}
template <typename T, typename U> ostream& operator<<(ostream &os, const map<T,U> &c){return out_container(os,ALL(c));}
template <typename T, typename U> ostream& operator<<(ostream &os, const unordered_map<T,U> &c){return out_container(os,ALL(c));}
template <typename T, typename U> ostream& operator<<(ostream& os, const pair<T,U> &p){os << "(" << p.first << "," << p.second << ")"; return os;}

template <typename T, typename U> T& chmin(T &a, const U &b){return a = (a<=b?a:b);}
template <typename T, typename U> T& chmax(T &a, const U &b){return a = (a>=b?a:b);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int N,K;
  while(cin >> N >> K){
    cout << (K<=(N+1)/2?"YES":"NO") << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int a,b;
  while(cin>>a>>b){
    if(a+b==0)break;
    int m[1100],w=0,o[1100],c=0;
    r(i,a)cin>>m[i];
    r(i,b)cin>>o[i];
    r(i,b){c++;
      w+=o[i];
      w+=m[w];
      if(w>=a)break;
    }
    cout<<c<<endl;
    }
}

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

#define fi first
#define se second

const int N = 1010;
const long long mod = 1e9 + 7;

using namespace std;

int n;
int m;
int d[N][N];

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(0);

        cin >> n >> m;
        d[1][1] = 1;
        for(int i = 1; i <= n; i++){
                for(int j = 1; j <= m; j++){
                        char c;
                        cin >> c;
                        if(c == '.'){
                                d[i][j] += d[i - 1][j] + d[i][j - 1];
                                if(d[i][j] >= mod){
                                        d[i][j] -= mod;
                                }
                        }
                }
        }
        cout << d[n][m] << "\n";
}



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

int main()
{
	long long int n,k,i,j;
	cin>>n>>k;
	long long int a[n];
	for(i=0;i<n;i++)
		cin>>a[i];
	bool dp[k+1]={false};
	for(i=1;i<=k;i++)
	{
		for(j=0;j<n;j++)
		{
			if(i-a[j]<0)
				continue;
			if(dp[i-a[j]])
				dp[i]=false;
			else
			{
				dp[i]=true;
				break;
			}
		}
	}
	
	if(dp[k])
		cout<<"First\n";
	else
		cout<<"Second\n";
		
	
	
	
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

N, K = map(int, raw_input().split())
D = set(raw_input().split())
for i in xrange(100000):
    for x in str(N):
        if x in D:
            break
    else:
        print N
        break
    N += 1



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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

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


int main(){
    string s; cin >> s;
    if(s.back() == 's'){
        s.push_back('e');
        s.push_back('s');
        cout << s << endl;
    }
    else{
        s.push_back('s');
        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    for (auto e: v) os << e << ",";
    os << "]";
    return os;
}

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// print floating-point number
// cout << fixed << setprecision(12) <<

// }}}

ll pow_mod(ll x, ll n, ll mod)
{
    ll ret = 1ll;
    ll v = x;
    for (; n > 0; n >>= 1) {
        if (n & 1) (ret *= v) %= mod;
        (v *= v) %= mod;
    }
    return ret;
}

constexpr int COMB_MAX = 5000;
ll fac[COMB_MAX];   // fac[i]  = i!        (mod MOD)
ll finv[COMB_MAX];  // finv[i] = (i!)^{-1} (mod MOD)
ll inv[COMB_MAX];   // inv[i]  = i^{-1}    (mod MOD)

void combInit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    FOR(i, 2, COMB_MAX){
        fac[i] = fac[i-1] * i % MOD;
        // i^{-1} (mod p) = -(p mod i)^{-1} * (p/i) (mod p)
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

ll comb(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;
}

int N, K;

void solve()
{
    combInit();
    FOR (i, 1, K+1) {
        cout << (comb(K-1, K-i) * comb(N-K+1, i)) % MOD << endl;
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 384
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]

memo = [0] * (1 << n)
dp = [0] * (1 << n)

def f(s):
    if memo[s]:
        return dp[s]
    memo[s] = 1

    # 集合sを一つのグループとしたときに得られるスコア
    score = 0
    for i in range(n):
        for j in range(i+1, n):
            if ((s >> i) & 1) & ((s >> j) & 1):
                score += a[i][j]

    # sの部分集合でs自身と空集合を除いた集合を列挙(テクニックが存在)
    t = (s-1) & s   # s自身を除く (今回は関係ないがs自身を含む場合は t = s としてあげる)
    while t > 0:
        # 集合t と, 集合sから集合tを除いた集合に分けて、それぞれ再帰的にスコアを求める
        score = max(score, f(t) + f(s ^ t))
        t = (t-1) & s

    dp[s] = score
    return dp[s]

print(f((1 << n) - 1))

Measured memory_bytes: 46428
#include<stdio.h>

int main(){
    long long int N,A,B;
    long long int i, tmp = 0, tmp2;
    scanf("%lld %lld %lld", &A, &B, &N);

    i = N;
    tmp2 = A * i / B - (A * (i / B));
    //printf("%lld %lld\n", A * i / B, (A * (i / B)));
    if (tmp < tmp2)
        tmp = tmp2;

    for (i = B - 1; i <= N; i+=B){
        tmp2 = A * i / B - (A * (i / B));
        //printf("%lld %lld\n", A * i / B, (A * (i / B)));
        if (tmp < tmp2)
            tmp = tmp2;
        else
            break;
    }
    printf("%lld\n", tmp);
    return 0;
}

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

int N;
int a[110];

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

    sort(a, a+N);

    ll ans = 1.0e18;
    for (int i = a[0]; i <= a[N-1]; i++) {
        ll sum = 0;
        for (int j = 0; j < N; j++) {
            sum += (i - a[j]) * (i - a[j]);
        }
        ans = min(ans, sum);
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n;
int h, w;
string table[50];

int main() {
	cin >> n;
	rep(kk, n) {
		cin >> h >> w;
		vector<char> vi;
		rep(i, h) {
			cin >> table[i];
			rep(j, w) {
				if (table[i][j] != '.')vi.push_back(table[i][j]);
			}
		}
		sort(ALL(vi));
		vi.erase(unique(ALL(vi)), vi.end());
		bool f = 0;
		ll mci[4][26] = {};
		rep(i, 26) {
			mci[2][i] = h - 1;
			mci[3][i] = w - 1;
		}
		set<char> sc;
		rep(i, vi.size()) {
			rep(j, h) {
				rep(k, w) {
					if (table[j][k] != '.') {
						mci[0][table[j][k] - 'A'] = max(mci[0][table[j][k] - 'A'], j);
						mci[1][table[j][k] - 'A'] = max(mci[1][table[j][k] - 'A'], k);
						mci[2][table[j][k] - 'A'] = min(mci[2][table[j][k] - 'A'], j);
						mci[3][table[j][k] - 'A'] = min(mci[3][table[j][k] - 'A'], k);
					}
				}
			}
			rep(j, vi.size()) {
				bool ok = 1;
				//rep(i, 4) {
				//	cout << mci[2][vi[j] - 'A'] << " " << mci[0][vi[j] - 'A'] << " "
				//		<< mci[3][vi[j] - 'A'] << " " << mci[1][vi[j] - 'A'] << endl;
				//}
				for (int k = mci[2][vi[j] - 'A']; k <= mci[0][vi[j] - 'A']; k++) {
					for (int l = mci[3][vi[j] - 'A']; l <= mci[1][vi[j] - 'A']; l++) {
						if (table[k][l] != vi[j]) {
							if (sc.find(table[k][l]) == sc.end())ok = 0;
						}
					}
				}
				if (ok)sc.insert(vi[j]);
			}
		}
		if (sc.size() == vi.size())cout << "SAFE" << endl;
		else cout << "SUSPICIOUS" << endl;
	}
}


Measured memory_bytes: 3144
//Heaplax
//别让自己后悔
#include<bits/stdc++.h>
#define N 501
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
struct node
{
	int id,pos,last;
	bool operator < (const node &i)const
	{
		return pos<i.pos;
	}
}x[N];
bool fix[N];
int n,a[N*N],have[N];
int main()
{
	re(n);
	for(int i=1;i<=n;++i)
		x[i].id=i,re(x[i].pos),a[x[i].pos]=i,x[i].last=i-1;
	sort(x+1,x+n+1);
	for(int i=1,j=1,k=1;i<=n*n;++i)
	{
		while(j<=n && !x[j].last)
			fix[x[j].id]=1,++j;
		if(!a[i])
		{
			if(j<=n)
			{
				a[i]=x[j].id;
				--x[j].last;
			}
			else
			{
				while(have[x[k].id]==n-1)++k;
				a[i]=x[k].id;
			}
			++have[a[i]];
		}
		else if(have[a[i]]!=a[i]-1)
		{
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	for(int i=1;i<=n*n;++i)
		printf("%d ",a[i]);
}


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

int main(){
    ll n;cin>>n;
    int k;
    string q="abcdefghijklmnopqrstuvwxyz";
    string ans="";
    while(1) {
        k=n%26;
        if(k!=0) ans+=q[k-1];
        if(k==0) {
          ans+="z";
          --n;
        }
        if(n<=26) break;
        n/=26;
    }
    reverse(ans.begin(), ans.end());
    cout<<ans<<endl;
   }

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

#define rep(i, n) for(int i = 0 ; i < n ; i ++)
#define vi vector<int>
int main(void){
  int n;
  cin>>n;
  vi a(n);
  rep(i,n)cin>>a[i];
  sort(a.begin(), a.end());
  cout<<a[a.size() - 1] - a[0]<<endl;
}


Measured memory_bytes: 256
<?php

$n = trim(fgets(STDIN));

$ans = 753;
for($i=0; $i<strlen($n)-2; $i++){
  $a = [$n[$i], $n[$i+1], $n[$i+2]];
  $a = implode($a)." ";
  $diff = abs(753-$a);
  if ($diff < $ans) $ans = $diff;
}

echo $ans;
  
?>

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

using namespace std;

int main() {
    int n, b;
    cin >> n;
    vector<int> a(n, 0);
    for (int i = 2; i <= n; i++) {
        cin >> b;
        a[b - 1]++;
    }
    for (int i = 0; i < n; i++) {
        cout << a[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4052
const config = {
    input: '/dev/stdin',
    newline: '\n'
};

const line = require('fs').readFileSync(config.input, 'utf-8').split(config.newline);

const bs = (arr, n, start, end) => {
    start = start || 0;
    end = end || arr.length;

    if (arr.length === 0 || start > end) return false;
    const mid = Math.floor((start + end) / 2);
    if (n === arr[mid]) return true;
    if (n < arr[mid]) {
        return bs(arr, n, start, mid-1);
    } else {
        return bs(arr, n, mid+1, end);
    }
};

const solve = (arr1, arr2) => arr2.filter(x => bs(arr1, x)).length;

const data1 = line[1].split(' ').map(Number);
const data2 = line[3].split(' ').map(Number);

console.log(solve(data1, data2));



Measured memory_bytes: 33972
use bigint;
sub nCk{my($n,$k)=@_;
	my$r=1;
	$r*=$n+1-$_,$r/=$_ for 1..$k;
	$r
}
($N,$A,$B)=glob<>;
@v=sort{$b<=>$a}glob<>;
$s+=$_ for@v[0..$A-1];
$l=$r=$A-1;
$l--while$l-1>=0&&$v[$l-1]==$v[$A-1];
$r++while$r+1<$N&&$v[$r+1]==$v[$A-1];
$p+=nCk($r-$l+1,$_-$l)for$A..($l?$A:$B);
printf"%f\n%d",$s/$A,$p


Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <stdio.h>
#include <cmath>
#include <limits.h>
using namespace std;

typedef long long ll;

#define min(a, b) (((a) < (b))? (a):(b))
#define max(a, b) (((a) > (b))? (a):(b))
#define REP(i, a, n) for(int i=(a); i<(n); ++i)
#define rep(i, n) REP(i, 0, (n))
#define square(a) (a)*(a)
#define pb push_back

int h,w;
char a[110][110];
int main(){
	cin >> h >> w;
	rep(i,h) cin >> a[i];
	
	rep(i,w+2) cout << '#';
	cout << "" << endl;
	rep(i,h){
		cout << '#';
		rep(j,w) cout << a[i][j];
		cout << '#' << endl;
	}
	rep(i,w+2) cout << '#';
	cout << "" << endl;
}

Measured memory_bytes: 256
l=[0 for i in range(26)]
a="abcdefghijklmnopqrstuvwxyz"
while True:
    try:
        tex = input()
    except :
        break
    tex=tex.lower()
    for i in tex:
        count=0
        for j in a:
            if i==j:
                l[count]+=1
            count+=1
    count=0
for k in a:
    print(k+" : "+str(l[count]))
    count+=1



Measured memory_bytes: 5568
#include<stdio.h>

int main(void){
  int N,K;
  scanf("%d",&N);

  scanf("%d",&K);
  int A[N];
  for(int i=0;i<N;i++){
    scanf("%d",A+i);
  }
    if((N-1)%(K-1) ==0){
    printf("%d",(N-1) / (K-1));
    
  }
  else{
  printf("%d",(N-1)/(K-1)+1);
  }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;void solve();int main(){ios::sync_with_stdio(0);cin.tie(0);solve();};typedef long long ll;
template<typename Type>void print_collection(Type coll){cout<<"{ ";for(auto e:coll)cout<<e<<' ';cout<<"}\n";}
void solve() {
  int A, B, C;
  cin >> A >> B >> C;
  if ((A < C  and C < B) or (A > C and C > B))
    cout << "Yes";
  else
    cout << "No";
  cout << '\n';
}

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int x, y, z, k;
    cin >> x >> y >> z >> k;

    vector<ll> a(x), b(y), c(z);
    rep(i, x) cin >> a[i];
    rep(i, y) cin >> b[i];
    rep(i, z) cin >> c[i];

    vector<ll> ab;
    rep(i, x) rep(j, y) ab.push_back(a[i] + b[j]);

    sort(ALL(ab), greater<ll>());

    vector<ll> abc;
    rep(i, min(k, (int)ab.size()))
    {
        rep(j, z)
        {
            abc.push_back(ab[i] + c[j]);
        }
    }

    sort(ALL(abc), greater<ll>());

    rep(i, k) OP(abc[i]);

    return 0;
}

Measured memory_bytes: 43368
def is_float_str(num_str, default=0):
    try:
        return {"is_float": True, "val": float(num_str)}
    except ValueError:
        return {"is_float": False, "val": default}


def compute(operand, val1, val2):
    if operand == "+":
        return val2 + val1
    elif operand == "-":
        return val2 - val1
    elif operand == "*":
        return val2 * val1
    elif operand == "/":
        return val2 / val1


def get_input():
    while True:
        try:
            yield input()
        except EOFError:
            break


if __name__ == '__main__':
    # split with ' '
    formulas = list(get_input())
    for (i, formula) in enumerate(formulas, 0):
        formulas[i] = formula.split(' ')
    stack = []

    for formula in formulas:
        stack = []
        for elm in formula:
            if is_float_str(elm)["is_float"]:
                stack.append(is_float_str(elm)["val"])
            elif elm in ['+', '-', '*', '/']:
                stack.append(compute(elm, stack.pop(), stack.pop()))
        if len(stack) == 1:
            print(format(stack[0], '.6f'))



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using i64 = long long;

class UF {
    int *par;
    int *rank;

    public:
    UF(int size) : par(new int[size]), rank(new int[size]()) {
        for (int i = 0; i < size; i++) par[i] = i;
    }
    ~UF() { delete[] par; delete[] rank; }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;

        if (rank[x] < rank[y]) par[x] = y;
        else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
        }
    }
};

int main() {
    int n;
    std::cin >> n;
    std::vector<std::pair<int, int>> a;
    std::vector<std::deque<int>> xs(100010), ys(100010);
    for (int i = 0; i < n; i++) {
        int x, y;
        std::cin >> x >> y;
        a.emplace_back(x, y);
        xs[x].push_back(i);
        ys[y].push_back(i);
    }

    UF uft(n);
    for (int i = 1; i <= 100000; i++) {
        if (xs[i].size() == 0) continue;
        for (auto v : xs[i]) uft.unite(xs[i].front(), v);
    }
    for (int i = 1; i <= 100000; i++) {
        if (ys[i].size() == 0) continue;
        for (auto v : ys[i]) uft.unite(ys[i].front(), v);
    }

    std::vector<std::set<int>> ux(100010), uy(100010);
    std::set<int> keys;
    for (int i = 0; i < n; i++) {
        ux[uft.root(i)].insert(a[i].first);
        uy[uft.root(i)].insert(a[i].second);
        keys.insert(uft.root(i));
    }

    i64 ret = 0;
    for (auto k : keys) {
        ret += (i64)ux[k].size() * (i64)uy[k].size();
    }
    std::cout << ret - n << std::endl;

    return 0;
}


Measured memory_bytes: 150260
#pragma region header
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a / gcd(a, b) * b ;
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion


signed main() {
    int n,k;cin >> n >> k;
    int mi = inf;
    vi v(n);
    rep(i, n)cin >> v[i];
    rep(i, n-k+1) {
        int x = v[i+k-1]-v[i];
        if(v[i+k-1]*v[i]<0) x+=min(abs(v[i+k-1]),abs(v[i]));
        else if(v[i+k-1]<0) x+=abs(v[i+k-1]);
        else x+=abs(v[i]);
        chmin(mi,x);
    }
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 4052
h, w, k = map(int, input().split())
S = [ [ int(i) for i in input()] for _ in range(h) ]
res = 10**4
for i in range( 1<<(h-1) ):
    pos = [0]*h
    x = 0
    for j in range(h-1):
        if i & ( 1 << j ):
            x += 1
        pos[j+1] = x

    ret = x
    x = 0
    cnt = [0]*h
    flag = 0
    while x < w:
        for y in range(h):
            cnt[pos[y]] += S[y][x]
            if cnt[pos[y]] > k:
                cnt = [0]*h
                ret += 1
                flag += 1
                break
        else:
            x += 1
            flag = 0

        if flag == 2:
            ret = 10**4
            break

    res = min(res, ret)
print(res)

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

int main(){
    string s;
    cin >> s;

    if (s=="Sunny"){
        cout << "Cloudy" << endl;
    }else if (s=="Cloudy"){
        cout << "Rainy" << endl;
    }else if (s=="Rainy"){
        cout << "Sunny" << endl;
    }
}

Measured memory_bytes: 764
import java.util.Scanner;

	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			
			for(int i=0;i<10000;i++) {
				if((b*i+c)%a==0) {
					System.out.println("YES");
					return;
				
				}
			}
			System.out.println("NO");
		}	
	}

Measured memory_bytes: 23764
import sys

s = input()
s = s[:4]
a = s[:2]
b = s[2:]

	
if 0 <  int(a) <= 12 and 0 <  int(b) <= 12:

	print("AMBIGUOUS")
	sys.exit()


elif int(a) >= 0 and 0 < int(b) <= 12:

	print("YYMM")
	sys.exit()

elif 0 < int(a) <= 12 and int(b) >= 0:

	print("MMYY")
	sys.exit()

print("NA")




Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

long long mod = 1e9 + 7;

long long big_pow(long long a, long long b) {
	long long res = 1;
	while (b) {
		if (b & 1) {
			res = (res * a) % mod;
		}

		a = (a * a) % mod;
		b >>= 1;
	}

	return res % mod;
}	

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	long long n, a, b;
	cin >> n >> a >> b;

	long long total_bouquets = (big_pow(2, n) % mod) - 1;
	long long x = 1, y = 1;
	for (long long i = n; i >= n - a + 1; --i) {
		x *= i;
		x %= mod;
	}

	for (long long i = 2; i <= a; ++i) {
		y *= i;
		y %= mod;
	}

	total_bouquets -= (x * (big_pow(y, mod - 2) % mod) % mod);
	total_bouquets = (total_bouquets + mod) % mod;

	x = 1; 
	y = 1;
	for (long long i = n; i >= n - b + 1; --i) {
		x *= i;
		x %= mod;
	}

	for (long long i = 2; i <= b; ++i) {
		y *= i;
		y %= mod;
	}

	total_bouquets -= (x * (big_pow(y, mod - 2) % mod) % mod);
	total_bouquets = (total_bouquets + mod) % mod;

	cout << total_bouquets << "\n";

	return 0;

}

Measured memory_bytes: 3608
num,num2 = map(int,input().split())
num3 = input()
l = [str(i) for i in range(10)]
count = []
c = 0
for i in num3:
    if(i in l):
        c += 1
    else:
        count.append(c)
        c = 0
count.append(c)
if(num == count[0] and num2 == count[1]):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;

ll func(ll n) {
  int ans = 0;
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ans++;
      if(n / i != i) {
        ans++;
      }
    }
  }
  return ans;
}

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  vector<ll> dp(n + 10, 2);
  dp[1] = 1;
  for(int i = 1; i <= n; i++) {
    ll a, b, c;
    a = i;
    b = i;
    c = (n / i);
    ans += c * (2 * a + (c - 1) * b) / 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 81396
import numpy as np

H,W = map(int,input().split())

A = np.array(tuple(tuple(map(int,input().split())) for _ in range(H)))
B = np.array(tuple(tuple(map(int,input().split())) for _ in range(H)))

D = np.abs(A-B)
del A,B

if W > H:
    W,H = H,W
    D = D.T

L = D.max()*(H+W-1)+1
dp0 = np.zeros((W,L), dtype=bool)
dp1 = np.zeros_like(dp0)

dp1[0,D[0,0]] = True
for y in range(H):
    for x in range(W):
        d = D[y,x]

        dp1[x,d:] |= dp0[x,:L-d]
        dp1[x,:L-d] |= dp0[x,d:]
        dp1[x,:d] |= dp0[x,d:0:-1]
        dp1[x,d:] |= dp1[x-1,:L-d]
        dp1[x,:L-d] |= dp1[x-1,d:]
        dp1[x,:d] |= dp1[x-1,d:0:-1]
    dp0,dp1 = dp1, np.zeros_like(dp1)

print(min(i for i,v in enumerate(dp0[-1]) if v))


Measured memory_bytes: 15720
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> h(n+1000),cost(n+1000,1e9);
    rep(i,n) cin >> h[i];
    cost[0] = 0;
    cost[1] = abs(h[1]-h[0]);
    rep(i,n){
        reps(j,1,k+1){
            if(i+j>=n) break;
            //cout << "i:" << i << " " << " j:" << j << " " <<"i+j:" << i+j << endl;
            cost[i+j] = min(cost[i+j],cost[i] + abs(h[i+j]-h[i]));
        }
    }
    // rep(i,n){
    //     cout << i << " " << cost[i] << endl;
    // }
    cout << cost[n-1] << endl;

    return 0;
}

Measured memory_bytes: 1024
from math import factorial

def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

n = int(input())
k = int(input())


ans = 0

if len(str(n)) < k:
    print(0)
    exit()

def ans1(n,k):
    global ans
    m = len(str(n))
    if m-1 >= k:
        ans += combinations_count(m-1, k) * 9 ** k

    if m >= k:
        ans += (int(str(n)[0])-1) * combinations_count(m-1, k-1) * 9 ** (k-1)
        if k >= 2 and m > 1:
            ans1(int(str(n)[1:]), k-1)
        elif k == 1:
            ans += 1

ans1(n,k)

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    vector<ll> S(N+1, 0);
    map<ll, ll> cnt;
    for (int i = 1; i <= N; i++) {
        S[i] = (S[i - 1] + A[i - 1]) % M;
        if (cnt.count(S[i]) == 0) {
            cnt[S[i]] = 1;
        } else {
            cnt[S[i]]++;
        }
    }
    ll ans = cnt[0];
    for (auto& kv: cnt) {
        if (kv.second >= 2) {
            ans += ((kv.second * (kv.second - 1)) >> 1);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5760
#include <stdio.h>
#include <math.h>
#include <vector>
using namespace std;

int n;
int p, q;
int max1;
int coun;

void msk()
{
    coun = 0;
    max1 = p * p + q * q;
    for (int m = 0; m * m <= max1; m++)
    {
        for (int n = 0; m * m + n * n <= max1; n++)
        {
            if (m * m + n * n == 0)
                continue;

            if ((m * p + n * q) % (m * m + n * n) == 0 && (m * q - n * p) % (m * m + n * n) == 0)
            {
                coun++;
            }
            if (m != 0 && (m * p + n * q) % (m * m + n * n) == 0 && (m * q - n * p) % (m * m + n * n) == 0)
            {
                coun++;
            }
            if (n != 0 && (m * p + n * q) % (m * m + n * n) == 0 && (m * q - n * p) % (m * m + n * n) == 0)
            {
                coun++;
            }
            if (m != 0 && n != 0 && (m * p + n * q) % (m * m + n * n) == 0 && (m * q - n * p) % (m * m + n * n) == 0)
            {
                coun++;
            }
        }
    }
    if (coun == 8)
    {
        printf("P\n");
    }
    else
    {
        printf("C\n");
    }
}

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        if (n == 0)
            return 0;
        scanf("%d %d", &p, &q);
        msk();
    }
    return 0;
}


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

int main(){
int n;
cin >> n;
string s,t;
cin >> s >> t;
 string u ;
 for(int i = 0; i < 2*n; ++i ){
     if(i%2 == 0){
         u += s.at(i/2);
     }
     else{
         u += t.at((i-1)/2);
     }
 }
 cout << u << endl;
}

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

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

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

ll N;

bool f(ll x){
  ll n=N;
  if(x==1)return false;
  while(n%x==0)n/=x;
  return (n%x==1);
}

vector<int64_t>divisor(int64_t n) {
  vector<int64_t>ret;
  for(int64_t i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n)ret.push_back(n/i);
    }
  }
  sort(begin(ret),end(ret));
  return ret;
}

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

  cin>>N;
  auto X=divisor(N);
  auto Y=divisor(N-1);
  ll ans=0;
  for(auto it:X){
    ans+=f(it);
  }
  for(auto it:Y){
    ans+=f(it);
  }
  cout<<ans<<endl;

  return 0;
}


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

typedef long long ll;

int main(void) {
	int N, A, B;
	ll ans;

	cin >> N >> A >> B;

	if (A > B)
		ans = 0LL;
	else if (N == 1) {
		if (A != B)
			ans = 0LL;
		else
			ans = 1LL;
	}
	else
		ans = (ll)(N - 2) * (B - A) + 1LL;
	
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256