akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
using namespace std;

int bipartiteMaximumMatchings(const vector<vector<bool> >& graph)
{
    int answer = 0;
    int n = graph.size();
    int m = graph[0].size();
    vector<int> selectN(n, -1);
    vector<int> selectM(m, -1);

    for(int i=0; i<n; ++i){
        vector<bool> visitedN(n, false);
        vector<bool> visitedM(m, false);
        visitedN[i] = true;
        vector<int> path(min(n,m)*2, -1);

        path[0] = i;
        int index = 1;
        for(;;){
            while(++path[index] < m && (!graph[path[index-1]][path[index]] || selectN[path[index-1]]==path[index] || visitedM[path[index]]));
            if(path[index] < m){
                if(selectM[path[index]] == -1){
                    for(int j=0; j<index; j+=2){
                        selectN[path[j]] = path[j+1];
                        selectM[path[j+1]] = path[j];
                    }
                    ++ answer;
                    break;
                }
                if(!visitedN[selectM[path[index]]]){
                    path[index+1] = selectM[path[index]];
                    visitedM[path[index]] = true;
                    visitedN[path[index+1]] = true;
                    index += 2;
                }
            }
            else{
                path[index] = -1;
                index -= 2;
                if(index < 0)
                    break;
            }
        }

		if(answer == m)
			break;
    }

    return answer;
}

void solve(const vector<int>& blue, const vector<int>& red)
{
	vector<vector<bool> > graph(blue.size(), vector<bool>(red.size(), false));
	for(unsigned i=0; i<blue.size(); ++i){
		vector<int> num;
		int a = blue[i];
		int b = 2;
		while(a >= b*b){
			if(a % b == 0){
				num.push_back(b);
				while(a % b == 0)
					a /= b;
			}
			++ b;
		}
		if(a > 1)
			num.push_back(a);

		for(unsigned j=0; j<red.size(); ++j){
			for(unsigned k=0; k<num.size(); ++k){
				if(red[j] % num[k] == 0){
					graph[i][j] = true;
					break;
				}
			}
		}
	}

	cout << bipartiteMaximumMatchings(graph) << endl;
}

int main()
{
    for(;;){
        int m, n;
        cin >> m >> n;
        if(m == 0 && n == 0)
            break;

		vector<int> blue(m);
		vector<int> red(n);
		for(int i=0; i<m; ++i)
			cin >> blue[i];
		for(int i=0; i<n; ++i)
			cin >> red[i];

        solve(blue, red);
    }

    return 0;
}

Measured memory_bytes: 968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

const int MAX = 1e6;
const int MOD = 1e9 + 7;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll big = 1e9 + 7;
int main()
{
    ll X, Y;
    cin >> X >> Y;
    ll ans = 0;
    ll a = (-X + 2 * Y) / 3;
    ll b = (2 * X - Y) / 3;
    if (((-X + 2 * Y) % 3 != 0) || ((2 * X - Y) % 3 != 0) || (a < 0) || (b < 0))
    {
        ans = 0;
    }
    else
    {
        COMinit();
        ans = COM(a + b, a);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 23680
#include <stdio.h>
int n;
long long s, x, y;
long long a[200000];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", a + i);
		s += a[i];
	}
	for (int i = 1; i < n; i++) {
		a[i] += a[i - 1];
	}
	x = s - 2 * a[0];
	if (x < 0)x = -x;
	for (int i = 1; i < n - 1; i++) {
		y = s - 2 * a[i];
		if (y < 0)y = -y;
		if (y < x)x = y;
	}
	printf("%lld\n", x);
}

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

typedef long long ll;

