akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end(), greater<ll>());
    ll b[N + 1]{};
    for (int i = 0; i < N; i++) {
        b[i + 1] = b[i] + A[i];
    }
    ll A_MAX = 2 * 100000 + 1;
    ll d[A_MAX]{}; // d[i]: パワーi以上を持つ人の数
    for (int i = 0; i < N; i++) {
        d[A[i]]++;
    }
    for (int i = A_MAX - 1; i >= 1; i--) {
        d[i - 1] += d[i];
    }
    ll l = -1;
    ll r = A_MAX + 1;
    while (r - l > 1) {
        ll m = (l + r) / 2;
        ll s = 0;
        for (int i = 0; i < N; i++) {
            s += d[max(0ll, m - A[i])];
        }
        if (s >= M) {
            l = m;
        } else {
            r = m;
        }
        //cout << l << " " << r << " " << m << " " <<s << "\n";
    }
    //cout << l << " " << r << "\n";
    ll ans = 0;
    ll t = M;
    ll s = 0;
    for (int i = 0; i < N; i++) {
        int v = max(0, (int)(r - A[i]));
        
        t = max(0ll, min(d[v], M - s));
        //cout << i << "  " << v << "  " << t << "\n";
        ans += b[t] + t * A[i];
        s += t;
    }
    ans += l * (M - s);
    //cout << d[0] << "\n";
    cout << ans << "\n";
    
    return 0;
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

vector<ll> divisor(ll n) {
	vector<ll> res;
	for (int i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			res.push_back(i);
			if (i != n / i) {
				res.push_back(n / i);
			}
		}
	}
	return res;
}

