akhauriyash/Code-Regression huggingface dataset:
import sys

"""テンプレ"""

# 高速
input = sys.stdin.readline

# 1行を空白でリストにする(int)
def intline():
    return list(map(int, input().split()))


# 上のstrヴァージョン
def strline():
    return list(map(str, input().split()))


# 1列に並んだ数
def intlines(n):
    return [int(input() for _ in range(n))]


# 上の文字列ヴァージョン
def lines(n):
    return [input() for _ in range(n)]
    

# Union-Find木  http://at274.hatenablog.com/entry/2018/02/02/173000
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)


# 重み付きのUnion-Find木　http://at274.hatenablog.com/entry/2018/02/03/140504
class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        # 根への距離を管理
        self.weight = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 併合
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            # 木の高さが同じだった場合の処理
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]




"""ここからメインコード"""

k, s = intline()
r = range
ans = 0
for x in r(k+1):
    for y in r(k+1):
        if x + y <= s and s - x - y <= k:
            ans += 1
print(ans)


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define Cout(s) cout << s << endl;
#define CoutV(vec)        \
    for (auto v : vec)    \
    {                     \
        cout << v << " "; \
    }                     \
    cout << endl;
#define CoutVV(vecvec)      \
    for (auto vec : vecvec) \
        CoutV(vec);

using ll = long long;
using P = pair<int, int>;
#define INF 10000000;

ll MOD = 1e9 + 7;

// aのp乗を求める
long modpow(ll a, int p)
{
    if (p == 0)
        return 1;
    if (p % 2 == 0)
    {
        //pが偶数
        int halfP = p / 2;
        ll half = modpow(a, halfP);

        // a^(p/2) をhalfとして、half*halfを計算
        return half * half % MOD;
    }
    else
    {
        // pが奇数なら偶数にする
        return a * modpow(a, p - 1) % MOD;
    }
}

// 10*9*8 / 3*2*1
// 10*9*8 -> ansMul
// 3*2*1  -> ansDiv
ll calcComb(int a, int b)
{
    if (b > a - b)
        return calcComb(a, a - b);
    ll ansMul = 1;
    ll ansDiv = 1;

    for (int i = 0; i < b; i++)
    {
        ansMul *= (a - i);
        ansDiv /= (i + 1);
        ansMul %= MOD;
        ansDiv %= MOD;
    }

    ll ans = ansMul * modpow(ansDiv, MOD - 2) % MOD;

    return ans;
}

struct op
{
    int x, y, a, b;
};

int main()
{
    
    int h, w;
    cin >> h >> w;
    int g[h][w];
    rep(i, 0, h)
    {
        rep(j, 0, w)
        {
            cin >> g[i][j];
        }
    }
    vector<op> v;
    rep(i, 0, h)
    {
        rep(j, 0, w)
        {
            if (g[i][j] & 1)
            {
                if (j == w - 1 && i != h - 1)
                { // down
                    --g[i][j];
                    ++g[i + 1][j];
                    v.push_back({i, j, i + 1, j});
                }
                else if (j < w - 1)
                {
                    --g[i][j];
                    ++g[i][j + 1];
                    v.push_back({i, j, i, j + 1});
                }
            }
        }
    }
    cout << v.size() << '\n';
    for (op o : v)
    {
        cout << o.x + 1 << ' ' << o.y + 1 << ' ' << o.a + 1 << ' ' << o.b + 1 << '\n';
    }
}

Measured memory_bytes: 5232
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vec;
int main(){
  string s,memo;
  long k,count=0;
  cin>>s>>k;
  
  rep(i,s.length()){
    if(s[i]!='1'){memo=s[i]; break;}
    count++;
  }
  
  if(k>count)cout<<memo;
  else cout<<1;
  
  
  
  
  
}

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

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

using namespace std;
using lint=long long;

