akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <functional>
#include <vector>

using namespace std;
int main()
{
	long long Ans = 0;
	long long temp = 0;
	long long N = 0;
	string S;

	cin >> N;
	cin >> S;

	char a[2];
	char b[2];

	long long Ecounter = 0;
	long long Wcounter = 0;

	for (int j = 1; j < N; j++) {
		if (S[j] == 'E') {
			Ecounter++;
		}
	}

	Ans = Ecounter + Wcounter;
	temp = Ans;

	for (int i = 0; i < N; i++) {

		temp = Ecounter + Wcounter;
		if (temp < Ans) {
			Ans = temp;
		}

		a[0] = S[i];
		b[0] = S[i + 1];

		if (a[0] == 'W') {
			Wcounter = Wcounter + 1;
			
		}
		if (b[0] == 'E') {
			Ecounter--;
			
		}

	}

	cout << Ans;

	return 0;
}

Measured memory_bytes: 900
import java.util.Arrays;
import java.util.Scanner;

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

        int n = sc.nextInt();
        int[] l = new int[n];

        Arrays.setAll(l, i->sc.nextInt());
//        for (int i=0; i<n; i++) l[i] = sc.nextInt();

        Arrays.sort(l);

        long ans = 0;

        for (int i=0; i<n-2; i++){
            for (int j=i+1; j<n-1; j++){
                for (int k=j+1; k<n; k++){
                    if (l[i]+l[j]>l[k] && l[j]-l[i]<l[k]){
                        ans++;
                    }else {
                        break;
                    }
                }
            }
        }
        System.out.println(ans);
    }

}


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

using namespace std;
 
string key[] = {"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
 
int main(){
    int n;
     
    cin >> n;
    while(n--){
        string str,tmp = "";
        cin >> str;
 
        int cnt = 0 ,t = 0;
        string s = "";
        for(int i = 0 ; i < str.size() ; i++){
            if(str[i]=='0'){
                if(!cnt) continue;
                tmp += key[t][cnt-1];
                t = cnt = 0;
            }
            else{
                t = str[i]-'0';
                if((cnt>2)&&(t==2||t==3||t==4||t==5||t==6||t==8)) cnt -= 3;
                else if((cnt>3)&&(t==7||t==9)) cnt -= 4;
                else if((cnt>4)&&t==1) cnt -= 5;
                cnt++;
            }
        }
        cout << tmp << endl;
    }
     
    return 0;
}

Measured memory_bytes: 3168
def ans(n,k):
  s=str(n)
  a=len(s)
  b=int(s[0])
  if(n==0):
    return 0
  elif(k==1):
    return 9*(a-1)+b
  elif(k==2):
    return int(81*(a-1)*(a-2)/2)+9*(b-1)*(a-1)+ans(n-b*10**(a-1),1)
  else:
    return int(729*(a-1)*(a-2)*(a-3)/6)+int(81*(b-1)*(a-1)*(a-2)/2)+ans(n-b*10**(a-1),2)

N=int(input())
K=int(input())
print(ans(N,K))

Measured memory_bytes: 3064
#include <cstdio>
#include <cmath>
using namespace std;
int fastin(){
	register int i; register char ch;
	while (ch = getchar(), ch < '0' || ch > '9');
	i = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9') i = i * 10 + ch - '0';
	return i;
}
int main(){
	register int i;
	register long long a, b;
	scanf("%lld %lld", &a, &b);
	for (i = 1; a <= b; ++i) a <<= 1;
	printf("%d", i - 1);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define ll long long
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e - 9
#define all(x) (x).begin(), (x).end()
using namespace std;
inline ll read()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == ' - ') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int MOD = 1e9  + 7;
int n, m, a[200010], b[200010], A = 0, B = 0;
int main()
{
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);sort(a+1,a+1+n);
    for (int i=1;i<=m;i++) scanf("%d",&b[i]);sort(b+1,b+1+m);
    for (int i=1;i<n;i++) A=(1LL*(a[i+1]-a[i])*i%MOD*(n-i)+A)%MOD;
    for (int i=1;i<m;i++) B=(1LL*(b[i+1]-b[i])*i%MOD*(m-i)+B)%MOD;
    printf("%lld\n",1ll*A*B%MOD);
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

ll v[20];

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int N; cin >> N;

    F0R(i,N) {
        ll x; cin >> x;

        if (x <= 399)       v[1]++;
        else if (x <= 799)  v[2]++;
        else if (x <= 1199) v[3]++;
        else if (x <= 1599) v[4]++;
        else if (x <= 1999) v[5]++;
        else if (x <= 2399) v[6]++;
        else if (x <= 2799) v[7]++;
        else if (x <= 3199) v[8]++;
        else v[10]++;
    }


    ii res = {0,0};
    FOR(i,1,9) {
        if (v[i]) res.f++;
    }

    res.s = min(1000LL,res.f+v[10]);
    if (res.f == 0) res.f++;
    cout << res.f << " " << res.s << "\n";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
// --------------------------------------------------------
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c), 0)
#define SUMLL(c) accumulate(ALL(c), 0LL)
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int,int>;
using VP = vector<P>;
using VVP = vector<VP>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
static const double EPS = 1e-10;
static const double PI  = acos(-1.0);
static const ll MOD = 1000000007;
// static const ll MOD = 998244353;
static const int INF = 1 << 30;
// static const ll INF = 1LL << 62;
// --------------------------------------------------------