signed main() {
	ll n;

	cin >> n;

	ll ans = 0;

	for (int i = 1; i <= n; i += 2) {
		if (divisor(i).size() == 8) {
			ans++;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define AfterDecimal(n) cout << fixed << setprecision(n);
#define pb push_back
#define pp(a, b) pair <a, b>
#define ll long long
#define ld long double
#define all(a) a.begin(), a.end()
#define pi pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
#define itr iterator
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
#define int ll
#define endl "\n"
 
using namespace __gnu_pbds;
using namespace std;
 
template <class T> T printr(T p) { cout << p << '\n'; return 0; }
template <class T> T printe(T p) { cout << p << '\n'; exit(0); }
template <class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template <class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
 
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << "# "<< name << " = " << arg1 << '\n';
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1 && arg1, Args &&... args){
        const char* comma = strchr(names + 1 ,',');
        cout << "# ";
        cout.write(names, comma - names)<< " = " << arg1 << " | ";
        __f(comma + 1, args...);
}
#else
#define debug(...) 36
#endif
 
ll power(ll x, ll y, ll p){ 
   ll res = 1;
   x = x % p;  
   while (y > 0) {
      if (y & 1) 
         res = (res * x) % p; 
      y = y >> 1;
      x = (x * x) % p; 
   }
   return res;
}
 
const ll INF = (ll)(8e18);
const ll MOD = 1e9 + 7;
 
const int M = 1e12;

int32_t main()
{
    IOS;
    #ifndef ONLINe5E_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif

    int n, k;
    cin >> n;

    int dp[n][3];

    fori(n) {
        int a, b, c;
        cin >> a >> b >> c;

        if(i==0) {
            dp[i][0] = a, dp[i][1] = b, dp[i][2] = c;
            continue;
        }

        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a;
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b;
        dp[i][2] = max(dp[i-1][1], dp[i-1][0]) + c;
    }

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

    #ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}

//g++ -DLOCAL -DDEBUG -std=c++17 -Wshadow -Wall -o "c" "icpc.cpp" -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g

Measured memory_bytes: 2560
#include <bits/stdc++.h>
//#define DEBUG
typedef long long ll;
using namespace std;
template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}

void solve(){
    int n;
    cin >> n;
    vector<int> A;
    A.reserve(n);
    for( int i = 0; i < n ; i++){
        int a;
        cin >> a;
        A.push_back(a);
    }
    vector<int> up_peak;
    vector<int> down_peak;
    int status = 0;
    for(int i = 1 ; i < n ; i++){
        if( status == 0 ){
            if ( A[i] < A[i-1]){
                up_peak.push_back(i-1);
                status = -1; 
            }else if ( A[i] > A[i-1]){
                down_peak.push_back(i-1);
                status = 1;
            } 
        }else if (status == 1){
            if( A[i] < A[i-1]){
                status = -1;
                up_peak.push_back(i - 1);
            }
        }else{
            if( A[i] > A[i-1]){
                status = 1;
                down_peak.push_back(i - 1);
            }
        }
    }
    if( down_peak.size() == 0){
        cout << "1000\n";
        return;
    }
    if(up_peak.size() == 0){
        int money = 1000;
        int stock = money / A[down_peak[0]];
        money = money - stock * A[down_peak[0]];
        money = money + stock * A[A.size() -1];
        cout << money << "\n";
        return;
    }
    //else we have trade

    ll money = 1000; 
    ll stock = 0;
    int i = 0, j = 0;
    if( up_peak[0] < down_peak[0]){
        j = 1;
    }

    for( i = 0; i < down_peak.size() && j < up_peak.size(); i++){
        //buy
        stock = money / A[down_peak[i]];
        money = money - stock * A[down_peak[i]];

        //sell
        money = money + stock * A[up_peak[j]];
        j++;
    }
    if( i < down_peak.size()){
        //one more time
        stock = money / A[down_peak[i]];
        money = money - stock * A[down_peak[i]];
        
        //sell 
        money = money + stock * A[A.size() -1];
    }
    cout << money << "\n";

}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}


Measured memory_bytes: 3640
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define Yes(condition) if(condition){ cout << "Yes" << '\n'; }else{ cout << "No" << '\n'; }
#define YES(condition) if(condition){ cout << "YES" << '\n'; }else{ cout << "NO" << '\n'; }
#define yes(condition) if(condition){ cout << "yes" << '\n'; }else{ cout << "no" << '\n'; }




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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

int main() {
    ll n, m;
    string s, t;
    cin >> n >> m;
    cin >> s >> t;
    ll l = lcm(n, m);
    ll p1 = 0, p2 = 0, k1 = l / m, k2 = l / n;
    bool ok = true;
    while(p1 < n && p2 < m && ok){
        if(s[p1] != t[p2]){
            ok = false;
        }
        p1 += k1;
        p2 += k2;
    }
    if(ok){
        cout << l << endl;
    }
    else{
        cout << -1 << endl;
    }
}


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

using namespace std;

int main() {
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<long long> P(A);
  vector<long long> Q(B);
  vector<long long> R(C);
  for (auto &p : P) cin >> p;
  for (auto &q : Q) cin >> q;
  for (auto &r : R) cin >> r;
  sort(P.rbegin(), P.rend());
  sort(Q.rbegin(), Q.rend());
  sort(R.rbegin(), R.rend());

  vector<long long> I(X + Y);
  for (int i = 0; i < X; i++) {
    I[i] = P[i];
  }
  for (int i = 0; i < Y; i++) {
    I[X + i] = Q[i];
  }
  sort(I.rbegin(), I.rend());
  int i = 0;
  while (i < C and i < X + Y and R[i] > I[X + Y - 1 - i]) {
    I[X + Y - 1 - i] = R[i];
    i++;
  }
  long long ans = 0;
  for (auto i : I) {
    ans += i;
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 3968
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

ll MOD = 1e9 + 7;
ll f[1000001] = {};
void fact() {
	f[0] = 1;
	rep(i, 1, 1000001)f[i] = f[i - 1] * i %MOD;
}

ll p(ll e, ll n) {
	if (n == 0)return 1;
	if (n == 1)return e;

	ll t = p(e, n / 2);
	if (n & 1) {
		return ((t*t % MOD)*e) % MOD;
	}
	else {
		return t * t % MOD;
	}
}

ll nCr(ll n, ll r) {
	return ((f[n] * p(f[r], MOD - 2) % MOD) * p(f[n - r], MOD - 2) % MOD);
}

map<ll, ll> prime;

int main() {
	fact();
	ll n, m; cin >> n >> m;

	ll t = m;
	for (int i = 2; t != 1; i++) {
		while (!(t % i)) {
			prime[i]++;
			t /= i;
		}
		//while (t != 1) {
		//	if (t % i == 0) {
		//		prime[i]++;
		//		t /= i;
		//	}
		//	else {
		//		break;
		//	}
		//}
	}

	ll ans = 1;
	//rep(i, 0, 100001) {
	//	if (prime[i]) {
	//		ans = ans * nCr(prime[i] + n - 1, prime[i]) % MOD;
	//	}
	//}
	for (map<ll, ll>::iterator it = prime.begin(); it != prime.end(); it++) {
		ans = (ans * nCr(n - 1 + it->second, it->second) % MOD);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 8064
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int r,n,i,k;
    cin>>n;
    string str;
    cin>>str;
    for(i=0;i<str.length();i++)
    {
        k=str[i]-'A'+n;
        if(k>25)
        {
            r=k%26;
            cout<<char('A'+r);
        }
        else
        {
            cout<<char('A'+k);
        }
    }


 return 0;
}


Measured memory_bytes: 3636
/*
时间:2020-7-31
书籍：算法和数据结构
内容：递归搜索
页数：P111
*/
#include<iostream>
#include<string>
using namespace std;
int* A;
int n;
bool judge(int i, int m)                            //从输入值M中减去所选元素的递归函数
{
	if (m == 0)
		return true;
	else if (i >= n)
		return false;
	bool rec;
	rec = (judge(i + 1, m)) || (judge(i + 1, m - A[i]));                //m和m-A[i]相当于一个选当前的数，一个不选当前的数，只有有一个最终成立，那么就可以组成
	return rec;
}
int main()
{
	int q;
	cin >> ::n;
	A = new int[n];
	for (int i = 0; i < n; ++i)
		cin >> A[i];
	cin >> q;
	int m;
	for (int i = 0; i < q; ++i)
	{
		cin >> m;
		if (judge(0, m))
			cout << "yes" << endl;
		else
			cout << "no" << endl;
	}
	delete[]A;
	return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
typedef long long ll; typedef long double ld;
#define INF 1LL<<60
ld lginf = -1;
ll mul(ll a, ll b) { if (lginf < 0) lginf = log10l(INF); ld aa = log10l(a), bb = log10l(b);
    if (lginf <= aa + bb) return INF; return a * b; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
ll lcm(ll a, ll b) { if (a == INF || b == INF) return INF; return mul(a / gcd(a, b), b); }
/*---------------------------------------------------------------------------------------------------
????????????????????????????????? ??§?????§  
??????????????? ??§?????§ ???????´<_??? ?????? Welcome to My Coding Space!
???????????? ??? ?´_???`??????/??? ???i     
?????????????????????????????? ???  |???|     
????????? /?????? /??£??£??£??£/??????|  
??? ???_(__??????/???    ???/ .| .|????????????  
??? ????????????/????????????/??????u??????  
---------------------------------------------------------------------------------------------------*/




typedef long double ld;
#define INF 1LL<<60
int N; ll M; ll A[20]; ld P[20];
ll f[1 << 20];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M;
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, N) {
        int x; cin >> x;
        P[i] = x / 100.0;
    }

    // f[mask] := ??¨?????????mask??¨?????§????????????????????°
    rep(mask, 1, 1 << N) {
        ll lc = 1;
        rep(i, 0, N) if(mask & (1 << i)) lc = lcm(lc, A[i]);
        f[mask] = M / lc;
    }

    // ????????????????????????????????\??????????????????????????????
    // f[mask] := ??¨?????????mask?????????????????§????????????????????°
    rep(i, 0, N) rep(j, 0, 1 << N) if (j & (1 << i)) f[j] -= f[j ^ (1 << i)];

    ld ans = 0;
    rep(mask, 0, 1 << N) {
        ld p = 1;
        rep(i, 0, N) {
            if (mask & (1 << i)) p *= P[i];
            else p *= 1 - P[i];
        }

        ans += (ld)abs(f[mask]) * p;
    }
    printf("%.10llf\n", ans);
}

Measured memory_bytes: 11556
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  int a[3][3];
  rep(i,3)rep(j,3) R a[i][j];
  int n;
  R n;
  rep(i,n) {
    int x;
    R x;
    rep(j,3)rep(k,3) {
      if(a[j][k]==x) a[j][k]=-1;
    }
  }
  rep(i,3) {
    int c=0;
    rep(j,3) {
      if(a[i][j]==-1) c++;
    }
    if(c==3) {
      pr("Yes");
      return;
    }
  }
  rep(i,3) {
    int c=0;
    rep(j,3) {
      if(a[j][i]==-1) c++;
    }
    if(c==3) {
      pr("Yes");
      return;
    }
  }
  int c=0;
  rep(i,3) {
    if(a[i][i]==-1) c++;
  }
  if(c==3) {
    pr("Yes");
    return;
  }
  c=0;
  rep(i,3) {
    if(a[i][2-i]==-1) c++;
  }
  if(c==3) {
    pr("Yes");
    return;
  }
  pr("No");
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
// Template {{{
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;

#ifdef LOCAL
#include "contest.h"
#else
#define error(args...) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

typedef pair<int, int> Query;
//set<Query> queries;
const int MAX_M = 1e5 + 10;
set<int> queries[MAX_M];
map<int, int> result[MAX_M];
struct BIT{
    vector<LL> sums;
    BIT(int n) : sums(n) {}

    // v[at] += by
    void add(int at, LL by) {
        while(at < sums.size()){
            sums[at] += by;
            at |= at + 1;
        }
    }

    // v[0] + ... + v[at]
    LL get(int at) {
        LL res = 0;
        while(at >= 0) {
            res += sums[at];
            at = (at & (at + 1)) - 1;
        }
        return res;
    }

    // --- optional ---
    int size() const { return sums.size(); }
    LL operator [](int idx) const { return sums[idx]; }
};
int main(){
    iostream_init();

    int N, M;
    while(cin >> N >> M) {
        REP(i, MAX_M) result[i].clear();
        REP(i, MAX_M) queries[i].clear();

        vector<pair<int, int>> ps(N);
        REP(i, N) cin >> ps[i].first >> ps[i].second;
        sort(ps.begin(), ps.end());

        auto set = [&](int x1, int x2, int y1, int y2) {
            // queries.insert(Query(x2, y2));
            // queries.insert(Query(x1-1, y2));
            // queries.insert(Query(x2, y1-1));
            // queries.insert(Query(x1-1, y1-1));
             queries[x2].insert(y2);
             queries[x1-1].insert(y2);
             queries[x2].insert(y1-1);
             queries[x1-1].insert(y1-1);
        };
        auto get = [&](int x1, int x2, int y1, int y2) {
            int res = 0;
            res += result[x2][y2];
            res -= result[x1-1][y2];
            res -= result[x2][y1-1];
            res += result[x1-1][y1-1];
            return res;
        };

        for(int d = 1; d <= M; d++) {
            for(int x = d; x <= M; x += d) {
                set(max(x-d+1, 1), x, x, M);
            }
        }

        int idx = 0;
        int qi = 0;
        BIT bit(M + 1);
        for(int x = 0; x <= M; x++) {
            while(idx < ps.size() && ps[idx].first == x) {
                bit.add(ps[idx].second, 1);
                idx++;
            }

            for(auto y : queries[x]) {
                result[x][y] = (int)bit.get(y);
            }
        }

        for(int d = 1; d <= M; d++) {
            int ans = 0;
            for(int x = d; x <= M; x += d) {
                int g = get(max(1, x-d+1), x, x, M);
                // error(d, x-d+1, x, x, M, g);
                ans += g;
            }
            cout << ans << endl;
        }
        // break;
    }

    return 0;
}



Measured memory_bytes: 141696
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void PRINT(T container, bool withSize) { if(withSize) cout<<container.size()<<endl; for(auto it : container) cout<<it<<" "; cout<<endl; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T> >;
typedef signed long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

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

    int n,k,s; cin>>n>>k>>s;
    vi ans;

    int INF = 1e9;
    if(s==INF)
        INF--;

    FOR(i,k)
        ans.push_back(s);

    FOR(i,n-k)
        ans.push_back(INF);

    PRINT(ans, 0);

    return 0;
}



Measured memory_bytes: 2296
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define mp make_pair
#define pi acos(-1)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
#define pi acos(-1)
using namespace std;
ll n;
ll ara[100009][4];
ll dp[100009][4];
ll  k;
ll call(ll ind,ll pre )
{
    if(ind==n-1) return 0;
    ll &ret=dp[ind][pre];
    if(ret!=-1) return ret;
    ll a=0;
    ll b=0;
    for(ll i=0;i<3;i++)
    {
        if(i==pre) continue;
        if(ind+1<n) a=ara[ind+1][i]+call(ind+1,i);
        b=max(a,b);
    }
    return ret=b;
}
int  main()
{
    memset(dp,-1,sizeof dp);
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<3;j++) cin>>ara[i][j];
    }
    ll a=ara[0][0]+call(0,0);
    ll b=ara[0][1]+call(0,1);
    ll c=ara[0][2]+call(0,2);
    cout<<max(a,max(b,c))<<endl;
}


Measured memory_bytes: 14336
n = int(input())
xy = [list(map(int,input().split())) for _ in range(n)]
a = []
b = []
for i in range(n):
    a.append(xy[i][0]+xy[i][1])
    b.append(xy[i][0]-xy[i][1])
a_sort = sorted(a)
b_sort = sorted(b)

print(max(a_sort[-1]-a_sort[0],b_sort[-1]-b_sort[0]))

Measured memory_bytes: 65260
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int N;
vector<double> A, B, C;

// 1-indexed BIT (i : [1, len])
template<typename T, int len>
struct BIT
{
    array<T, len + 1> val;
    void reset() { val.fill(0); }
    BIT() { val.fill(0); }
    void add(int pos, T v)
    {
        while (pos > 0 && pos <= len)
        {
            val[pos] += v;
            pos += pos & -pos;
        }
    }
    T sum(int pos)
    {
        T res = 0;
        while (pos > 0)
        {
            res += val[pos];
            pos -= pos & -pos;
        }
        return res;
    }
};

BIT<int, 40001> bit;

int cnt(const vector<double> &vec)
{
    vector<double> vec_sorted = vec;
    sort(vec_sorted.begin(), vec_sorted.end());
    
    map<double, int> ma;
    REP(i, vec_sorted.size()) ma[vec_sorted[i]] = i + 1;

    bit.reset();
    int ans = 0;
    for (auto v : vec)
    {
        ans += bit.sum(ma[v]);
        bit.add(ma[v], 1);
    }
    return ans;
}

double solve(const vector<double> &A, const vector<double> &B, const vector<double> &C)
{
    using p = pair<double, double>;
    vector<p> info(N);
    REP(i, N) info[i] = p((double)A[i] / B[i], (double)C[i] / B[i]);
    sort(info.begin(), info.end());

    double l = -2E8, r = 2E8;
    while (r - l > 1E-10 and (r - l) > (abs(l) + abs(r)) * 1E-10)
    {
        double c = (l + r) / 2;
        vector<double> vec(N);
        REP(i, N) vec[i] = info[i].second - info[i].first * c;
        if (cnt(vec) > N * (N - 1) / 2 / 2) l = c;
        else r = c;
    }
    return l;
}

int main()
{
    cin >> N;
    A.resize(N);
    B.resize(N);
    C.resize(N);
    REP(i, N) cin >> A[i] >> B[i] >> C[i];

    cout << solve(A, B, C) << " " << solve(B, A, C) << endl;
}


Measured memory_bytes: 7196
n,*s=map(int,open(0).read().split());s,t,f,g=[s[i*n:i*n+n]for i in range(4)];a=[n*[0]for _ in[0]*n];r=range(n)
for b in range(64):
  e=1<<b;u=[k&e for k in f];v=[k&e for k in g];l=[0]*n;m=l[:]
  for i in r:
    for j in r:
      if(u[i]&v[j])|((s[i]^1)*u[i])|((t[j]^1)*v[j]):a[i][j]|=e;l[i]+=1;m[j]+=1
  for i in r:
    if s[i]*u[i]*(l[i]==0):
      for j in r:
        if(t[j]^1)*(n-m[j]>1):a[i][j]|=e;m[j]+=1;break
  for j in r:
    if t[j]*v[j]*(m[j]==0):
      for i in r:
        if(s[i]^1)*(n-l[i]>1):a[i][j]|=e;l[i]+=1;break
h=a[0][:];w=[i[0]for i in a]
for i in r:
  for j in r:w[i]=(w[i]|a[i][j]if s[i]else w[i]&a[i][j]);h[j]=(h[j]|a[i][j]if t[j]else h[j]&a[i][j])
if(g!=h)|(f!=w):print(-1);exit() 
for i in a:print(*i)

Measured memory_bytes: 99096
#include <stdio.h>
#define rep(i,n) for(int (i) = 0; (i) < (n); ++ (i) )

void printArray(int A[] , int N) {
    rep(i,N-1)
        printf("%d ", A[i]);
    printf("%d\n", A[N-1]);
}

void insertionSort(int A[], int N) {
    int ins,cmp;
    for(ins = 1; ins < N; ins++) {
        int value = A[ins];
        for(cmp = ins -1; cmp >= 0 && A[cmp] > value ;cmp--) {
            A[cmp+1] = A[cmp];
        }
        A[cmp+1] = value;
        printArray(A, N);
    }
}

int main(void) {
    int A[100];
    int N;
    
    scanf("%d", &N);
    rep(i,N)
        scanf("%d", &A[i]);
    printArray(A, N);
    insertionSort(A, N);
    return 0;
}


Measured memory_bytes: 2752
def main():
    N = int(input())
    d = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}
    for i in range(N):
        S = str(input())
        d[S] += 1
    AC = d['AC']
    AC = str(AC)
    WA = d['WA']
    WA = str(WA)
    TLE = d['TLE']
    TLE = str(TLE)
    RE = d['RE']
    RE = str(RE)
    print('AC x ' + AC)
    print('WA x ' + WA)
    print('TLE x ' + TLE)
    print('RE x ' + RE)
main()

Measured memory_bytes: 9216
#include <iostream>
#include <cstdio>
#include <cmath>

const double PI = 3.14159265;

struct Point {
    double x, y;
};

// 回転行列を掛け合わせる関数
void Rotation(const Point& s, const Point& t, Point& u) {
    double params = 60.0;
    double rad = params * PI / 180.0;
    double cos60 = cos(rad);
    double sin60 = sin(rad);

    u.x = cos60 * (t.x - s.x) - sin60 * (t.y - s.y) + s.x;
    u.y = sin60 * (t.x - s.x) + cos60 * (t.y - s.y) + s.y;
}

void KochCurve(const int n, Point left, Point right) {
    if(n != 0){
        // 多分ここで再帰
        Point s;
        Point t;
        Point u;

        // ベクトルで座標を計算する
        s.x = (2.0 * left.x + 1.0 * right.x) / 3.0;
        s.y = (2.0 * left.y + 1.0 * right.y) / 3.0;
        t.x = (2.0 * right.x + 1.0 * left.x) / 3.0;
        t.y = (2.0 * right.y + 1.0 * left.y) / 3.0;

        Rotation(s, t, u);

        KochCurve(n-1, left, s);
        printf("%08f %08f\n", s.x, s.y);
        KochCurve(n-1, s, u);
        printf("%08f %08f\n", u.x, u.y);
        KochCurve(n-1, u, t);
        printf("%08f %08f\n", t.x, t.y);
        KochCurve(n-1, t, right);

    }
}

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

    Point left;
    left.x = 0;
    left.y = 0;

    Point right;
    right.x = 100;
    right.y = 0;

    printf("%08f %08f\n", left.x, left.y);
    KochCurve(n, left, right);
    printf("%08f %08f\n", right.x, right.y);
}