int main(){
	int n,k; scanf("%d%d",&n,&k);
	vector<lint> a(n);
	rep(i,n) scanf("%lld",&a[i]), a[i]--;

	vector<lint> sum(n+1);
	rep(i,n) sum[i+1]=(sum[i]+a[i])%k;

	map<lint,int> f;
	rep(i,min(n+1,k)) ++f[sum[i]];

	lint ans=0;
	rep(i,n){
		--f[sum[i]];
		ans+=f[sum[i]];
		if(k+i<=n) ++f[sum[k+i]];
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 15872
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

public class Program
{
	static public void Main(string[] args)
	{
		string str = Console.ReadLine();
		int[] data = str.Split(' ').Select(x => int.Parse(x)).ToArray();
		int n = data[0] / data[1];
		int mod = data[0] % data[1];
		Console.WriteLine(n + (mod > 0 ? 1 : 0));
	}
}

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

int main() {
    string S;
    cin >> S;
    
    bool judge = true;
    int r = S.size()-1;
    for (int i = 0; i < S.size(); i++)
        if (S[i] != S[r--])
            judge = false;

    r = S.size() / 2 -1;
    for (int i = 0; i < S.size() / 2; i++)
        if (S[i] != S[r--])
            judge = false;

    r = S.size() - 1;
    for (int i = (S.size()+3) / 2 - 1; i < S.size(); i++)
        if (S[i] != S[r--])
            judge = false;
    
    if (judge)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 1e9 + 7;
const long long inf = 1e18;
 
using namespace std;
 

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 
ll binomialCoeff(ll n, ll k) 
{ 
	ll C[n + 1][k + 1]; 
	ll i, j; 


	for (i = 0; i <= n; i++) 
	{ 
		for (j = 0; j <= min(i, k); j++) 
		{ 
			
			if (j == 0 || j == i) 
				C[i][j] = 1; 

			else
				C[i][j] = (C[i - 1][j - 1] + 
										C[i - 1][j])%MOD; 
		} 
	} 

	return C[n][k]; 
}
bool compare(const string &a , const string&b){
	
}
 
void solve()
{
	int n  ;
	cin>>n ;
	int a[n] ;
	rep(i , n)cin>>a[i] ;
	int ans =0 ;
	repu(i ,  1 , n){
		if(i%2 && a[i-1]%2){
			ans++;
		}
	}
	cout<<ans<<endl;
}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3748
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        // スペース区切りの整数の入力
        int a = sc.nextInt();
        int h = (a / 60)/ 60;
        int m = a % 3600 / 60;
        int s = a % 60;

        // 出力
        // System.out.println(a);
        System.out.println(h+":"+m+":"+s);
        // System.out.println(m);
        // System.out.println(s);

    }
}


Measured memory_bytes: 26232
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll n = in();
	string s; cin >> s;
	ll tmp = 0, ans = 0;
	REPC(i, s) {
		if (i == 'I')++tmp;
		else --tmp;
		ans = max(ans, tmp);
	}
	cout << ans << endl;
}

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

using namespace std;

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

    int ans=1, div=1000000007;
    for(int i=1; i<=n; i++){
        ans = (long long) ans * i % div;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
const int MAXN=2e5+5;
const int MOD=1000000000;
const LL INF=(2e5)*(1e9)+5;
LL a[MAXN];
LL sum[MAXN];

int main()
{
    ios::sync_with_stdio(false);
    int n;
    while(cin>>n)
    {
        LL tot=0;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
            sum[i]=sum[i-1]+a[i];
            tot+=a[i];
        }
        LL Min=INF;
        for(int i=1;i<n;i++)
        {
            if(Min>abs(2*sum[i]-tot))
                Min=abs(2*sum[i]-tot);
        }
        cout<<Min<<endl;
    }

    return 0;
}

Measured memory_bytes: 3328
M=10**9+7
f=[1]
for j in range(1,10**6):f+=f[-1]*j%M,
i=[pow(f[-1],M-2,M)]
for j in range(1,10**6)[::-1]:i+=i[-1]*j%M,
x,y=map(int,input().split())
n,m=divmod(x+y,3)
print((m<1)*(x*2>=y)*(y*2>=x)*f[n]*i[~n-n+y]*i[~y+n]%M)



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

int w,h;