using mint = modint998244353;

int N;
static const int MAX_N = 200000;
vector<vector<mint>> T(10, vector<mint>(MAX_N + 1, 0));

// lazy segtree
struct S {
    mint a;
    int l, r;
};
struct F {
    int D;
};
S op(S x, S y) { return S{x.a + y.a, min(x.l, y.l), max(x.r, y.r)}; }
S e() { return S{0, INF, -INF}; }
S mapping(F f, S x) {
    if (f.D == 0) return x;
    return S{T[f.D][N+1-x.l] - T[f.D][N+1-x.r - 1], x.l, x.r};
}
F composition(F f, F g) {
    if (f.D == 0) {
        return g;
    } else if (g.D == 0) {
        return f;
    }
    return f;
}
F id() { return F{0}; }
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
 
    int Q; cin >> N >> Q;
    vector<S> A(N); REP(i,N) A[i] = S{mint(10).pow(N-i-1),i+1,i+1};
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(A);

    // cumsum preprocessing
    FOR(d,1,10) FOR(i,1,MAX_N+1) T[d][i] = T[d][i-1] + mint(d) * mint(10).pow(i-1);

    int L, R, D;
    REP(_, Q) {
        cin >> L >> R >> D;
        seg.apply(L-1, R, F{D});
        cout << seg.all_prod().a.val() << '\n';
    }
 
    return 0;
}

Measured memory_bytes: 20704
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}

int D;
int N = 26;
vi c;
vvi s;
vi ans;
vi las;



pii rec(int n, int dd, vi lass){
    
    if(dd == D || n == 3) return {0,1};
    
    int los = 0;
    rep(i,N) los += c[i]*(dd-lass[i]);
    int res = -infi;
    int an = 1;
    
    rep(i,N){
        vi la = lass;
        int ddd = s[dd][i]-los+c[i]*(dd-lass[i]);
        la[i] = dd;
        int da = ddd+rec(n+1,dd+1,la).fi;
        if(chmax(res,da)) an = i+1;
        
    }
    
    
    return {res,an};
    
}



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

    cin >> D;
    c.resize(N);
    s.resize(D, vi(N));
    
    in(N,c);
    rep(i,D) rep(j,N) cin >> s[i][j];
    
    ans.resize(D);
    las.assign(N,-1);
    
    
    
    
    
    rep(d,D){
        ans[d] = rec(0,d,las).se;
        las[ans[d]-1] = d;
    }









    
    
    
    rep(i,D) cout << ans[i] << endl;
    
    

    return 0;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