int main(){
    ll n, m, ans = 1;
    cin >> n >> m;
    for(ll i=1; i*i<=m; i++){
        if(m%i == 0){
            if(m/i >= n)ans = max(ans, i);
            if(i >= n)ans = max(ans, m/i);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N, x =  map(int, input().split(' '))
A = list(map(int, input().split(' ')))
A.sort()

n, ans = 0, 0
for i in range(N):
    if n + A[i] <= x:
        n += A[i]
        ans += 1
    else:
        break

if n < x and ans == N:
    print(ans - 1)
else:
    print(ans)

Measured memory_bytes: 38512
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

int main() {
    int x,y;
    cin >> x >> y;
    bool exist = false;
    for(int i = 0;i<=x;i++) {
        for(int j = 0;j<=x;j++) {
            if(i+j == x) {
                if((2*i+4*j)==y) {
                    exist = true;
                    break;
                }
            }
        }
    }
    if(exist) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3596
#include <stdio.h>
int main()
{
  int a,b;
  scanf("%d %d",&a,&b);
  int c,d,e;
  c=a+b;
  d=a-b;
  e=a*b;
  if(c>=d&&c>=e)
    printf("%d",c);
    else if(d>=c&&d>=e)
      printf("%d",d);
  else 
    printf("%d",e);
  return 0;
}

Measured memory_bytes: 128
/**
 * Author: AcFunction
 * Date:   2019-08-29 13:52:19
 * Email:  3486942970@qq.com
**/

#include <bits/stdc++.h>

using namespace std;

const int N = 5005; 
const int INF = 1000000000; 

int n, k, flag = 0; 
char s[N];
int ans[N], cac[N];  

void update() {
  int ok = 0; 
  for(int i = 1; i <= n; i++) {
    if(cac[i] < ans[i]) {
      ok = 1; break ; 
    } 
    if(cac[i] > ans[i]) {
      ok = -1; break ; 
    }
  }
  if(ok == 1) 
    for(int i = 1; i <= n; i++) 
      ans[i] = cac[i]; 
}

int main() {
  scanf("%d %d", &n, &k);
  scanf("%s", s + 1); 
  int minc = INF; 
  for(int i = 1; i <= n; i++) {
    minc = min(minc, s[i] - 'a'); 
    ans[i] = 27; 
  }
  int tmp = 1; 
  int cnt = 0; 
  for(int j = 1; j <= k - 1; j++) {
    tmp *= 2; 
    if(tmp >= n) {
      for(int i = 1; i <= n; i++) {
        putchar(char(minc + 'a')); 
      }
      return 0; 
    }
  } 
  for(int i = 1; i <= n; i++) {
    s[i] - 'a' == minc ? cnt++ : cnt = 0; 
    if(cnt == 0) continue ; 
    if(i == n) {
      int tmpl = tmp * cnt * 2; 
      if(tmpl >= n) {
        for(int i = 1; i <= n; i++) {
          putchar(char(minc + 'a')); 
        }
        return 0; 
      }
      for(int j = 1; j <= tmpl; j++) cac[j] = minc;
      int pos = n - cnt;  
      for(int j = tmpl + 1; j <= n; j++) {
        cac[j] = s[pos] - 'a'; 
        pos--; 
      }    
      update();
    }
    else {
      int tmpl = tmp * cnt; 
      if(tmpl >= n) {
        for(int j = 1; j <= n; j++) {
          putchar(char(minc + 'a')); 
        }
        return 0; 
      }
      for(int j = 1; j <= tmpl; j++) cac[j] = minc; 
      int pos = i + 1; 
      for(int j = tmpl + 1; j <= n; j++) {
        if(pos <= n) cac[j] = s[pos] - 'a'; 
        else cac[j] = s[2 * n + 1 - pos] - 'a'; 
        pos++; 
      }
      update(); 
    }
  }
  for(int i = 1; i <= n; i++) putchar(char(ans[i] + 'a')); 
  return 0; 
}

Measured memory_bytes: 384
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>

using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=a-1;i>=n;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=5e5+10,oo=0x3f3f3f3f,MOD=1e9+7;
const double PI = acos(-1);

void solve(){
    ll h,w;
    cin>>h>>w;
    if(h==1|w==1)
        cout<<1<<endl;
    else
        cout<<(h*w+1)/2<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();

}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1 LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

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

    if(S[S.size()-1] == 's'){
        S += "es";
    }
    else S += 's';

    cout << S << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=1; i<=(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N,T;
    cin>>N>>T;
    vi t(N);
    rep(i,N) cin>>t[i];
    ll ans=0;
    rep(i,N-1) ans+=min(t[i+1]-t[i],T);
    ans+=T;
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] ary = new int[n];
		
		for(int i=0; i<n; i++){
			ary[i] = in.nextInt();
		}
		for(int i=n-1; i>=0; i--){
			System.out.print(ary[i]);
			if(i == 0){
				break;
			}else{
				System.out.print(" ");
			}
		}
		System.out.println();
		in.close();
	}
}

Measured memory_bytes: 19620
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };

ll gcd(ll x, ll y)
{
	ll r;

	if (x == 0 || y == 0)  // 引数チェック
	{
		fprintf(stderr, "引数エラーです。\n");
		return 0;
	}

	// ユーグリッドの互除法
	while ((r = x % y) != 0)  // yで割り切れるまでループ
	{
		x = y;
		y = r;
	}
	return y;
}

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

	ll n, k, ans = 0;
	cin >> n >> k;
	vll v(n);
	ll ma = 0;
	rep(i, n) {
		cin >> v[i];
		ma = max(ma, v[i]);
		if (ans == 0) ans = v[i];
		else ans = gcd(ans, v[i]);
	}
	if(ma < k) cout << "IMPOSSIBLE\n";
	//cout << ans << endl;
	else if (k % ans == 0) cout << "POSSIBLE\n";
	else cout << "IMPOSSIBLE\n";
	return 0;
}