int main()
{   
    cin >> w >> h;  
    multimap<long long, int > v;
    long long temp;
    long long cost = 0;
    for (int i = 0; i < w; ++i)
    {
      cin >> temp;
      v.insert(pair<long long,int>(temp, 1));
    	
    }

    for (int i = 0; i < h; ++i)
    {
      cin >> temp;
      v.insert(pair<long long,int>(temp, 2));
    	
    }

    int a = w+1;
    int b = h+1;

    for (multimap<long long, int>::iterator i=v.begin(); i!=v.end(); i++)
    {
    	if ((*i).second == 1)
    	{
        cost += b * (*i).first;
        if (a>1)
        {
          a--;
        }
    	}else if ((*i).second == 2)
    	{
    	cost += a * (*i).first;
        if (b>1)
        {
          b--;
        }
    	}
    }
    cout << cost << endl;
    return 0;  
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ld = long double;
using ii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vii = vector<ii>;
using vvii = vector<vii>;

template<class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<class TIn, class TOut = null_type>
using order_tree = tree<TIn, TOut, less<TIn>, rb_tree_tag,
	tree_order_statistics_node_update>;

constexpr int INF = 2000000010;
constexpr ll LLINF = 9000000000000000010LL;

ll mod(ll a, ll M) { return (a%M+M)%M; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int T;
	cin >> T;
	while (T--) {
		ll A, B, C, D;
		cin >> A >> B >> C >> D;

		if (D < B || A < B) { cout << "No\n"; continue; }
		if (D == B) { cout << (A % B <= C ? "Yes\n" : "No\n"); continue; }
		if (B <= C) { cout << "Yes\n"; continue; }

		A -= B * ((max(0LL, A - C) + B - 1LL) / B);
		if (A < 0LL) { cout << "No\n"; continue; }

		ll x = D - (D / B) * B;
		if (x == 0) { cout << "Yes\n"; continue; }

		bool ok = true;
		for (int i = 0; ok && i < 1000000; ++i) {
			ok = ok && A >= 0LL;
			A += (C + 1LL - A + x - 1LL) / x * x - B;
		}

		cout << (ok?"Yes\n":"No\n");
	}
	
	return 0;
}


Measured memory_bytes: 256
def amari(x):
    if x == 0:
        return 'a'
    elif x == 1:
        return 'b'
    elif x == 2:
        return 'c'
    elif x == 3:
        return 'd'
    elif x == 4:
        return 'e'
    elif x == 5:
        return 'f'
    elif x == 6:
        return 'g'
    elif x == 7:
        return 'h'
    elif x == 8:
        return 'i'
    elif x == 9:
        return 'j'
    elif x == 10:
        return 'k'
    elif x == 11:
        return 'l'
    elif x == 12:
        return 'm'
    elif x == 13:
        return 'n'
    elif x == 14:
        return 'o'
    elif x == 15:
        return 'p'
    elif x == 16:
        return 'q'
    elif x == 17:
        return 'r'
    elif x == 18:
        return 's'
    elif x == 19:
        return 't'
    elif x == 20:
        return 'u'
    elif x == 21:
        return 'v'
    elif x == 22:
        return 'w'
    elif x == 23:
        return 'x'
    elif x == 24:
        return 'y'
    elif x == 25:
        return 'z'
    
N = int(input())
K = 0
k = 0
i = 0
my_str = []
while True:
    if  k <= N <= K:
        N = N - k #number in the floor
        for j in range(i): # i=length of the coded name
            my_str.append(amari(N % 26))
            N = N // 26
        strA = ''.join(my_str[::-1])
        print(strA)
        exit()
    else:
        i += 1
        k = K + 1
        K += 26 ** i

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

#define MOD 1000000007

int main() {
  int a, b;
  cin >> a >> b;

  int ans = a * b;

  cout << ans << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<ll> Vec;
typedef vector<Vec> DVec;
typedef vector<DVec> TVec;
typedef priority_queue<P, vector<P>, greater<P>> PQ;

#define fi                first
#define se                second
#define pb                push_back
#define INF               LLONG_MAX/3
#define MOD               1000000007
#define bcnt              __builtin_popcount
#define all(x)            (x).begin(),(x).end()
#define srt(x)            sort(all(x))
#define rvs(x)            reverse(all(x))
#define uni(x)            x.erase(unique(all(x)),x.end())
#define ub(x,y)           (upper_bound(all(x),y)-x.begin())
#define lb(x,y)           (lower_bound(all(x),y)-x.begin())
#define rep(i,n)          repl(i,0,n-1)
#define mkp(x,y)          make_pair(x,y)
#define mmax(x,y)         (x>y?x:y)
#define mmin(x,y)         (x<y?x:y)
#define maxch(x,y)        x=mmax(x,y)
#define minch(x,y)        x=mmin(x,y)
#define exist(x,y)        (find(all(x),y)!=x.end())
#define each(itr,v)       for(auto itr:v)
#define repl(i,a,b)       for(ll i=(ll)(a);i<=(ll)(b);i++)
#define dvec(n1,n2,i)     DVec(n1,Vec(n2,i))
#define tvec(n1,n2,n3,i)  TVec(n1,dvec(n2,n3,i))
#define MAX_N 55555

// エラトステネスの篩 [1,n]
bool is_prime[MAX_N+1];

void sieve(ll n){
  for(ll i=0;i<=n;i++)is_prime[i]=true;
  is_prime[0]=is_prime[1]=false;

  for(ll i=2;i<=n;i++){
    if(is_prime[i]){
      for(ll j=2*i;j<=n;j+=i)is_prime[j]=false;
    }
  }
}

int main() {
  cin.sync_with_stdio(false);
  sieve(MAX_N);
  Vec prs;
  for(auto i=1; i*5+1 <= MAX_N; i++){
    if(is_prime[i*5+1])prs.pb(i*5+1);
  }
  ll N;
  cin >> N;
  rep(i,N)cout << prs[i] << (i == N-1 ? "" : " ");
  cout << endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



int main(){
	int x,a,b;
	cin >> x >> a >> b;

	if(abs(x-a) < abs(x-b))P("A");
	else P("B");

	return  0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    char c;
    int ans = 700;
    for(int i = 0; i < 3; i++){
        scanf("%c", &c);
        ans += (c == 'o' ? 100 : 0);
    }
    printf("%d\n", ans);
    return 0;
}

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

struct knapsack{
    int value;
    int weight;
};

int main(){
    int N, W = 0;
    knapsack sack[120];
    int memo[120][10020];
    
    cin >> N >> W;
    
    for(long long int n = 0;n < N;n++){
        cin >> sack[n].value >> sack[n].weight;
    }
    
    for(int i = 0;i <= N;i++){
        for(int j = 0;j <= W;j++){
            if(sack[i].weight > j){
                memo[i+1][j] = memo[i][j];
            }else{
                memo[i+1][j] = max(memo[i][j], memo[i+1][j - sack[i].weight] + sack[i].value);
            }
        }
    }
    
    cout << memo[N][W] << endl;
    
    return 0;
}

Measured memory_bytes: 7024
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>

#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;
// RRBBRB
// rrrbbb
int f(vector<int> q) {
	cout << "?";
	for (auto qq : q)
		cout << " " << qq + 1;
	cout << endl << flush;
	string s;
	cin >> s;
	if (s == "Red")
		return 1;
	else if (s == "Blue")
		return -1;
	else
		return 0;
}

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	int b = 0, e = n;
	vector<int> q;
	for (int i = 0; i < n; i++)
		q.push_back(i);
	int c0 = f(q);
	while (b < e) {
		int m = (b + e) / 2 + 1;
		q.clear();
		for (int i = m; i < n + m; i++)
			q.push_back(i);
		int cm = f(q);
		if (cm == c0) {
			b = m;
		}
		else {
			e = m - 1;
		}
	}
	vector<int> res(2 * n, 0);
	res[b] = c0;
	res[b + n] = -c0;
	q.clear();
	for (int i = b + 1; i < b + n; i++) 
		q.push_back(i);
	for (int i = 0; i < 2 * n; i++) {
		if (res[i] == 0 && (i < b || i > b + n)) {
			q.push_back(i);
			res[i] = f(q);
			q.pop_back();
		}	
	}
	for (int i = b + 1; i < b + n; i++) {
		q.clear();
		for (int j = b; j <= b + n; j++) {
			if (i == j) continue;
			q.push_back(j);
		}
		res[i] = -f(q);
	}
	cout << "! ";
	for (int i = 0; i < 2 * n; i++) {
		if (res[i] == 1)
			cout << "R";
		else
			cout << "B";
	}
	cout << endl << flush;

}


Measured memory_bytes: 724
fun main(args :Array<String>) {
    val n = readInteger()
    val s = readLine()!!
    val sb = StringBuilder(n)
    for (c in s) {
        val zeroFirst = c.toInt() - 'A'.toInt()
        val plusN = zeroFirst + n
        val modValue = plusN % ('Z' - 'A' + 1)
        val plusA = modValue + 'A'.toInt()
        sb.append(plusA.toChar())
    }
    println(sb)
}

fun readInteger() = readLine()!!.toInt()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 33740
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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; }
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main(){
    ll x, y;
    cin >> x >> y;
    string ans;
    if(abs(x-y)<=1) ans = "Brown";
    else ans = "Alice";
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,m,x,y,ans1,ans2,Min=2e9;
long long b[710],f[710][710],s[710],t[710];
void dfs(int x,int y)
{
	b[x]=y;
	ans2+=(y>0);
	ans1+=(y<0);
	for(int i=1;i<=n;i++)
	if(x!=i&&!f[x][i])
	{
		if(!b[i])dfs(i,-y);
		else if(b[i]==y)
		{
			cout<<-1;
			exit(0);
		}
	}
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		scanf("%lld%lld",&x,&y);
		f[x][y]=1;
		f[y][x]=1;
	}
	s[0]=1;
	for(int i=1;i<=n;i++)
	if(!b[i])
	{
		ans1=ans2=0;
		dfs(i,1);
		memset(t,0,sizeof(t));
		for(int j=0;j<=n;j++)
		{
			t[j+ans1]=t[j+ans1]|s[j];
			t[j+ans2]=t[j+ans2]|s[j];
		}
		for(int j=0;j<=n;j++)s[j]=t[j];
	}
	for(int i=0;i<=n;i++)if(s[i])Min=min(Min,(i*i-i)/2+(n-i)*(n-i-1)/2);
	cout<<Min;
	return 0;
} 

Measured memory_bytes: 7612
import bisect

N = int(input())
lst_a = sorted([int(x) for x in input().split()])
lst_b = sorted([int(x) for x in input().split()])
lst_c = sorted([int(x) for x in input().split()])
ans = 0
for b in lst_b:
    i = bisect.bisect_left(lst_a, b)
    j = bisect.bisect_right(lst_c, b)
    ans += i * (N - j)

print(ans)

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

int main(){
  long long n,m; cin >> n >> m;
  if(n == 1 && m == 1)
    cout << 1;
  else if(n == 1)
    cout << m - 2;
  else if(m == 1)
    cout << n -2;
  else
    cout << (n-2) * (m-2);
}

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

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

    string s;
    cin >> s;
    list<char> lst(s.begin(), s.end());
    bool flag = true;

    int Q;
    cin >> Q;
    while (Q--) {
        int q;
        cin >> q;
        if (q == 1) flag = not flag;
        else {
            int f;
            char c;
            cin >> f >> c;
            if ((flag && f == 1) || (not flag && f == 2)) {
                lst.push_front(c);
            } else {
                lst.push_back(c);
            }
        }
    }
    if (not flag) lst.reverse();
    string ans(lst.begin(), lst.end());
    cout << ans << endl;
}