string x ;
  for (int i=0;i<N;i++){
  cin>>x;
if(x=="Y"){cout<<"Four"<<endl;
          break;}
    else if (x!="Y"&&i==N-1){
    cout<<"Three"<<endl;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
#define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        2e18
 #define sm         -1e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
   
    #endif
}




void solve()
{
 
int n;
cin >> n ;

set<string>st;
for(int i=0;i<n;i++)
{
  string s;
  cin>>s;
  st.insert(s);
}

cout<<sz(st);
}

int32_t main()
{
  pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    // cout << "Time taken by function: "
    //      << duration.count() << " microseconds" << endl; 

 }


Measured memory_bytes: 19248
//https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/5/DPL_5_F

#include <bits/stdc++.h>

using namespace std;

long long MOD = 1e9 + 7;

long long f[1010][1010];

int main() {
    long long n;//ボール
    long long k;//箱
    cin >> n >> k;

    f[0][0] = 1;
    for (int i = 1; i <= 1000; ++i) {
        f[i][0] = 0;
        f[i][i] = 1;
    }

    for (long long i = 1; i <= 1000; ++i) {
        for (long long j = 1; j <= 1000; ++j) {
            f[i][j] = (f[i - 1][j - 1] + j * f[i - 1][j] + MOD) % MOD;
        }
    }

    long long ans = 0;
    for (int i = 0; i <= k; ++i) {
        ans = (ans + f[n][i] + MOD) % MOD;
    }
    cout << ans << endl;
    return 0;
}

/*
 * 第2種スターリング数を使う。
 * 区別できるn個のボールを区別できないi個の箱（空箱なし）
 * に入れる方法をf[n][i]とする。
 * f[n][k]=f[n-1][k-1]+k*f[n-1][k]
 * i=1..kの和が答え。
 * 
 */


Measured memory_bytes: 11012
import sys
input = sys.stdin.readline
#input = sys.stdin.buffer.readline

# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np


def main():
	xy=list(map(int,input().split()))
	ans=0
	li=[0,3,2,1]

	for i in xy:
		if i<=3:
			ans+=li[i]

	if sum(xy)==2:
		ans+=4

	print(ans*100000)







if __name__ == "__main__":
	main()


Measured memory_bytes: 3060
S = gets.chomp
T = gets.chomp

offset = (0 .. S.size - T.size).reverse_each.find do |offset|
  found = T.size.times.all? do |i| 
    S[offset + i] == '?' || S[offset + i] == T[i]
  end
end
if offset
  z = S.tr('?','a')
  z[offset,T.size] = T
  puts z
else
  puts "UNRESTORABLE"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int D, N;
	cin >> D >> N;
	
	int cur = 1, c = 0;
	while (true) {
		int t = cur, ct = 0;
		while (t % 100 == 0) {
			t /= 100;
			++ct;
		}
		if (ct == D) {
			++c;
			if (c == N) {
				cout << cur << endl;
				return 0;
			}
		}
		++cur;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 10010;
const int MAXM = 1000010;
const int MAXK = 110;
const int MAXQ = 200010;

string s;
int k, n;
ll dp[MAXN][MAXK][2];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> s >> k;
    n = SZ(s);
    s = " " + s;
    dp[0][0][1] = 1;
    FOR(i,0,n-1) {
        FOR(j,0,k-1) {
            FOR(l,0,1) 
                FOR(p,0,9) {
                    if (l) {
                        if (p > s[i+1] - '0') continue;
                        if (p < s[i+1] - '0') dp[i+1][(j+p) % k][1-l] = (dp[i+1][(j+p) % k][1-l] + dp[i][j][l]) % MODBASE;
                        else dp[i+1][(j+p) % k][l] = (dp[i+1][(j+p) % k][l] + dp[i][j][l]) % MODBASE;
                    }
                    else {
                        dp[i+1][(j+p) % k][l] = (dp[i+1][(j+p) % k][l] + dp[i][j][l]) % MODBASE;
                    }
                }
        }
    }
    cout << (dp[n][0][1] + dp[n][0][0] - 1 + MODBASE) % MODBASE;
    return 0;
}


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

int main() {
	ios::sync_with_stdio(false);

	int x;
	cin >> x;

	cout << (x / 500) * 1000 + ((x % 500) / 5) * 5 << endl;			
	return 0;
}

Measured memory_bytes: 256
def ca():
    x,y,z,k=map(int,input().split())
    a=[int(i)for i in input().split()]
    b=[int(i)for i in input().split()]
    c=[int(i)for i in input().split()]
    c.sort(reverse=True)
    AB=[i+j for i in a for j in b]
    AB.sort(reverse=True)
    ans=[i+j for i in AB[:k]for j in c]
    ans.sort(reverse=True)
    for i in ans[:k]:
        print(i)
    exit()
print(ca())

Measured memory_bytes: 142668
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << x << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep (i, n) cin >> h[i];
  sort(all(h));
  cout << distance(lower_bound(all(h), k), h.end()) << endl;
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  ll a = count(s.begin(),s.end(),'a');
  ll b = count(s.begin(),s.end(),'b');
  ll c = count(s.begin(),s.end(),'c');
  
  if( abs(a-b) <= 1 && abs(a-c) <= 1 && abs(b-c) <= 1 ){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 512
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <bitset>

using namespace std;

typedef long long int ll;
typedef vector<ll> vl;
typedef vector<string> vs;


int main(){
	ll a, b, c, a1, b1, c1, ans;
	cin >> a >> b >> c;
	ans = 0;

	while (1) {
		if ((a % 2 == 1) | (b % 2 == 1) | (c % 2 == 1)) {
			cout << ans << endl;
			break;
		}
		if (a == b & b == c) {
			cout << "-1" << endl;
			break;
		}
		ans ++;
		a1 = a;
		b1 = b;
		c1 = c;
		a += b1 / 2 + c1 / 2;
		b += a1 / 2 + c1 / 2;
		c += a1 / 2 + b1 / 2;
	}
	
	return 0;

}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int n,k;
    cin>>n>>k;
    if(n<k)
	cout<<min(n,k-n);
    else
    {
	if(n==k)
	    cout<<0;
	else
	{
	    if(n%k==0)
		cout<<0;
	    else
	    {
		 n = n%k;
		 cout<<min(n,abs(n-k));
	    } 
	}
    
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val s = cin.nextLong()
    val x1: Long = 1000000000

    var y2: Long = s / x1
    if (s % x1 != 0.toLong()) {
        y2 += 1
    }
    val p = x1 * y2 - s

    val x2 = p
    val y1: Long = 1

    print(0)
    print(" ")
    print(0)
    print(" ")
    print(x1)
    print(" ")
    print(y1)
    print(" ")
    print(x2)
    print(" ")
    print(y2)
    println()
}

Measured memory_bytes: 29608
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;

int N, M;

int main() {
    cin >> N >> M;
//    vector<pair<int, int>> A(N + M);
//    vector<int> par(N), level(N);
    map<int, map<int, bool>> par, child;
    for (int i = 0; i < N + M; i++) {
        int p, c;
        cin >> p >> c;
        par[c][p] = true;
        child[p][c] = true;
    }
    queue<int> root;
    vector<int> ans(N + 1);
    for (int i = 1; i < N + 1; i++) {
        if (par[i].size() == 0) {
            root.push(i);
            ans[i] = 0;
            break;
        }
    }
    while (!root.empty()) {
        int r = root.front(); root.pop();
        for (auto itr = child[r].begin(); itr != child[r].end() ; itr++) {
            int f = (*itr).first;
            if (par[f].size() == 1) {
                ans[f] = r;
                root.push(f);
            } else {
                par[f].erase(r);
            }
        }
    }
    
    for (int i = 1; i < N + 1; i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 29312
#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<int,int>
#define vint vector<int>
#define pb push_back
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
int read(){
	int g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const int N=30;
char s[N];
int n,vis[N];
namespace solve1{
	void Main(){
		for(int i=1;i<=n;i++)cout<<s[i],vis[s[i]-'a']=1;
		for(int i=0;i<26;i++)if(!vis[i]){cout<<(char)(i+'a');break;}
	}
}
namespace solve2{
	void Main(){
		vis[s[n]-'a']=1;	
		for(int i=n-1;i>=1;i--){
			for(int j=s[i]-'a'+1;j<26;j++)if(vis[j]){
				s[i]=(char)(j+'a');
				for(int k=1;k<=i;k++)cout<<s[k];
				return void();
			}vis[s[i]-'a']=1;
		}puts("-1");
	}
}
signed main(){
	scanf("%s",s+1);n=strlen(s+1);
	if(n<26)solve1::Main();
	else solve2::Main();
	return signed();
}

Measured memory_bytes: 3716
s = input()
if len(s) % 2 == 1:
    #奇数
    a = s[:(len(s)-1)//2]
    b = s[(len(s)+1)//2:]
else:
    #偶数
    a = s[:len(s)//2]
    b = s[len(s)//2:]
b = b[::-1]
#print(a,b)
c = 0
for i in range(len(s)//2):
    if a[i] != b[i]:
        c += 1
print(c)


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

int main()
{
    int H, W, h, w;
    cin >> H >> W;
    cin >> h >> w;
    cout << (H - h) * (W - w) << endl;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	string S; cin >> S;
	int cnt = 0;
	rep(i, S.size()) if (S[i] == 'o') cnt++;
	cout << (cnt + 15 - S.size() > 7 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#define NDEBUG
NDEBUG


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <queue>
#include <random>


using namespace std;

template<class T>
using vec = std::vector<T>;


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


// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END


// Section with adoption of array and vector algorithms.


//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//
//template <class T> using StdTree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    template<int N>
    struct bytetype {
        
    };

    
    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}

template<class T>
vector<T> next_vec(istream& in, size_t n) {
  vector<T> ret(n);
  for (size_t i = 0; i < n; ++i) {
    ret[i] = next<T>(in);
  }
  return ret;
}


void solve(istream& in, ostream& out) {
  auto n = next<int>(in);
  auto k = next<int>(in);
  auto a = next_vec<int>(in, n);
  vec<int> win(k + 1, -1);

  function<int(int)> rec = [&] (int x) -> int {

    if (x < a[0]) {
      return 0;
    }
    auto& res = win[x];
    if (res != -1) return res;
    res = 0;
    FOR(i, n) {
      if (x >= a[i]) {
        if (!rec(x - a[i])) {
          res = 1;
          return res;
        }
      }
    }
    return res;
  };

  if (rec(k)) {
    out << "First\n";
  } else {
    out << "Second\n";
  }

}

//#include <fstream>


int main() {
//  ifstream fin("bridges.in");
//  ofstream fout("bridges.out");
    solve(cin, cout);
//  solve(fin, fout);
    return 0;
}



Measured memory_bytes: 6912
n, x = map(int, input().split())
A = sorted([int(i) for i in input().split()], reverse=True)
B = [abs(A[0] - x)]

for i in range(n-1):
    B.append(A[i] - A[i+1])
    
def gcd(x, y):
    while y > 0:
        x, y = y, x % y
    return x

for i in range(n-1):
    B[i+1] = gcd(B[i], B[i+1])
    
print(B[-1])

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

int m[60][60];
int a[4] = {1, -1, 0, 0};
int b[4] = {0, 0, 1, -1};
int main(){
  int h, w; cin >> h >> w;
  string s[51];
  for (int i = 0; i < h; i++) {
    cin >> s[i];
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') m[i+1][j+1] = 1;
    }
  }
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      if (m[i][j] == 1) {
        for (int u = 0; u < 4; u++) {
          if (m[i+a[u]][j+b[u]] == 1) break;
          if (u == 4 - 1) {
            printf("No\n");
            return 0;
          }
        }
      }
    }
  }
  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 256
from collections import deque
S = deque(list(input()))
Q = int(input())
f = 0
for _ in range(Q):
  a, *b = input().split()
  f += int(a)
  if a == "2":
    if (int(b[0]) + f) % 2 == 1 :
      S.appendleft(b[1])
    else:
      S.append(b[1])
D = list(S)
print ("".join(D) if f % 2 == 0 else "".join(D[::-1]))

Measured memory_bytes: 10340
import heapq
import sys
input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    Q = []
    for _ in range(N):
        a, b = map(int, input().split())
        heapq.heappush(Q, [a, b])
    
    ans = 0
    P = []
    for i in range(1, M+1):
        if len(Q)!=0:
            a, b = heapq.heappop(Q)
            while a==i:
                heapq.heappush(P, [b*(-1), a])
                if len(Q)==0:
                    break
                a, b = heapq.heappop(Q)
            heapq.heappush(Q, [a, b])
        if len(P)!=0:
            b, a = heapq.heappop(P)
            ans += b*(-1)
    
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 20076
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <numeric>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>
#include <cctype>
#include <string>
constexpr long long int MOD = 1000000007LL;
long long int search(const int s, const int t, const std::vector<int>& s_list, const std::vector<int>& t_list, std::vector< std::vector<long long int>>& memo) {
	if (s >= s_list.size() || t >= t_list.size()) return 1;
	else if (memo[s][t] >= 0) return memo[s][t];
	else if (s_list[s] == t_list[t]) return memo[s][t] = (search(s + 1, t, s_list, t_list, memo) + search(s, t + 1, s_list, t_list, memo)) % MOD;
	else return memo[s][t] = (search(s + 1, t, s_list, t_list, memo) + search(s, t + 1, s_list, t_list, memo) - search(s + 1, t + 1, s_list, t_list, memo) + MOD) % MOD;
}
int main() {
	int n, m; std::cin >> n >> m;
	std::vector<int> s_list(n), t_list(m);
	for (auto& s : s_list) std::cin >> s;
	for (auto& t : t_list) std::cin >> t;
	std::vector<std::vector<long long int>> memo(n, std::vector<long long int>(m, -1));
	std::cout << search(0, 0, s_list, t_list, memo) << std::endl;
}


Measured memory_bytes: 33536
#include <bits/stdc++.h>
const int N=2e5+5,INF=2e9;
using namespace std;
template<typename tp>inline void r(tp &n){
	n=0;char c=getchar();
	while(!isdigit(c)) c=getchar();
	while( isdigit(c)) n=n*10+c-48,c=getchar();	
}
int main(){
	
	int n;
	r(n);int l=0,cnt=0;
	if((n&1)==0||(n%5==0)) return 0*puts("-1");
	while(true){
		++cnt;
		l=(l*10+7)%n;
		if(!l) {printf("%d\n",cnt);return 0;}	
		if(cnt>19260817) break;
	}
	puts("-1");
	return 0;
}


Measured memory_bytes: 3720
from math import gcd

from math import factorial as f

from math import ceil, floor, sqrt
import math

import bisect
import re
import heapq

from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

yes = "Yes"
no = "No"


def main():
    n = ii()
    l = li()
    cnt = 0
    for i in range(n):
        for j in range(i + 1, n):
            for k in range(j + 1, n):
                if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]:
                    continue
                if l[i] + l[j] <= l[k] or l[i] + l[k] <= l[
                        j] or l[k] + l[j] <= l[i]:
                    continue
                cnt += 1
    print(cnt)


main()


Measured memory_bytes: 10024
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int a=scan.nextInt();
        int b=scan.nextInt();
        System.out.print(a*b);
        System.out.print(" ");
        System.out.println(2*(a+b));
    }
}


Measured memory_bytes: 26412
while True:
    n,x=map(int,input().split())
    if (n,x)==(0,0):
        break
    ans=0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i+j+k==x:
                    ans+=1
    print(ans)


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

int main() {
  int n, m;
  cin >> n >> m;
  map<int, vector<int>> child;
  rep(i, n) child[i].push_back(i);
  map<int, int> parent;
  rep(i, n) parent[i] = 0;
  int x, y;
  rep(i, m) {
    cin >> x >> y;
    x--; y--;
    parent[y]++;
    child[x].push_back(y);
  }
/*  rep(i, n) {cout << i << " " << parent[i] << endl;
             rep(j, child[i].size()) cout << child[i][j];
             cout << endl;}*/
  vector<P> dp(n);
  queue<int> nodes;
  rep(i, n) if (parent[i] == 0) nodes.push(i);
  rep(i, n) {dp[i].first = 0; dp[i].second = 0;}
/*    cout << "d "; rep(l, n) cout << dp[l].first; cout << endl;
    cout << "c "; rep(l, n) cout << dp[l].second; cout << endl;
    cout << "p "; rep(l, n) cout << parent[l]; cout << endl;
    cout << "ch"; rep(l, n) cout << child[l].size()-1; cout << endl;*/
  while (nodes.size() > 0) {
    int j = nodes.front();
    nodes.pop();
    dp[j].second = 1;
    if (child[j].size() > 1) {
//      cout << "ch " << j << " " << child[j].size() << endl;
      rep(k, child[j].size()-1) {
//        cout << j << " " << child[j][k+1] << endl;
        dp[child[j][k+1]].first = max(dp[j].first + 1, dp[child[j][k+1]].first);
        parent[child[j][k+1]]--;
        if (parent[child[j][k+1]] == 0) nodes.push(child[j][k+1]);
      }
    }
  }
  
  int max = 0;
  rep(i, n) if (max < dp[i].first) max = dp[i].first;
  cout << max << endl;
}


Measured memory_bytes: 17024
a, b, c = input().split()
if int(a) < int(b):
    if int(b) < int(c):
        print(a, b, c)
    else:
        if int(a) < int(c):
          print(a, c, b)
        else:
          print(c, a, b)
else:
    if int(a) > int(c):
      if int(b) > int(c):
        print(c, b, a)
      else: 
        print(b, c, a)
    else:
      print(b, a, c)


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

int main(){
	int n, x, counter;

    cin >> n >> x;
    counter = 0;

	do{
	  for (int i = 1; i <= n-2; i++){
        for(int j = i+1; j <= n-1; j++){
      	  for (int k= j+1; k <= n; k++){
      		if (i + j + k == x){
      			counter++;
      		}
      	  }
        }
      }
       
      cout << counter << endl;
      cin >> n >> x;
      counter = 0;
    }while(n != 0 || x != 0);
}


Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	var s string
	x := 0
	max := 0

	scanner.Scan()
	scanner.Scan()
	s = scanner.Text()

	for _, c := range s {
		if c == 'I' {
			x++
		} else {
			x--
		}

		if x > max {
			max = x
		}
	}

	fmt.Println(max)
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 3 * 105000;

int p;
int n;
int a[MAXN];
pair<int, int> twoMax[MAXN];

void update(pair<int, int> &p, int x) {
  if (x == -1) {
    return;
  }
  if (p.first == -1 || a[x] > a[p.first]) {
    p.second = p.first;
    p.first = x;
  } else if (x != p.first && (p.second == -1 || a[x] > a[p.second])) {
    p.second = x;
  }
}

int main() {

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

  int ans = 0;
  twoMax[0] = {0, -1};
  for (int i = 1; i < n; i++) {
    twoMax[i] = {i, -1};
    for (int j = 0; j < 18; j++) {
      if (i & (1 << j)) {
        int go = i ^ (1 << j);
        update(twoMax[i], twoMax[go].first);
        update(twoMax[i], twoMax[go].second);
      }
    }
    ans = max(ans, a[twoMax[i].first] + a[twoMax[i].second]);
    printf("%d\n", ans);
  }

  return 0;
}


Measured memory_bytes: 6272
#include<stdio.h>
#include<string.h>
int main(){
    int i, j;
    int n;
    int a, b;
    char str[1000];
    char op[10];
    char p[1000];
    scanf("%s", str);
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%s %d %d", op, &a, &b);
        if(strcmp(op, "print")==0){
            for(j=a; j<=b; j++){
                printf("%c", str[j]);
            }
            printf("\n");
        }
        else if(strcmp(op, "reverse")==0){
            char tmp;
            int l=b;
            for(j=a;j<=(b+a)/2;j++){
                
                    tmp=str[j];
                    str[j]=str[l];
                    str[l]=tmp;
                    l--;
                }
        }
        else if(strcmp(op, "replace")==0){
            int k=0;
            scanf("%s", p);
            for(j=a; j<=b; j++)str[j]=p[k++];
        }
    }
    
    return 0;
}

Measured memory_bytes: 2604
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int t = Integer.parseInt(sc.next());
        List<Integer> list = new ArrayList<>();
        Map<Integer, Integer> map = new TreeMap<>();
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int a = Integer.parseInt(sc.next());
            list.add(a);
            min = Math.min(min, a);
            int temp = a - min;
            map.merge(temp, 1, Integer::sum);
        }
        Object[] ary = map.keySet().toArray();
        System.out.println(map.get(ary[ary.length - 1]));
    }
}

Measured memory_bytes: 52496
# ABC 122 C

import bisect

N, Q = map(int, input().split())

S = input()

indexes = []  # 'AC' の開始位置

startPos = 0

while True:
    index = S.find('AC', startPos)
    if index != -1:
        indexes.append(index)
        startPos = index + 2
    else:
        break

for i in range(Q):
    l, r = map(int, input().split())
    i = bisect.bisect_left(indexes, l-1)
    j = bisect.bisect_left(indexes, r-1)
    print(j-i)


Measured memory_bytes: 5768
//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<cstring>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<iterator>
#include<algorithm>
#include<bitset>

#define Filein(N) freopen("N", "r", stdin);
#define Fileout(N) freopen("N", "w", stdout);
#define sci(x) scanf("%d", &x)
#define sci2(x,y) scanf("%d%d", &x,&y)
#define scll2(x,y) scanf("%lld%lld",&x,&y)
#define scll(x) scanf("%lld",&x)
#define scd(x) scanf("%lf", &x)
#define scstr(x) scanf("%s", x)
#define pfi(x) printf("%d", x)
#define pfll(x) printf("%lld", x)
#define pfd(x) printf("%f", x)
#define pfstr(x) printf("%s", x)
#define ps printf(" ")
#define pn printf("\n")
#define pfdt printf("..")

#define For(var,start,end) for(int var=start; var<=end;i++)
#define rFor(var,start,end) for(int var=start; var>=end; i--)
#define TestCase int testcase, cs=1; cin>>testcase;while(testcase--)

#define mkp make_pair
#define pb push_back
#define fi first
#define se second

#define px(x) cout<<"X -> "<<x<<endl;
#define py(x) cout<<"Y = "<<x<<endl;
#define pz(x) cout<<"Z >> "<<x<<endl;
#define pstr(x) printf("%s\n",x);

using namespace std;
using ll = long long;
using vi = vector <int>;
using mpii = map<int,int>;
using si = set<int>;
using sll = set<ll>;
using vll= vector<ll>;

#define INF 1000000000
#define LINF 4000000000000000000
#define pi  (2*acos(0))
#define Mod 1000000007

  int ar[100100];

 int main(){

  ll n,p,q,a,b,sum=0;

   cin>>n;
   For(i,0,n-1){
   scll(p);
   sum+=p;
   ar[p]++;
   }

  scll(q);
  while(q--){
    scll2(a,b);
   ll dif = b-a;
   ll to = ar[a]*dif;
   ar[b]+=ar[a];
   ar[a] = 0;
   sum+=to;
    pfll(sum);pn;


  }






    return 0;
}







Measured memory_bytes: 4080
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        int[] weight = new int[N];
        long[] value = new long[N];
        for(int i = 0; i < N; i++) {
            weight[i] = sc.nextInt();
            value[i] = sc.nextLong();
        }
        long[][] dp = new long[N+1][W+1];
        dp[0][0] = 0;
        for(int i = 1; i <= N; i++) {
            for(int j = 0; j <= W; j++) {
                if(j - weight[i-1] >= 0) dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j-weight[i-1]] + value[i-1]);
                else dp[i][j] = dp[i-1][j];
            }
        }
        System.out.println(dp[N][W]);
    }
}