Measured memory_bytes: 1024
unittest
{
	assert( [ "0 0 1 2" ].parse.expand.solve == "UURDDLLUUURRDRDDDLLU" );
//	assert( [ "-2 -2 1 1" ].parse.expand.solve == "UURRURRDDDLLDLLULUUURRURRDDDLLDL" );		// 答えが複数あるのでこっちには一致しないけど大丈夫
	assert( [ "-2 -2 1 1" ].parse.expand.solve == "UUURRRDDDLLLLUUUURRRRDRDDDDLLLLU" );
}



import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto sxytxy = input.front.split.to!( long[] );
	return tuple( sxytxy[ 0 ], sxytxy[ 1 ], sxytxy[ 2 ], sxytxy[ 3 ] );
}

auto solve( long sx, long sy, long tx, long ty )
{
	auto ans = "";
	
	// 距離を計算
	long dx = tx - sx;
	long dy = ty - sy;
	
	// 1週目の経路
	ans ~= "U".repeat( dy ).join;
	ans ~= "R".repeat( dx ).join;
	ans ~= "D".repeat( dy ).join;
	ans ~= "L".repeat( dx ).join;
	
	// 2週目の経路（1週目と重複しないように1マス大回りする）
	ans ~= "L";
	ans ~= "U".repeat( dy + 1 ).join;
	ans ~= "R".repeat( dx + 1 ).join;
	ans ~= "DR";
	ans ~= "D".repeat( dy + 1 ).join;
	ans ~= "L".repeat( dx + 1 ).join;
	ans ~= "U";
	
	return ans;
}


Measured memory_bytes: 380
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

ll gcd(ll a, ll b){ return b==0?a:gcd(b,a%b);}