Measured memory_bytes: 10320
import java.util.*;

public class Main {
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int n = a + b;
		if (a - b > n) {
			n = a - b;
		}
		if (a * b > n) {
			n = a * b;
		}
		System.out.println(n);
	}

}


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

bool solve() {
    string s;
    cin >> s;
    for ( char c : s) {
        if ( c == '7' ) return true;
    }
    return false;
}

int main() {
    string ans = solve() ? "Yes" : "No";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3628
using System;

namespace Hi
{
    class Program
    {
        static void Main()
        {
            var ab = Console.ReadLine().Split();
            int a = int.Parse(ab[0]);
            int b = int.Parse(ab[1]);
            Console.WriteLine(a*b+" "+((a*2)+(b*2)));
        }
    }
}

Measured memory_bytes: 9052
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int Q = sc.nextInt();
		int l[] = new int[Q];
		int r[] = new int[Q];
		for(int i = 0; i< Q; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		}
		
		int prime_cnt[] = new int[100001];
		boolean prime[] = new boolean[100001];
		Arrays.fill(prime, true);
		prime[0] = false;
		prime[1] = false;
		int cnt = 0;
		for(int i = 2; i <= 100000; i++) {
			int c = 2;
			while(i * c <= 100000) {
				prime[i * c] = false;
				c++;
			}
		}
		
		
		for(int i = 3; i <= 100000; i++) {
			if(!prime[(i + 1) / 2] || !prime[i]) {
				prime_cnt[i] = cnt;
				continue;
			}
			cnt++;
			prime_cnt[i] = cnt;
		}
		
		for(int i = 0; i < Q; i++) {
			System.out.println(prime_cnt[r[i]] - prime_cnt[l[i] - 1]);
		}
	}
}