Measured memory_bytes: 126932
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong bignum = 1_000_000_007;
alias Cake = Tuple!(long, "beauty", long, "tasty", long, "popular");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    long n, d;
    scan(n, d);
    long monitor = 2 * d + 1;
    ((n + monitor - 1)/ monitor).writeln();
}

Measured memory_bytes: 256
#include <cstdio>

#define max(a, b) (a<=b ? b : a)

int main()
{
  int a=0;
  int b=0;
  scanf("%d %d", &a, &b);
  printf("%d", max((a + max(a-1, b)), (b + max(a, b-1))));
  return 0;
}


Measured memory_bytes: 128
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double a = (double)sc.nextInt();
        double b = (double)sc.nextInt();
        double x = (double)sc.nextInt();

        if (x <= a*a*b/2) {
            double rad = Math.atan( (2*x/(a*b)) / b );
            System.out.println(90 - Math.toDegrees(rad));
        } else {
            double rad = Math.atan( (b - (2*x/(a*a) - b))  / a );
            System.out.println(Math.toDegrees(rad));
        }
    }
}


Measured memory_bytes: 23124
from collections import deque
N, M, r = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    s, t, d = map(int, input().split())
    G[s].append((t, d))

INF = 10**18
def SPFA(N, G, s):
    dist = [INF] * N
    cont = [0] * N
    cnts = [0]* N

    dist[s] = 0
    cont[s] = 1
    cnts[s] += 1
    que = deque([s])
    su = s; num = 1
    while que:
        v = que.popleft()
        cont[v] = 0
        d = dist[v]
        su -= d
        num -= 1
        for w, c in G[v]:
            r = d + c
            if r < dist[w]:
                if not cont[w]:
                    cnts[w] += 1
                    if N <= cnts[w]:
                        return None
                    if que and r < que[0]:
                        que.appendleft(w)
                    else:
                        que.append(w)
                    cont[w] = 1
                    su += r
                    num += 1
                    dist[w] = r
                    while su < dist[que[0]]*num:
                        que.append(que.popleft())
                else:
                    su += r - dist[w]
                    dist[w] = r
    return dist