ll add(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a+b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll mul(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a*b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

const int N = 200000+5;

int n;
int a[N];
ll prefix[N];
ll suffix[N];
int prefmin[N];
int suffmin[N];
ll memo[N][3][3];
bool vis[N][3][3];

ll DP(int pos, int used, int last){
	if(pos >= n+1) return used? 0LL : -1LL<<50;
	if(vis[pos][used][last]) return memo[pos][used][last];
	ll ans = LLONG_MIN;
	if(used){
		if(last) ans = a[pos+1] + DP(pos+2, used, 1);
		else ans = max(a[pos] + DP(pos+2, used, 0), a[pos+1] + DP(pos+2, used, 1));
	}
	else{
		if(last){
			ans = max(ans, a[pos+1] + DP(pos+2, used, 1));
			ans = max(ans, DP(pos + 1, 1, 0));
		}
		else{
			ans = max(a[pos] + DP(pos+2, used, 0), a[pos+1] + DP(pos+2, used, 1));
			ans = max(ans, DP(pos + 1, 1, 0));
		}
	}
	vis[pos][used][last] = true;
	return memo[pos][used][last] = ans;
}

int main(){
	ri(n);
	for(int i=1; i<=n; i++){
		ri(a[i]);
	}
	ll ans = LLONG_MIN;
	if(n & 1){
		ans = DP(1,0,0);
	}
	else{
		ans = max(a[1] + DP(3, 1, 0), a[2] + DP(3, 1, 1));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 28072
import java.util.*;

class Main {
  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
    final int n = sc.nextInt();
    final int m = n % 10;
    switch (m) {
      case 2:
      case 4:
      case 5:
      case 7:
      case 9:
	    System.out.println("hon");
        break;
      case 0:
      case 1:
      case 6:
      case 8:
	    System.out.println("pon");
		break;
      case 3:
      default:
	    System.out.println("bon");
        break;
    }
  }
}


Measured memory_bytes: 35584
package main
import("fmt"
       "strings"
     )

func main(){
  var a string
  fmt.Scan(&a)
  A := strings.Split(a,"")
  if A[0] == A[1] && A[1] == A[2]{
    fmt.Println("No")
  } else{
    fmt.Println("Yes")
  }
}

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

int main()
{

    int X, A, B;
    scanf("%d", &X);
    char dammy;
    scanf("%c", &dammy);
    scanf("%d", &A);
    scanf("%c", &dammy);
    scanf("%d", &B);

    int nokori;
    nokori = (X - A) % B;
    printf("%d", nokori);
    

    return 0;
}


Measured memory_bytes: 128
N,K = map(int,input().split())
MOD = 10**9+7

MAXN = N+5
fac = [1,1] + [0]*MAXN
finv = [1,1] + [0]*MAXN
inv = [0,1] + [0]*MAXN
for i in range(2,MAXN+2):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

def comb(n,r):
    if n < r: return 0
    if n < 0 or r < 0: return 0
    return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD

def nhr(n,r):
    return comb(n+r-1, r)

ans = 0
K = min(K,N-1)
for i in range(K+1):
    ans += comb(N,i) * nhr(N-i,i)
    ans %= MOD
print(ans)

Measured memory_bytes: 28340
n,a,b=input().split(" ")
n=int(n)
a=int(a)
b=int(b)
lst=input()
cnt=0
cnt2=0
for i in range(n):
  if lst[i]=="a":
    if cnt<a+b:
      print("Yes")
      cnt+=1
    else:
      print("No")
  elif lst[i]=="b":
    if cnt<a+b and cnt2<b:
      print("Yes")
      cnt+=1
      cnt2+=1
    else:
      print("No")
  else:
    print("No")

Measured memory_bytes: 9236
import math
a,b,h,m = map(int, input().split())
A = (a*math.sin(math.radians(h*30+m/2)),a*math.cos(math.radians(h*30+m/2)))
B = (b*math.sin(math.radians(m*6)),b*math.cos(math.radians(m*6)))
print(((A[0]-B[0])**2+(A[1]-B[1])**2)**0.5)

Measured memory_bytes: 9580
import java.util.Scanner;
 
class Main {
 
	public static void main(String[] args) {
		
		Scanner stdIn = new Scanner(System.in);
 
		int A = stdIn.nextInt();
		int B = stdIn.nextInt();

		if(A % B == 0 ){
			System.out.print( A / B);
		}else{
			System.out.print( A / B + 1);
		}

	}
    
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int K, N, x;
cin >> K >> N ;
vector<int> A(N);
for (int i = 0; i < N; i++) {
  cin >> A.at(i);
}
x = A.at(0) + K - A.at(N-1);
for (int i = 1; i < N; i++)
{
    if(x <= A.at(i) - A.at(i - 1)){
        x = A.at(i) - A.at(i - 1);
    };
};
cout << K - x << endl;
}

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

int main(void) {
  int x, n;
  cin >> x >> n;
  int p[n];
  for(int i = 0; i < n; i++) {
    cin >> p[i];
  }
  for(int i = 0; i <= n; i++) {
    bool flag_1 = true;
    bool flag_2 = true;
    for(int j = 0; j < n; j++) {
      if(p[j] == x-i) flag_1 = false;
      if(p[j] == x+i) flag_2 = false;
    }
    if(flag_1) {
      cout << x-i << endl;
      break;
    } else if(flag_2) {
      cout << x+i << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

int main() {
  int d, t, s;
  scanf("%d %d %d", &d, &t, &s);
  if (d <= t * s) { 
      printf("Yes\n");
  } else {
      printf("No\n");
  }
  return 0;
}

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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__);
#else
#define dbg(...) 
#endif

int main() {
	ios_base::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;

	bool ok=true;
	for(int i=0; i<s.size(); i++){
		if(s[i]!=t[i]) ok=false;
	}
	cout << (ok?"Yes":"No") << endl;
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	
	int a,b;
	
	cin>>a>>b;
	
	if (a<=b) cout<<"unsafe";
	else cout<<"safe";
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod =1e9+7;
ll power(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1)res=res*a%mod;
        b>>=1;
        a=a*a%mod;
    }
    return res;
}
ll inv(ll x){
    return power(x,mod-2);
}
ll gcd(ll a,ll b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int main(){
    int t[111]={0};
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            t[j*i]=1;
        }
    }
    int n;
    cin>>n;
    if(t[n]){
        cout<<"Yes";
    }
    else cout<<"No";

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int px,py; 
int w,h,f[100][100];

bool cheak(){
  if(f[px][py] == 0){
    cout << "LOOP" << endl;
    return true;
  }
  return false;
}

int main(){

  char ma[100][100];
  while(  cin >> h >> w,w + h ){
    for(int i = 0 ; i < h ; i++){
      for(int j = 0 ; j < w ; j++){
	cin >> ma[j][i];
	f[j][i] = 1;
      }
    }

    px = 0,py = 0; 
    while(1){
      if(ma[px][py] == '>' ){
	px++;
	if(cheak())break;
      } else if(ma[px][py] == 'v' ){
	py++;
	if(cheak())break;
      }else if(ma[px][py] == '<' ){
	px--;
	if(cheak())break;
      }else if(ma[px][py] == '^' ){
	py--;
	if(cheak())break;
      } else {
	cout << px << " " << py << endl;
	break;
      }
      f[px][py] = 0;
    }
  }
}

Measured memory_bytes: 1212
#include <stdio.h>
int main(void){
  
  int n,m,i,j;
  int q[1000][100];
  int a[100];
 
  while(1){
    int rank=1;

    scanf("%d %d",&n,&m);
    
    if(n==0&&m==0)break;
    
    for(i=0;i<n;i++)
      for(j=0;j<m;j++)
	scanf("%d",&q[i][j]);
   
    for(i=0;i<m;i++){
      a[i]=0;
      for(j=0;j<n;j++)
	a[i]+=q[j][i];
    }
   
    int k=m-1;

    for(i=n;i>=0;i--){
      for(j=0;j<m;j++){
	if(a[j]==i){
	  if(k!=0){
	    printf("%d ",j+1);
	    k--;
	  }
	  else printf("%d\n",j+1);
	}
      }
    }
    
  }
  return 0;
}

Measured memory_bytes: 1416
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N; cin >> N;
    int A[N+1], B[N];
    for(int i = 0; i < N+1; i++) cin >> A[i];
    for(int i = 0; i < N; i++) cin >> B[i];
    long sum = 0;
    for(int i = 0; i < N; i++){        
        if(B[i] < A[i]){ 
            sum += B[i];
            A[i] = A[i] - B[i];
            B[i] = 0;
        }else{
            sum += A[i];
            B[i] = B[i] - A[i];
            A[i] = 0;
        }
        if(B[i] < A[i+1]){
            sum += B[i];
            A[i+1] = A[i+1] - B[i];
            B[i] = 0;
        }else{
            sum += A[i+1];
            B[i] = B[i] - A[i+1];
            A[i+1] = 0;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 1024
a = input()
count_A = 0
count_B = 0
for i in range(0,3):
    if a[i] == "A":
        count_A += 1
    if a[i] == "B":
        count_B += 1

if count_A == 3 or count_B == 3:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 2940
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int N,NN;
	ll res=-1e15,fr=0,br=0;
	priority_queue<ll,vector<ll>,greater<ll> >F;
	priority_queue<ll,vector<ll> >BB;
	vector<ll>C;
	stack<ll>BC;
	queue<ll>FC;
	cin>>N;
	NN=3*N;
	for(int i=0;i<NN;i++)
	{
		ll x;
		cin>>x;
		C.push_back(x);
	}

	//back
	for(int i=NN-1;i>=N-1;i--)
	{
		if(BB.size()>N)
		{
			br-=BB.top();
			BB.pop();
			BC.push(br);
		}
		else if(BB.size()==N)
		{
			BC.push(br);
		}
		BB.push(C[i]);
		br+=C[i];
	}

	//front
	for(int i=0;i<=N*2;i++)
	{
		if(F.size()>N)
		{
			fr-=F.top();
			F.pop();
			FC.push(fr);
		}
		else if(F.size()==N)
		{
			FC.push(fr);
		}
		fr+=C[i];
		F.push(C[i]);
	}



	for(;!FC.empty();)
	{
		res=max(res,FC.front()-BC.top());
		FC.pop();
		BC.pop();
	}

	cout<<res<<endl;
}

Measured memory_bytes: 7664
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,e;
  string s,ss,sss;
  cin>>a;
  bool fl=false;
  for(int i=1;i<=9;i++)
    if(a%i==0 && 1<=a/i && a/i<=9 && 1 <= i && i<=9)
      fl=true;
  if(fl)
  cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

int main() {
    int A;
    int B;
    vector<vector<char>> g;

    g.resize(100);
    for(int i = 0;i < 100;i++) {
        g[i].resize(100);
    }
    for(int i = 0;i < 100;i++) {
        for(int j = 0;j < 50;j++) {
            g[i][j] = '.';
        }
    }
    for(int i = 0;i < 100;i++) {
        for(int j = 50;j < 100;j++) {
            g[i][j] = '#';
        }
    }

    scanf("%d%d", &A, &B);

    for(int a = 0;a < A - 1;a++) {
        g[(a%50)*2][(a/50)*2 + 51] = '.';
    }
    for(int b = 0;b < B - 1;b++) {
        g[(b%50)*2][(b/50)*2] = '#';
    }
    printf("%d %d\n", 100, 100);
    for(int i = 0;i < 100;i++) {
        for(int j = 0;j < 100;j++) {
            printf("%c", g[i][j]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;int n,m,l,x,i,a[1<<18];main(){cin>>n>>m;n*=2;while(cin>>a[i])i++;sort(a,a+n);for(i--;i>l;i--){while(a[i]+a[l]<m&&l<i-1)l++;if(a[i]+a[l]>=m){a[i]-=m;l++;}}sort(a,a+n);for(i=0;i<n;i++)x=max(x,a[i]+a[n-i-1]);cout<<x;}

Measured memory_bytes: 4340
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#ifndef bhartiya
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif


typedef long long ll;
typedef pair<ll, ll> pll;
typedef gp_hash_table<long long, long long> umap;
typedef tree<int, null_type, less<int>, rb_tree_tag,
		tree_order_statistics_node_update> oset;
// not that imp
typedef pair<pll, ll> plll;
typedef vector<ll> vl;
typedef vector<pll> vll;

#define inf 200000000000000ll
#define mod 1000000007ll
#define eps 1e-7
#define PI 3.1415926535897932385
// #define PI acos(-1)

#define pb push_back
#define bitc  __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) memset(ar, val, sizeof(ar))

#ifdef bhartiya
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
inline bool equals(double a, double b) {return fabs(a - b) < 1e-9;}
ll gcd(ll a, ll b){ return b==0 ? a : gcd(b, a%b); }

const ll maxn = 500005;
ll n;
ll a[maxn];

int main() 
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0), cout.precision(10); //cout<<fixed;
    cin.exceptions(cin.failbit);
    #ifdef bhartiya
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin>>t;
    while(t--){
        ll n,x;
        cin>>n>>x;
        rep(i,n){
            cin>>a[i];
        }
        ll curr = 0;
        ll cnt = 1;
        rep(i,n){
            curr += a[i];
            if(curr <= x) cnt++;
            else break;
        }
        cout<<cnt;
    }
    end_routine();
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int x,y,i,p=0;
  scanf("%d %d",&x,&y);
  for(i=0;i<=x;i++){
    if(i*2+(x-i)*4==y){
      p=1;
      break;
    }
  }
  if(p==0){printf("No\n");}
  else{printf("Yes\n");}
}

Measured memory_bytes: 1664
//https://atcoder.jp/contests/abc154/tasks/abc154_a

#include<bits/stdc++.h>
using namespace std;

int main()
{
    string s,t,u;
    int a,b;

    cin>>s>>t>>a>>b>>u;
    if(s==u) a--;
    else b--;
    cout<<a<<" "<<b<<"\n";


    return 0;
}



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

#define int long long
int n, m;
int a[101010], b[101010], c[101010];
int cnt[101010];

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

  int p, to;
  cin >> p;
  p--;
  for (int i = 1; i < m; i++){
    cin >> to;
    to--;
    cnt[min(p, to)]++;
    cnt[max(p, to)]--;

    p = to;
  }

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

  for (int i = 0; i < n; i++){
    cnt[i] += cnt[i - 1];
  }

  int ans = 0;
  for (int i = 0; i < n; i++){
    ans += min(cnt[i] * a[i], cnt[i] * b[i] + c[i]);
  }

  cout << ans << endl;
}

Measured memory_bytes: 6224
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }





int N;
vector<long long> a;

void dec(map<long long, long long> &ma, long long a) {
    ma[a]--;
    if (ma[a] == 0) {
        ma.erase(a);
    }
}

int main() {
    while (cin >> N) {
        a.resize(N);
        for (int i = 0; i < N; ++i) cin >> a[i];
        map<long long, long long> ma;
        for (int i = 0; i < N; ++i) ma[-a[i]]++;

        long long res = 0;
        for (int i = 0; i < N && !ma.empty(); ++i) {
            long long val = -ma.begin()->first;
            
            dec(ma, -val);
            long long po = 1;
            while (po <= val) po *= 2;
            long long rem = po - val;
            if (ma.count(-rem)) {
                ++res;
                dec(ma, -rem);
            }
        }

        cout << res << endl;
    }
}


Measured memory_bytes: 14336
package main
import "fmt"
var mod int64
func main() {
  var l,a,b,m int64
  fmt.Scan(&l,&a,&b,&m)
  mod = m
  t := int64(1)
  y := Identity(3)
  for d:=1;d<19;d++ {
    t *= 10
    inf,sup := t/10,t-1
    if inf > a+b*(l-1) { break }
    if sup < a { continue }
    s0,sl := (inf-a+b-1)/b,(sup-a)/b
    if s0 > l-1 { s0 = l-1 }
    if inf <= a { s0 = 0 }
    if sup >= a+b*(l-1) { sl = l-1 }
    c := sl-s0+1
    z := NewMatrix(3)
    z[0].v[0] = t%mod
    z[1].v[0] = 1
    z[1].v[1] = 1
    z[2].v[1] = b%mod
    z[2].v[2] = 1
    y = y.MatMul(z.Pow(c))
  }
  x := Vector{[]int64{0,a%mod,1}}
  fmt.Println(x.DotProduct(y.ColVec(0)))
}
type Vector struct { v []int64 }
func(x Vector) DotProduct(y Vector) int64 {
  if len(x.v) != len(y.v) || len(x.v) == 0 { return 0 }
  d := (x.v[0]*y.v[0])%mod
  for i:=1;i<len(x.v);i++ { d = (d+(x.v[i]*y.v[i])%mod)%mod }
  return d
}
type Matrix []Vector
func NewMatrix(n int) Matrix {
  m := Matrix{}
  for i:=0;i<n;i++ { m = append(m,Vector{make([]int64,n)}) }
  return m
}
func Identity(n int) Matrix {
  e := NewMatrix(n)
  for i:=0;i<n;i++ { e[i].v[i] = 1 }
  return e
}
func(a Matrix) ColVec(j int) Vector {
  if len(a) == 0 || j >= len(a[0].v) { return Vector{nil} }
  v := make([]int64,len(a))
  for i:=0;i<len(a);i++ { v[i] = a[i].v[j] }
  return Vector{v}
}
func(a Matrix) Transpose() Matrix {
  if len(a) == 0 || len(a[0].v) == 0 { return Matrix{Vector{nil}} }
  m := Matrix{}
  for j:=0;j<len(a[0].v);j++ { m = append(m,a.ColVec(j)) }
  return m
}
func(a Matrix) VecMul(x Vector) Vector {
  if len(a) == 0 || len(a[0].v) != len(x.v) ||
  len(x.v) == 0 { return Vector{nil} }
  v := make([]int64,len(a))
  for i:=0;i<len(a);i++ { v[i] = a[i].DotProduct(x) }
  return Vector{v}
}
func(a Matrix) MatMul(b Matrix) Matrix {
  if len(a) == 0 || len(a[0].v) == 0 || len(b) == 0 || len(b[0].v) == 0 ||
  len(a[0].v) != len(b) { return Matrix{Vector{nil}} }
  m := Matrix{}
  for j:=0;j<len(b[0].v);j++ { m = append(m,a.VecMul(b.ColVec(j))) }
  return m.Transpose()
}
func(a Matrix) Pow(n int64) Matrix {
  if len(a) == 0 || len(a[0].v) == 0 ||
  len(a) != len(a[0].v) { return Matrix{Vector{nil}} }
  if n == 0 { return Identity(len(a)) }
  if n%2 == 0 { c := a.Pow(n/2);return c.MatMul(c) }
  return a.MatMul(a.Pow(n-1))
}

Measured memory_bytes: 1024
n = int(input())
d, x = map(int, input().split(' '))
a = [int(input()) for i in range(n)]
count = int()

for i in range(n):
# print('#',i+1, '人目')
  for dy in range(100):
    day =  dy * a[i] + 1
    if day > d:
      break
    else:
#     print('#',day, '日目')
      count+=1
# print('#count', count)

print(count + x)

Measured memory_bytes: 3060
<?php
 
function input($func = null) {
    if ($func === null) {
        return trim(fgets(STDIN));
    } else {
        return $func(trim(fgets(STDIN)));
    }
}
function input_array($func = null) {
    if ($func === null) {
        return explode(' ', input());
    } else {
        return array_map(function($v) use ($func) {
            return $func($v);
        }, explode(' ', input()));
    }
}

$s = str_split(input('strval'));
$count = count($s);

$sum = 0;

$white_count = 0;
for ($position = 0; $position < $count; $position++) {
    if ($s[$position] === 'W') {
        $sum += $position - $white_count;
        $white_count++;
    }
}

echo $sum . "\n";

Measured memory_bytes: 19192
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100100;
const int MOD = 1000000007;
const int inf = 1001001001;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

int gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



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

    int N,K;cin >> N >> K;
    string S;cin >> S;
    int different = 0;
    for(int i = 0;i<N-1;i++){
        if(S.at(i) != S.at(i+1)) different++;
    }
    int happy = N-1;
    //一回の操作で2人幸せにできる
    cout << happy-max(0,different-2*K) << endl;

}


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

int main()
{
    int N,i,min,max;
    cin>> N;
    int number[N];
    cin>>number[0];
    min=number[0];
    max=number[0];
    for(i=1;i<N;i++){
        cin >>number[i];
        if(number[i]>max) 
            max=number[i];
        if(number[i]<min) 
            min=number[i];
    }
    cout<<abs(max-min)<< endl;
	return 0;
}


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

using namespace std;
typedef long long ll;

const int MAXN = 100005;

int n, T;
int a[MAXN];
int mn, mx, cnt;

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

void solve()
{
	mn = a[1];
	for(int i = 2; i <= n; i++)
	{
		if(a[i] > mn)
		{
			int tmp = a[i] - mn;
			if(tmp > mx)
			{
				mx = tmp;
				cnt = 1;
			}
			else if(tmp == mx)
			{
				cnt++;
			}
		}
		mn = min(mn, a[i]);
	}
	cout << cnt << endl;
}

void output()
{
}

int main()
{
	input();
	solve();
	output();

	return 0;
}


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

using namespace std;

int main()
{
  string left = "qwertasdfgzxcvb";
  string right = "yuiophjklnm";
  string s;
  while(cin >> s, s != "#"){
    int cnt = 0;
    for(int i = 0; i < s.size()-1; i++){
      if(left.find(s[i]) != string::npos && right.find(s[i+1]) != string::npos ||
	 left.find(s[i+1]) != string::npos && right.find(s[i]) != string::npos) cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}

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

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for (size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int INF = 1e9 + 1;

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

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

    vector<int> dp(n, INF);
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j : {i + 1, i + 2}) {
            if (j < n) {
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        }
    }

    cout << dp[n - 1] << "\n";

    return 0;
}



Measured memory_bytes: 1024
N = int(input())
A = list(input().split())

l = []
r = []
flag = False
if N % 2 == 0:
    for i in range(N-1, 0, -2):
        if flag:
            print(" ", end="")
        print(A[i], end="")
        flag = True
    for i in range(0, N, 2):
        if flag:
            print(" ", end="")
        print(A[i], end="")
else:
    for i in range(N-1, -1, -2):
        if flag:
            print(" ", end="")
        print(A[i], end="")
        flag = True
    for i in range(1, N, 2):
        if flag:
            print(" ", end="")
        print(A[i], end="")


print()


Measured memory_bytes: 21664