Measured memory_bytes: 70908
n = list(map(int, input().split()))
w = [0] * n[0]
for i in range(n[0]):
    w[i] = int(input())
    
def check(p):
    i = 0
    for j in range(n[1]):
        s = 0
        while s + w[i] <= p:
            s += w[i]
            i += 1
            if i == n[0]:
                return True
    return False

def solve():
    left = 0
    right = 100000 * 10000
    min_p = 100000 * 10000
    while right - left > 1:
        mid = (right + left) // 2
        if check(mid):
            if min_p > mid:
                min_p = mid
            right = mid
        else:
            left = mid
    print(min_p)

solve()


Measured memory_bytes: 9244
x = int(input())

a = 0
b = 0
flg = True

while True:
  a += 1
  for i in range(a):
    if a**5 - i**5 == x:
      a = a
      b = i
      flg = False
      break
    elif a**5 + i**5 == x:
      a = a
      b = -i
      flg = False
      break
  if flg == False:
    break
  
a = str(a)
b = str(b)
print(a+' '+b)

Measured memory_bytes: 9144
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N=int(input())
    results=[]
    for i in range(1,N):
        results.append(sum(map(int,str(i)))+sum(map(int,str(N-i))))
    print(min(results))
    


resolve()

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

int main() {
	string s;
	cin >> s;
	vector<int>a(s.length());
	vector<int>c(26,0);
	for (int i = 0; i < s.length(); i++) {
		a.at(i) = s.at(i) - 'a';
		c.at(a.at(i))++;
	}
	if (s.length() <= 25) {
		ll ans;
		for (int i = 0; i < 26; i++) {
			if (c.at(i) == 0) {
				ans = i;
				break;
			}
		}
		char c = 'a' + ans;
		cout << s << c << endl;
	}
	else {
		set<int>b;
		b.insert(a.at(s.length() - 1));
		a.at(s.length() - 1) = -1;
		for (int i = 1; i < 26; i++) {
			int d = a.at(s.length() - 1 - i);
			for (auto e : b) {
				if (e > d) {
					char f = 'a' + e;
					cout << s.substr(0,26-i-1) << f << endl;
					return 0;
				}
			}
			b.insert(d);
			a.at(s.length() - 1 - i) = -1;
		}
		cout << -1 << endl;
	}
}


Measured memory_bytes: 256
import Control.Monad
 
main :: IO ()
main = do
  n <- readLn
  xs <- replicateM n readLn :: IO [Int]
  print $ greedyCustormors xs 1

