akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define rep(i,n) for(int i=0; i<n; i++)
#define pb(a) push_back(a)
#define mp make_pair

int main()
{

  ll a,b,k;

  cin >> a >> b >> k;

  k -= a;
  a = 0;

  if(k < 0){

    a = k * -1;
    cout << a << " " << b << endl;
    return 0;

  } else if(k == 0){

    cout << a << " " << b << endl;
    return 0;

  }

  k -= b;
  b = 0;

  if(k < 0){
    b = k * -1;
  }

  cout << a << " " << b << endl;

  return 0;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxd =1e5+10;
char s[maxd];
int main()
{
    // freopen("a.in","r",stdin);
    // freopen("k.out","w",stdout);
    scanf("%s",s);
    for(int i=1;s[i];i++)
        if(s[i] == s[i-1]){
            printf("Bad");
            return 0;
        }
    printf("Good");
    return 0;
}  

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

int main(){
    ll n,ans=0;
    cin>>n;
    vector<ll> a(n+1),b(n);
    for(int i=0;i<=n;i++) cin>>a[i];
    for(int i=0;i<n;i++)  cin>>b[i];
    for(int i=n-1;i>=0;i--){
        if(a[i+1]>=b[i]) ans+=b[i];
        else if(a[i]+a[i+1]>=b[i]){
            ans+=b[i];
            a[i]=a[i]+a[i+1]-b[i];
        }else{
            ans+=(a[i]+a[i+1]);
            a[i]=0;
        }
    }
    cout<<ans;
    return 0;
}

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

int main() {
	int n, omax = 0, emax = 0, om, em;
	vector<int> o(100001, 0);
	vector<int> e(100001, 0);
	cin >> n;

	for (int i = 0; i < n / 2; i++) {
		int a, b;
		cin >> a >> b;
		o[b]++; e[a]++;
		if (o[b] > omax) {
			omax = o[b]; om = b;
		}
		if (e[a] > emax) {
			emax = e[a]; em = a;
		}
	}

	sort(o.rbegin(), o.rend());
	sort(e.rbegin(), e.rend());

	if (om != em) {
		cout << n - o[0] - e[0] << endl;
	}
	else {
		cout << min(n - o[0] - e[1], n - o[1] - e[0]) << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<ctime>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++i)
using namespace std;

template <typename tn> void read (tn & a) {
	tn x = 0, f = 1; char c = getchar();
	while (c < '0' || c > '9'){ if (c == '-') f = -1; c = getchar(); }
	while (c >= '0' && c <= '9'){ x = x * 10 + c - '0'; c = getchar(); }
	a = f == 1 ? x : -x;
}

const int MAXN = 100100;
int n, ans;
ll a[MAXN], ax;

int main() {
	read(n);
	ax = 0;
	rep(i, 1, n) {
		read(a[++ax]);
		if (a[ax] > n) --ax, ++ans;
	}
	n = ax;
	sort(a + 1, a + 1 + n);
	for (int i = 1; i <= n;) {
		int j = i;
		while (j < n && a[j + 1] == a[i]) ++j;
		int l = j - i + 1;
		if (l >= a[i]) {
			ans += l - a[i];
		}
		else {
			ans += l;
		}
		i = j + 1;
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#include<string.h>
#define inf 9000000000000000000
#define maxn 200006
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
#define endl '\n'
#define mapint_iterator map<int,int> :: iterator
#define mapll_iterator map<ll,ll> :: iterator
#define setint_iterator set<int> :: iterator
#define setll_iterator set<ll> :: iterator
#define setpint_iterator set<pint> :: iterator
#define setpll_iterator set<pll> :: iterator
#define trace(x) cout<<#x<<": "<<x<<" "<<endl
#define trace2(x,y) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x,y,z) cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a,b,c,d) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define cout1(a) cout<<a<<endl
#define cout2(a,b) cout<<a<<' '<<b<<endl
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define cout4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define vcout(v,i) cout<<v[i].fi<<" "<<v[i].se<<endl
typedef priority_queue<ll,vector<ll>,greater<ll> > pqset;
typedef priority_queue<pint,vector<pint>,greater<pint> > pqset_ll;
#define pb push_back
#define fi first
#define se second
#include<ext/pb_ds/assoc_container.hpp>
ll dxk[]={0,0,1,-1,1,1,-1,-1};
ll dyk[]={1,-1,0,0,1,-1,1,-1};
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> os_pair;
#define acc (ios::sync_with_stdio(false),cin.tie(0))
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>0;i--)
#define repeat(i,start,n) for(ll i=start;i<n;i++)
#define print(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" ";}
ll ll_max(ll a,ll b,ll c){return max(a,max(b,c));}
int int_max(int a,int b,int c){return max(a,max(b,c));}
ll ll_min(ll a,ll b,ll c){return min(a,min(b,c));}
int int_min(int a,int b,int c){return min(a,min(b,c));}
ll max(int a,ll b){ return max((ll)a,b);}
ll min(int a,ll b){ return min((ll)a,b);} 
ll min(ll a,int b){ return min(a,(ll)b);}
ll max(ll a,int b){ return max(a,(ll)b);}
ll dx[]={0,0,1,-1};
ll dy[]={1,-1,0,0};
//ifstream cin("b_read_on.txt"); ofstream cout("output3.txt");
//Chronology: Binary Search,Greedy,dp,dfs and similar
//Use (<<) for multiplication
//Use (>>) for division
// In dp, first try top-down,then bottom-up
//ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed;cerr.tie(NULL);cout.precision(10);
// find_by_order -> value at index
// order_of_key -> index of value
void solve(int countu){
	ll n,m;
	cin>>n>>m;
	ll sum=0;
	rep(i,m){
		ll b;
		cin>>b;
		sum+=b;
	}
	if(n-sum<0)
		cout1(-1);
	else
		cout1(n-sum);
}
int main(){
    int t=1;
	//scanf("%d",&t);
	int countu=1;
    while(t--){
    	solve(countu);
    	countu++;
    }
}

Measured memory_bytes: 3608
#import sys
#input = sys.stdin.readline
def main():
    N = int( input())
    A = list( map( int, input().split()))
    B = list( map( int, input().split()))
    C = list( map( int, input().split()))
    now = A[0]
    ans = sum(B)
    for i in range(1, N):
        if now + 1 == A[i]:
            ans += C[now-1]
        now = A[i]
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n, m = map(int,input().split())
    E = [[] for _ in range(n)]
    indeg = [0] * n
    for _ in range(n + m - 1):
        u, v = map(int,input().split())
        u -= 1; v -= 1
        E[u].append(v)
        indeg[v] += 1

    par = [None] * n
    stack = [(v, -1) for v in range(n) if indeg[v] == 0] # 仮定より indeg[v] == 0 の元が1つだけ存在
    while stack:
        v, p = stack.pop()
        par[v] = p
        for nv in E[v]:
            indeg[nv] -= 1
            if indeg[nv] == 0:
                stack.append((nv, v))

    for v in range(n):
        print(par[v] + 1)
resolve()

Measured memory_bytes: 61104
#include <stdio.h>

#define MIN(a, b)	((a)<(b)?(a):(b))

int main(void)
{
	int cicada[51][51];
	int path[51][51];
	char in[100];
	int W, H;
	int x, y;
	
	scanf("%d%d", &H, &W);
	
	for (y = 1; y <= H; y++){
		scanf("%s", in);
		for (x = 1; x <= W; x++){
			cicada[y][x] = in[x - 1] - '0';
		}
	}
	
	for (y = 1; y <= H; y++){
		for (x = 1; x <= W; x++){
			if (x == 1 && y == 1){
	            path[y][x] = cicada[y][x];
				continue;
			}
			if (y == 1){
				path[y][x] = path[y][x - 1] + cicada[y][x];
				continue;
			}
			if (x == 1){
				path[y][x] = path[y - 1][x] + cicada[y][x];
				continue;
			}

			path[y][x] = MIN(path[y][x - 1], path[y - 1][x]) + cicada[y][x];
		}
	}

	printf("%d\n", path[H][W]);
	
	return (0);
}

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

const int mod = 1e9+7;

int c[70];
ll a[300010];

int main() {
    int n;
    scanf("%d", &n);
    for(int i=1; i<=n; i++)
        scanf("%lld", &a[i]);
    ll ans = 0;
    for(int i=1; i<=n; i++) {
        ll tmp = 1;
        for(int j=0; j<60; j++) {
            if(a[i]&1) {
                ans = (ans+tmp*(i-1-c[j])%mod)%mod;
                c[j]++;
            }
            else
                ans = (ans+tmp*c[j]%mod)%mod;
            a[i] >>= 1;
            tmp = tmp*2%mod;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 2560
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")

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

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
string s;
map<pair<string, int>, int> dp;
ll f(int x, string prv)
{
    auto itx = dp.find({prv, x}); 
    if(x == sz(s)) return 0;
    if(itx != dp.end()) return (*itx).s;
    ll t1 = -1e9, t2 = -1e9;
    if(x + 1 <= sz(s)) 
    {
        string a = s.substr(x, 1);
        // cout << a << "\t";
        if(a != prv) t1 = f(x + 1, a);
    }
    if(x + 2 <= sz(s)) 
    {
        string b = s.substr(x, 2);
        if(b != prv) t2 = f(x + 2, b); 
    }
    dp[{prv, x}] = max(t1, t2) + 1;
    // cout <<x << " " << prv << " " << dp[{prv, x}] << "\n";
    return dp[{prv, x}];
}
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> s;
    cout << f(0, "");
    return 0;
}

Measured memory_bytes: 77332
s = input()
K = int(input())
ans = ''
for ind,i in enumerate(s):
    if(i=='a' and ind!=len(s)-1):
        ans+='a'
        continue
    d = 123-ord(i)
    if(ind==len(s)-1):
        K%=26
        if(K>=d):
            ans += chr(97+K-d)
            continue
        ans+=chr(ord(i)+K)
    elif(K>=d):
        K-=d
        ans+='a'
    else:
        ans+=i
print(ans)


Measured memory_bytes: 3444
#include "iostream"
#include "math.h"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
//#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}

int main() {
  int s, w;
  cin >> s >> w;
  print(s <= w ? "unsafe" : "safe");
  return 0;
}

Measured memory_bytes: 3652
/*
          , -- 、
        /;;;;;;', 　　　
        i二二二i
      , ' 　    ヽ ???
     i　ﾉﾉﾉﾉﾉﾍ .', 　　
     〉ﾘi' ﾟ ヮﾟﾉﾚく　 WAyon..........
  ○⊂}〈lﾄ--ｲl〉{つ● 　　
      ,ｒ/ー i-ヽヽ 　　　
     ｀｀i_ﾗi_ﾗ
*/


#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int INF=(int)1e12;
const int mod=(int)1e9+7;
#define all(a) (a).begin(),(a).end()
typedef vector<vector<int>> graph;

#define pb push_back

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int gcd(int a,int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}



signed main () {
    string s;cin >>s;
    vector<int> dp(200020);
    //s...n-1
    int n=s.size();
    rep(i,n){
        dp[i]=s[n-1-i]-'0';
    }

    //累積和
    vector<int> sum(n+1);
    int ten=1;
    rep(i,n){
        sum[i+1]=sum[i]+dp[i]*ten;
        sum[i+1]%=2019;
        ten*=10;
        ten%=2019;
    }
    vector<int> coun(2019);
    int ans=0;
    for(int i=n;i>=0;i--){
        ans+=coun[sum[i]%2019];
        coun[sum[i]%2019]++;
        ans%=mod;
    }
    cout <<ans%mod<<endl;
}

Measured memory_bytes: 6720
#include<cstdio>
#include<algorithm>
#define Mod 998244353
#define LL long long
using namespace std;
int n,k;
int g[2001][2001]; // (j) pairs (last must) in (i) slots
int h[2001][2001]; // (j) pairs             in (i) slots
int C[4001][4001];
int f(int n,int p,int F){
	// (p) pairs, (F) free , in (n) slots
	int Ans=0;
	if(!F) return h[n][p];
	for(int i=0;i<=n;++i){
		Ans=(Ans+(LL)h[i][p]*C[n-i+F-1][F-1])%Mod;
	}
	return Ans;
}
int main(){
	scanf("%d%d",&k,&n);
	
	for(int j=0;j<=2000;++j) g[0][j]=h[0][j]=1;
	for(int j=1;j<=2000;++j) g[1][j]=2, h[1][j]=2*j;
	for(int i=2;i<=2000;++i){
		for(int j=1;j<=2000;++j){
			g[i][j]=(2ll*h[i-1][j-1]+g[i-1][j])%Mod;
			h[i][j]=(g[i][j]+h[i][j-1])%Mod;
		}
	}
	
	C[0][0]=1;
	for(int i=0;i<=4000;++i) C[i][0]=1;
	for(int i=1;i<=4000;++i) for(int j=1;j<=i;++j) C[i][j]=(C[i-1][j-1]+C[i-1][j])%Mod;
	
	for(int i=2;i<=k+k;++i){
		int Ans=f(n,min((i-1)/2,(k+k-i+1)/2),k-2*min((i-1)/2,(k+k-i+1)/2)-(1-i%2));
		if(i%2==0) Ans=(Ans+f(n-1,min((i-1)/2,(k+k-i+1)/2),k-2*min((i-1)/2,(k+k-i+1)/2)-(1-i%2)))%Mod;
		printf("%d\n",Ans);
	}
	return 0;
}

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

void solve(){
	int n,x,t;
	cin>>n>>x>>t;
	int q=n/x;
	if(n%x==0)
	{
		cout<<q*t;
	}
	else{
		cout<<(q+1)*t;
	}
}

int main(){
	solve();
}


Measured memory_bytes: 3600
#pragma comment(linker, "/STACK:102400000,102400000")
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define INF 0X3F3F3F3F
#define N 200010
#define M 2000100
#define LL long long
#define FF(i,a,b) for(int i=a;i<=b;++i)
#define RR(i,a,b) for(int i=a;i>=b;--i)
#define FJ(i,a,b) for(int i=a;i<b;++i)
#define SC(x) scanf("%d",&x)
#define SCC(x,y) scanf("%d%d",&x,&y)
#define SCCC(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define SS(x) scanf("%s",x)
#define PR(x) printf("%d\n",x)
#define CL(a,b) memset(a,b,sizeof(a))
#define FD T&q=fd[rt],&ql=fd[rt<<1],&qr=fd[rt<<1|1]
#define MID int mid=((l+r)>>1)
#define lson rt<<1,l,mid
#define rson rt<<1|1,mid+1,r
#define zero(x) (((x)>0?(x):-(x))<EPS)
#define PB push_back
#define SZ size
#define PII pair<int,int>
#define PLL pair<long long,long long>
#define MP make_pair
#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
using namespace std;
const int MOD=1000000007;
const double PI=acos(-1.0);
const double EPS=1e-8;
inline int II(){int n=0,ch=getchar();bool t=0;if(ch==-1)return 0;
for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')t=1;
for(;ch>='0'&&ch<='9';n=n*10+ch-'0',ch=getchar());if(t)return -n;return n;}
LL a,b;
int main(){
    scanf("%lld%lld",&a,&b);
    if(a*2<=b){
        printf("%lld\n",a+(b-a*2)/4);
    }
    else {
        printf("%lld\n",b/2);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
int a[N];
map<int,int> mp;
int main(){
	int n; cin >> n;
	for (int i=0; i <n;i ++){
		cin >> a[i];
		mp[a[i]]++;
	}
	long long ans = 0;
	for (auto it = mp.rbegin(); it!=mp.rend(); it++){
		a[0] = it->second;
		long long int ai = it->first;
		if (a[0] >= 4){
			if (ans) cout << ans * ai << endl;
			else cout << ai * ai << endl;
			return 0;
		}
		else if (a[0] >= 2){
			if (ans) {
				cout << ans * ai << endl;
				return 0;
			}
			else ans = ai; 
		}
	}
	puts("0");
}

Measured memory_bytes: 5376
# include <bits/stdc++.h>
//# pragma GCC optimize("Ofast")
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define forn(i, n) for (int i = 0; i < int(n); i++)
# define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define fore(i, l, r) for (int i = int(l); i < int(r); i++)
# define fors(i, s) for (int i = 0; s[i]; i++)
# define in freopen("input.txt", "r", stdin)
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
  
using namespace std;
  
const ll INF = 1e18;
const int mod = 1e9 + 7;
const int N = 3e5 + 7;
 
int main()
{      
	speed;
	ll a, b;
	cin >> a >> b;
	int g = __gcd(a, b);
	cout << a / g * b;
	time; 
}

Measured memory_bytes: 256
MOD = 998244353

N,A,B,K = map(int,input().split())

A,B = sorted((A,B))

if (A+B)*N < K:
  print(0)
  exit()

# tabulate combinations



# 拡張ユークリッド互除法
# ax + by = gcd(a,b)の最小整数解を返す
def egcd(a, b):
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)


# mを法とするaの乗法的逆元
def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m


memo = [0]*(N+1)
memo[0] = memo[N] = 1
for k in range(1,N//2+1):
  v = memo[k-1]*(N-k+1)*modinv(k,MOD)
  v %= MOD
  memo[k] = memo[N-k] = v

cnt = 0

for b in range(N+1):
  a = (K-b*B)//A
  if 0 <= a <= N and a*A+b*B == K:
    cnt += memo[a]*memo[b]
    cnt %= MOD

print(cnt)

Measured memory_bytes: 10128
num_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input())

print(num_list[k-1])


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

namespace ABC118A
{
    class MainClass
    {
        static int[] s;
        static int[] n;

        public static void Main(string[] args)
        {

            s = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);

            if (s[1] % s[0] == 0)
            {
                Console.WriteLine(s[0] + s[1]);
            }
            else
            {
                Console.WriteLine(s[1] - s[0]);
            }

            return;

        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdio>
using namespace std;

int main() {

    //freopen(" E:\\workspace\\CLionProjects\\demo\\index.txt","r",stdin);
    int x,y,divisor=1;

    int maxDiver=100000;
    vector<int >diverList;
    diverList.push_back(1);
    diverList.push_back(2);
    for(int i=3;i<maxDiver;i++){
        bool  flag=true;
        for(int j=2;j<sqrt(i);j++){
            if(i%j==0){
                flag=false;
                break;
            }
        }
        if(flag)diverList.push_back(i);
    }
    int length=diverList.size();
    cin>>x>>y;

    for(int i=1;i<length;){
        if(x%diverList[i]==0&&y%diverList[i]==0){
            divisor*=diverList[i];
            x=x/diverList[i];
            y=y/diverList[i];
        } else{
            i++;
        }
    }
    cout<<divisor<<endl;

    return 0;
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define Test int T;cin>>T;while(T--)
#define ls lower_bound
#define up upper_bound
#define bs binary_search
#define S second
#define F first
#define vi vector<int>  
#define pii pair<int,int>
#define vpii vector<pii>
#define vvi vector<vi>
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define m_n(v) *min_element(all(v))
#define m_x(v) *max_element(all(v))
#define ___(a) for(auto &i:a) cin>>i
#define __(a)  for(auto i:a) cout<<i<<" "
#define nl cout<<"\n";
#define momo(k) memset(k,0,sizeof(k))
#define momi(k) memset(k,-1,sizeof(k))
/* 
#include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
*/
int power(int x, int y,int mod){
    int res = 1;
    while (y)
    {
        if (y & 1)
        res = (res*x)%mod;
        y = y>>1;
        x = (x*x)%mod;
    }
    return res;
}
int modInverse(int a, int m){
    int m0 = m;
    int y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        int q = a / m;
        int t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;

    return x;
}
int binomial(int n,int k){
    int res = 1;
    if ( k > n - k )
        k = n - k;

    for (int i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}

// vector<int> prime;
// void sieve(){
//     bool arr[300000]={0};
//     prime.pb(2);
//     for(int i=3;i<300000;i+=2){
//         if(arr[i])continue;
//         for(int j=i*i;j<300000;j+=i) arr[j]=1;
//         prime.pb(i);
//     }
// }
// const int N=1e18+2;
const int mod = 1e9+7;
const int N = 3e3+2;
int n;
double p[N];

void solve(){
    double dp[n+1][n+1];
    memset(dp,0.0,sizeof(dp));
    dp[0][0] = 1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(j == 0) dp[i][j] = (1-p[i])*dp[i-1][j];
            else dp[i][j] = p[i]*dp[i-1][j-1] + (1-p[i])*dp[i-1][j];
        }
    }
    double ans = 0.0;
    for(int i=(n+1)/2;i<=n;i++){
        ans += dp[n][i];
    }
    cout<<ans;
}

int32_t main() {
    IOS;
    cout<<fixed<<setprecision(10);
    cin>>n;
    memset(p,0.0,sizeof(p));
    for(int i=1;i<=n;i++){
        cin>>p[i];
    }
    solve();
    return 0;
}

Measured memory_bytes: 74112
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;

  int MAX = max(max(a,b),c);

  if(MAX==a)
  cout<< b+c <<endl;
  else if(MAX==b)
  cout<< a+c <<endl;
  else
  cout<< b+a <<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,i,c,times;
string s;
int main()
{
	cin>>n;
	cin>>s;
	for(i=0;i<n;i++)
		if(s[i]=='W')
			c++;
	for(i=n-c;i<n;i++)
		if(s[i]!='W')
			times++;
	cout<<times;
	return 0;
}

Measured memory_bytes: 3696
#include <iostream>
#include <vector>
using namespace std;
 
typedef long long ll;
 
int main () {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
 
  vector < ll > mon(n+1), heros(n);
  for (int i = 0; i <= n; i++) cin >> mon[i];
  for (int i = 0; i < n; i++) cin >> heros[i];

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ll m = min(heros[i], mon[i]);
    ans += m;
    heros[i] -= m, mon[i] -= m;

    m = min(heros[i], mon[i+1]);
    ans += m;
    heros[i] -= m, mon[i+1] -= m;
  }

  cout << ans << "\n";
 
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long   ll;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<ll, ll>    pll;
typedef pair<ull, ull>    pull;
typedef pair<ll, ll>  pii;
typedef pair<ld, ld>  pld;
ll n;
ll a[100009];
ll c1(ll x){
    for(ll i = 0; i < n; ++i)
        x -= x%a[i];
    if(x >= 2)
        return 1;
    return 0;
}
ll c2(ll x){
    for(ll i = 0; i < n; ++i)
        x -= x%a[i];
    if(x > 2)
        return 0;
    return 1;
}
ll calc(ll x){
    for(ll i = 0; i < n; ++i)
        x -= x%a[i];
    return x;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    
    cin >> n;
    for(ll i = 0; i < n; ++i)
        cin >> a[i];
    ll l = 0, r = 1e18;
    while(l < r){
        ll m = l + (r-l)/2;
        if(c1(m))
            r = m;
        else
            l = m+1;
    }
    if(calc(l) != 2){
        cout << "-1\n";
        return 0;
    }
    cout << l << " ";
    r = 1e18;
    while(l < r){
        ll m = l + (r-l+1)/2;
        if(c2(m))
            l = m;
        else
            r = m-1;
    }
    cout << r << "\n";
}

Measured memory_bytes: 1024
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

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

  int n; cin >> n;
  vector<tuple<int, int, char, int64, string>> vec;
  for (int i = 0; i < n; ++i) {
    int v, w; char t; int64 d; string na;
    cin >> v >> w >> t >> d >> na;
    vec.emplace_back(make_tuple(v, w, t, d, na));
  }

  sort(all(vec));

  for (int i = 0; i < n; ++i) {
    cout << get<0>(vec[i]) << " " << get<1>(vec[i]) <<  " " << get<2>(vec[i]) <<  " " << get<3>(vec[i]) <<  " " << get<4>(vec[i]);
    cout << '\n';
  }

  return 0;
}


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

const int N = 100;
const int mod = 1e9 + 7;
typedef long long LL;

char s[N], t[N];

int n;
LL dp[N][3][3];

int main(){
	scanf("%d", &n);
	scanf("%s", s);
	scanf("%s", t);
	memset(dp, 0, sizeof(dp));
	if(s[0] == t[0]){
		dp[0][0][0] = dp[0][1][1] = dp[0][2][2] = 1;
	} else {
		dp[0][0][1] = dp[0][1][0] = 1;
		dp[0][0][2] = dp[0][2][0] = 1;
		dp[0][1][2] = dp[0][2][1] = 1;
	}
	for(int i=1; i<n; i++){
		for(int j=0; j<3; j++){
			for(int k=0; k<3; k++){
				if(j == k){
					if(s[i] == t[i]){
						for(int l=0; l<3; l++){
							if(l == j)	continue;
							dp[i][l][l] = (dp[i][l][l] + dp[i-1][j][k]) % mod;
						}
					} else {
						for(int l=0; l<3; l++){
							if(l == j)	continue;
							dp[i][l][3 - j - l] = (dp[i][l][3-j-l] + dp[i-1][j][k]) % mod;
						}
					}
				} else {
					if(s[i] == t[i]){
						int l = 3 - j - k;
						dp[i][l][l] = (dp[i][l][l] + dp[i-1][j][k]) % mod;
					} else {
						for(int l=0; l<3; l++){
							if(s[i]!=s[i-1] && l == j)	continue;
							if(s[i]==s[i-1] && l != j)	continue;
							for(int m=0; m<3; m++){
								if(m==l)	continue;
								if(t[i]!=t[i-1] && m==k)	continue;
								if(t[i]==t[i-1] && m!=k)	continue;
								dp[i][l][m] = (dp[i][l][m] + dp[i-1][j][k])% mod;
							}
						}
					}
				}
			}
		}
	}
	LL ans = 0;
	for(int i=0; i<3; i++){
		for(int j=0; j<3; j++)	ans += dp[n-1][i][j];
	}
	printf("%lld\n", ans % mod);
	return 0;
}

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

using namespace std;

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<ll, ll, ll> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int N, M;
    cin >> N >> M;
    vector< vector<ll> > cake(3, vector<ll>(N));
    rep(i, N) cin >> cake[0][i] >> cake[1][i] >> cake[2][i];

    ll ans = 0;
    for(int bit = 0; bit < 8; bit++){
        vector<ll> xyz(3, 0);
        vector<pair<ll, int> > p(N);
        for(int i = 0; i < 3; i++){
            if(bit>>i & 1){
                rep(j, N){
                    p[j].first -= cake[i][j];
                    p[j].second = j;
                }
            }else{
                rep(j, N){
                    p[j].first += cake[i][j];
                    p[j].second = j;
                }
            }
        }
        sort(p.begin(), p.end(), greater< pair<ll,int> >());
        rep(i, M){
            rep(j, 3) xyz[j] += cake[j][p[i].second];
        }
        ans = max(ans, abs(xyz[0])+abs(xyz[1])+abs(xyz[2]));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/*input
1
*/
#include <bits/stdc++.h>
using namespace std; 
#define int long long int
#define max(x, y) ((x) > (y) ? (x) :(y))
#define pii pair< int , int> 
#define vi vector<int>
#define fore( i ,st) for ( int i= 0 ; i < (int)(st) ; i ++)
#define REP( i , st , en ) for ( int i =st; i < (int)en; i++)
#define REPD( i , en , st ) for ( int i =en; i >= (int)st; i--)
#define SZ(a) (int)a.size()
#define all(v) v.begin() , v.end()
#define pb push_back
#define F first
#define S second
#define bitch_i_m_on_fiyaah_yeahhhh ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// const int mod = 998244353;
const int mod = 1e9+7;
ostream& operator << ( ostream&  o, vector<int> s){for ( int i = 0;  i < (int)s.size() ; i++)o << s[i] << " ";o << "\n";return o;}
void  add( int &a, int b){a = a + b;if ( a< 0 ) a += mod; if ( a> mod ) a-= mod;}
void sub( int &a, int b){a = a - b;if ( a < 0) a += mod;}
int mul( int a , int b){return ((a %mod) * (b %mod) ) %mod;}
int exp( int a , int pow){ return (pow == 0 ? 1 : ( pow & 1  ? mul ( a ,exp( mul(a, a) , pow /2) ) : exp(mul(a ,a) , pow/2)));}
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
// const int inf = 1e18;

const int maxn = 2e5 + 5;
void solve(int test ) 
{			
	vector<int> val;
	int X;cin >> X;
	val.push_back(0);
	for ( int i =1 ; i  <  400 ; i ++){
			val.push_back(i);
			val.push_back(-i);
	}
	set<int> s;
	for ( int x : val){
		s.insert( (int)pow(x ,5));
	}
	for ( int x : val){
		if ( s.count(X + (int)pow(x,5))){
			for ( int yy : val){
				if ( (int)pow(yy, 5) == X + (int)pow(x,5)){
					cout << yy << " " << x;
					return;
				}
			}
		}
	}

}
signed main(){
	bitch_i_m_on_fiyaah_yeahhhh
	int t =1; 
	// cin >> t;
	for ( int i = 0 ; i < t; i++)
	solve(i+1 );
}

Measured memory_bytes: 4168
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

// 10535724
const int B = 5;

int gcd(int x, int y) {
	if (x < y) swap(x, y);
	while(y > 0) {
		x %= y;
		swap(x, y);
	}
	return x;
}
int inside(int y, int x1, int x2, int h) {
	int res = x1 * (h - y) + x2 * y + 2;
	res -= gcd(x2, h - y);
	res -= gcd(x1, y);
	res -= gcd(abs(x1 - x2), h);
	assert(res % 2 == 0);
	return res / 2;
}
ll solve(int y, int w, int h, int k) {
	//eprintf("solve %lld\n", y);
	ll ans = 0;
	for (int x = 1; x < w; x++) {
		if (x * y + h - y > 2 * k + 2 * h) break;
		int mx = (2 * k - x * y) / (h - y);
		mx = max(0, mx);
		mx = min(mx, w - 1);
		ans += mx;
		for (int t = mx + 1; t <= mx + B + 3 * (h < 10) + (h < 1000); t++) {
			if (t <= 0 || t >= w) continue;
			ans += inside(y, t, x, h) <= k;
		}
	}
	return ans;
}
ll solve(int w, int h, int k) {
	ll ans = 0;
	for (ll y = 1; 2 * y <= h; y++) {
		ll cur = solve(y, w, h, k);
		if (2 * y != h) cur *= 2;
		ans += cur;
	}
	return ans;
}

int main()
{
	startTime = clock();
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int w, h, k;
	scanf("%d%d%d", &w, &h, &k);
	ll ans = solve(w, h, k) + solve(h, w, k);
	printf("%lld\n", ans * 2);

	return 0;
}


Measured memory_bytes: 3220
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int b20 = 2_000_000;
		int[] a = new int[b20+1];
		a[0] = 0;

		for(;;){
			String s = scan.next();
			if(s.equals("end"))
				break;
			if(s.equals("insert")){
				int k = scan.nextInt();
				insert(a, k);
			}else if(s.equals("extract"))
				System.out.println(extract(a));
		}

		scan.close();
		System.exit(0);
	}

	private static void insert(int[] a, int k){
		a[0]++;
		a[a[0]] = k;
		up(a, a[0]);
	}
	private static void up(int[] a, int i){
		if(i > 1 && a[i] > a[i/2]){
			int tmp = a[i];
			a[i] = a[i/2];
			a[i/2] = tmp;
			up(a, i/2);
		}
	}

	private static int extract(int[] a){
		int r = a[1];
		a[1] = a[a[0]];
		a[0]--;
		maxHeap(a, 1);
		return r;
	}
	private static void maxHeap(int[] a, int i){
		int l = i * 2;
		int r = i * 2 + 1;
		int max = i;
		if(l <= a[0] && a[l] > a[i])
			max = l;
		if(r <= a[0] && a[r] > a[max])
			max = r;
		if(max != i){
			int tmp = a[i];
			a[i] = a[max];
			a[max] = tmp;
			maxHeap(a, max);
		}
	}
}

Measured memory_bytes: 556432
#include <bits/stdc++.h>
#define M_PI 3.14159265358979323846

using namespace std;

void test_case()
{
    double a;
    cin>>a;
    cout<<std::fixed<<setprecision(2);
    cout<<a*M_PI*2<<"\n";

}

int main()
{
    test_case();

    return 0;
}


Measured memory_bytes: 3764
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;

int main() {
    int n;
    vector<ll> a;
    bool has_zero = false;
    int neg_parity = 0;

    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        ll v;
        scanf("%lld", &v);
        if (v == 0LL) {
            has_zero = true;
            a.push_back(0LL);
        } else if (v < 0LL) {
            neg_parity ^= 1;
            a.push_back(-v);
        } else {
            a.push_back(v);
        }
    }

    ll total = 0LL;
    for (auto aa : a)
        total += aa;

    if (has_zero) {
        printf("%lld\n", total);
    } else if (neg_parity == 1) {
        sort(a.begin(), a.end());
        printf("%lld\n", total - 2 * a[0]);
    } else {
        printf("%lld\n", total);
    }

    return 0;
}


Measured memory_bytes: 1400
#include<cstdio>
#include<cstring>
using namespace std;
char a[105],b[105];
int main(){
	scanf("%s %s",a,b);
	int n=strlen(a);

	for (int k=0;k<n;k++){
		int flag=1;
		for (int i=0;i<n;i++)
		if (a[i]!=b[(i+k)%n]) {
			flag=0;
			break;
		}
		if (flag) {
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 128
n = int(input())
t_point = 0
h_point = 0
for i in range(n):
    card = input().split()
    taro = card[0]
    card.sort()
    card.reverse()
    if card[0] == card[1]:
        t_point += 1
        h_point += 1
    elif card[0] == taro:
        t_point += 3
    else:
        h_point += 3

print(t_point,h_point)

Measured memory_bytes: 7568
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


ll dp1[111][MAX], dp2[111][MAX];
ll num[MAX];

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


  cin >> n >> m;
  ll r = sqrt(n);
  RFOR(i, 1, r + 1) {
    (tmp += num[i + 1]) %= mod;
    (num[i] = n / i - r - tmp + mod) %= mod;
  }
  dp1[0][0]++;
  rep(i, m) {
    ll sum = dp1[i][0];
    FOR(j, 1, r + 1) {
      (sum += dp1[i][j]) %= mod;
      dp2[i + 1][j] = (sum * (num[j])) % mod;
    }
    RFOR(j, 1, r + 1) {
      (sum += dp2[i][j]) %= mod;
      dp1[i + 1][j] = sum;
    }
  }

  FOR(i, 1, r + 1) (ans += dp1[m][i] + dp2[m][i]) %= mod;
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 350720
#include <iostream>
#include <queue>

using namespace std;

int main()
{
	int n, r, c;
	
	while(cin >> n >> r){
		queue<int> qa, qb, qc;
		for(int i = 0; i < n; i++){
			qa.push(i);
		}
		while(r--){
			cin >> c;
			for(int i = 0; i < n/2; i++){
				qb.push(qa.front());
				qa.pop();
			}
			while(!(qa.empty()&&qb.empty())){
				for(int i = 0; i < c && !qa.empty(); i++){
					qc.push(qa.front());
					qa.pop();
				}
				for(int i = 0; i < c && !qb.empty(); i++){
					qc.push(qb.front());
					qb.pop();
				}
			}
			
			while(!qc.empty()){
				qa.push(qc.front());
				qc.pop();
			}
		}
		
		cout << qa.back() << endl;
	}
	
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int i=0;
  if(s.at(0)=='1')
    i++;
  if(s.at(1)=='1')
    i++;
  if(s.at(2)=='1')
    i++;
  cout << i << endl;
}

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

#define mod (int)1e9+7
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define pb push_back
#define make_pair mp
#define pi acos(-1)


int main()
{
    float n,a,b;
    scanf("%f",&n);
    a=floor(n/1.08);
    b=a+1;
    if(floor(a*1.08)==n)
        printf("%.0f",a);
    else if(floor(b*1.08)==n)
        printf("%.0f",b);
    else
        printf(":(");

    return 0;
}


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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int W, H;
    cin >> W >> H;
    vector<int> a(W), b(H);
    ll sum = 0;
    REP(i, 0, W) {
        cin >> a[i];
        sum += a[i];
    }
    REP(i, 0, H) {
        cin >> b[i];
        sum -= b[i];
    }
    if (sum != 0) {
        cout << 0 << endl;
        return 0;
    }
    sort(a.rbegin(), a.rend());
    REP(i, 0, W) {
        sort(b.rbegin(), b.rend());
        REP(j, 0, H) {
            if (b[j] > 0 && a[i] > 0) {
                a[i]--;
                b[j]--;
            }
        }
        if (a[i] > 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    return 0;
}



Measured memory_bytes: 3140
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

// 容量Wのナップサックに、
//   価値 : v[i], 重さ : w[i]
// の品物を個数制限なしに詰めるときの価値の最大値
ll knapsack(ll W, vector<int> v, vector<int> w){
    const int n = v.size();
    vector<vector<ll>> dp(n + 1, vector<ll>(W + 1, 0LL));
    for (int i = 1; i <= n; ++i){
        for (int j = 0; j <= W; ++j){
            ll tmp = dp[i - 1][j];
            if (j - w[i - 1] >= 0 && j - w[i - 1] <= W)
                tmp = max(dp[i][j - w[i - 1]] + v[i - 1], tmp);
            dp[i][j] = tmp;
        }
    }
    return dp[n][W];
}

int main(void){
    ll N; cin >> N;
    int ga, sa, ca; cin >> ga >> sa >> ca;
    int gb, sb, cb; cin >> gb >> sb >> cb;
    N += knapsack(N, {(gb - ga), (sb - sa), (cb - ca)}, {ga, sa, ca});
    N += knapsack(N, {(ga - gb), (sa - sb), (ca - cb)}, {gb, sb, cb});
    cout << N << endl;
    return 0;
}

Measured memory_bytes: 977124
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val m = sc.nextInt()
    val a = Array(m) { 0 }
    val b = Array(m) { 0 }
    val c = Array(m) { mutableListOf<Int>() }
    val mask = Array(m) { 0 }
    for (i in 0 until m) {
        a[i] = sc.nextInt()
        b[i] = sc.nextInt()
        var tmp = 0
        for (j in 0 until b[i]) {
            val x = sc.nextInt() - 1
            c[i].add(x)
            tmp += 1.shl(x)
        }
        mask[i] = tmp
    }
    val size = 1.shl(n)
    var dp = Array(size) { Int.MAX_VALUE }
    dp[0] = 0
    for (i in 0 until m) {
        val newdp = dp.map { it }.toTypedArray()
        for (j in 0 until size) {
            if (dp[j] != Int.MAX_VALUE) {
                newdp[j or mask[i]] = Math.min(newdp[j or mask[i]], dp[j] + a[i])
            }
        }
        dp = newdp
    }
    val v = dp[size - 1]
    println(if (v == Int.MAX_VALUE) -1 else v)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 65184
#include "bits/stdc++.h"
using namespace std;
#ifdef LOCAL
void dprintf(const char *format, ...) {
  va_list arg;
  va_start (arg, format);
  vfprintf(stderr, format, arg);
  va_end(arg);
}
#define debug(arg) cerr << #arg << " = " << arg << endl;
#else
#define dprintf(...)
#define debug(x)
#endif
using ll = long long;

const int MOD = 1e9 + 7;
const int MAX_N = 3000;

int Count[1 + MAX_N][1 + MAX_N];

void addSelf(int &a, int b) {
  a += b;
  if (a >= MOD)
    a -= MOD;
}

void subSelf(int &a, int b) {
  a -= b;
  if (a < 0)
    a += MOD;
}

int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  Count[1][1] = 1;
  for (int n = 2; n <= N; n++) {
    for (int u = 1; u <= n; u++) {
      Count[n][u] = Count[n][u - 1];
      if (s[n - 2] == '<') {
        addSelf(Count[n][u], Count[n - 1][u - 1]);
      } else { // s[n - 2] == '>'
        addSelf(Count[n][u], Count[n - 1][n - 1]);
        subSelf(Count[n][u], Count[n - 1][u - 1]);
      }
    }
  }
  int answer = Count[N][N];
  printf("%d\n", answer);
  return 0;
}


Measured memory_bytes: 34176
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const double PI=acos(-1.0);
int main()
{
	int n;
	int l;
	cin>>n>>l;
	int t[3030];
	for(int i=0; i<n; i++){
		cin>>t[i];
	}
	double ansx=0, ansy=0;
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			ansx+=cos(PI*(t[i]+t[j])/l)*(n-1-j);
			ansx+=cos(PI*(t[i]+t[j])/l)*i;
			ansx-=cos(PI*(t[i]+t[j])/l)*(j-i-1);
			ansy+=sin(PI*(t[i]+t[j])/l)*(n-1-j);
			ansy+=sin(PI*(t[i]+t[j])/l)*i;
			ansy-=sin(PI*(t[i]+t[j])/l)*(j-i-1);
		}
	}
	ll tot=(ll)n*(n-1)*(n-2)/6;
	ansx/=(double)tot;
	ansy/=(double)tot;
	printf("%.10lf %.10lf\n", ansx, ansy);
	return 0;
}

Measured memory_bytes: 640
class MaximumHeap
  attr_accessor :tree

  def initialize(tree, heap_size)
    @tree = tree
    @heap_size = heap_size
  end

  def max_heapify(i)
    l = 2 * i + 1
    r = 2 * i + 2
    larget = nil
    if l < @heap_size && @tree[l] > @tree[i]
      largest = l
    else
      largest = i
    end
    if r < @heap_size && @tree[r] > @tree[largest]
      largest = r
    end

    if largest != i
      @tree[largest], @tree[i] = @tree[i], @tree[largest]
      max_heapify(largest)
    end
  end

  def build_max_heap
    (@heap_size / 2).downto(0) do |i|
      max_heapify(i)
    end
  end

end

h = gets.to_i
tree = gets.split.map { |i| i.to_i }
mh = MaximumHeap.new(tree, h)
mh.build_max_heap
puts ' ' + mh.tree*' '

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll x, k, d;
	cin >> x >> k >> d;
	x = abs(x);
	
	if (x > __int128(k)*d) {
		cout << x-k*d << endl;
	} else {
		ll y = x%d;
		ll i = (x-y)/d;

		if ((k-i)%2) y = abs(y-d);
		cout << y << endl;
	}



}



Measured memory_bytes: 3648