akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

int n, q;
vector<int> c;

struct query {
    int l;
    int r;
    int index;
    query() : l(0), r(0), index(0) {}
    query(int _l, int _r, int _index) : l(_l), r(_r), index(_index) {}
};

// セグメント木
// ref:https://ei1333.github.io/luzhiled/snippets/structure/segment-tree.html
template <typename Mnd>
struct segment_tree {
    int sz;
    vector<Mnd> data;
    function<Mnd(Mnd, Mnd)> f;
    Mnd e;
    //サイズだけ指定して初期化
    segment_tree(int _sz, function<Mnd(Mnd, Mnd)> _f, Mnd _e) : f(_f), e(_e) {
        sz = 1;
        while (sz < _sz) sz <<= 1;
        data.assign(sz * 2, e);
    }
    //参照渡しなので代入とかもできる
    Mnd& operator[](const int& k) {
        return data[k + sz];
    }
    //木を構築 O(n)
    void build() {
        for (int i = sz - 1; i > 0; i--) data[i] = f(data[2 * i], data[2 * i + 1]);
    }
    //更新しつつ木を再構築 O(log n)
    void update(int k, Mnd x) {
        data[k += sz] = x;
        while (k >>= 1) data[k] = f(data[2 * k], data[2 * k + 1]);
    }
    //[a,b)でのクエリに答える　O(log n)
    Mnd query(int a, int b) const {
        Mnd l = e, r = e;
        for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if (a & 1) l = f(l, data[a++]);
            if (b & 1) r = f(r, data[--b]);
        }
        return f(l, r);
    }
};

int main() {
    cin >> n >> q;
    c.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        c[i]--;
    }
    vector<query> queries(q);
    for (int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        l--;
        queries[i] = query(l, r, i);
    }
    sort(queries.begin(), queries.end(), [](query a, query b) { return a.l < b.l; });

    //次の色を得るための前計算
    vector<set<int>> colors(n);
    for (int i = 0; i < n; i++) {
        colors[c[i]].insert(i);
    }

    segment_tree<int> seg(
        n, [](int a, int b) { return a + b; }, 0);

    //初期状態を生成
    set<int> already_exist;
    for (int i = 0; i < n; i++) {
        if (already_exist.count(c[i]) == 0) {
            seg[i] = 1;
            already_exist.insert(c[i]);
        }
    }
    seg.build();
    vector<int> ans(q);
    int left = 0;
    for (int i = 0; i < q; i++) {
        while (queries[i].l > left) {
            seg.update(left, 0);
            colors[c[left]].erase(left);
            if (!colors[c[left]].empty()) {
                int k = *colors[c[left]].begin();
                seg.update(k, 1);
            }
            left++;
        }
        ans[queries[i].index] = seg.query(queries[i].l, queries[i].r);
    }
    for (int i = 0; i < q; i++) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 88036
#include <iostream>
using namespace std;
 
int main() {
	long long a, b, x, ans=0;
cin>>a>>b>>x;
 
 if(a<=b) {
ans=(b/x)-((a/x)) ;
}  if(a%x==0) {
 
ans++;
} 
cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        int i = 1;
        int xcubic;
        int a = 0;
        while(i>0){
            BufferedReader x = new BufferedReader(new InputStreamReader(System.in));
            a = Integer.parseInt(x.readLine());           
            if(a >= 1 && a <= 100 )
                i = -1;
         }
         xcubic = a*a*a;
         System.out.println(""+xcubic+"");
    }
}

Measured memory_bytes: 24244
(defun step-nexts (grid current-positions)
  (if (null current-positions)
    nil
    (progn
      (multiple-value-bind (i j) (values-list (pop current-positions))
        (loop for (a b) in '((0 1) (0 -1) (1 0) (-1 0))
              when (< (1+ (aref grid i j)) (aref grid (+ i a) (+ j b)))
              do (progn
                   (setf (aref grid (+ i a) (+ j b))
                         (1+ (aref grid i j)))
                   (setf current-positions (nconc current-positions
                                                  (list (list (+ i a) (+ j b))))))))
      (step-nexts grid current-positions))))