greedyCustormors :: [Int] -> Int -> Int
greedyCustormors [] _ = 0
greedyCustormors (x:xs) k | k==1  = (x-1) + greedyCustormors xs (k+1)
                          | k==x  = greedyCustormors xs (k+1)
                          | k>x  = greedyCustormors xs k
                          | otherwise = if ((x`mod`k) == 0) then x`div`k-1 + greedyCustormors xs k else (x`div`k) + greedyCustormors xs k


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

struct Segment_tree{
    using T=ll;

    int n;
    vector<T> data;
    const T out=(1LL<<31)-1;
    T offset = 0LL;

	inline T vmerge(T l,T r){return min(l,r);}

    Segment_tree(int n):n(n){data.assign(2*n,out);}

    void all_add(ll x){
    	offset += x;
    }

    void update(int p,T x) {  // set value at position p
        for(data[p+=n]=x -offset ; p > 1; p >>= 1){
        	data[p>>1]=vmerge(data[p],data[p^1]);
        }
    }

    T query(int l, int r) {  // sum on interval [l, r)
        T resl = out,resr = out;
        for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
            if (l&1) resl = vmerge(data[l++], resl);
            if (r&1) resr = vmerge(resr, data[--r]);
        }
        return vmerge(resl,resr) + offset;
    }
};


Segment_tree *lf,*rg;

void update(int pos,ll x){
	lf->update(pos,x-pos);
	rg->update(pos,x+pos);
}

void all_add(ll x){
	lf->all_add(x);
	rg->all_add(x);
}

ll query(int pos){
	ll ret=lf->query(0,pos+1)+pos;
	chmin(ret,rg->query(pos,rg->n)-pos);
	return ret;
}

ll w[200010];

int main(void){
	int n,q,a,b;
	cin >> n >> q >> a >> b;
	a--,b--;

	rep(i,q) cin >> w[i],w[i]--;

	lf = new Segment_tree(n);
	rg = new Segment_tree(n);

	update(b,0);
	int last = a;

	rep(i,q){
		ll cur=query(w[i]);
		all_add(abs(w[i]-last));
		update(last,cur);
		last = w[i];
	}

	ll ans=1LL<<60;
	rep(i,n) chmin(ans,lf->query(i,i+1)+i);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 8064
s = input()

n = len(s) - 1
ans = 0
for bit in range(2**n):
  a = s[0]
  for j in range(n):
    if (bit >> j) & 1:
      a += "+"
    a += s[j+1]
  ans += sum(map(int,a.split("+")))

print(ans)


Measured memory_bytes: 2940
#include<stdio.h>
#define MOD 1000000007
long int PROD(long int a,long int b){return (a+MOD)%MOD*((b+MOD)%MOD)%MOD;}//a*b
void quicksort(long int a[],int s,int t){
  if(s<t){
    long int i=s,j=t,p=a[(s+t)/2];
    while(1){
      while(a[i]>p)i++;
      while(p>a[j])j--;
      if(i>=j)break;
      a[i]^=a[j]^=a[i]^=a[j];
      i++;j--;
    }
    quicksort(a,s,i-1);quicksort(a,j+1,t);
  }
}
int main(){
  long int p[200001],m[200001],i,j,k,n,x=0,y=0,r=1;
  scanf("%ld%ld",&n,&k);
  for(i=0;i<n;i++){scanf("%ld",&j);if(j>0){p[x]=j;x++;}else{m[y]=-j;y++;}}
  quicksort(p,0,x-1);quicksort(m,0,y-1);
  if(x==0&&k%2){for(i=1;i<=k;i++)r=PROD(r,-m[y-i]);printf("%ld",r);return 0;}
  if(n==k){for(i=0;i<x;i++)r=PROD(r,p[i]);for(i=0;i<y;i++)r=PROD(r,-m[i]);printf("%ld",r);return 0;}
  j=k<y?k-k%2:y-y%2;
  while(j>1&&k-j+1<x&&p[k-j]*p[k-j+1]>m[j-1]*m[j-2])j-=2;
  for(i=0;i<k-j;i++)r=PROD(r,p[i]);
  for(i=0;i<j;i++)r=PROD(r,-m[i]);
  printf("%ld",r);
}


Measured memory_bytes: 3304
n=int(input())
alis=list(map(lambda x:int(x)-1,input().split()))
counter=0
for i in range(n):
    if i!=n-1:
        if i==alis[i]:
            alis[i],alis[i+1]=alis[i+1],alis[i]
            counter+=1
    else:
        if i==alis[i]:
            alis[i],alis[i-1]=alis[i-1],alis[i]
            counter+=1
print(counter)

Measured memory_bytes: 14008
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説どおりに作成したソースコード
 */
public class Main {

	private static final char[] BASES = new char[] { '3', '5', '7' };

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			String n = scanner.next();
			int answer = IntStream.range(3, n.length()).map(i -> calc(i)).sum();
			int[] number = new int[n.length()];
			Arrays.fill(number, 0);
			while (increaseNumber(number)) {
				String string = getNumber(number);
				if (string.compareTo(n) > 0) {
					break;
				} else {
					if (is753(number)) {
						answer++;
					}
				}
			}
			System.out.println(answer);
		}
	}

	/**
	 * numberで表す数字を一つ上げる
	 * 
	 * @param number
	 * @return 上げられない場合はfalse
	 */
	private static boolean increaseNumber(int[] number) {
		return increaseNumber(number, 0);
	}

	/**
	 * numberで表す数字は753数字かどうかを判定する
	 * 
	 * @param number
	 * @return numberで表す数字は753数字かどうか
	 */
	private static boolean is753(int[] number) {
		return BASES.length == Arrays.stream(number).distinct().count();
	}

	/**
	 * numberのi番目の数字を一つ上げる
	 * 
	 * @param number
	 * @param i
	 * @return 上げられない場合はfalse
	 */
	private static boolean increaseNumber(int[] number, int i) {
		if (i < number.length) {
			number[i]++;
			if (number[i] >= BASES.length) {
				number[i] = 0;
				return increaseNumber(number, i + 1);
			}
			return true;
		}
		return false;
	}

	/**
	 * n桁の七五三数の数を計算する
	 * 
	 * @param n
	 * @return n桁の七五三数の数
	 */
	private static int calc(int n) {
		return pow(3, n) - 3 * pow(2, n) + 3;
	}

	/**
	 * numberの配列から3,5,7の文字列へ変換する
	 * 
	 * @param number 配列
	 * @return 3,5,7の文字列
	 */
	private static String getNumber(int[] number) {
		StringBuilder sb = new StringBuilder();
		for (int i = number.length - 1; i >= 0; i--) {
			sb.append(BASES[number[i]]);
		}
		return sb.toString();
	}

	/**
	 * nのｍ乗を計算する
	 * 
	 * @param n
	 * @param m
	 * @return nのｍ乗
	 */
	private static int pow(int n, int m) {
		int result = 1;
		while (m > 0) {
			if (1 == (m & 1)) {
				result *= n;
			}
			n *= n;
			m >>= 1;
		}
		return result;
	}
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll K, S;
    cin >> K >> S;
    ll ans = 0;
    rep(x, K + 1) {
        rep(y, K + 1) {
            ll z = S - x - y;
            if (0 <= z && z <= K) {
                ans++;
            }
        }
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]