Measured memory_bytes: 3160
#include<iostream>
#include "algorithm"
#include "bits/stdc++.h"
using namespace std ;
#define ll long long
int t;
string a="AC";
string b="TLE";
string c="WA";
string d="RE",e;
int x,y,p,q;
int main(){
    cin>>t;
    while(t--){
        cin>>e;
        if(e==a)
            x++;
        if(e==b)
            y++;
        if(e==c)
            p++;
        if(e==d)
            q++;
    }
    cout<<"AC x "<<x<<endl;
    cout<<"WA x "<<p<<endl;
    cout<<"TLE x "<<y<<endl;
    cout<<"RE x "<<q;
    return 0;
}

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

long long n,a[100010],s;

int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        s+=a[i]*(i%2*2-1);
    }
    cout<<s;
    for(int i=1;i<n;i++){
        s=a[i]*2-s;
        cout<<' '<<s;
    }
}

Measured memory_bytes: 2048
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
#include<tuple>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
#define rrep(i,n)for(int i=n-1;i>=0;i--)
#define REP(i,n) for (int i = 1; i <= (int)n; i++)//i=1からi=nまで
#define RREP(i,n)for(int i=n;i>=1;i--) 
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = pow(10, 9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;
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; cin >> X;
    rep(a, 200) {
        for (int b = -200; b < 200; b++) {
            if (pow(a, 5) - pow(b, 5) == X) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3928
#include<iostream>
using namespace std;
int main(){
    int a,b,x;
    cin>>a>>b>>x;
    if(x<a)
    {
        cout<<"NO"<<endl;
    }
    else
    {
        x-=a;
        if(b>x){
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }
    }
}

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

int main()
{
  int n;
  cin >> n;
  if(n % 2)
  {
    cout << "Hello World" << endl;
    return 0;
  }
  int a, b;
  cin >> a >> b;
  cout << a + b << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String s = sc.next();

        int result = 0;
        for (int i = 2; i < n; i++) {
            result = s.charAt(i) == 'C' && s.charAt(i - 1) == 'B' && s.charAt(i - 2) == 'A' ? result + 1 : result;
        }

        System.out.println(result);

        sc.close();
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
const long long mod = 1e9 + 7 ;
const int N = 3e5+122; 

int n;
long long a[N], cnt[100][4];
long long ans;
int main () {

	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];

	for(int i = n; i >= 1; i--) {
		for(int j = 60; j >= 0; j--) {
			ans += (cnt[j][bool((a[i] & (1LL<<j)) ^ (1LL << j))] * ((1LL<<j)%mod))%mod;
			ans%=mod;
			cnt[j][bool(a[i] & (1LL<<j))]+=1;
		}
	}
	cout<<ans;
}
            

              




Measured memory_bytes: 2560
#include <iostream>
#include <cmath>
#include <vector>
#include <iomanip>
using namespace std;

struct Dice{
	int top;
	int front;
	int right;
	int left;
	int back;
	int bottom;
};
void roll_n(Dice &dice2)
{
	int a = dice2.top;
	dice2.top = dice2.front;
	dice2.front = dice2.bottom;
	dice2.bottom = dice2.back;
	dice2.back = a;
}
void roll_e(Dice &dice2)
{
	int a = dice2.top;
	dice2.top = dice2.left;
	dice2.left = dice2.bottom;
	dice2.bottom = dice2.right;
	dice2.right = a;
}
void roll_w(Dice &dice2)
{
	int a = dice2.top;
	dice2.top = dice2.right;
	dice2.right = dice2.bottom;
	dice2.bottom = dice2.left;
	dice2.left = a;
}
void roll_s(Dice &dice2)
{
	int a = dice2.top;
	dice2.top = dice2.back;
	dice2.back = dice2.bottom;
	dice2.bottom = dice2.front;
	dice2.front = a;
}
void roll(Dice &dice, char direction)
{
	if(direction == 'N'){
		roll_n(dice);
	}
	else if(direction == 'E'){
		roll_e(dice);
	}
	else if(direction == 'W'){
		roll_w(dice);
	}
	else{
		roll_s(dice);
	}
}
bool kakunin_6dimensions(Dice &a, Dice &b)
{	
	if(a.top == b.top
	&& a.front == b.front
	&& a.right == b.right
	&& a.left == b.left
	&& a.back == b.back
	&& a.bottom == b.bottom
	){
		return true;
	}
	return false;
}
bool kakunin_4dimensions(Dice &dice, Dice &dice2)//front????????????E????????????4?????¢???top????????´??????????¢????
{
	for(int i = 0; i < 4; i ++){
		roll_e(dice2);
		if(kakunin_6dimensions(dice, dice2) == true){
			return true;
		}
	}
	return false;
}
bool kakunin_6tops(Dice &dice, Dice &dice2)//6?????????top?????????????????????
{
	string str = "ESESES";
	for(int i = 0; i < str.size(); i++){
		roll_s(dice2);
		if(kakunin_4dimensions(dice, dice2) == true){
			return true;
		}
		roll_n(dice2);
		roll(dice2, str[i]);
	}
	return false;
}
int main(void)
{	
	Dice dice;
	Dice dice2;
	
	cin >> dice.top >> dice.front >> dice.right >> dice.left >> dice.back >> dice.bottom;
	cin >> dice2.top >> dice2.front >> dice2.right >> dice2.left >> dice2.back >> dice2.bottom;
	
	if(kakunin_6tops(dice, dice2) == true){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

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

long long int gcd(long long int a, long long int b)
{
    for(long long int k = 1; k > 0;)
    {
        if(a % b == 0)
        {
            return b;
            break;
        }
        else
        {
            k = a%b;
            a = b;
            b = k;
        }
    }
}

int main()
{
    int N;
    long long int t;
    cin >> N;
    long long int A[N];
    for(int i=0; i<N; i++)
    {
        cin >> A[i];
    }
    
    for(int j=0; j<N-1; j++)
    {
        if(A[j] > A[j+1])
        {
            t = (A[j]/gcd(A[j], A[j+1])) * A[j+1];
            A[j+1] = t;
        }
        else
        {
            t = (A[j]/gcd(A[j+1], A[j])) * A[j+1];
            A[j+1] = t;
        }

    }
    
    cout << A[N-1] << endl;
    
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    char s[105],t[210];
    cin>>s>>t;
    strcat(t,s);
     cout<<t<<endl;
return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

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

	int sum=1;
	for (int i = 1; i < s.size(); i++){
		if(s[i]==s[i-1])continue;
		sum++;
	}

	cout<<sum<<endl;

	return 0;
}


Measured memory_bytes: 512
n = int(input())
s = input()
t = input()
res = s+t
kekka = n*2
import copy
for i in range(n):
    tmp = list(res)
    del tmp[n]
    target = "".join(tmp)
    if target[:n] == s and target[-n:] == t:
        kekka = len(target)
        #print(target)
    res = copy.deepcopy(tmp)

print(kekka)


Measured memory_bytes: 3444
from math import factorial

n,k=map(int, input().split())
mod=10**9+7

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

def comb(m,r):
    if m < 0 or r < 0 or m < r: return 0
    if m==0 or r==0: return 1
    a=factorial(m)%mod
    b=factorial(r)%mod
    c=factorial(m-r)%mod
    return (a*power_func(b,mod-2)*power_func(c,mod-2))%mod

def power_func(a,b):
    if b == 0: return 1
    if b%2==0:
        d=power_func(a,b//2)
        return d*d %mod
    if b%2==1:
        return(a*power_func(a,b-1))%mod

ans=0
for i in range(1,k+1):
    temp=comb(n-k+1,i)
    temp2=comb(k-1,i-1)
    print(int(temp*temp2)%mod)

Measured memory_bytes: 3444
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.lang.*;
import java.lang.Exception;
import java.lang.Integer;
import java.lang.Math;
import java.lang.String;
import java.lang.System;
import java.util.StringTokenizer;


class Main {
    public static void main(String[] a) throws IOException {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));

        try {
            String s = r.readLine();
            StringTokenizer st;
            while(s != null) {
                st = new StringTokenizer(s);
                int sum = Integer.parseInt(st.nextToken()) + Integer.parseInt(st.nextToken());
                System.out.println((int)Math.log10(sum) + 1);
                s = r.readLine();
            }
        } catch (Exception e) {
            System.exit(0);
        }
    }
}

Measured memory_bytes: 16892
#include <iostream>
#include <string>

using namespace std;

const int NMAX = 500 + 5;

int N, M;
string red[NMAX];
string blue[NMAX];

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

    cin >> N >> M;

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

    for (int j = 0; j < M; ++ j)
        for (int i = 0; i < N; ++ i)
            if (j & 1)
                red[i][j] = '#';
            else
                blue[i][j] = '#';
    for (int i = 0; i < M; ++ i) {
        red[0][i] = blue[N - 1][i] = '#';
        blue[0][i] = red[N - 1][i] = '.';
    }

    for (int i = 0; i < N; ++ i)
        cout << red[i] << '\n';
    cout << '\n';
    for (int i = 0; i < N; ++ i)
        cout << blue[i] << '\n';
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF  2000000000
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<int, int>
#define pb push_back
#define mp make_pair
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d)<<endl;
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
#define SUM(a, n) accumulate(a, a+n, 0)
#define VSUM(v) accumulate(ALL(v), 0);
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(a)-1;i>=(b);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))

signed main(){ INIT;
    VAR(int, a, b);
    VAR(string, s);
    if(s.size() != a + b + 1){
        No;
        RET;
    }
    REP(i, a){
        if(s[i] < '0'|| '9' < s[i] ){
            No;
            RET;
        }
    }
    if(s[a] != '-'){
        No;
        RET;
    }
    REP(i, b){
        if(s[a+i+1] < '0'|| '9' < s[a+i+1]){
            No;
            RET;
        }
    }
    Yes;
RET;}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int i1;
  int n,x;
  
  scanf("%d %d", &n,&x);
  
  int m[n];
  int min=999999;
  
  for(i1=0;i1<n;i1++){
    scanf("%d", &m[i1]);
    x = x-m[i1];
    if(min>m[i1]) min=m[i1];
  }
  
  printf("%d", n+(int)x/min);
  
  return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007; 
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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





int main(){
    int N; std::cin >> N;
    std::unordered_map<std::string, int> mp;
    long long cnt(0);
    {
        std::string s;
        for(int i(0); i < N; ++i){
            std::cin >> s;
            std::sort(std::begin(s), std::end(s));
            cnt += mp[s]++;
        }
    }
    std::cout << cnt << std::endl;
    return 0;
}


Measured memory_bytes: 10660
import java.util.*;
import java.text.*;

class Main {
    public static void main(String[]args)throws Exception {
        Scanner sc = new Scanner(System.in);
        Comparator<String> cs = new Comparator<String>() {
            public int compare(String s1, String s2) {
                int l1 = s1.length();
                int l2 = s2.length();
                int l = Math.min(l1, l2);
                for(int i = 0; i < l; i++) {
                    int d = s1.charAt(i) - s2.charAt(i);
                    if(d != 0) return d;
                }
                return l1 - l2;
            }
            public boolean equals(Object o) {
                return o == this;
            }
        };
        int n = sc.nextInt();
        int c1 = 0, c2 = 0;
        while(n-->0){
            String x = sc.next();
            String y = sc.next();
            int c = cs.compare(x, y);
            if(c < 0) {
                c2 += 3;
            } else if(c > 0) {
                c1 += 3;
            } else {
                c2 ++;
                c1 ++;
            }
        }
        System.out.println("" + c1 + " " + c2);
    }
}

Measured memory_bytes: 20844
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
using datas=pair<ll,ll>;
using tdata=pair<datas,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncrlistp[200000],modncrlistm[200000];

ll modncrs(ll n,ll r){
  ll i,j;
  if(modncrlistp[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistp[i])break;
    }
    if(i<0){
      modncrlistp[0]=1;
      rep1(i,n+1){
        modncrlistp[i]=(modncrlistp[i-1]*i)%mod;
      }
    }else{
      For(j,i+1,n+1){
        modncrlistp[j]=(modncrlistp[j-1]*j)%mod;
      }
    }
  }
  if(modncrlistm[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistm[i])break;
    }
    if(i<0){
      modncrlistm[0]=1;
      rep1(i,n+1){
        modncrlistm[i]=(modncrlistm[i-1]*modinv(i))%mod;
      }
    }else{
      For(j,i+1,n+1)modncrlistm[j]=(modncrlistm[j-1]*modinv(j))%mod;
    }
  }
  return (((modncrlistp[n]*modncrlistm[r])%mod)*modncrlistm[n-r])%mod;
}

