akhauriyash/Code-Regression huggingface dataset:
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  string s;
  cin >> s;

  ll n = s.size();
  vvll dp(n + 1, vll(2, INF));
  dp[0][0] = 0;
  rep(i, n) {
    ll di = s[n - 1 - i] - '0';
    dp[i + 1][0] = dp[i][0] + di;
    dp[i + 1][1] = dp[i][0] + 10 - di;
    if (dp[i][1] != INF) {
      chmin(dp[i + 1][0], dp[i][1] + di + 1);
      chmin(dp[i + 1][1], dp[i][1] + 9 - di);
    }
  }

  ll ans = min(dp[n][0], dp[n][1] + 1);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 55964
#include <iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim()
{
    int u, minV;
    int d[MAX], p[MAX], color[MAX];

    for (int i = 0; i < n; i++)
    {
        d[i] = INFTY;
        p[i] = -1;
        color[i] = WHITE;
    }
    d[0] = 0;

    while (1)
    {
        minV = INFTY;
        u = -1;
        for (int i = 0; i < n; i++)
        {
            if (minV > d[i] && color[i] != BLACK)
            {
                u = i;
                minV = d[i];
            }
        }
        if (u == -1)
        {
            break;
        }
        color[u] = BLACK;
        for (int v = 0; v < n; v++)
        {
            if (color[v] != BLACK && M[u][v] != INFTY)
            {
                if (d[v] > M[u][v])
                {
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        if (p[i] != -1)
        {
            sum += M[i][p[i]];
        }
    }
    return sum;
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            int e;
            cin >> e;
            M[i][j] = (e == -1) ? INFTY : e;
        }
    }

    cout << prim() << endl;
    return 0;
}


Measured memory_bytes: 3108
ss = input()

first_zero_count = 0
first_zero_last = '0'
first_one_count = 0
first_one_last = '1'
for s in ss:
    first_zero_count += 1 if s == first_zero_last else 0
    first_one_count += 1 if s == first_one_last else 0
    first_zero_last, first_one_last = first_one_last, first_zero_last
print(min(first_zero_count, first_one_count))


Measured memory_bytes: 3188
#include <stdio.h>

#define MAX 101

int main(void)
{
    int i, j;

    int row, column;
    scanf("%d %d", &row, &column);

    int in_mat[MAX][MAX];
    for (i = 0; i < row; i++){
        for (j = 0; j < column; j++){
            scanf("%d", &in_mat[i][j]);
        }
    }

    int in_vec[MAX];
    for (j = 0; j < column; j++){
        scanf("%d", &in_vec[j]);
    }

    int out_vec[MAX];
    for (i = 0; i < row; i++){
        out_vec[i] = 0;
        for (j = 0; j < column; j++){
            out_vec[i] += in_mat[i][j] * in_vec[j];
        }
        printf("%d\n", out_vec[i]);
    }

    return 0;

}

Measured memory_bytes: 1064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int N, x;
    cin >> N >> x;
    if(x == 1 || x == 2 * N - 1){
        No();
        return 0;
    }
    if(x == 2){
        Yes();
        for (int i = 3; i < N+1; i++) {
            printf("%d\n", i);
        }
        printf("%d\n", 1);
        printf("%d\n", 2);
        for (int i = N+1; i < 2*N; i++) {
            printf("%d\n", i);  
        }
    }
    else{
        queue<int> q;
        for (int i = 1; i < x-2; i++) {
            q.push(i);
        }
        for (int i = x+2; i < 2*N; i++) {
            q.push(i);
        }
        Yes();
        int tmp;
        for (int i = 0; i < N-3; i++) {
            tmp = q.front();
            q.pop();
            printf("%d\n", tmp);
        }
        printf("%d\n", x-2);
        printf("%d\n", x+1);
        printf("%d\n", x);
        printf("%d\n", x-1);
        while(!q.empty()){
            tmp = q.front();
            q.pop();
            printf("%d\n", tmp);    
        }
    }


}

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

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 T> inline T gcd(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T lcm(T a,T b){return a*b/gcd(a,b);}

const int INF=1e9;
const double eps=0.0000000001;



int main(){
  ll n;
  cin >> n;
  ll a[1000000],ans=0;
  FOR(i,n){
    cin >> a[i];
  }
  ll aa[1000000];
  aa[0]=0;
  FOR(i,n){
    aa[i+1]=aa[i]+a[i];
  }
  sort(aa,aa+n+1);
ll cnt=1;
  FOR(i,n){
    if(aa[i]==aa[i+1]){
      cnt++;
    }else{
      if(cnt>1){
        ans+=cnt*(cnt-1)/2;
      }
      cnt=1;
    }
  }
  ans+=cnt*(cnt-1)/2;

  cout << ans << endl;
}


Measured memory_bytes: 7296
#include<cstdio>
#include<algorithm>
using namespace std;
int a[102];
int n;
int main()
{
  scanf("%d",&n);
  for(int i=1; i<=n+n; i++) scanf("%d",&a[i]);
  sort(a+1,a+n+n+1);
  int ans = 0;
  for(int i=1; i<=n+n; i+=2) ans += min(a[i],a[i+1]);
  printf("%d\n",ans);
return 0;
}

Measured memory_bytes: 128
N, M, Q = map(int, input().split())
abcd = [tuple(map(int, input().split())) for i in range(Q)]

A_list = [[1, i] for i in range(1, M+1)]
for i in range(2, N):
  t_list = []
  for e in A_list:
    for j in range(e[-1], M+1):
      t_list.append(e + [j])
  A_list = t_list

# print(A_list)

ans = 0
for A in A_list:
  t = 0
  for a, b, c, d in abcd:
    if (A[b-1] - A[a-1]) == c:
      t += d
  ans = max(ans, t)

print(ans)


Measured memory_bytes: 19816
const main = stdin => {
  const input = stdin.trim().split('\n')

  const [X, A] = input[0].split(' ').map(x => parseInt(x))

  if (X < A) {
    console.log(0)
  } else {
    console.log(10)
  }
}
// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 30528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    string s;cin >> s;
    int ans=0;
    FORR(i,n,1){
        vector<int> dp(n+1);
        FORR(j,n-1-i,0){
            if(s[j]!=s[j+i]) dp[j]=0;
            else dp[j]=min(dp[j+1]+1,i);
            chmax(ans,dp[j]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3672
# -*- coding: utf-8 -*-
N=int(input())
H=list(map(int,input().split()))
ans=0
temp=0
for i in range(len(H)-1):
    if H[i]>=H[i+1]:
        temp=temp+1
    else:
        if temp>ans:
            ans=temp
        temp=0
if temp>ans:
    ans=temp
print(ans)

Measured memory_bytes: 14252
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll mod = 1000000007;
const int N = 200010;
ll fact[N], invf[N];

ll add(ll x, ll y){
    return (x+y)%mod;
}

ll mul(ll x, ll y){
    return (x%mod)*(y%mod)%mod;
}

ll powll(ll x, ll y){
    x %= mod;
    ll res = 1LL;
    while(y){
        if (y & 1LL)
            res *= x;
        res %= mod;
        x = (x*x) % mod;
        y >>= 1LL;
    }
    return res;
}

ll divll(ll x, ll y){
    x %= mod;
    return (x * powll(y,mod-2)) % mod;
}

ll nPr(ll n, ll r){
    if (n < r || r < 0) return 0;
    return mul(fact[n], invf[n-r]);
}

ll nCr(ll n, ll r){
    if (n < r || r < 0) return 0;
    return mul(mul(fact[n], invf[r]), invf[n-r]);
}

void init_f(){
    fact[0] = 1;
    FOR(i,1,N-1){
        fact[i] = (fact[i-1] * i) % mod;
    }
    invf[N-1] = divll(1, fact[N-1]);
    FORR(i,N-1,1){
        invf[i-1] = (invf[i] * i) % mod;
    }
}

int n;
VI e[N];
ll dp[N], sz[N], ans[N];

void dfs(int now, int past){
    sz[now] = dp[now] = 1;
    for (int next : e[now]){
        if (next == past) continue;
        dfs(next, now);
        sz[now] += sz[next];
        dp[now] = (dp[now] * dp[next]) % mod;
        dp[now] = (dp[now] * nCr(sz[now] - 1, sz[next])) % mod;
    }
}

void dfs2(int now, int past, ll p){
    ll x = (p * nCr(n - 1, n - sz[now])) % mod;
    ans[now] = (dp[now] * x) % mod;
    for (int next : e[now]){
        if (next == past) continue;
        ll y = (dp[next] * nCr(n - 1, sz[next])) % mod;
        dfs2(next, now, divll(ans[now], y));
    }
}

int main(void){
    cin >> n;
    REP(i,n-1){
        int u = in() - 1, v = in() - 1;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    init_f();
    dfs(0, -1);
    ans[0] = dp[0];
    for (int next : e[0]){
        ll x = (dp[next] * nCr(n - 1, sz[next])) % mod;
        dfs2(next, 0, divll(ans[0], x));
    }
    REP(i,n) printf("%lld\n", ans[i]);
    return 0;
}


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

if(N==4||N==7||N==8||N==11||N==12||N==14||N==15||N==16){
	cout<<"Yes";
}else if(N>17){
	cout<<"Yes";
}else{
	cout<<"No";
}


}

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

int main() {
	int N, K;
	cin >> N >> K;
	int work = 0;
	for(int i = 0;i < N;i++){
		int dummy;
		cin >> dummy;
		work += min(dummy,abs(K - dummy));
	}
	cout << work * 2 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	int a = 0, b = 0, i =0, sum = 0;
	
	while(scanf("%d %d", &a, &b)!=EOF) 
	{
		sum = a + b;
	
			for(i = 1; i < 15; i++)
		{	
		if(sum < 10)
			{
			printf("%d\n", i);
			break;	
			}
		else
			{	
			sum = sum / 10;
		 	}
		}
	}
		
	return 0;
}


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

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

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

using namespace std;
int N, ptr, res;
int A[100000];
int main()
{
    scanf("%d", &N);
    for (int i = 0; i < N; i++)
        scanf("%d", &A[i]);
    sort(A, A + N);
    while (ptr < N)
    {
        int cc = A[ptr], f = 0;
        while (ptr < N && A[ptr] == cc)
            f++, ptr++;
        res += f % 2;
    }
    printf("%d\n", res);
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <unordered_map>
#include <deque>
#include <list>
#include <set>
#include <random>

using namespace std;
using ll = long long;


using Apple = struct {
    ll yum;
    int color;
};

int main(){
    const int NONE = 0;
    const int RED = 1;
    const int GREEN = 2;

    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<Apple> apples;
    for(int i = 0;i < a;++i) {
        ll yum;
        cin >> yum;
        apples.push_back(Apple{yum, RED});
    }
    for(int i = 0;i < b;++i){
        ll yum;
        cin >> yum;
        apples.push_back(Apple{yum,GREEN});
    }
    for(int i = 0;i < c;++i){
        ll yum;
        cin >> yum;
        apples.push_back(Apple{yum,NONE});
    }
    sort(apples.begin(),apples.end(),[](const Apple& left,const Apple& right){
        return left.yum > right.yum;
    });
    int redc = 0;
    int greenc = 0;
    int totalc = 0;
    ll total = 0;
    for(int i = 0;i < apples.size();++i){
        if(apples[i].color == RED){
            if(redc < x){
                ++redc;
                ++totalc;
                total += apples[i].yum;
            }
        }
        else if(apples[i].color == GREEN){
            if(greenc < y){
                ++greenc;
                ++totalc;
                total += apples[i].yum;
            }
        }
        else{
            ++totalc;
            total += apples[i].yum;
        }
        if(totalc == x + y)break;
    }
    cout << total << endl;
}


Measured memory_bytes: 10476
A, B, C, X = [int(input()) for _ in range(4)]

max_a = min(X//500, A)
c = 0

for a in range(0, max_a+1):
    rest1 = X - 500 * a
    max_b = min(rest1//100, B)
    for b in range(0, max_b+1):
        rest2 = rest1 - 100 * b
        if rest2//50 <= C:
            c += 1
print(c)

Measured memory_bytes: 3060
m,d=map(int,input().split())
count=0
for i in range(m):
  for j in range(d):
    if ((j+1)//10)*((j+1)%10)==(i+1) and (j+1)//10>=2 and (j+1)%10 >=2:

      count+=1
print(count)

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  void solve() {
    vector<int> a(4), b = {1, 4, 7, 9};
    for (int i = 0; i < 4; ++i) {
      cin >> a[i];
    }
    sort(a.begin(), a.end());
    if (a == b) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);

  Problem::Solver sol;
  sol.solve();
  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 2147483647
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;

vector<int> value;
int N;

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

void update(int i, int x) {
	i += N - 1;
	value[i] = x;
	while (i > 0) {
		i = (i - 1) / 2;
		value[i] = gcd(value[i * 2 + 1], value[i * 2 + 2]);
		//cout <<i<<" "<< value[i * 2 + 1] << " " << value[i * 2 + 2] << endl;
	}
}

int query(int a, int b, int k, int l, int r) {
	if (r <= a || b <= l)return 0;
	//cout << " " << k << " "<<l << " " << r << endl;
	if (a <= l && r <= b)return value[k];
	else {
		int c1 = query(a, b, 2 * k + 1, l, (l + r) / 2);
		int c2 = query(a, b, 2 * k + 2, (l + r) / 2,r);
		//cout << a << " " << b << " " << c1 << " " << c2 << endl;
		return gcd(c1, c2);
	}
}


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

	int n;
	cin >> n;
	N = 1;
	while (N < n)N *= 2;
	value = vector<int>(2 * N - 1);
	REP(i, value.size())value[i] = 0;
	REP(i, n) {
		int a;
		cin >> a;
		update(i,a);
	}
	//REP(i, value.size())cout << value[i]<<" ";
//	cout << endl;
	int ans = 0;
	FOR(i,1, n-1) {
		int cnt = gcd(query(0, i, 0, 0, N), query(i + 1, n, 0, 0, N));
		//cout << 0 << " " << i << " " << query(0, i, 0, 0, N) << endl;
		//cout << i + 1 << " " << n << " " << query(i + 1, n, 0, 0, N) << endl;
		ans = max(ans, cnt);
	}
	ans = max(ans, query(1, n, 0, 0, N));
	ans = max(ans, query(0, n - 1, 0, 0, N));
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

/*
*/

ll m[2],d[2];

int main(void){
	rep(i,2)cin>>m[i]>>d[i];
	cout<<(m[0]!=m[1]?1:0)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll s, t, d;
  cin >> s >> t >> d;
  vector<ll> w(d);
  for (int i = 0; i < d; i++)
    cin >> w[i];
  ll minw = 0;
  ll sum = 0;
  for (int i = 0; i < d; i++) {
    sum += w[i];
    minw = min(minw, sum);
  }

  ll s2 = s;
  for (int i = 0; i < d; i++) {
    s2 += w[i];
    if (s2 <= t) {
      cout << i + 1 << endl;
      return 0;
    }
  }

  if (sum >= 0) {
    cout << -1 << endl;
    return 0;
  }
  sum = -sum;
  ll e = (s - t + minw + sum - 1) / sum;
  ll ans = e * d;
  s -= sum * e;
  for (int i = 0; i < d; i++) {
    s += w[i];
    if (s <= t) {
      cout << ans + i + 1 << endl;
      return 0;
    }
  }

  return 0;
}


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


int main(){
	int N;
	set<int> S;
	cin >> N;
	rep(i,N){
		int buf;
		cin >> buf;
		S.insert(buf);
	}
	if(S.size() == N) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 9856
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    static final int N = 50;

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

        long K = sc.nextLong();

        System.out.println(solve(K));

        sc.close();
    }

    static String solve(long K) {
        long[] a = new long[N];
        Arrays.fill(a, N - 1 + K / N);

        for (int i = 0; i < (int) (K % N); ++i) {
            for (int j = 0; j < a.length; ++j) {
                if (j == i) {
                    a[j] += N;
                } else {
                    --a[j];
                }
            }
        }

        return String.format("%d\n%s", a.length,
                Arrays.stream(a).mapToObj(String::valueOf).collect(Collectors.joining(" ")));
    }
}

Measured memory_bytes: 29012
import sys
import math
import collections
import bisect
import itertools
import decimal
import copy
import heapq

# import numpy as np

# sys.setrecursionlimit(10 ** 6)
INF = 10 ** 20
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))
flush = lambda: sys.stdout.flush()


# ===CODE===
def main():
    a, b, c, d = ns()
    ans = 0 if a <= 0 <= b or c <= 0 <= d else -INF

    x = [a, b]
    y = [c, d]
    for xi in x:
        for yi in y:
            tmp = xi * yi
            ans = max(ans, tmp)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 77492
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

A,B = inputIL()

print((A+B)%24)

Measured memory_bytes: 63980
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <random>
using namespace std;
 

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pb push_back
#define forn(i, n) for (int i = 0; i < n; ++i)
//#define int long long

 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
 
 
const int MAXN = 2e5 + 5;
const ll MOD = 998244353;
const ll INF = INT64_MAX;


mt19937 rnd(time(0));


ll fact[MAXN];


ll pw(ll a, ll x) {
	ll res = 1;
	while (x > 0) {
		if (x & 1) {
			res = (res * a) % MOD;
		}
		a = (a * a) % MOD;
		x >>= 1;
	}
	return res;
}


ll inv(ll x) {
	return pw(x, MOD - 2);
}


ll cnk(ll n, ll k) {
	return ((fact[n] * inv(fact[k])) % MOD * inv(fact[n - k])) % MOD;
}


signed main() {
	//FAST_IO;
	int n, m, k;
	cin >> n >> m >> k;
	int ans = 0;
	forn(i, MAXN) {
		if (i == 0) {
			fact[i] = 1;
			continue;
		}
		fact[i] = (fact[i - 1] * i) % MOD;
	}
	forn(i, k + 1) {
		ll kek = ((cnk(n - 1, i) * m) % MOD * pw(m - 1, n - i - 1)) % MOD;
		ans = (ans + kek) % MOD;
	}
	cout << ans << "\n";
 	return 0;
}

Measured memory_bytes: 5208
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
  int h, w;
  cin >> h >> w;
  string frame = "##";
  for(int i = 0; i < w; i++){
    frame.push_back('#');
  }
  cout << frame << endl;
  vector<string> s(h);
  for(int i = 0; i < h; i++){
    cin >> s[i];
    cout << '#' << s[i] << '#' << endl;
  }
  cout << frame << endl;
}

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

// 配列出力関数
void OutputArray(int A[], int N)
{
    for (int x=0; x<N-1; x++) {
        // 空白区切りで出力
        std::cout << A[x] << " ";
    }
    std::cout << A[N-1] << std::endl;
}

// 結果出力
void DisplayResults(int A[], int N, int Cnt)
{
    OutputArray(A, N);
    std::cout << Cnt << std::endl;
}

// 選択ソート実行関数
void SelectionSort(int R[], int N)
{
    // ソート回数をカウント
    int cnt_sort = 0;
    for (int i=0; i<N; i++) {
        // 初期化しないとRuntime Error
        int v = 0;
        int minVal = 100;
        for (int j=i; j<N; j++) {
            if (R[j] < minVal) {
                minVal = R[j];
                v = j;
            }
        }
        if (R[i] != R[v]) {
            std::swap(R[i], R[v]);
            cnt_sort++;
        }
    }
    DisplayResults(R, N, cnt_sort);
}

int main()
{
    static const int MAX = 100;
    int n, R[MAX];
    std::cin >> n;
    
    for (int i=0; i<n; i++) std::cin >> R[i];
    
    SelectionSort(R, n);
    return 0;
}


Measured memory_bytes: 3088
n = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)

ans = a[0]
cnt = 1
index = 1
while cnt < n - 1:
    ans += 2 * a[index]
    index += 1
    cnt += 2
    
if cnt == n - 1:
    print(ans)
else:
    print(ans - a[index - 1])

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,j,N) for(int i = (N-1);i >= (j);i--)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

LL cal(LL dis,LL A,LL B){
    LL one = 1;
    LL ret_val = 0;


    _for(i,0,41){
        LL mod = (one<<(i+1));
        LL beg = (A % mod);
        LL mov = (dis % mod);

        LL mid = mod/2-1;
        LL ed = mod-1;

        //cout << mov <<" "<<mid <<" "<< ed <<endl;

        LL n = 0;

        if(!i) n += dis/2;

        if(mov > 0 && beg < mid){
            mov -= (mid-beg);
            beg = mid;
        }

        if(mov > 0){
            if(ed - beg >= mov){
                n += mov;
                mov = 0;
            }
            else{
                mov -= ed-beg;
                n += ed-beg;
            }
        }
        if(mov > 0){
            mov -= (mid+1);
            beg = mid;
        }
        if(mov > 0){
            n += mov;
        }

        //cout << n << endl;
        if(n%2){
            ret_val = ret_val | (one << i);
        }

    }
    return ret_val;
}

int main()
{
    LL A,B;
    cin >> A >> B;
    LL dis = B - A;
    LL do_s = cal(dis,A,B);
    //cout << do_s << endl;
    LL ret_val = do_s ^ A;

    cout << ret_val << endl;

    return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int a, b;
	cin >> a >> b;
	if ((a * b) % 2 != 0) {
		out("Yes");
	}
	else {
		out("No");
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int p = 998244353;
int n,k; int fac[1001000]; int inv[1001000]; int max(int a,int b){return a>b?a:b;} int del(int a,int b){return ((a-b)%p+p)%p;} int calc(int a,int b){return (a+b)%p;}
int Pow(int a,int x) { int now = 1; for(;x;x >>= 1,a = 1ll*a*a%p) if(x&1)now = 1ll*now*a%p; return now; }
int C(int i,int j) { if(j > i || j < 0) return 0; int now = 1ll*fac[i]*inv[j]%p; now = 1ll*now*inv[i-j]%p; return now; }
int main() {
	scanf("%d%d",&n,&k);
    int ans = 0;
    fac[0] = 1;inv[0] = 1;for (int i=1;i<=1000000;i++)fac[i] = 1ll*fac[i-1]*i%p,inv[i] = Pow(fac[i],p-2);
	for (int x=max((k+1)/2,n);x<=k;x++) { int y = (x*2==k?k-x-1:k-x),t = x-n+1; ans = calc(ans,del(C(x+y,x),C(x+y,y-t))); }
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 8064
{-# LANGUAGE OverloadedStrings #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.Map.Strict               as M
import           Data.Char
import Data.Bits


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las

solve :: Int -> [Int] -> Int
solve n as = 
    let 
        amap = IM.fromList $ zip [1..] as
        findRight total right
            | right > n = (total, right)
            | newTotal /= newXor = (total, right)
            | otherwise = findRight newTotal $ right + 1
            where
                newVal = amap IM.! right
                newTotal = total + newVal
                newXor = total `xor` newVal

        go (right, total, ans) left =
            let
                (newTotal, newRight) = findRight total right
                newNum = newRight - left
            in
                (newRight, newTotal - amap IM.! left, ans + newNum)
        (_, _, ans) = foldl' go (1, 0, 0) [1..n]
    in 
    ans

comb 0 xs = [[]]
comb _ [] = []
comb n (x:xs) = [x:y | y <- comb (n-1) xs] ++ comb n xs

main = do
    n <- readInt
    xs <- sort <$> readInts
    let (a:b:_) = drop (n `div` 2 - 1) xs
    print $ b - a






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

using namespace std;

const int N = 1e2+7;

int a, b;

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> a >> b;
    for (int i = 1; i <= 3; ++i) {
        if (a != i && b != i) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<set>
#include<map>
#include<utility>
#define ul unsigned long long int
#define ll long long int
#define MAX 1000000+1
using namespace std;
#define F first
#define S second
#define pi 2*acos(0.0)
#define PB push_back
#define Pp push
#define LSTAGE 1
int arr[200010];
ll bfs(vector<int> a[])
{
    queue<int>v;
    v.push(1);
    int t;
    arr[1] = 0;
    int x;
    while(v.size())
    {
        t = v.front();
        v.pop();
        if(arr[t]==2) return 1;
        for(int i= 0; i < a[t].size(); i++)
        {
            x = a[t][i];
            if(arr[x]==-1)
            {
                v.push(x);
                arr[x] = arr[t]+1;

            }
        }

    }
    return 0;

}


int main()
{
    ll n, m;
    cin >> n >> m;
    for(int i = 1; i <=n; i++)
        arr[i] = -1;
    vector<int> v[n+1];
    int t1, t2;


    for(int i = 0; i < m; i++)
    {
        cin >> t1 >> t2;
        v[t1].PB(t2);
        v[t2].PB(t1);
    }
    bfs(v);
    if(arr[n]==2) cout <<"POSSIBLE";
    else cout <<"IMPOSSIBLE";


    return 0;
}


Measured memory_bytes: 13168
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    C=[0]*9
    n=int(input())
    for a in map(int,input().split()):
        s=a//400
        if(s>=8): C[8]+=1
        else: C[s]+=1

    cnt=sum(1 for i in range(8) if(C[i]))
    print(max(1,cnt),cnt+C[-1])
resolve()

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,k;
int a[125];
bool win[125252];

int main(){
  scanf("%d%d",&n,&k);
  REP(i,n)scanf("%d",a+i);
  win[0] = false;
  FOR(i,1,k+1){
    REP(j,n){
      int v = a[j];
      if(i-v>=0 && !win[i-v]){
        win[i] = true;
        break;
      }
    }
  }
  puts(win[k] ? "First" : "Second");
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
typedef pair<int, int> P;
int cpair(vector<P>& hand){
  map<int, int> cnt;
  REP(i,hand.size()) cnt[hand[i].first]++;
  int res = 0;
  FORIT(it, cnt){
    if(it->second == 2) res++;
    else if(it->second == 4) res += 2;
  }
  return res;
}
bool three(vector<P>& hand){
  map<int, int> cnt;
  REP(i,hand.size()) cnt[hand[i].first]++;
  int res = 0;
  FORIT(it, cnt){
    if(it->second == 3) res++;
  }
  return (bool)res;
}
bool four(vector<P>& hand){
  map<int, int> cnt;
  REP(i,hand.size()) cnt[hand[i].first]++;
  int res = 0;
  FORIT(it, cnt){
    if(it->second == 4) res++;
  }
  return (bool)res;
}
bool specialstraight(vector<P>& hand){
  int specialcase[] = {1,10,11,12,13};
  REP(i,5)if(hand[i].first != specialcase[i]) return false;
  return true;
}
bool straight(vector<P>& hand){
  if(specialstraight(hand)) return true;
  REP(i,4)if(hand[i].first + 1 != hand[i+1].first) return false;
  return true;
}
bool flash(vector<P>& hand){
  REP(i,4)if(hand[i].second != hand[i+1].second) return false;
  return true;
}
int judge(vector<P>& hand){
  if(specialstraight(hand) && flash(hand)) return 8;
  if(straight(hand) && flash(hand)) return 7;
  if(four(hand)) return 6;
  if(cpair(hand) && three(hand)) return 5;
  if(flash(hand)) return 4;
  if(straight(hand)) return 3;
  if(three(hand)) return 2;
  if(cpair(hand) == 2) return 1;
  if(cpair(hand) == 1) return 0;
  return -1;
}
int main(){
  int v[4][13];
  int pt[9];
  int N;
  map<char, int> id;
  id['S'] = id.size() - 1;
  id['C'] = id.size() - 1;
  id['H'] = id.size() - 1;
  id['D'] = id.size() - 1;
  bool f = false;
  while(cin>>N){
    if(f) cout<<endl;
    else f = true;
    REP(i,4)REP(j,13)cin>>v[i][j];
    REP(i,9)cin>>pt[i];
    while(N--){
      vector<P> hand;
      REP(i,5){
        string s; cin>>s;
        P p;
        if(isdigit(s[0])) p.first = s[0] - '0';
        else if(s[0] == 'A') p.first = 1;
        else if(s[0] == 'J') p.first = 11;
        else if(s[0] == 'Q') p.first = 12;
        else if(s[0] == 'K') p.first = 13;
        else if(s[0] == 'T') p.first = 10;
        else assert(false);
        p.second = id[s[1]];
        hand.push_back(p);
      }
      sort(hand.begin(), hand.end());
      int point = 0;
      REP(i, 5) point += v[hand[i].second][hand[i].first-1];
      int power = judge(hand);
      //printf("%d:",power);
      //REP(i, 5) printf("%d,%d ", hand[i].first, hand[i].second); cout<<endl;
      if(power != -1) power = pt[power];
      else power = 0;
      cout<<point*power<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int dp[3010][3010] = {};

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t; cin >>s >> t;
    int slen = s.length();
    int tlen = t.length();
    REP(i,slen){
        REP(j,tlen){
            if(s[i] != t[j]){
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
            }
            else{
                dp[i+1][j+1] = max({dp[i][j+1],dp[i+1][j],dp[i][j]+1});
            }
        }
    }
    //cout << dp[slen][tlen] << endl;
    int sp = slen;
    int tp = tlen;

    //REP(i,slen+1){
    //    REP(j,tlen+1){
    //        cout << dp[i][j] << " ";
    //    }
    //    cout << endl;
    //}
    string ans;
    while(sp != 0 && tp != 0){
        if(dp[sp-1][tp] != dp[sp][tp] && dp[sp][tp-1] != dp[sp][tp]){
            //ans.pb(s[sp-1]);
            ans += s[sp-1];
            sp--;
            tp--;
        }
        else{
            if(dp[sp-1][tp] == dp[sp][tp]) sp--;
            else tp--;
        }
    }

    reverse(ans.begin(),ans.end());
    cout << ans << endl;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
const long INF=1000000000000000;

int main() {
    long A,B,C,D,E,F;
    cin>>A>>B>>C>>D>>E>>F;
    
    set<long> sugar,water;
    for(int c;c*C<=F;c++){
        for(int d=0;d*D<=F;d++){
            if(c*C+d*D<=F) sugar.insert(c*C+d*D);
        }
    }
    for(int a=0;a*100*A<=F;a++){
        for(int b=0;b*100*B<=F;b++){
            if(a*100*A+b*100*B<=F) water.insert(a*100*A+b*100*B);
        }
    }
    long anssw=1,anss=-1;
    for(auto itew=water.begin();itew!=water.end();++itew){
        auto ites=(--sugar.upper_bound(min(F-*itew,(*itew)/100*E)));
        
        if((*ites)*anssw>anss*((*itew)+(*ites))){
            anssw=(*ites)+(*itew);
            anss=(*ites);
        }
    }
    
    cout<<anssw<<" "<<anss<<endl;
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
dic, c = {}, 0
for i in range(N):
    b = min(a[i] // 400, 8)
    if b not in dic:
        dic[b] = 1
    if b == 8:
        c += 1
m, M = len(dic.keys()), len(dic.keys())
if c > 0:
    m = max(1, m - 1)
    M += c - 1
print(m, M)

Measured memory_bytes: 38384
#include <iostream>
#include <string.h>
#include <math.h>
#define M 100001
char str[M];
using namespace std;

int main()
{
    cin >> str;
    long int len = strlen(str);
    int alp[26] = {1};
    for(long int i = 0; i < len; i++)
    {
        int flag = (int)str[i];
        if( flag >= 97 || flag <= 122 ) alp[flag-97] = -1;
    }
    for(int i = 0; i < 26; i++)
    {
        if(alp[i] != -1) { cout << (char)(97+i) << endl; break; }
        else if(i == 25) cout << "None" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <complex>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(3);

    int n;
    cin >> n;
    while (n--)
    {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        int maxV = 0, minV = 0;
        int t = 1;
        int siz = s.size();

        for (int i = 0; i < siz; ++i)
        {
            
            minV = minV * 10 + s[i] - '0';
        }

        reverse(s.begin(), s.end());

        for (int i = 0; i < siz; ++i)
        {
            maxV = maxV * 10 + s[i] - '0';
        }
        cout << maxV - minV << endl;
    }
    return 0;
}


Measured memory_bytes: 2960
import scala.io.StdIn._
import scala.collection._

object Main {

  class Sieve(val n: Int){
    private[this] val top = (n - 3) / 2 + 1
    private[this] val sqrtLimit = (Math.sqrt(n).toInt - 3) / 2

    private[this] val cmpsts = new Array[Int]((top >>> 5) + 1)
    def isPrime(ci: Int): Boolean = (cmpsts(ci >>> 5) & (1 << (ci & 31))) == 0
    def notPrime(ci: Int): Unit = cmpsts(ci >>> 5) |= 1 << (ci & 31)

    def next(i: Int): Int = if((i > top) || isPrime(i)) 2 * i + 3 else next(i + 1)

    def exec: Iterator[Int] = {
/*
      for{
        i <- 0 to sqrtLimit
        if isPrime(i)
        j <- Range(((2 * i + 3)*(2 * i + 3)-3)/2, top, (2 * i + 3))
      } notPrime(j)
*/
      /*
      (0 to sqrtLimit).map{ i =>
        val p = 2 * i + 3
        if(isPrime(i))Range((p*p-3)/2, top, p).map{notPrime}
      }
      */

      (0 to sqrtLimit).withFilter(isPrime).map { i =>
        val p = 2 * i + 3
        Range((p*p-3)/2, top, p).map(notPrime)
      }

      if(n==2)Iterator.single(2)
      else Iterator.single(2) ++ Iterator.iterate(3)(p => next((p - 1) / 2)).takeWhile(_ <= n)
    }
  }

  def loop(s: String){
    if(s != null){
       val Array(n,_*) = s.split(" ").map(_.toInt)
       if(n<2) println(0)
       else println(new Sieve(n).exec.size)
       loop(readLine)
    }
  }

  def main(args: Array[String]): Unit = loop(readLine)
}

Measured memory_bytes: 306480
import java.util.*;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if((a*b)%2==0)System.out.println("Even");
		else System.out.println("Odd");
		sc.close();
	}
}

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


int main(){
	int n;
	cin >> n;
	int b = INT_MAX;
	int ans = 0;
	int temp_ans = 0;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		if(x <= b){
			if(b != INT_MAX){
			  temp_ans++;
			}
			b = x;
		}
		else {
			b = x;
			ans = max(ans, temp_ans);
			temp_ans = 0;
		}
	}
	ans = max(ans, temp_ans);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    long N;
    scanf ("%ld",&N);
    int i;
    char bits[40];
    long sum = 0;
    int maxbit = 0;
    for ( i = 0 ; 1 ; i ++) //終了条件に意味なし
    {
        if ( (N - sum) % ((long)1 << (i + 1))  == 0 )
        {
            bits[i] = 0;
            //printf("%dketameha0\n",i);
        }
        else
        {
            //printf("%dketameha1\n",i);
            bits[i] = 1;
            if ( i % 2 == 0 )
            {
                sum += ((long)1 << i);
            }
            else
            {
                sum -= ((long)1 << i);
            }
        }
        
        if ( sum == N)
            break;
        
        maxbit ++;
    }
    
    for (i = maxbit ; i >= 0 ; i -- )
    {
        printf("%s", bits[i] ? "1" : "0");
    }
    printf("\n");
    return 0;
    
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353LL
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
#include <boost/multiprecision/cpp_int.hpp>

namespace mp = boost::multiprecision;
int main() {
	mp::cpp_int a, b, x;
	cin >> a >> b >> x;
	if (x < a) {
		cout << x%MAX_MOD << endl;
		return 0;
	}
	mp::cpp_int ans = 0;
	mp::cpp_int nya = (x - a) / (a - b);
	nya++;
	ans = (nya%MAX_MOD) * (a%MAX_MOD);
	ans %= MAX_MOD;
	x -= nya * (a-b);
	cout << (ans%MAX_MOD + x%MAX_MOD)%MAX_MOD << endl;
	return 0;
}


Measured memory_bytes: 3252