import collections

cS = collections.Counter(S)
cT = collections.Counter(T)
ans = 0

for x in list(cS.keys()):
  ans = max(cS[x] - cT[x],ans)
print(ans)

Measured memory_bytes: 9332
using System;

class Program
{
    static void Main () 
    {
        String[] inline = Console.ReadLine().Split(' ');
        long x = long.Parse(inline[0]);

        long a = -150;
        long b = -150;
        for(long i = a; i <= 150; i++)
        {
            for(long j  = b; j <= 150; j++)
            {
                long y = (long) (Math.Pow(i,5) - Math.Pow(j,5));
                if(x == y)
                {
                    Console.WriteLine("{0} {1}", i, j);
                    Environment.Exit(0);
                }
            }
        }
        Console.WriteLine("none");
    }
}

Measured memory_bytes: 28156
// C

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};

int main(){
  int N,K,S;
  cin>>N>>K>>S;
  for (int i(0);i<K;i++){
    cout << S << " ";
  }
  for (int i(0);i<N-K;i++){
    if (S != 1000000000){
      cout << 1000000000 <<" ";
    }else{
      cout << 1 <<" ";
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 1280
#include "bits/stdc++.h"
using namespace std;
#ifdef LOCAL
#define debug(x)   cerr<<#x<<" = "<<x<<endl
#else
#define debug(x) 
#endif
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define pii pair<int,int>
#define endl '\n'
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
const int inf = 1e18 + 5;
const int nax = 1e4 + 4;
int dp[nax];
int val[nax],wei[nax];
// minimise the weight to achieve h value
signed main()
{
    #ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif 
    IOS
    int h,n; cin>>h>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>val[i]>>wei[i];
    }
    dp[0] = 0;
    for(int i=1;i<=h;i++) dp[i] = inf; 
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=h;j++)
        {
            dp[j] = min(dp[max(0LL,j-val[i])] + wei[i],dp[j]);
        }
    }
    cout<<dp[h];
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

long long dp[101][100001];
int main(){
int N;
long long W;
cin>>N>>W;
long long w[101],v[101];
for(int i=1;i<N+1;i++){
cin>>w[i]>>v[i];
}
  for(int i=0;i<N+1;i++){
    for(int value=0;value<100001;value++){
      dp[i][value]=999999999999;
    }
  }
  dp[0][0]=0;
for(int i=1;i<N+1;i++){
for(int value=1;value<100001;value++){
if(value>v[i]){
dp[i][value]=min(dp[i-1][value-v[i]]+w[i],dp[i-1][value]);
}
else{
dp[i][value]=min(dp[i-1][value],w[i]);
}
}
}
int answer=0;
for(int value=1;value<100001;value++){
if(dp[N][value]<=W){
answer=max(answer,value);
}
}
cout<<answer<<endl;

}

Measured memory_bytes: 79104
n = int(input())
count = 0

def dfs(s):
	if int(s) > n:
		return 0
	if all(s.count(c) > 0 for c in '357'):
		count = 1
	else:
		count = 0
	count += dfs(s + '3')
	count += dfs(s + '5')
	count += dfs(s + '7')
	return count

print(dfs('0'))

Measured memory_bytes: 3060
#include<cstdio>
#include<cmath>
#define For(i,A,B) for(i=(A);i<=(B);++i)
int c[45][20];
inline short Min(short a,short b){return a<b?a:b;}
inline void chkmax(short&a,short b){if(a<b)a=b;}
int main(){
	int n;
	short i,j,maxtwo=0,maxfive=0,two,five;
	long double tm;
	long long x,t,ans=0ll;
	scanf("%d",&n);
	while(n--){
		scanf("%Lf",&tm);t=x=floor(tm*1e9)+0.5;
		for(two=0;!(t&1);t>>=1)++two;
		for(t=x,five=0;!(t%5);t/=5)++five;
		For(i,0,maxtwo)
			For(j,0,maxfive)if(Min(i+two,j+five)>17)ans+=c[i][j];
		++c[two][five];
		chkmax(maxtwo,two);chkmax(maxfive,five);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1744
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<u32>();
    let (a, b) = (line[0], line[1]);

    println!("{}", (b-1+a-2)/(a-1));
}


Measured memory_bytes: 4352
void main() {
	auto ip = readAs!(ulong[]), N = ip[0], X = ip[1];
	F = new ulong[](51);
	L = new ulong[](51);
	F[0] = L[0] = 1;
	foreach(i; 0..50) {
		F[i+1] = 2*F[i]+3;
		L[i+1] = 2*L[i]+1;
	}
	
	calc(N, X).writeln;
}

ulong[] F, L;

long calc(long N, long X) {
	if(N == 0) return 1;
	if(X == 1) return 0;
	if(X == F[N]) return L[N];
	if(X == 2+F[N-1]) return L[N-1]+1;
	else {
		if(X <= 1+F[N-1]) return calc(N-1, X-1);
		else return L[N-1]+1+calc(N-1, X-2-F[N-1]);
	}
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    int ans = 0;
    rep(i, sz(s)) {
        if (s[i] == '+') {
            ans++;
        } else {
            ans--;
        }
    }
    cout << ans << endl;
}

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

int main() {
  int N;
  int i;
  string s;
  int green = 0, white = 0, peach = 0, yellow = 0;
  
  cin >> N;
  
  for (i = 0; i < N; i++) {
    cin >> s;
    
    if (s == "G") {
      green = 1;
    } else if (s == "W") {
      white = 1;
    } else if (s == "P") {
      peach = 1;
    } else if (s == "Y") {
      yellow = 1;
    } else {
      cout << "error" << endl;
    }
  }

  if (yellow == 1) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }

}


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

int main() {
    int N;
    string S;
    cin >> N >> S;
    int ans = 1;
    for (int i = 0; i < N-1; ++i) {
        if(S[i] != S[i+1]) ans++;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>
#include <limits>
#include <iomanip>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

int main()
{
    int N;
	cin >> N;

	vector<int> A(N);
	vector<ll> B(N + 1, 0);
	for (size_t i = 0; i < N; i++)
	{
		cin >> A[i];
		B[i + 1] = B[i] + A[i];
	}

	ll ans = 0;
	for (size_t i = 0; i < N; i++)
	{
		ll sum = (B[N] - B[i + 1]) % mod;
		ans += A[i] * sum;
		ans %= mod;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 10005
 
#define PI   3.14159265358979323846264338327950

#define PB push_back 
#define F first
#define S second
 
#define ll 	 long long int

#define mod  1000000007

vector<ll> v;
bool p[MAXX];
int main()
{
	FAST;
	ll n, k;
	cin >> n >> k;
	if(n == 1){
		cout << k;
		return 0;
	}
	ll h = n -1;
	ll mx = 0;
	for(ll i = 1; i <= 1000000; i++){
		if(k % i == 0){
			ll x = 0;
			ll a = pow(i, h);
			if(k % a == 0){
				mx = max(mx, __gcd(i, k/a));
			}
		}
	}
	cout << mx;
	return 0;
}

Measured memory_bytes: 4088