(defun main ()
  (let* ((h (read))
         (w (read))
         (grid (make-array (list (+ h 2) (+ w 2)) :initial-element -1))
         (white-num 0))
    (loop
      for i from 1 to h do 
      (loop
        for j from 1 to w
        for c in (concatenate 'list (read-line))
        do (if (equal c #\.)
             (progn
               (incf white-num)
               (setf (aref grid i j) 9999)))))
    (setf (aref grid 1 1) 0)
    (step-nexts grid '((1 1)))
    (format t "~a~%"
            (if (/= (aref grid h w) 9999)
              (- white-num (aref grid h w) 1)
              -1))))

(main)


Measured memory_bytes: 12260
#include<cstdio>
#include<map>
using namespace std;

int func(int n) {
    if (n % 2 == 0) return n / 2;
    else return 3 * n + 1;
}

int main() {
    int s, n;
    map<int, int> d;

    scanf("%d", &s);

    n = 1;
    while (d.count(s) == 0) {
        d[s] = n;
        s = func(s);
        n++;
    }

    printf("%d\n", n);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<map>

using namespace std;
#define fin(ans) cout << (ans) << '\n'
int main()
{
    int A,B;
    cin >> A >> B;
    if(B < 0){
        if(A-B > A*B)fin(A-B);
        else fin(A*B);
    }else{
        if(A+B > A*B) fin(A+B);
        else fin(A*B);
    }
    return 0;
}

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

#define ll long long
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n, m) for (int (i) = (n); (i) < (m); (i)++)
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

int main() {
   int a, b;
   cin >> a >> b;
   int c = a*b;
   if (c&1) {
      puts("Odd");
   } else {
      puts("Even");
   }

   return 0;
}

Measured memory_bytes: 256
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner scan = new Scanner(System.in)) {
			
			int N = scan.nextInt();
			int C = scan.nextInt();
			int[] price = new int[N];
			Queue<Integer>  pq = new PriorityQueue<>(N, Collections.reverseOrder());
			
			for (int i = 0; i < N; i++) {
				int p = scan.nextInt();
				pq.add(p);
			}

			for (int i = 0; i < C; i++) {
				int half = pq.poll()/2;
				pq.add(half);
			}
			
			Long sum = 0L;
			for(Integer p :pq) {
				sum+=p;
			}
			System.out.println(sum);
		}
	}
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<pair<T, T>>& vp) {
	for (int i = 0; i < vp.size(); ++i) {
		s << "(" << vp[i].first << "," << vp[i].second << ")" << ( i+1 == vp.size() ? "" : ",\t" );
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	for (int i = 1; i < 50000; i++) {
		double c = double(i) * 1.08;
		if (n == (int)c) {
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'


void solve()
{
 int n;
 cin>>n;
  int a[n],dp[n];
 for (int i = 0; i < n; ++i)
 {
   cin>>a[i];
 }
dp[0]=0;
dp[1]=abs(a[1]-a[0]);
  
  for(int i=2;i<n;i++)
  {
    dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
  }

  cout<<dp[n-1];

}

int main() 
{ IOS
    
    solve();
  

  return  0;

}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#define INT long long int
using namespace std;
int r, g, b;

int main()
{
    ios::sync_with_stdio(false);
    cin>>r>>g>>b;
    if( (g*10+b)%4 == 0 ) cout<<"YES"<<endl;
    else cout<<"NO\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define scl(n) scanf("%lld", &n)
#define pcl(n) printf("%lld\n", n)
#define pcl1(n) printf("%lld ", n)
#define dev(x) cout << #x << " " << x << " ";
#define PTT pair<ll, ll>

map<ll, ll> mp, mp1;
map<ll, ll>::iterator itr;

int main()
{
    ll a[5];
    for (int i = 0; i < 5; i++)
    {
        cin >> a[i];
    }

    for (int i = 0; i < 5; i++)
    {
        if (a[i] == 0)
        {
            cout << i + 1 << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 1000005
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return (ans.x+m)%m;
}
int fact[N];
void calfac(int n ){
fact[0] = 1;
for(int i = 1 ; i <= n+2; i++){
 fact[i] = (((fact[i-1]%mod)*(i%mod))%mod + mod)%mod;
}
 }
int calc(int n , int r){
 if(r > n)return 0;
 if(r == n)return 1;
 int ans = 1;
 ans = ((ans%mod)*(fact[n])%mod + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[n-r] , mod)%mod) + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[r] , mod)%mod) + mod)%mod;
 return (ans+mod)%mod;
}
int dp[N+10];
void sieve(){
	  for(int i = 1 ; i <= N ;i++){
	  		dp[i] = i;
	  }
	  for(int i = 2 ; i <= N ;i++){
	  	  if(dp[i] == i){
	  	  	 for(int j = 2*i ; j <= N ;j+=i){
		  	  	 	  dp[j] = min(dp[j] , i);
	  	  	 }
	  	  }
	  }
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
sieve();
ll total = 0;
 for(int c = 1 ; c <= n-1 ; c++){
 	    int no = n-c;
        int sm = dp[no];
        int prev = sm;
        int cnt = 1;
        ll ans = 1;
        while(no%sm == 0 && no > 1){
        	  no  = no/sm;
        	  prev = sm;
        	  sm = dp[no];
        	  if(sm != prev){
        	  	  ans = ans*(cnt+1);
        	  	  cnt= 1;
        	  }
        	  else
        	  cnt++;
        }
  total += ans;
 }
 cout<<total<<endl;
}


Measured memory_bytes: 11464
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define pi 3.141592653589793238462643383279502884197
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int aa,bb,xx;
	cin>>aa>>bb>>xx;
	double a,b,x;
	a = 1.0 * aa; b = 1.0 * bb; x = 1.0 * xx;
	double ok = 0.0, ng = 90.0;
	while( ng - ok > 0.0000000001){
		double mid = ( ng + ok ) / 2.0;
		double yoko = a / tan( (90.0-mid) * pi / 180.0 ) ; 
		double volu = 0.0;
		if( yoko <= b ){
			volu = a * a * ( b - yoko ) + a * a * yoko / 2.0;
		}
		else{
			volu = a * b * b * tan( (90.0-mid) * pi / 180.0 ) / 2.0;
		}
		//cout<< mid <<" "<< yoko << " "<< volu <<endl;
		if( volu >= x ){
			ok = mid;
		}
		else{
			ng = mid;
		}
	}
	cout<<setprecision(18)<<ok<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(v) for(int k=head[v];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=5e5+5,M=1e7+5,INF=1e9,mod=1e9+7;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
il void gen(){freopen("data.in","w",stdout);}
int n,d[N],f[N],D,Q;
int pre[N],suf[N];
int main(){
	read(n,D);
	rep(i,1,n)read(d[i]);
	pre[0]=D;
	rep(i,1,n)
		pre[i]=min(pre[i-1],abs(pre[i-1]-d[i]));
	read(Q);
	suf[n+1]=1;
	repd(i,n,1)
		if(d[i]/2>=suf[i+1])suf[i]=suf[i+1];else
			suf[i]=suf[i+1]+d[i];
	rep(i,1,Q){
		int x=read();
		if(pre[x-1]<suf[x+1])puts("NO");else puts("YES");
	}	
}

Measured memory_bytes: 9728
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	[ n, m ] <- readInts
	[ ps, ys ] <- transpose <$> replicateM m readInts
	mapM_ ( uncurry $ printf "%06d%06d\n" ) $ solve n m ( sort $ zip3 ys ( map pred ps ) [ 0 .. ] )

solve n m lists = runST $ do
	counts <- newArray ( 0, n - 1 ) 0 :: ST s ( STUArray s Int Int )
	res <- newArray_ ( 0, m - 1 ) :: ST s ( STArray s Int ( Int, Int ) )
	forM_ lists $ \( y, p, idx ) -> do
		modifyArray counts p succ
		nth <- readArray counts p
		writeArray res idx ( p + 1, nth )
	getElems res

Measured memory_bytes: 74108
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define INF 9223372036854775807 / 2
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair


using namespace std;

std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }



int defaultValue(int n) {
	if (n % 10 == 0) return n;

	return (n / 10) * 10 + 10;
}



signed main() {
	int N, arr[5];
	cin >> N;
	cin >> arr[0] >> arr[1] >> arr[2] >> arr[3] >> arr[4];
	int minimal = LL_HALFMAX;
	for (int i = 0; i < 5; i++) {
		if (arr[i] < minimal) minimal = arr[i];
	}
	N -= minimal;

	if (N <= 0) {
		cout << 5 << "\n";
		return 0;
	}

	int additional = 0;
	if (N % minimal == 0) {
		additional = N / minimal;
	}
	else {
		additional = N / minimal + 1;
	}
	cout << additional + 5<<"\n";


	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
change = 0
for i in range(n-1):
	minA = 1000
	doko = 0
	for u in range(i+1, n):
		if minA > a[u]:
			minA = a[u]
			doko = u
	if minA < a[i]:
		a[i], a[doko] = a[doko], a[i]
		change += 1
print(*a)
print(change)


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

using namespace std;
using ll = long long;

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

  int n, k;
  cin >> n >> k;
  vector<bool> available(10, true);
  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    available[d] = false;
  }
  vector<int> d;
  for (int i = 0; i < 10; i++) {
    if (available[i])
      d.push_back(i);
  }

  queue<int> q;
  q.push(0);
  while (true) {
    auto cur = q.front();
    q.pop();
    if (cur >= n) {
      cout << cur << endl;
      return 0;
    }
    for (auto x : d) {
      if (cur == 0 && x == 0)
        continue;
      q.push(cur * 10 + x);
    }
  }
  exit(1);

  return 0;
}


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

okane = 1000
kabu = 0
syozi=False

for i in range(n):
    if syozi:
        if i == n-1:
            okane = okane + a[i]*kabu
            break
        if a[i+1] >= a[i]:
            continue
        else:
            okane = okane + a[i]*kabu
            kabu = 0
            syozi = False
    else:
        if i == n-1:
            break
        if a[i+1] <= a[i]:
            continue
        else:
            kabu = okane//a[i]
            okane = okane - kabu*a[i]
            syozi = True

print(okane)


Measured memory_bytes: 9212
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

#define ECHO(v) cout << v << endl;

ll f(ll b, ll n){
    if(n < b)return n;
    return f(b, n/b) + n % b;
}
int main(void){
    ll n, s;
    cin >> n;
    cin >> s;
    if(n == s){
        cout << n+1 << endl;
        return 0;
    }
    if(n < s){
        cout << -1 << endl;
        return 0;
    }
    ll sqrtn = sqrt(n);
    FOR(i, 2, sqrtn+1){
        if(f(i, n)==s){
            cout << i << endl;
            return 0;
        }
    }
    for(int p = (int)sqrtn; p >= 1; p--){
        if((n-s)%p != 0)continue;
        ll b = 1 + (n-s)/p;
        if(b == 0)continue;
        if(f(b, n) == s){
            cout << b << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np
import sys
# input = sys.stdin.readline
# sys.setrecursionlimit(10**8)
 
num_str = input()

num_sum = 0
for i in range(len(num_str)):
  num_sum+=int(num_str[i])
 
if num_sum%9 == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 27140
#include<stdio.h>
#include<string.h>

int main()
{
    char s[10005];
    int i,len,p;
    scanf("%d",&p);
    scanf("%s",s);
    len=strlen(s);
    for(i=0; i<len; i++){
       s[i]=s[i]+p;
       if(s[i]>'Z') s[i]=s[i]-26;
    }
    printf("%s\n",s);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(){
	int n, q, i, l, r;
  	int num = 0;
    int ans = 0;
  
  	scanf("%d %d", &n, &q);
   	char s[n+1];
  	int pop[n+1];
  	scanf("%s", s);
  	pop[0] = 0;
    for(i=1; i<n; i++){
       	if(s[i-1] == 'A' && s[i] == 'C'){
           	num++;
            pop[i] = num;
        }else pop[i] = num;
    }
  
   	for(i=0; i<q; i++){
    	scanf("%d %d", &l, &r);
      	ans = pop[r-1] - pop[l-1];
        printf("%d\n",ans);
    }
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> d;
    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        d.push_back(t);
    }
    sort(d.begin(),d.end(),greater<int>());
    int ans=0;
    for(int i=0;i<k;i++){
        ans+=d[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
ll n , k ,arr[100005] , memo[100005];
ll solve(ll i)
{
	if(i == n - 1)
		return 0;
	ll &ans = memo[i];
	if(~ans)
		return ans;
	ans = 1e9;
	for(int j = 1;j <= k && j + i < n;j++)
		ans = min(ans , abs(arr[i] - arr[i + j]) + solve(i + j));
	return ans;
}
int main()
{
	abdelrahman010
	cin >> n >> k;
	memset(memo , -1 , sizeof memo);
	for(int i = 0;i < n;i++)
		cin >> arr[i];
	cout << solve(0);
	return 0;
}


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

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

using namespace std;

void BFS(vector<vector<pair<int, int>>> &G, int &max, vector<int> &ans) {
	queue<pair<int, int>> que;
	que.push(make_pair(1, -1)); // チェックするノード番号, 直前の色
	map<int, int> check;
	check[1]++;

	while (!que.empty()) {
		int num = que.front().first;
		int color = que.front().second;
		que.pop();
		int edge = G[num - 1].size();
		if (edge > max)max = edge;

		int count = 1;
		rep(i, G[num - 1].size()) {
			if (check[G[num - 1][i].first] == 0) {
				if (count == color)count++;
				ans[G[num - 1][i].second] = count;
				que.push(make_pair(G[num - 1][i].first, count));
				check[G[num - 1][i].first]++;
				count++;
			}
		}
	}
}

int main() {
	int N;
	cin >> N;
	vector<vector<pair<int, int>>> G(N);
	vector<int> ans(N - 1);

	int a, b;
	rep(i, N-1) {
		cin >> a >> b;
		G[a - 1].push_back(make_pair(b, i));
		G[b - 1].push_back(make_pair(a, i));
	}

	int K = 0;
	BFS(G, K, ans);
	cout << K<< endl;
	rep(i, N - 1) {
		cout << ans[i] << endl;
	}
}

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

int main() {
	ll N;
	cin >> N;
	vector<ll> vec = { 0 };

	for (ll i = 1; i < sqrt(N) + 1; i++) {
		if (N % i == 0) {
		   ll a = i + N / i - 2;
			vec.push_back(a);
		}
	}

	sort(vec.begin(), vec.end());
	cout << vec.at(1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    set<int> st;
    for (int i = 0; i < 3; ++ i) {
        int a;
        cin >> a;
        st.insert(a);
    }
    cout << st.size();
}

Measured memory_bytes: 256
n = input()

if n[-1] == "2" or n[-1] == "4" or n[-1] == "5" or n[-1] == "7" or n[-1] == "9":
  print("hon")
elif n[-1] == "0" or n[-1] == "1" or n[-1] == "6" or n[-1] == "8":
  print("pon")
else:
  print("bon")

Measured memory_bytes: 9056
#include <stdio.h>

int main(void) {
  int i;
  int cards[3];
  int total = 0;

  for(i=0; i<3; i++) {
    scanf("%d",&cards[i]);
    total += cards[i];
  }

  if(total >= 22) printf("bust\n");
  else printf("win\n");

}

Measured memory_bytes: 128
n, m = map(int, input().split())
A = []
B = [''] * m
for i in range(m):
    p, y = map(int, input().split())
    A.append([p,y,i])
A.sort()
count = 0
i, x = 1, 1
for a in A:
    if a[0] == i:
        B[a[2]] = '{:06}{:06}'.format(a[0], x)
    else:
        i, x = a[0], 1
        B[a[2]] = '{:06}{:06}'.format(a[0], x)
    x += 1
for b in B:
    print(b)

Measured memory_bytes: 31908
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Main {

	static int[] num;
	final static int AB = 753;
	public static void main(String[] args) throws Exception {
		try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
			num = Arrays.stream(br.readLine().split("")).mapToInt(Integer::parseInt).toArray();
			int min = 999;
			for(int i=0; i<num.length-2; i++) {
				String r = String.valueOf(num[i]);
				r += String.valueOf(num[i+1]);
				r += String.valueOf(num[i+2]);
				int iii = Math.abs(Integer.parseInt(r) - AB);
				if(iii < min) min = iii;
			}
			System.out.println(min);
		}
	}

}


Measured memory_bytes: 28628
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int sdkys(int a,int b){
    if(b==0) return a;
    return sdkys(b,a%b);
}
int sskbs(int a,int b){
    return a*b/sdkys(a,b);
}
int sosu(int a){
    if(a==2){
        return 1;
    }
    for(int i=2;i<sqrt(a)+1;i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}
vector<int> v;
int n,m,cnt=0,ans=0,aa[220000],ab[220000];
pair<int,int> pp[220000];
string s,ss[220000];
char ch;
queue<int> que;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>aa[i];
        cnt+=max(aa[i-1]-aa[i],0LL);
        aa[i]=max(aa[i],aa[i-1]);
    }
    cout<<cnt;
}

Measured memory_bytes: 12056
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define mkp make_pair
//#define d double
void solve(){
	int n,m;
	cin>>n>>m;
	vl dp(1<<n,inf);
	vi cost(m);
	vvi keys(m);
	set<int> st;
	for(int i=0;i<m;i++){
		int a,b,x;
		cin>>a>>b;
		cost[i]=a;
		for(int j=0;j<b;j++) cin>>x,keys[i].pb(x-1),st.insert(x-1);
	}
	if(st.size()!=n){
		cout<<"-1"<<endl;
		return ;
	}
	dp[0]=0;
	for(int mask=0;mask<(1<<n);mask++){
		for(int i=0;i<m;i++){
			int msk=mask;
			for(int j=0;j<keys[i].size();j++){
				dp[mask|(1<<keys[i][j])]=min(dp[mask|(1<<keys[i][j])],dp[mask]+cost[i]);
				msk|=(1<<keys[i][j]);
				dp[msk]=min(dp[msk],dp[mask]+cost[i]);
			}
		}
	}
	int target=(1<<n)-1;
	cout<<dp[target];
}
int32_t main(){
FIO;
int t=1;
//cin>>t;
while(t--){
	solve();
}
}

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

  		int c[]={0,0,0,0};
      	int stack1;
      	int stack2;
      	boolean yn = true;
      
      	for(int i = 0;i < 3 && yn;i++){
          	stack1 = sc.nextInt() - 1;
          	stack2 = sc.nextInt() - 1;
        	c[stack1]++;
          	c[stack2]++;
          	if(c[stack1] > 2 || c[stack2] > 2) yn = false;
        }
      	
      	if(yn) System.out.println("YES");
      	else System.out.println("NO");
        
	}
}


Measured memory_bytes: 36040
l = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
n = int(input())
for num in range(n):
    b,f,r,v = [int(x) for x in input().split()]
    l[b-1][f-1][r-1] += v
for b in range(4):
    for f in range(3):
        for r in range(10):
            print('', l[b][f][r], end='')
        print("")
    if b != 3:
        print("#" * 20)

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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;

ll f(vll A){
	ll t =0;
	for(int i=0;i<5;i++){
		t+=A[i];
		while(t%10!=0 && i!=4)
			t++;
	}
	return t;

}

void solve() {
	vll A(5);
	for(int i=0;i<5;i++) cin>>A[i];
	sort(all(A));
	ll ans=1e18;
	do {
		ans=min(ans,f(A));
	}while(next_permutation(all(A)));
	cout<<ans<<"\n";
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;

	//ll t;cin>>t;while(t--)
	solve();

}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string>
using namespace std;


int main() {

	string str;
	char a[20];
	int size = 0;
	cin >> str;

	for (int i = 0;;i++) {
		if (str[i] == '\0')break;
		size++;
	}

	for (int i = size; i > 0; i--) {
		printf("%c", str[i - 1]);
	}
	printf("\n");

	//system("pause");
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
 
using namespace std;
typedef pair<int, int> P;
 
int main(void) {
    string s;
    cin >> s;
 
    int sum_all = 0, sum, lev = 0;
    stack<int> st;
    stack<P> stP;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '\\')
            st.push(i);
        else if (s[i] == '/') {
            if (st.empty()) continue;
            int j = st.top(); st.pop();
 
            sum_all += i - j;
            sum = i - j;
            while (stP.size() > 0 && j < stP.top().first) {
                sum += stP.top().second;
                stP.pop();
            }
            stP.push(P(j, sum));
        }
    }
 
    vector<int> v;
    while (stP.size()) {
        v.push_back(stP.top().second);
        stP.pop();
    }
    reverse(v.begin(), v.end());
 
 
    cout << sum_all << endl;
    cout << v.size();
    for (int  i = 0; i < v.size(); i++)
        cout << " " << v[i];
    cout << endl;
 
    return 0;
}


Measured memory_bytes: 3296
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define elif else  if
#define INF 1000000009
using namespace std;
int n,cnt;
string s;
signed main(){
	cin>>n;
	s=to_string(n);
	rep(i,s.size()){
		int a=s[i]-48;
		cnt+=a;
	}
	if(n%cnt==0){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int a,b,c,d,e,f,g;
cin>>a>>b>>c>>d;
e=max(a*c,a*d);
    f=max(e,b*c);
    g=max(f,b*d);
    cout<<g<<endl;
    

    return 0;}

Measured memory_bytes: 3668
from collections import deque

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

mapping = {}
for n in range(N):
    mapping[n+1] = []

for i in range(M):
    A, B = map(int, input().split())
    mapping[A].append(B)
    mapping[B].append(A)

dest = {}
distance = {}
for n in range(N):
    distance[n+1] = -1
    dest[n+1] = -1

stack = deque()
stack.append(1)
distance[1] = 0

while len(stack) != 0:
    number = stack.popleft()
    next_distance = distance[number]+1

    for m in mapping[number]:
        if distance[m] >= 0:
            continue
        else:
            dest[m] = number
            distance[m] = next_distance
            stack.append(m)

for n in range(N):
    if distance[n+1] < 0:
        print("No")
        exit()

print("Yes")
for n in range(1, N):
    print(dest[n+1])



Measured memory_bytes: 62908
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
int a[300],b[300],c[300],d[300],e[301][301],n,m;
int fi(int p,int q){
  int i;
  if(e[p][q]!=-1)
    return e[p][q];
  int mx=0;
  for(i=0;a[p]*i<=q;++i)
    mx=max(mx,fi(p+1,q-a[p]*i)+b[p]*i);
  return e[p][q]=mx;
}
int fj(int p,int q){
  int i;
  if(e[p][q]!=-1)
    return e[p][q];
  int mx=0;
  for(i=0;a[p]*i<=q;++i)
    mx=max(mx,fj(p+1,q-a[p]*i)+c[p]*i);
  return e[p][q]=mx;
}
int fk(int p,int q){
  int i;
  if(e[p][q]!=-1)
    return e[p][q];
  int mx=0;
  for(i=0;a[p]*i<=q;++i)
    mx=max(mx,fk(p+1,q-a[p]*i)+d[p]*i);
  return e[p][q]=mx;
}
int main(){
  int i;
  //int n,m;
  while(cin>>n>>m){
    //int a[300],b[300],c[300],d[300];
    string s;
    for(i=0;i<n;++i){
      getline(cin,s);
      getline(cin,s);
      cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    int mx=0;
    memset(e,-1,sizeof(e));
    memset(e[n],0,301*sizeof(int));
    mx=max(mx,fi(0,m));
    memset(e,-1,sizeof(e));
    memset(e[n],0,301*sizeof(int));
    mx=max(mx,fj(0,m));
    memset(e,-1,sizeof(e));
    memset(e[n],0,301*sizeof(int));
    mx=max(mx,fk(0,m));
    cout<<mx<<endl;
  }
  return 0;
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

struct Edge { int to, c; };

struct State {
	int v, c;
	bool operator > (const State& e) const { return c > e.c; }
};

int N, M, K, dst[3030];
vector< vector< Edge > > adj;

void solve() {
	for_(i,0,N) dst[i] = 3030 * 1010;
	
	priority_queue< State, vector< State >, greater< State > > que;
	
	for_(i,0,K) {
		int s;
		cin >> s;
		--s;
		que.push(State{s, 0});
		dst[s] = 0;
	}
	
	while (!que.empty()) {
		State s = que.top(); que.pop();
		
		if (dst[s.v] < s.c) continue;
		
		for (const Edge& e : adj[s.v]) {
			if (dst[e.to] > s.c + e.c) {
				dst[e.to] = s.c + e.c;
				que.push(State{e.to, dst[e.to]});
			}
		}
	}
	
	int ans = 0;
	
	for_(v,0,N) {
		int dst_v = dst[v];
		
		for (const Edge& e : adj[v]) {
			int dst_u = dst[e.to];
			ans = max(ans, int(double(dst_v + dst_u + e.c) / 2.0 + 0.5));
		}
	}
	
	cout << ans << endl;
}

int main() {
	cin >> N >> M >> K;
	
	adj.assign(N, vector< Edge >());
	
	for_(i,0,M) {
		int a, b, l;
		cin >> a >> b >> l;
		--a; --b;
		adj[a].push_back(Edge{b, l});
		adj[b].push_back(Edge{a, l});
	}
	
	solve();
}

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

ll knapsack(ll n,ll w,ll *Wt,ll *c)
{
    ll t[n+1][w+1];
    
    
    memset(t,0,sizeof(t));
    
    
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(Wt[i-1]<=j)
                t[i][j]=  max( ( c[i-1] +t[i-1][j-Wt[i-1]] ),
                               ( t[i-1][j] )   );
    
            else t[i][j]= t[i-1][j] ; 
        }
    }
    
    return t[n][w];
}


int main()
{
    ll n,w;
    
    cin >>n>>w;
    
    ll c[n];
    ll Wt[n];
    
    for(ll i=0;i<n;i++)
    {
        cin>>Wt[i]>>c[i];
    }
    
    cout <<knapsack(n,w,Wt,c);
}

Measured memory_bytes: 82420
MOD = 10**9 + 7

K = input()
D = int(input())

N = len(K)
dp = [[[0]*2 for _ in range(D)] for _ in range(N+1)] # 上から i まで見て余りが j であるものの数
dp[0][0][0] = 1

# 0 -> K ちょうど
# 1 -> K より小さい
for i in range(N):
    k = int(K[i])
    for j in range(D):
        dp[i+1][(j+k)%D][0] += dp[i][j][0]
        dp[i+1][(j+k)%D][0] %= MOD
        for d in range(10):
            dp[i+1][(j+d)%D][1] += dp[i][j][1]
            if d < k:
                dp[i+1][(j+d)%D][1] += dp[i][j][0]
            dp[i+1][(j+d)%D][1] %= MOD

print((dp[N][0][0]+dp[N][0][1]-1)%MOD)

Measured memory_bytes: 130140
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d", &a); 
 if(a<=100&&a>=64){b=64;}
 if(a<64&&a>=32){b=32;}
 if(a<32&&a>=16){b=16;}
 if(a<16&&a>=8){b=8;}
 if(a<8&&a>=4){b=4;}
 if(a<4&&a>=2){b=2;}
 if(a<2&&a>=1){b=1;}
    printf("%d",b);
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

string S;
/*
vector<string> t = {
"AKIHABARA"
"KIHABARA",
"AKIHBARA",
"KIHBARA",
"AKIHABRA",
"KIHABRA",
"AKIHBRA",
"KIHBRA",
"AKIHABAR",
"KIHABAR",
"AKIHBAR",
"KIHBAR",
"AKIHABR",
"KIHABR",
"AKIHBR",
"KIHBR"
};
*/
vector<string> t = {"AKIHABARA", "KIHABARA", "AKIHBARA", "KIHBARA", "AKIHABRA", "KIHABRA", "AKIHBRA", "KIHBRA", "AKIHABAR", "KIHABAR", "AKIHBAR", "KIHBAR", "AKIHABR", "KIHABR", "AKIHBR", "KIHBR"};
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> S;
  sort(all(t));
  uniq(t);
  assert(t.size() == 16);
  if (find(all(t), S) == t.end()) cout << "NO\n";
  else cout << "YES\n";
  return 0;
}


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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

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

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

	if (K * 2 - 1 > N) {
		puts("-1");
		return 0;
	}

	V<int> a(N), b(N), c(N);

	if (N % 2 == 0) {
		int n = N / 2;
		rep(i, N) {
			if (i % 2 == 0) {
				a[i] = i / 2;
				b[i] = i / 2 + N + n;
			} else {
				a[i] = i / 2 + n;
				b[i] = i / 2 + N;
			}
			c[i] = N * 2 + i;
		}
	} else {
		int n = (N + 1) / 2;
		rep(i, N) {
			if (i % 2 == 0) {
				a[i] = i / 2;
				b[i] = i / 2 + N + n - 1;
			} else {
				a[i] = i / 2 + n;
				b[i] = i / 2 + N;
			}
			c[i] = N * 2 + i;
		}
	}

	rep(i, N) {
		cout << a[i] + K << " " << b[i] + K << " " << c[i] + K << endl;
	}


	return 0;
}

Measured memory_bytes: 3456
import java.util.Scanner;

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

        if (w >= s) {
            System.out.println("unsafe");
        } else {
            System.out.println("safe");
        }
    }
}



Measured memory_bytes: 35760
#include <bits/stdc++.h>
using namespace std;
int main(){
	int w,h,x,y,r;
	cin>>w>>h>>x>>y>>r;
	if(x<r||y<r||x+r>w||y+r>h){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	return 0;
}



Measured memory_bytes: 3112
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;

signed main(){
    ll n;
    cin>>n;
    double a,aa;
    a = n/1.08;
    ll b1 = a;
    ll b2 = b1+1;
    if(floor(b1*1.08)==n) cout<<b1<<endl;
    else if(floor(b2*1.08)==n) cout<<b2<<endl;
    else cout<<":("<<endl;
}


Measured memory_bytes: 256
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int main()
{
	int n,ca=0,cb=0;
	string s;
	cin>>n>>s;
	rep(i,s.size()) if(s[i]=='R') ca++;else cb++;
	if(ca>cb) puts("Yes");
	else puts("No");
	rt0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) a.begin(),a.end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define lson (ind<<1)
#define rson (ind<<1|1)
#define se second
#define fi first
#define sz(x) ((int)x.size())
#define EX0 exit(0);
#define INF 1e9 + 7
#define BIG 1e18

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
typedef vector<ll> VLL;
typedef vector<int> VI;
const int block_size = 320;
typedef complex<ll> point;
const ll mod = 1e9 + 7;
const ll inf = 1e9 + 7;
const ld eps = 1e-9;
const db PI = atan(1) * 4;

template<typename T, typename S>inline bool upmin(T&a, const S&b) { return a > b ? a = b, 1 : 0; }
template<typename T, typename S>inline bool upmax(T&a, const S&b) { return a < b ? a = b, 1 : 0; }

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }
namespace SOLVE {
	void main() {
		ll n, maxw;
		cin >> n >> maxw;
		vector<pair<ll,ll>> coins(n);
		ll sumvalues = 0;
		REP(i, 0, n) {
			cin >> coins[i].first; // weights
			cin >> coins[i].second; // values
			sumvalues += coins[i].second;
		}
		sort(coins.begin(), coins.end()); // sort by weight
		VLL minw(sumvalues + 2000, BIG); // the min weight that can make each value

		minw[0] = 0; // smallest weight for value 0 is 0
		ll ans = 0;

		REP(i, 0, n) {
			RREP(j, sumvalues + 5, 0) {
				if (minw[j] + coins[i].first < minw[j + coins[i].second]) {
					minw[j + coins[i].second] = minw[j] + coins[i].first;

					if (minw[j + coins[i].second] <= maxw) {
						if (j + coins[i].second >= ans) {
							ans = j + coins[i].second;
						}
					}
				}
			}
		}

		cout << ans;
	}
}


signed main() {

	int t;
	//    in(t);
	t = 1;
	while (t--) {
		SOLVE::main();

	}

	return 0;
}


Measured memory_bytes: 1024
import numpy as np

K = int(input())

top = np.ones(10, dtype=int)
adj = np.eye(10, dtype=int)
adj[1:, :-1] += np.eye(9, dtype=int)
adj[:-1, 1:] += np.eye(9, dtype=int)

counts = [top]
tmp = top
for _ in range(10):
    tmp = np.dot(tmp, adj)
    counts.append(tmp)

for i in range(10):
    for j in range(1, 10):
        if K > counts[i][j]:
            K -= counts[i][j]
        else:
            break
    else:
        continue
    break

ans = [-1] * (i + 1)
ans[i] = j

for d in range(i, 0, -1):
    for k in range(max(0, j - 1), min(9, j + 1) + 1):
        if K > counts[d - 1][k]:
            K -= counts[d - 1][k]
        else:
            ans[d - 1] = k
            j = k
            break


print("".join(list(map(str, ans))[::-1]))


Measured memory_bytes: 12508
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
int n, m, q;
vector<int> a, b, c, d;
int ans = 0;

void dfs(vector<int> A){
if(A.size() == n+1){
    int cnt = 0;
    rep(i, q){
        if(A[b[i]] - A[a[i]] == c[i]){
            cnt += d[i];
        }
    }
    if(ans < cnt) ans = cnt;
    return ;
}
A.push_back(A.back());
while(A.back() <= m){
    dfs(A);
    A.back()++;
}
}

int main(){

cin >> n >> m >> q;
a.resize(q); b.resize(q); c.resize(q); d.resize(q);
rep(i, q){
    cin >> a [i]>> b[i] >> c[i] >> d[i];
}
vector<int> aa;
aa = {1};
dfs(aa);
cout << ans << endl;

}

Measured memory_bytes: 3612