dist = SPFA(N, G, r)
if dist is None:
    print("NEGATIVE CYCLE")
else:
    for i in range(N):
        print(dist[i] if dist[i] < INF else "INF")


Measured memory_bytes: 6568
import java.lang.*;
import java.util.*;

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

        int fruit = scan.nextInt();
        int num = scan.nextInt();

        int[] arr = new int[fruit];

        for (int i = 0; i < fruit; i++) {
            arr[i] = scan.nextInt();
        }

        Arrays.sort(arr);
        int sum = 0;
        for (int i = 0; i < num; i++) {
            sum += arr[i];
        }

        System.out.println(sum);
    }
}


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

int main(){
  int ans = 0, tmp = 10;
  for(int i = 0; i < 5; i++){
    int b; cin >> b;
    if(b % 10 == 0) ans += b;
    else{
      ans += (b / 10 + 1)*10;
      tmp = min(tmp, b % 10);
    }
  }
  if(tmp == 10) cout << ans << endl;
  else cout << ans - 10 + tmp << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define func(a) ((a==0)?26:a)

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  
  ll n,i,count=0,temp=0;
  cin>>n;
  while(1){
    if(pow(26,count)>=(25*n/26.0 + 1.0)) break;
    count++;
  }
  n = n - 26*((ll)(pow(26,count-1)-1))/25;
  //cout<<count<<" "<<n;
  count--; n--;
  while(count>=0){
    cout<<char(n/((ll)(pow(26,count)))+'a');
    n = n%((ll)(pow(26,count)));
    count--;
  }
  
}