ll modncr(ll n,ll r){
  if(r*2>n)return modncr(n,n-r);
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}

int main(){
  ll i,H,W,A,B,ans=0,N;
  cin>>H>>W>>A>>B;
  For(i,B+1,W+1){
    ans=(modncrs(H-A-1+i-1,i-1)*modncrs(A+W-i-1,A-1))%mod+ans;
    ans%=mod;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3200
#include <iostream>

using namespace std;

#define int long long
#define rep(i,n) for(int i=0; i<(int)(n); i++)

const int mod = (int)1e9+7;

signed main() {
  int n, k;
  cin >> n >> k;
  
  int s = 0;
  rep(i,n+2-k) {
    int j = k + i;
    s += j * (n - j + 1) + 1;
    s %= mod;
  }
  cout << s << endl;
  return 0; 
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define int long long
#define INT_MAX INT64_MAX
#define INT_MIN INT64_MIN
#define PI 3.14159265358979323846
#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main
#define MOD 1000000007
/* DEFINE cout */
#define pln cout << "===============================\n"
#define on cout<<"\n"
#define os cout<<" "
#define o2(a,b) cout<<a<<" "<<b
#define o(a) cout << a
#define bitcount __builtin_popcount
/* DEFINE cout */
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);//fastio
using namespace std;
struct hash_pair { // use pair as key in unordered_map<pair<int,int>,int,hash_pair>;
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
int diviso[10000001];
bool prime[10000001];
int P=MOD-2;
int factorial[10000001]={0};
int powerFunction(int x,int y){
    int res = 1;
    int p = MOD;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
void sieveFunction(int maxLimit){
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1]=false;
    for(int i=2; maxLimit >= i ; i++){
        if(prime[i]){
            diviso[i] = 2;
            for(int j=2*i ; maxLimit >= j ; j+=i){
                prime[j]=false;
                int temp = j;
                int cnt = 0;
                while(temp % i == 0){
                    cnt++;
                    temp /= i;
                }
                diviso[j] *= (cnt+1);
            }
        }
    }
}
void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
        factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

signed main(){
    fastio;
    for(int i=0; 10000000>=i; i++){
        diviso[i] = 1;
    }
    sieveFunction(10000000);
    int ans = 1;
    int n;
    cin >> n;
    for(int i=2; n>=i; i++){
        ans += (i*(diviso[i]));
    }
    cout << ans << endl;
    
}






Measured memory_bytes: 91500
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long a = sc.nextInt();
		long b = sc.nextInt();
		for (int i = 1; i < n; i++) {
			long aa = sc.nextInt();
			long bb = sc.nextInt();
			if ((double)a  * bb >= (double)b * aa) {
				if (a % aa != 0) {
					a += aa - (a % aa);
				}
				b = a / aa * bb;
			} else {
				if (b % bb != 0) {
					b += bb - (b % bb);
				}
				a = b / bb * aa;
			}
		}
		System.out.println(a + b);
	}
}


Measured memory_bytes: 25784