Measured memory_bytes: 4052
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;
T chmin(T)(ref T x, T y){ if(x > y) x = y; return x; } T chmax(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	long h = rlong;
	int n = rint;
	long[] as = rlong(n);

	if(as.sum >= h) "Yes".writeln;
	else "No".writeln;

}

Measured memory_bytes: 4248
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {

	rd := bufio.NewReader(os.Stdin)

	b, _, err := rd.ReadLine()
	if err != nil {
		panic(err)
	}
	w:=strings.ToLower(string(b))

	var count int
	for {
		b, _, err := rd.ReadLine()
		if err != nil {
			panic(err)
		}
		if string(b) == "END_OF_TEXT" {
			break
		}
		for _, t := range strings.Split(strings.ToLower(string(b)), " ") {
			if t == w {
				count++
			}
		}
	}

	fmt.Println(count)
}



Measured memory_bytes: 1144
//    _____ _     _                _           _     _ _     _     
//    \_   \ |_  (_)___  __      _| |__   __ _| |_  (_) |_  (_)___ 
//     / /\/ __| | / __| \ \ /\ / / '_ \ / _` | __| | | __| | / __|
//  /\/ /_ | |_  | \__ \  \ V  V /| | | | (_| | |_  | | |_  | \__ \
//  \____/  \__| |_|___/   \_/\_/ |_| |_|\__,_|\__| |_|\__| |_|___/
//                                                                 
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int sz=1e6+9;
string s;
int val[11];
ll ans;

int main(){
	val[1]=1;
	val[2]=2;
	val[3]=3;
	val[4]=4;
	val[5]=5;
	val[6]=4;
	val[7]=3;
	val[8]=2;
	val[9]=1;
	cin>>s;
	reverse(all(s));
	// cout<<s<<'\n';
	for(int i=0;i<s.size();i++){
		char u=s[i];
		int k=u-'0';
		if(k==10){
			k=0;
			s[i]='0';
			if(i+1<s.size()) s[i+1]++;
			else s.pb('1');
		}
		ans+=val[k];
		if(k==5){
			if(i+1<s.size()&&s[i+1]>='5'){
				s[i]='0';
				s[i+1]++;
			}
		}
		if(k>5){
			s[i]='0';
			if(i+1<s.size()){
				s[i+1]++;
			}else{
				s.pb('1');
			}
		}
	}	
	cout<<ans<<'\n';
	// cout<<s;
	return 0;
}


// 071124352843082689980268260461870329544947902850155739939617914882059723833462648323979853562951413
// 002124352053003000001200301402001320054050012001155040040020024003050033043403050423000004503002413

Measured memory_bytes: 1412